Process SMIL directives in XML data: Difference between revisions

From Rosetta Code
Content added Content deleted
m (flag for difficulty issues, use template magic to put solution in page)
(removed OpenGL and X3D and keep only SMIL)
Line 1: Line 1:
Please rename into: "process Smiled Data"
{{difficulty}}

{{draft task}}
{{draft task}}
<!-- {{task|3D}} -->
<!-- {{task|3D}} -->
OpenGL commonly requires the facility to be able to obtain geometric data and supplementary information, such as animation data, from a file. The task is to obtain data from a given file and place into appropriately organized X3D data structures. The Smil animation statements found within the file should be stored in an XML record, because X3D data structures are not supposed to contain Smil data.


In order to represent evolutions of data over time, the [http://www.w3.org/TR/SMIL/ SMIL] standard provides a solution to record the animation of data formated in XML.
* X3D: [[wp: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]
* Smil: [[wp:Synchronized_Multimedia_Integration_Language|on Wikipedia]] / [http://www.w3.org/TR/SMIL/ SPECS] / [http://www.w3.org/TR/SMIL/smil-animation.html#q35 Examples]


The task is to create an utility that given the first Smiled XML file, would return the second one
Here is the pure X3D base of our file containing only geometry:

* [[wp:Synchronized_Multimedia_Integration_Language|Smil on Wikipedia]] and [http://www.w3.org/TR/SMIL/smil-animation.html#q35 at W3]
And here is the same data with additional Smil statments that you should load, display and animate with OpenGL (or something else):


<lang xml><?xml version="1.0" ?>
<lang xml><?xml version="1.0" ?>
<smil>
<X3D>
<X3D>
<Scene>
<Scene>
Line 16: Line 19:
<Transform translation='0.0 0.0 0.0' scale='1 1 1'>
<Transform translation='0.0 0.0 0.0' scale='1 1 1'>
<Shape>
<Shape>
<Box size='2 1 2'/>
<Box size='2 1 2'>
<animate attributeName="size" from="2 1 2"
to="1 2 1" begin="0s" dur="10s"/>
</Box>
<Appearance>
<Appearance>
<Material diffuseColor='0.0 0.6 1.0'/>
<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>
</Appearance>
</Shape>
</Shape>
</Transform>
</Transform>
</Scene>
</Scene>
</X3D></lang>
</X3D></smil></lang>


At t = 0 second here is the expected output:
And here is the same data with additional Smil statments that you should load, display and animate with OpenGL (or something else):


<lang xml><?xml version="1.0" ?>
<lang xml><?xml version="1.0" ?>
<smil>
<X3D>
<X3D>
<Scene>
<Scene>
Line 35: Line 43:
<Transform translation='0.0 0.0 0.0' scale='1 1 1'>
<Transform translation='0.0 0.0 0.0' scale='1 1 1'>
<Shape>
<Shape>
<Box size='2 1 2'>
<Box size='2 1 2'/>
<animate attributeName="size" from="2 1 2"
to="1 2 1" begin="0s" dur="10s"/>
</Box>
<Appearance>
<Appearance>
<Material diffuseColor='0.0 0.6 1.0'>
<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>
</Appearance>
</Shape>
</Shape>
</Transform>
</Transform>
</Scene>
</Scene>
</X3D></smil></lang>
</X3D></lang>


At t = 2 second here is the expected output:
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>


If you are in shape, try to implement the &lt;seq&gt; tag too ([http://www.w3.org/TR/SMIL/smil-timing.html#edef-seq def], [http://www.w3.org/TR/SMIL/smil-timing.html#q175 ex.]), we could for example put successivelly a Box, a Sphere, a Cone into it.


<lang xml><?xml version="1.0" ?>
It should be possible to insert "animate" tags against every attribute of the base file and it is important to be able to insert timelines into the data structure.
<X3D>

<Scene>
'''Warnings:'''
<Viewpoint position="0 0 8" orientation="0 0 1 0"/>
* This task is a draft, you can modify it if you find a way to enhance it,
<PointLight color='1 1 1' location='0 2 0'/>
* The coordinates in the X3D data are not important. For example, the provided box data may not be positioned centrally to the viewpoint, Please fix this if you can.
<Transform translation='0.0 0.0 0.0' scale='1 1 1'>

<Shape>

<Box size='1.8 1.2 1.8'/>
=={{header|OCaml}}==
<Appearance>
{{:Loading animated 3D data/OCaml}}
<Material diffuseColor='0.2 0.56 0.8'/>

</Appearance>
{{omit from|Batch File|No way of writing complex parsers and no access to GUI functions, let alone OpenGL.}}
</Shape>
{{omit from|GUISS}}
</Transform>
{{omit from|PARI/GP}}
</Scene>
{{omit from|Unlambda|Supports neither OpenGL nor files.}}
</X3D></lang>

Revision as of 14:24, 25 May 2014

Please rename into: "process Smiled Data"

Process SMIL directives in XML data is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

In order to represent evolutions of data over time, the SMIL standard provides a solution to record the animation of data formated in XML.

The task is to create an utility that given the first Smiled XML file, would return the second one

And here is the same data with additional Smil statments that you should load, display and animate with OpenGL (or something else):

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

 <Scene>
   <Viewpoint position="0 0 8" orientation="0 0 1 0"/>
   <PointLight color='1 1 1' location='0 2 0'/>
   <Transform translation='0.0 0.0 0.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>

At t = 0 second here is the expected output:

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

 <Scene>
   <Viewpoint position="0 0 8" orientation="0 0 1 0"/>
   <PointLight color='1 1 1' location='0 2 0'/>
   <Transform translation='0.0 0.0 0.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>

At t = 2 second here is the expected output:


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

 <Scene>
   <Viewpoint position="0 0 8" orientation="0 0 1 0"/>
   <PointLight color='1 1 1' location='0 2 0'/>
   <Transform translation='0.0 0.0 0.0' scale='1 1 1'>
     <Shape>
       <Box size='1.8 1.2 1.8'/>
       <Appearance>
         <Material diffuseColor='0.2 0.56 0.8'/>
       </Appearance>
     </Shape>
   </Transform>
 </Scene>

</X3D></lang>