48
X3DOM Documentation, Release 1.4.0
(x3dom.pat). You can change the marker by creating a new one with thepatterngenerator, putting the results into the
Data folder and renaming it to x3dom.pat. Please note that you should keep the generator’s default values for marker
resolution and segment size of 16×16 and 50% in orderto work properly.
Including the FLARToolkit marker tracker
The compiled SWFis included via object and embed tags into the HTML page. It calls the Javascript function:
set_marker_transform(value)
as soon as it recognizes a marker in the video. The exchanging values include the marker’s position and orientation.
As mentioned, they are used to set the 3D object’s position and rotation.
Asimple 3D Scene
The demo scene shows a simple AR application: The earth globe, which hovers above the marker. A second layer
shows the actual clouds surround the whole planet; live data loaded into the 3D scene.
Our demo is declared in HTML and structured in several divisions. Both, the 3D content and the compiled SWF, are
grouped inside two several <Div /> nodes. The layer containing the 3d markup is styled with CSS and positioned on
top of the compiled flash movie. Note that both have to have the same size and position in order to achieve a well
augmentation effect.
Then, we set up a <MatrixTransform /> node, which groups every 3D object we want to be positioned on the
marker. Inside we declare a simple <Sphere /> geometry and texture it with a png file of earth’s appearance.
Around the first one, we place a second <Sphere /> object at the same position but with a larger scale and texture
it with the transparent cloud data.
The basic structure
<x3d>
<scene>
<viewpoint fieldOfView=’0.60’ position=’0 0 0’></viewpoint>
<matrixtransform id="root_transform">
<transform
translation="0 0 20" scale="50 50 50"
rotation="0 1 0 3.145">
<transform def="earth" rotation="1 0 0 0 -1.57">
<shape>
<appearance>
<imageTexture url="some_texture.jpg">
</imageTexture>
</appearance>
<sphere></sphere>
</shape>
</transform>
<transform def="clouds" rotation="1 1 0 0 0 -1.57"
scale="1.1 1.1 1.1">
<shape>
<appearance>
<imageTexture url="some_texture2.jpg">
</imageTexture>
</appearance>
<sphere></sphere>
</shape>
1.2. Tutorial
29