<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>Crunks Blog &#187; Reseach &amp; Development</title>
	<atom:link href="http://www.artbycrunk.com/blog/category/reseach-tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.artbycrunk.com/blog</link>
	<description></description>
	<lastBuildDate>Sun, 18 Jul 2010 16:07:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<image>
			<title>Crunks Blog</title>
			<url>http://www.artbycrunk.com/blog_favicon.png</url>
			<link>http://www.artbycrunk.com/blog</link>
			<width></width>
			<height></height>
			<description></description>
		</image>		<item>
		<title>Augmented Reality : The Code</title>
		<link>http://www.artbycrunk.com/blog/2010/04/augmented-reality-coding/</link>
		<comments>http://www.artbycrunk.com/blog/2010/04/augmented-reality-coding/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 22:25:54 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[Augmented Reality (AR)]]></category>
		<category><![CDATA[Reseach & Development]]></category>
		<category><![CDATA[AR]]></category>
		<category><![CDATA[Collada]]></category>
		<category><![CDATA[FLAR]]></category>
		<category><![CDATA[flash]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=823</guid>
		<description><![CDATA[<br/>The Actionscript Code to the Augmented Reality 101 Sample File. I added comments and seperated the code wherever i could.]]></description>
			<content:encoded><![CDATA[<br/><p>In my last post on <a href="http://www.artbycrunk.com/blog/2010/04/augmented-reality-101/" target="_blank">Augmented Reality 101</a>, i had shown a sample of how the FLARToolkit outputs using Flash. Here i would like to share the code i had written for that sample  so that u know what are all the modules that u need to import from the various packages, (from FLAR and Papervision) and what are all the classes that need to be defined to get this to work. You will obviously need to replace the model file and the marker file to a custom one, rest of it is a good skeleton code to build something for AR.</p>
<p>The below code may require you to have the FLEX SDK 3.0 Library &#8211; <a href="http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+3" target="_blank">Download from HERE.</a></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p823code1'); return false;">View Code</a> ACTIONSCRIPT3</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8231"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
</pre></td><td class="code" id="p823code1"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #9900cc; font-weight: bold;">package</span> <span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Bitmap</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">PixelSnapping</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.display</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Sprite</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Camera</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.media</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Video</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.utils</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ByteArray</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//FLAR IMPORT</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>FLARCode<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>param<span style="color: #000066; font-weight: bold;">.</span>FLARParam<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>raster<span style="color: #000066; font-weight: bold;">.</span>rgb<span style="color: #000066; font-weight: bold;">.</span>FLARRgbRaster_BitmapData<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>detector<span style="color: #000066; font-weight: bold;">.</span>FLARSingleMarkerDetector<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//PAPERVISION IMPORT SCENE GLOBALS</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>core<span style="color: #000066; font-weight: bold;">.</span>transmat<span style="color: #000066; font-weight: bold;">.</span>FLARTransMatResult<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>support<span style="color: #000066; font-weight: bold;">.</span>pv3d<span style="color: #000066; font-weight: bold;">.</span>FLARBaseNode<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>libspark<span style="color: #000066; font-weight: bold;">.</span>flartoolkit<span style="color: #000066; font-weight: bold;">.</span>support<span style="color: #000066; font-weight: bold;">.</span>pv3d<span style="color: #000066; font-weight: bold;">.</span>FLARCamera3D<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000066; font-weight: bold;">.</span>LazyRenderEngine<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scenes</span><span style="color: #000066; font-weight: bold;">.</span>Scene3D<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>view<span style="color: #000066; font-weight: bold;">.</span>Viewport3D<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//PAPERVISION IMPORT OBJECTS GLOBALS</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>objects<span style="color: #000066; font-weight: bold;">.</span>parsers<span style="color: #000066; font-weight: bold;">.</span>DAE<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>lights<span style="color: #000066; font-weight: bold;">.</span>PointLight3D<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>WireframeMaterial<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>utils<span style="color: #000066; font-weight: bold;">.</span>MaterialsList<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>ColorMaterial<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>shadematerials<span style="color: #000066; font-weight: bold;">.</span>FlatShadeMaterial<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>materials<span style="color: #000066; font-weight: bold;">.</span>shadematerials<span style="color: #000066; font-weight: bold;">.</span>PhongMaterial<span style="color: #000066; font-weight: bold;">;</span>
	<span style="color: #0033ff; font-weight: bold;">import</span> org<span style="color: #000066; font-weight: bold;">.</span>papervision3d<span style="color: #000066; font-weight: bold;">.</span>events<span style="color: #000066; font-weight: bold;">.</span>FileLoadEvent<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
	<span style="color: #009900; font-style: italic;">//INITIALIZE SWF PARAMS</span>
	<span style="color: #000000;">&#91;</span>SWF<span style="color: #000000;">&#40;</span><span style="color: #004993;">width</span>=<span style="color: #990000;">&quot;640&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">height</span>=<span style="color: #990000;">&quot;480&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">frameRate</span>=<span style="color: #990000;">&quot;30&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">backgroundColor</span>=<span style="color: #990000;">&quot;#FFFFFF&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> ArApp <span style="color: #0033ff; font-weight: bold;">extends</span> <span style="color: #004993;">Sprite</span>
	<span style="color: #000000;">&#123;</span>
		<span style="color: #009900; font-style: italic;">//EMBED MARKER FILE (NEEDS FLEX SDK 3)</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;Data/crunkMarker16.pat&quot;</span><span style="color: #000066; font-weight: bold;">,</span> mimeType=<span style="color: #990000;">&quot;application/octet-stream&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> pattern<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//EMBED CAMERA PARAMS FILE (NEEDS FLEX SDK 3)</span>
		<span style="color: #000000;">&#91;</span>Embed<span style="color: #000000;">&#40;</span><span style="color: #004993;">source</span>=<span style="color: #990000;">&quot;Data/camera_para.dat&quot;</span><span style="color: #000066; font-weight: bold;">,</span> mimeType=<span style="color: #990000;">&quot;application/octet-stream&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> params<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Class</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//FLAR VARS</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> Param<span style="color: #000066; font-weight: bold;">:</span>FLARParam<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> Code<span style="color: #000066; font-weight: bold;">:</span>FLARCode<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> raster<span style="color: #000066; font-weight: bold;">:</span>FLARRgbRaster_BitmapData<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> detector<span style="color: #000066; font-weight: bold;">:</span>FLARSingleMarkerDetector<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> resultMat<span style="color: #000066; font-weight: bold;">:</span>FLARTransMatResult = <span style="color: #0033ff; font-weight: bold;">new</span> FLARTransMatResult<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//WEBCAM DATA VARS</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> webcamBox<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Camera</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> video<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Video</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> capture<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">BitmapData</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//PAPERVISION VARS</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> viewport<span style="color: #000066; font-weight: bold;">:</span>Viewport3D<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> camera3d<span style="color: #000066; font-weight: bold;">:</span>FLARCamera3D<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> scene<span style="color: #000066; font-weight: bold;">:</span>Scene3D<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> renderer<span style="color: #000066; font-weight: bold;">:</span>LazyRenderEngine<span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #6699cc; font-weight: bold;">var</span> markerNode<span style="color: #000066; font-weight: bold;">:</span>FLARBaseNode<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//EXTERNAL MODEL VARS</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> ext_model<span style="color: #000066; font-weight: bold;">:</span>DAE<span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> ArApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
&nbsp;
			doArApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">Event</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">ENTER_FRAME</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> doArApp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">// FLAR CONSTRUCTOR</span>
		Param = <span style="color: #0033ff; font-weight: bold;">new</span> FLARParam<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		Param<span style="color: #000066; font-weight: bold;">.</span>loadARParam<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> params<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> <span style="color: #004993;">ByteArray</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		Code = <span style="color: #0033ff; font-weight: bold;">new</span> FLARCode<span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		Code<span style="color: #000066; font-weight: bold;">.</span>loadARPatt<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> pattern<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//WEBCAM DATA</span>
		webcamBox = <span style="color: #004993;">Camera</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">getCamera</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000066; font-weight: bold;">!</span>webcamBox<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				<span style="color: #004993;">trace</span> <span style="color: #000000;">&#40;</span><span style="color: #990000;">'No webcam!!!!'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
				<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'No webcam!!!!'</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #000000;">&#125;</span>
&nbsp;
		webcamBox<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">setMode</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">640</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">480</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">30</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		video = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Video</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">640</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">480</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		video<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">attachCamera</span><span style="color: #000000;">&#40;</span>webcamBox<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//BITMAP DATA</span>
		capture = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">BitmapData</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">640</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">480</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		capture<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		raster = <span style="color: #0033ff; font-weight: bold;">new</span> FLARRgbRaster_BitmapData<span style="color: #000000;">&#40;</span>capture<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		detector = <span style="color: #0033ff; font-weight: bold;">new</span> FLARSingleMarkerDetector<span style="color: #000000;">&#40;</span>Param<span style="color: #000066; font-weight: bold;">,</span> Code<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">80</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//PV3D DATA</span>
		camera3d = <span style="color: #0033ff; font-weight: bold;">new</span> FLARCamera3D<span style="color: #000000;">&#40;</span>Param<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		scene = <span style="color: #0033ff; font-weight: bold;">new</span> Scene3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		markerNode = scene<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> FLARBaseNode<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #0033ff; font-weight: bold;">as</span> FLARBaseNode<span style="color: #000066; font-weight: bold;">;</span>
		viewport = <span style="color: #0033ff; font-weight: bold;">new</span> Viewport3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		renderer = <span style="color: #0033ff; font-weight: bold;">new</span> LazyRenderEngine<span style="color: #000000;">&#40;</span>scene<span style="color: #000066; font-weight: bold;">,</span> camera3d<span style="color: #000066; font-weight: bold;">,</span> viewport<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//OBJECT BASED VARS - LIGHTS, MATERIALS, MODEL.</span>
		<span style="color: #6699cc; font-weight: bold;">var</span> light<span style="color: #000066; font-weight: bold;">:</span>PointLight3D = <span style="color: #0033ff; font-weight: bold;">new</span> PointLight3D<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		light<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">x</span> = <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">;</span>
		light<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">y</span> = <span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span>
		light<span style="color: #000066; font-weight: bold;">.</span>z = <span style="color: #000066; font-weight: bold;">-</span><span style="color: #000000; font-weight:bold;">1000</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #6699cc; font-weight: bold;">var</span> ar_materials<span style="color: #000066; font-weight: bold;">:</span>MaterialsList = <span style="color: #0033ff; font-weight: bold;">new</span> MaterialsList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#123;</span>all<span style="color: #000066; font-weight: bold;">:</span> <span style="color: #0033ff; font-weight: bold;">new</span> PhongMaterial<span style="color: #000000;">&#40;</span>light<span style="color: #000066; font-weight: bold;">,</span>0xffffff<span style="color: #000066; font-weight: bold;">,</span>0x000000<span style="color: #000066; font-weight: bold;">,</span><span style="color: #000000; font-weight:bold;">0.3</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		ext_model = <span style="color: #0033ff; font-weight: bold;">new</span> DAE<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		ext_model<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">load</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">'model/dastardly2.dae'</span><span style="color: #000066; font-weight: bold;">,</span>ar_materials<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #009900; font-style: italic;">//CUSTOM OBJECT TRANSFORM</span>
		ext_model<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">scale</span> = <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">;</span>
		ext_model<span style="color: #000066; font-weight: bold;">.</span>rotationX = <span style="color: #000000; font-weight:bold;">90</span><span style="color: #000066; font-weight: bold;">;</span>
		markerNode<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>ext_model<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
		<span style="color: #004993;">addChild</span><span style="color: #000000;">&#40;</span>viewport<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">loop</span><span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Event</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> <span style="color: #000000;">&#123;</span>
			capture<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span>video<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
&nbsp;
			<span style="color: #6699cc; font-weight: bold;">var</span> detected<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #0033ff; font-weight: bold;">try</span> <span style="color: #000000;">&#123;</span>
				detected = detector<span style="color: #000066; font-weight: bold;">.</span>detectMarkerLite<span style="color: #000000;">&#40;</span>raster<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">80</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;</span>amp<span style="color: #000066; font-weight: bold;">;&amp;</span>amp<span style="color: #000066; font-weight: bold;">;</span> detector<span style="color: #000066; font-weight: bold;">.</span>getConfidence<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000066; font-weight: bold;">&amp;</span>gt<span style="color: #000066; font-weight: bold;">;</span> <span style="color: #000000; font-weight:bold;">0.5</span><span style="color: #000066; font-weight: bold;">;</span>
			<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">catch</span> <span style="color: #000000;">&#40;</span>e<span style="color: #000066; font-weight: bold;">:</span><span style="color: #004993;">Error</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span>
&nbsp;
			<span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>detected<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				detector<span style="color: #000066; font-weight: bold;">.</span>getTransformMatrix<span style="color: #000000;">&#40;</span>resultMat<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//GET</span>
				markerNode<span style="color: #000066; font-weight: bold;">.</span>setTransformMatrix<span style="color: #000000;">&#40;</span>resultMat<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//SET</span>
				markerNode<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//GO</span>
			<span style="color: #000000;">&#125;</span> <span style="color: #0033ff; font-weight: bold;">else</span> <span style="color: #000000;">&#123;</span>
				markerNode<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">visible</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//REMOVE IF MARKER NO IN FRAME</span>
			<span style="color: #000000;">&#125;</span>
			renderer<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">render</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span> <span style="color: #009900; font-style: italic;">//RENDER THE SCENE</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2010/04/augmented-reality-coding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<series:name><![CDATA[Augmented Reality]]></series:name>
	</item>
		<item>
		<title>Augmented Reality 101</title>
		<link>http://www.artbycrunk.com/blog/2010/04/augmented-reality-101/</link>
		<comments>http://www.artbycrunk.com/blog/2010/04/augmented-reality-101/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 18:25:06 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[Augmented Reality (AR)]]></category>
		<category><![CDATA[Reseach & Development]]></category>
		<category><![CDATA[AR]]></category>
		<category><![CDATA[Collada]]></category>
		<category><![CDATA[FLAR]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[Papervision]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=763</guid>
		<description><![CDATA[<br/>Augmented Reality Test, History, Info and the amazing FLARToolkit.]]></description>
			<content:encoded><![CDATA[<br/><p>Augmented Reality Test.<br />
1. <strong>Download the Marker File Here.</strong>. <a rel="nofollow" title="Download version 0.1 of crunkMarker2.png" href="http://www.artbycrunk.com/blog/files/crunkMarker2.png" rel="wp-prettyPhoto[g763]">crunkMarker2.png </a>
<p>2. To Watch <strong>Lores Model </strong>Version <a href="http://www.artbycrunk.com/blog/swf/batmob.swf" title="Lores Model Version" rel="wp-prettyPhoto[g763]"><span style="color: #ff0000;">CLICK HERE</span></a>(Requires a Webcam) .<br />
This lores model is <strong>16798 Triangles</strong>&#8230; (1.02MB &#8211; Please give it time to Load).</p>
<p>3. To Watch <strong>Hires Model</strong> Version <a href="http://www.artbycrunk.com/blog/swf/batmob2.swf" title="Hires Model Version" rel="wp-prettyPhoto[g763]"><span style="color: #ff0000;">CLICK HERE</span></a>(Requires a Webcam).<br />
This hires model is <strong>68412 Triangles</strong>&#8230; (5.06MB &#8211; Please give it time to Load)</p>
<h3><span style="font-weight: normal; font-size: 13px;">&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</span></h3>
<p>Recently i have been seeing lots of hype happening around the AR (Augmented Reality) Tech&#8230; so as i was looking around the web i came across this amazing Action-script Class library made by<a href="http://saqoosha.net/" target="_blank"> Saqoosha</a> called <a href="http://www.libspark.org/wiki/saqoosha/FLARToolKit/en" target="_blank">FLARToolKit</a></p>
<p><strong>History :</strong> FLARToolKit is an AS3 ported version of <a href="http://nyatla.jp/nyartoolkit/wiki/index.php">NyARToolkit</a>, which is a Java ported version of ARToolKit.<br />
ARToolKit was originally developed by Dr. Hirokazu Kato, and its ongoing  development is being supported by the Human Interface Technology Laboratory (<a href="http://www.hitl.washington.edu/">HIT Lab</a>) at the University of Washington, <a href="http://www.hitlabnz.org/">HIT Lab NZ</a> at the University of Canterbury, New Zealand, and <a href="http://www.artoolworks.com/">ARToolworks,  Inc</a>, Seattle.</p>
<p><strong>FLARToolKit  recognize the marker from input image. and calculate its orientation  and position in 3D world which equals to doing all the hardwork as far as AR Technology is concerned.</strong></p>
<p>The FLARToolKit currently works with a variety of Flash 3D Engines like <a onclick="javascript:pageTracker._trackPageview('/outbound/article/alternativaplatform.com');" href="http://alternativaplatform.com/en/alternativa3d/" target="_blank">Alternativa3D</a>,  <a onclick="javascript:pageTracker._trackPageview('/outbound/article/away3d.com');" href="http://away3d.com/" target="_blank">Away3D</a>,  <a onclick="javascript:pageTracker._trackPageview('/outbound/article/code.google.com');" href="http://code.google.com/p/papervision3d/" target="_blank">Papervision3D</a>,  and <a onclick="javascript:pageTracker._trackPageview('/outbound/article/flashsandy.org');" href="http://flashsandy.org/" target="_blank">Sandy3D</a> etc. my personal choice here is papervision 3d since i have used it before and through what ive seen is just plainly amazing :)</p>
<p>So for this example i have used&#8230;</p>
<p>Flash as the main program here loaded with the FLARToolKit Library,<br />
Papervision3D 2.0 for the viewport rendering, lighting and 3d geometry display.<br />
Blender for making Geometry and exporting Collada (dae) files.<br />
ARToolkit Marker Gen for the custom marker generation.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>The FLAR theory process follows some very simple steps.   <strong> </strong></p>
<p><strong>1. Flash Displays Webcam Data</strong> &#8211; Since u cant do AR without a Webcam.. the first step is to get ur webcam feed in Flash  through the Camera.getCamera();<strong><br />
</strong></p>
<p><strong>2. Applies Camera Correction</strong> &#8211; FLARToolKit  comes with a binary camera parameters file which it loads to correct lens distortion from your webcam. <a href="http://www.hitl.washington.edu/artoolkit/download/" target="_blank">Calib_camera2</a> is the software used to generate this file and it is existent from the original ARToolKit. Most examples u see online state that the default <strong>camera_para.dat</strong> that comes with the Toolkit works for everything.</p>
<p><strong>3. Finding Matching Marker</strong> &#8211; The Marker is a .pat (pattern file) that FLAR will continuously be scanning for. The pattern file consists of four 16&#215;48 matrices, one for each direction and 48 is for RGB color information. There is an Air app created by Saqoosha for easy marker creation <strong><a href="http://saqoosha.net/lab/FLARToolKit/MarkerGenerator/MakerGenerator.air">here</a></strong>..</p>
<p><strong>4. Marker is Detected &#8211; </strong>As the marker detector basically basically scan through the bitmapData from the web cam feed and comparing it to the provided marker pattern from the marker file. On marker detection, FlarToolkit will will built a transformation matrix around the marker and create a Flar Base Node to sit on top of it.</p>
<p><strong>5. FLAR Base Node -</strong> The FLAR base node is just a ground plane of which all the geometry u want to show will be created, The transformation matrix will hold all the data required to properly orient ur 3d data in comparison to marker orientation.</p>
<p><strong>6. 3D Render Engine &#8211; </strong>And finally the visual part , at this level with a bunch of papervision classes , like viewport3d and lights, we can finally display the desired geometry.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>here are screenshots of the actually model, with color applied :)</p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2010/04/dastardly_04.jpg" rel="wp-prettyPhoto[g763]"><img class="alignnone size-full wp-image-798" title="dastardly_04" src="http://www.artbycrunk.com/blog/wp-content/storage/2010/04/dastardly_04.jpg" alt="" width="519" height="489" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2010/04/augmented-reality-101/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<series:name><![CDATA[Augmented Reality]]></series:name>
	</item>
		<item>
		<title>Anti-aliasing Filters &amp; Sampling</title>
		<link>http://www.artbycrunk.com/blog/2009/11/anti-aliasing-filters-sampling/</link>
		<comments>http://www.artbycrunk.com/blog/2009/11/anti-aliasing-filters-sampling/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 19:29:08 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[Fundamentals]]></category>
		<category><![CDATA[Reseach & Development]]></category>
		<category><![CDATA[filters]]></category>
		<category><![CDATA[Rendering]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=589</guid>
		<description><![CDATA[<br/>All CGI images are made of fundamental building blocks called pixels. a pixel is the smallest breakdown of an image, and can only be made of one one color. When an image is rendered, the renderer needs to assign a single color to each pixel of the overall image depending on what object that pixel represents. This standard process brings up some problem as to what we call aliasing. where thin lines or diagonal lines are present in an image. To overcome this entire thing, we use a process called Anti-Aliasing. Here each pixel is multi-sampled i.e each pixel is broken down into multiples smaller parts which equals to more color information and then all the samples are averaged out using a Anti-alias filter, so as to obtain the final one color per pixel value.]]></description>
			<content:encoded><![CDATA[<br/><h4>Background Information<br />
________________________________________________________________________________________________________________</h4>
<p>All CGI images are made of fundamental building blocks called pixels. a pixel is the smallest breakdown of an image, and can only be made of one one color. When an image is rendered, the renderer needs to assign a single color to each pixel of the overall image depending on what object that pixel represents. This standard process brings up some problem as to what we call aliasing. where thin lines or diagonal lines are present in an image. To overcome this entire thing, we use a process called Anti-Aliasing. Here each pixel is multi-sampled i.e each pixel is broken down into multiples smaller parts which equals to more color information and then all the samples are averaged out using a Anti-alias filter, so as to obtain the final one color per pixel value.</p>
<h2>________________________________________________________________________</h2>
<h2>Sampling Methods<br />
________________________________________________________________________</h2>
<p><strong>Fixed Sampling </strong>- Uses a fixed number of samples per pixel when processing an image.<br />
<strong>Adaptive Sampling -</strong> The number of samples used per pixel varies depending on the contrast of your scene. Either vary by a fixed distance<br />
<strong>Custom</strong> <strong>Sampling </strong>- Custom Sampling allows you to tune the Min Sample Level and Max Sample Level independently, while retaining true <span>adaptive sampling.<br />
</span></p>
<h2>________________________________________________________________________</h2>
<h2>Anti-aliasing Filters<br />
________________________________________________________________________</h2>
<p><a rel="”lightbox”" href="http://www.artbycrunk.com/blog/wp-content/storage/2009/11/AA_Filters_Curves.jpg" rel="wp-prettyPhoto[g589]"><img class="alignnone size-full wp-image-604" title="AA_Filters_Curves" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/11/AA_Filters_Curves.jpg" alt="AA_Filters_Curves" width="510" height="87" /></a></p>
<p><strong>Box Filter</strong> &#8211; A pretty Balanced Speed/Quality Filter. Gets you the fastest results, Due to it having a Step Curve the sample contributions are always taken from the center of the pixel.</p>
<p><strong>Area Filter &#8211; </strong>A little more advanced than the Box Filter in the case that it blur the image slighty.<strong></strong></p>
<p><strong>Triangle/Tent Filter &#8211; </strong>Overall SlowerSpeed/Better Quality than the box filter. In this case samples at the center have maximum contribution while samples further away from the center have a leanear falloff to the contribution.</p>
<p><strong>Gaussian Filter &#8211; </strong>Produces Best Quality/Slowest Speed. Gauss uses a curved fall-off for determining sample contributions. The contribution falloff from the center to the edge of the pixel is smooth. Gauss requires a higher filter size than normal due to which the images get a little blurry.</p>
<p><strong>Mitchell &amp; Lanczos &#8211; </strong>Both are variants to the Gauss, but they tend to increase the overall contrast and the sharpness of the image. A good allround filter that gives reasonable sharpness</p>
<p><strong>Quadratic B-Spline</strong><strong> Filter</strong><strong> -</strong> Produces Good Quality at speeds faster than the Gauss Filter. Compared to the Gauss filter the contribution from the center of the pixel does not peak but archieves a more quadratic curve.</p>
<p><strong>CatmullRom</strong><strong> Filter</strong><strong> -</strong> Speed Same as Mitchell and Lanczos  but Catmull-Rom filter, gives the most sharpening. the contribution curve travels also in negative to give best overall contribution.</p>
<p><strong>Sinc Filter -</strong> i dont know how this works.. if someone find out please let me know<strong><br />
</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2009/11/anti-aliasing-filters-sampling/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Terrain through GeoControl 2</title>
		<link>http://www.artbycrunk.com/blog/2009/05/terrain-through-geocontrol-2/</link>
		<comments>http://www.artbycrunk.com/blog/2009/05/terrain-through-geocontrol-2/#comments</comments>
		<pubDate>Sat, 16 May 2009 08:49:45 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[FirstSteps]]></category>
		<category><![CDATA[DEM]]></category>
		<category><![CDATA[geocontrol]]></category>
		<category><![CDATA[terragen]]></category>
		<category><![CDATA[terrain]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=408</guid>
		<description><![CDATA[<br/>I recently discovered this not so new software called geoControl which has just come out with version 2.. and has added a bunch of new features. I have seen everything in the software yet. especially the new isolines features, but for the general aspect of terrain generation was quite strong,
Below ...]]></description>
			<content:encoded><![CDATA[<br/><p>I recently discovered this not so new software called geoControl which has just come out with version 2.. and has added a bunch of new features. I have seen everything in the software yet. especially the new isolines features, but for the general aspect of terrain generation was quite strong,</p>
<p>Below is an examples that i rendered of the output of geoControl, very basic stuff.. made from a DEM map which i converted to terragen TER file , and then got into geocontrol2 to render, after tweaking various options inside the software i managed to get a lot of different variations.. i wish the software was more interactive on render, but right now its like u do a bunch of slider changes and then hit render, even u rotate the model. i tried 1024 resolution and was very in satified with the results, maybe its made for some other purpose.  All the below images are with a 2048 texture/displacement  resolution. which takes about 10-15 mins to render.</p>
<p>Somehow the thumbnails look blur.  Click on the images for bigger sharper preview.</p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con5.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con5" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con5-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con6.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con6" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con6-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con4.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con4" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con4-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con3.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con3" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con3-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con2.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con2" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con2-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con1.jpg" rel="wp-prettyPhoto[g408]"><img class="alignnone size-medium wp-image-413" title="geo_con1" src="http://www.artbycrunk.com/blog/wp-content/storage/2009/05/geo_con1-300x205.jpg" alt="geo_con5" width="492" height="336" /></a></p>
<p>MORE LINKS<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><strong>GeoControl 2 Offical Website</strong> &#8211; http://www.geocontrol2.com/<br />
<strong>GeoControl 2 Features</strong> -  http://www.geocontrol2.com/e_geocontrol_geocontrol2.htm</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2009/05/terrain-through-geocontrol-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Playing in The Mud (Mudbox 2009)</title>
		<link>http://www.artbycrunk.com/blog/2008/10/playing-in-the-mud-mudbox-2009/</link>
		<comments>http://www.artbycrunk.com/blog/2008/10/playing-in-the-mud-mudbox-2009/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 20:12:41 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[FirstSteps]]></category>
		<category><![CDATA[dragon]]></category>
		<category><![CDATA[mud]]></category>
		<category><![CDATA[mudbox]]></category>
		<category><![CDATA[sculpting]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=92</guid>
		<description><![CDATA[<br/>I finally managed to get my hands on a trial version of mudbox today morning, and decided to do some stuff so that i could see whats new, or wheater it was worth the hype. Well for the first thing, it doesnt look very different from the last version other ...]]></description>
			<content:encoded><![CDATA[<br/><p>I finally managed to get my hands on a trial version of mudbox today morning, and decided to do some stuff so that i could see whats new, or wheater it was worth the hype. Well for the first thing, it doesnt look very different from the last version other than the name Autodesk and some new tabs, well for one thing autodesk has managed to keep the same simplicity of use that the original mudbox gave, but there are still a lot of things i would like to see in it, other than going into maya everytime u need a small change.</p>
<p><strong>So, after about 6hrs of dooling, here is what i came up with</strong></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test8.jpg" rel="wp-prettyPhoto[g92]"><img class="alignnone size-full wp-image-97" title="test8" src="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test8.jpg" alt="" width="500" height="364" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test9.jpg" rel="wp-prettyPhoto[g92]"><img class="alignnone size-full wp-image-94" title="test9" src="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test9.jpg" alt="" width="500" height="363" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test7.jpg" rel="wp-prettyPhoto[g92]"><img class="alignnone size-full wp-image-96" title="test7" src="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test7.jpg" alt="" width="500" height="362" /></a></p>
<p><a href="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test6.jpg" rel="wp-prettyPhoto[g92]"><img class="alignnone size-full wp-image-95" title="test6" src="http://www.artbycrunk.com/blog/wp-content/storage/2008/10/test6.jpg" alt="" width="500" height="362" /></a></p>
<ul>
<li>Well, the new mudbox definately has a speed upgrade, in both sculpting and viewport interactivity</li>
<li>my final mesh was to 7 Levels that is abt <strong>75,29,656 Polygons or 7 Million Polygons</strong>, but yet sculpting was very interactive, was gettin abt 37FPS in the viewport,</li>
<li>this new version of mudbox uses the power of next generation graphics cards to show realtime shadows and reflections, so it can turn ur majorly slow down ur machine when the use any of these facny new options,</li>
<li>i did not seem to find a button to render the current image, that is why all the above images are screeshots 0_0.</li>
<li>One of the weird things i noticed quite late was, the saved file size, seems to be much bigger now, i wonder what all it saves, cause the last saved .mud file takes about 819MB, and i have already saved around 15files before i realized this, so today mudbox project takes around 6.5GB of HDD space for me.</li>
<li>I personally feel they could have done something better of the default shader, (the one that u see in the render) cause its really a weird shader.</li>
<li>I did not go to far out in checking all the new features, somehow i got quite irritated with a lot of missing features realted to Modelling and Sculpting itself.</li>
<li>Mudbox really needs a posing solution, it quite a problem to get ur files from another software and then see it in mudbox and then suddenly u dont like it , and u need to repeat the process.</li>
</ul>
<div>Overall it was a good thing to try something new after quite sometime, and all in a days work. :)</div>
]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2008/10/playing-in-the-mud-mudbox-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Realtime Shading with HLSL</title>
		<link>http://www.artbycrunk.com/blog/2008/09/realtime-shading-with-hlsl/</link>
		<comments>http://www.artbycrunk.com/blog/2008/09/realtime-shading-with-hlsl/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 20:04:58 +0000</pubDate>
		<dc:creator>Crunk</dc:creator>
				<category><![CDATA[Realtime Rendering]]></category>
		<category><![CDATA[HLSL]]></category>
		<category><![CDATA[Shading]]></category>

		<guid isPermaLink="false">http://www.artbycrunk.com/blog/?p=40</guid>
		<description><![CDATA[<br/>For those who dont know what HLSL (High Level Shader Language) is its a propreoraty shading language made by Micrsoft for use with Direct3D API.
Autodesk FBX (FilmBox) format is currently the standard format for game assests, including most games now developed for the XBOX 360.
Note : Since i originally come from ...]]></description>
			<content:encoded><![CDATA[<br/><p>For those who dont know what <a href="http://en.wikipedia.org/wiki/High_Level_Shader_Language" target="_blank">HLSL</a> (High Level Shader Language) is its a propreoraty shading language made by Micrsoft for use with Direct3D API.</p>
<p><a href="http://usa.autodesk.com/adsk/servlet/index?id=6837478&amp;siteID=123112" target="_blank">Autodesk FBX </a>(FilmBox) format is currently the standard format for game assests, including most games now developed for the XBOX 360.</p>
<p><strong>Note :</strong> Since i originally come from using 3d artist tools, i will be refrencing the common simplicities that are taken for granted. other than starting out with a blank pad in the game programming world :)</p>
<ul>
<li>Before we get into shading we need something to shade.. namely a model, and its not as simple as saying file&gt;Open.. in the game programming world, new objects need to be drawn onto the viewable space, which includes itterating through every seperate piece of geometry that a single character is made of. generally speaking, when u need to draw something in 2d or 3d, u obviously need something to draw it on u cant draw in thin air, so u need to build the space on which u can draw. to archieve this we need 3 matrices namely the world, view, and projection <a title="matrix" href="http://en.wikipedia.org/wiki/Matrix_(mathematics)" target="_blank">matrix.</a></li>
</ul>
<p><strong>World Matrix -</strong> Is basically defining the origin of the worldspace, a point from which everyother object can form a relation, or be relative too.</p>
<p><strong>View Matrix -</strong>  is the position of the camera in 3d space i.e XYZ values, the camera target and a camera up vector which defines the up director for the camera.</p>
<p><strong>Projection Matrix -</strong> is the behavior of a world matrix to the view matrix, simply speaking its the calcuation between the world as seen through the camera, which could be orthagonal or perspective, properties like the field of view, aspect ratio ( viewport width / viewport height ), near and Far ClipPlaneDIstance.</p>
<p>Gettin these three things in place will let you successfully load up anykind of model for basic shading purposes.</p>
<ul>
<li>A Background on shading in the computer world, is that all graphical data is vector based data, meaning that if this data was to be rendered as is, u would get a huge block of continiously flowing numbers, Yes exactly like the matrix, expections that it would be green.. so to see this data in the form that we humans find more apealling, that is through pictures, this vecotor needs to be converted to pixel based information, a process nowdays commonly known as rasterization, in doing so the processor read every vector data and calculates the equivalent pixel based value, to show the final shaded model.</li>
</ul>
<p>Now we can get down to the actual HLSL ShadingModel, a standard file structure consists of 4 major parts the Input(Incoming Vertex Data), Vertex Shader Functions, Output, Pixel Shader Functions, Techniques.</p>
<p><strong>Input(Incoming Vertex Data)</strong> &#8211; This is where all the incoming vertex data is stored for futther calculation, this includies data from other textures, models, cameras, matrixes etc. it is basically a storage block ( Buffer ) for migrating data.</p>
<p><strong>Vertex Shader Functions</strong> &#8211; This is where all the various methods for processing the input data reside, with a combination of these functions, a variety of results can be archieved, like calculating object normal space, or normals in relation to light, basically all kind of vector data. </p>
<p><strong>Output(Outgoing Vertex Data)  -</strong> This is again a buffer for vertex data, the only difference is that this data has already been worked on by the vertex shader functions, and is now ready to go to the next level which is processing by the pixel shader class.</p>
<p><strong>Pixel Shader Functions</strong> &#8211; This is where all the calculated vector data, is re-calculated with pixel based logic, so that the realtime renderer can finally get the needed values to display the required object in worldspace.</p>
<p><strong>Techniques </strong>- A technique is a function where a specific vector and pixel rendering function can be put together as a combination of different varities of rendering. like if u had an object that required normal vector rendering and another didnt not require that logic, then u could write 2 techniques, where 1 would have a function for calculating normal data and the other would be for stuff that didnt need normal calculations.</p>
<ul>
<li>Below is the DirectX API to more define the ShadingModel Pipeline.</li>
</ul>
<p>The Microsoft Direct3D 10 API defines a process to convert a group of vertices, textures, buffers, and state into an image on the screen. This process is described as a rendering pipeline with several distinct stages.</p>
<p>The different stages of the Direct3D 10 pipeline<a href="http://en.wikipedia.org/wiki/Direct3D#cite_note-3"><span> </span></a>are:</p>
<ol>
<li><strong>Input Assembler</strong>: Reads in vertex data from an application supplied vertex buffer and feeds them down the pipeline.</li>
<li><strong>Vertex Shader</strong>: Performs operations on a single vertex at a time, such as transformations, skinning, or lighting.</li>
<li><strong>Geometry Shader</strong>: Processes entire primitives such as triangles, points, or lines. Given a primitive, this stage discards it, or generates one or more new primitives.</li>
<li><strong>Stream Output</strong>: Can write out the previous stage&#8217;s results to memory. This is useful to recirculate data back into the pipeline.</li>
<li><strong>Rasterizer</strong>: Converts primitives into pixels, feeding these pixels into the pixel shader. The Rasterizer may also perform other tasks such as clipping what is not visible, or interpolating vertex data into per-pixel data.</li>
<li><strong>Pixel Shader</strong>: Determines the final pixel colour to be written to the render target and can also calculate a depth value to be written to the depth buffer.</li>
<li><strong>Output Merger</strong>: Merges various types of output data (pixel shader values, alpha blending, depth/stencil&#8230;) to build the final result.</li>
</ol>
<ul>
<li>Now getin down to  some shader logic,</li>
</ul>
<div><strong>Pixel shader</strong> (abbreviation <em>PS</em>) is a <a class="mw-redirect" title="Shader (computer science)" href="http://en.wikipedia.org/wiki/Shader_(computer_science)">shader</a> program, normally executed on the <a title="Graphics processing unit" href="http://en.wikipedia.org/wiki/Graphics_processing_unit">graphics processing unit</a>. In <a title="OpenGL" href="http://en.wikipedia.org/wiki/OpenGL">OpenGL</a>, it is referred to as the <strong>fragment shader  </strong>.A pixel shader computes color (and optionally more attributes) of each rendered pixel &#8211; so the pixel shader defines how the pixels ultimately look. Pixel shaders range from very simple ones (e.g. always output the same color) to simple (e.g. read a color from a texture, apply lighting value) to complex ones that simulate <a title="Bump mapping" href="http://en.wikipedia.org/wiki/Bump_mapping">bump mapping</a>, shadows, specular highlights, translucency and other complex phenomena.  The pixel shader is executed for each pixel rendered, and independently from the other pixels. Taken in isolation, a pixel shader alone can&#8217;t produce very complex effects, because it operates only on a single pixel, without any knowledge of scene&#8217;s geometry or neighboring pixels. In <a title="Stream processing" href="http://en.wikipedia.org/wiki/Stream_processing">Stream processing</a> terms, pixel shader is a computation kernel function.  In addition to color of the pixel, the pixel shader can also alter the depth of the pixel (for <a title="Z-buffering" href="http://en.wikipedia.org/wiki/Z-buffering">Z-buffering</a>), or output more than one color if multiple Render Targets are active.</div>
<div><strong>Vertex shader</strong> (abbreviation <em>VS</em>) is a <a class="mw-redirect" title="Shader (computer science)" href="http://en.wikipedia.org/wiki/Shader_(computer_science)">shader</a> program, normally executed on the <a title="Graphics processing unit" href="http://en.wikipedia.org/wiki/Graphics_processing_unit">Graphics processing unit</a>.A vertex shader is a graphics processing function used to add special effects to objects in a 3D environment.</div>
<div>
<ul>
<li>Now some theory  of shaders, </li>
</ul>
</div>
<p><strong>Standard Shader &#8211; </strong>The major re-quiste for texutures  is UV which is available to us in the FBX model, but that information needs to be imported into the Shader Logic, that is go by itterating through the texutre co-ordinates and wraping it around the vector data and continously transorming that with the skin transform data, so as to always keep the data live and updated with new current snapshots of the model. Then that vecor data needs to be sent to the pixel shader, so that the vector is then compared with the texture file, to produced the write colors in the write space.</p>
<p><strong>Diffuse Shading / Lighting</strong> - Diffuse shading is based on a principle that a surface is brightest when its facing the light and it tapers into darkness as is faces away from the light, basically if we normalize a vector, we end up keeping its direction, but the magnitude gets set to a value of 1, and this makes it a unit vector, the dot product of two unit vectors eqauls to the cos of the angle between the two vectors, &#8212;  dot( unit vector , unit vector ) = cos ( angle )  &#8212;    so with this we can determine if the surface is facing the light based on the result of the dot product, a value of 1 means that it is dirrectly facing the light and a value of -1 is that its in total darkness. so 1 is the brightest and -1 is the darkest area. the cos(angle) is a floating point value.</p>
<p><strong>Normal Map Shading</strong> &#8211; Normal Mapping works on the principle that we do not need to use the normals from the vertices of a mesh, like in a generic vertex shader, in this case we can use the normals information stoed in an image. Normals contain XYZ information, and a normal map stores theses XYZ co-ordinates in the form of RGB color data, so in a normal shader, it basically overwrites the low number of normals derieved from the mesh, which a higher number which is then derieved from the normal map. The normal map can be generated from a high resolution object and can be used to shade a low detail mesh. normal maps are calculated in tangent space. </p>
<p><strong>Specular Shading &#8211; </strong>For specularity, light is reflected from a surface to the camera or eye, it is always dependent on these two factors, whihc is the reflected light and the placement of the camera, in shader terms this would be the light reflection direction and the view(eye) vector, calulating reflected light can be a very intensive method, since it is depended on various bounce levels, so <a href="http://en.wikipedia.org/wiki/James_F._Blinn" target="_blank">James F. Blinn (1977)</a> devised something called as a Half Vector. THe Half Vector is the vector which is between the light and the eye, and the angle between the vector and the normal, is the same as the angle between the reflected light and the eye. This process is much quicker to calculate. For more information on Half vecotor u can see <a href="http://portal.acm.org/citation.cfm?doid=563858.563893" target="_blank">Models of light reflection for computer synthesized pictures</a> by  James F. Blinn. but thats not enough, speuclar depends on how smooth of rough an object really is, and thats where the specular exponent calculation comes in.</p>
<p><strong>Reflection Shading &#8211; </strong>For reflection, we need a reflection vector, which can be archieved by calculating what the camera is seeing based of the normals. This then will reflect a specified texture data in form of a cube map, so as to fake the surroundings of the world, in realtime. On a more complex level these maps are also  gnenerated in realtime so as to continously be updated with the environment that the object resides in.</p>
<p><strong>Simple Shadows -</strong> For basic shadows, we need to make a shadow matrix that will draw a flattened version fo the object on a ground plane, the object can then be shaded with a constant color, so that it can look like a shadow on a ground plane. This can be quite an overkill at times, since it is basically making an instance of the character, and it still needs to calculate another set of vertices for the shadow.</p>
<p><strong>Stencil Buffer Shadows &#8211; </strong>The Flexibility of the stencil mesh is not to draw the shadow as a flattened mesh but to draw its shape like a sillothettes. the shadow matrix will still calculate a flattened version fo the object, but when the shadow needs to be draw, it will go throught a stencil mode, in which the pre-processor will check to see if there is overlapping of shadow pixels or no, so as to always keep only one value to a shadow pixel at any given time. This is also a better option for alpha blending, since there is no overlapping of information, it would not tend to jitter in realtime.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.artbycrunk.com/blog/2008/09/realtime-shading-with-hlsl/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
