Process SMIL directives in XML data: Difference between revisions

From Rosetta Code
Content added Content deleted
m (links to the specs)
m (fmt)
Line 1: Line 1:
One very common task in OpenGL is to load data from a file that contains geometry. These datas most often also contain additional informations, for example animation informations. In this task we propose to load X3D geometric datas with additional Smil animation statments. X3D ([http://en.wikipedia.org/wiki/X3D WP], [http://www.web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/X3D_XML.html SPECS of the XML form]) is not particularly supposed to be mixed with Smil ([http://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language WP], [http://www.w3.org/TR/SMIL/ SPECS]), but Smil is supposed to be mixable with any XML format.
One very common task in OpenGL is to load data from a file that contains geometry. These datas most often also contain additional informations, for example animation informations. In this task we propose to load X3D geometric datas with additional Smil animation statments. X3D is not particularly supposed to be mixed with Smil, but Smil is supposed to be mixable with any XML format.


* X3D: [http://en.wikipedia.org/wiki/X3D on Wikipedia] / [http://www.web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/X3D_XML.html SPECS of the XML form] / [http://www.web3d.org/x3d/specifications/ISO-IEC-19776-1.2-X3DEncodings-XML/Part01/examples.html Examples]
Here is the pure X3D base of our file:
* Smil: [http://en.wikipedia.org/wiki/Synchronized_Multimedia_Integration_Language on Wikipedia] / [http://www.w3.org/TR/SMIL/ SPECS] / [http://www.w3.org/TR/SMIL/smil-animation.html#q35 Examples]

Here is the pure X3D base of our file containing only geometry:


<lang xml><?xml version="1.0" ?>
<lang xml><?xml version="1.0" ?>
Line 45: Line 48:


Try to make it possible to insert "animate" tags for animating every attribute of the base file.
Try to make it possible to insert "animate" tags for animating every attribute of the base file.

In the example file, there is only a &lt;Box&gt; primitive, try to implement the primitives below too:
<lang xml> <Sphere radius="1"/>
<Cylinder radius="1" height="2"/>
<Cone bottomRadius="1" height="2"/></lang>

Revision as of 20:37, 2 January 2010

One very common task in OpenGL is to load data from a file that contains geometry. These datas most often also contain additional informations, for example animation informations. In this task we propose to load X3D geometric datas with additional Smil animation statments. X3D is not particularly supposed to be mixed with Smil, but Smil is supposed to be mixable with any XML format.

Here is the pure X3D base of our file containing only geometry:

<lang xml><?xml version="1.0" ?> <X3D>

 <Scene>
   <Viewpoint orientation="0 0 1 0" position="0 0 0"/>
   <PointLight color='1 1 1' location='0 2 0'/>
   <Transform translation='0.0 0.0 -3.0' scale='1 1 1'>
     <Shape>
       <Box size='2 1 2'/>
       <Appearance>
         <Material diffuseColor='0.0 0.6 1.0'/>
       </Appearance>
     </Shape>
   </Transform>
 </Scene>

</X3D></lang>

And here is the same datas with additional Smil statments that you should load, display and animate with OpenGL:

<lang xml><?xml version="1.0" ?> <smil> <X3D>

 <Scene>
   <Viewpoint orientation="0 0 1 0" position="0 0 0"/>
   <PointLight color='1 1 1' location='0 2 0'/>
   <Transform translation='0.0 0.0 -3.0' scale='1 1 1'>
     <Shape>
       <Box size='2 1 2'>
         <animate attributeName="size" from="2 1 2"
                                         to="1 2 1" begin="0s" dur="10s"/>
       </Box>
       <Appearance>
         <Material diffuseColor='0.0 0.6 1.0'>
           <animate attributeName="diffuseColor" from="0.0 0.6 1.0"
                                                   to="1.0 0.4 0.0" begin="0s" dur="10s"/>
         </Material>
       </Appearance>
     </Shape>
   </Transform>
 </Scene>

</X3D></smil></lang>

Try to make it possible to insert "animate" tags for animating every attribute of the base file.

In the example file, there is only a <Box> primitive, try to implement the primitives below too: <lang xml> <Sphere radius="1"/>

 <Cylinder radius="1" height="2"/>
 <Cone bottomRadius="1" height="2"/></lang>