Emma XMA Format

From Emma

  The following XML hierarchy is recognized:
  <emma>      - top level element. 
              Attributes: 
              version 
              Content: proto, expose, field, n, route, script, meta, interface, implement
  <proto>     - proto definition. 
              Attributes: 
              class(name of proto). 
              src (file containing implementation of object). 
              Content: proto, expose, field, n, route, script, interface, implement
  <field>     - field definition. 
              Attributes: 
              name (name of field),
              class (data type), 
              value (initial value), 
              from (source object and field, using '.' notation), 
              to (destination object and field, using '.' notation), 
              do (Lua script). 
              Accepts CDATA (number, string or boolean values). 
              Content: n, do, from, to.
  <n>         - Node declaration. 
              Attributes: 
              class (node type), 
              id (id used by other objects)
              implements (this object implements this interface)
              src (file containing implementation of object). 
              NOTE: use class or src, not both. 
              Content: f.
  <f>         - Field initialization. 
              Attributes: 
              name (field name), 
              value (initial value), 
              from (source object and field, using '.' notation), 
              to (destination 
              object and field, using '.' notation), 
              do (Lua script). Accepts CDATA (number, string or boolean 
              values). 
              Content: n, do, trigger, from, to.
  <expose>    - exposed object type of proto (top level or embedded).
              Attributes: 
              class (object type exposed).
              implements (this exposed object implements this interface)
              Content: f
  <script>    - Add scripting code in place. 
              Attributes: 
              class (mime-type of language script is written in),
              src (URL of a file containing the script),
              Accepts CDATA (script).
  <do>        - script attached to field. 
              Attributes: 
               script (Lua script).
               Accepts CDATA (Lua script)
  <route>     - Route between two fields. 
              Attributes: 
              from (source object and field, using '.' notation),
              to (destination object and field, using '.' notation),
              do (Lua script), after ('true' or 'false'). Accepts 
              CDATA (Lua script)
  <from>      - Route to the attached field. 
              Attributes: 
              from (source object and field, using '.' notation)
  <to>        - Route from the attached field. 
              Attributes: 
              to (destination object and field, using '.' notation)
  <interface> - Create an interface definition. 
              Attributes: 
              class (name of interface)
              Content: function
  <function>  - Create an interface definition. 
              Attributes: 
              name (name of function), params (params passed to function)
  <implement> - Declares that this proto implements this interface. 
              Attributes: 
              class (name of interface)
  <meta>      - Include metadata. 
              Attributes: 
              http-equiv (HTTP response header name)
              name (metainformation name)
              content (associated information)
              scheme (select form of content)
NOTE <n> and <f> are generic node and field elements. Any element
other than those listed above are accepted whereever an <n> or <f>
element is accepted. Where <n> is accepted, the element name is
used as the type attribute. Where <f> is accepted, the element name is
used as the name attribute.

Sample:

<emma version="0.6">

<!--
<meta name="description" content="Spinning robot test"/>
<meta name="author" content="Chris Marrin"/>
-->

<script>
	<![CDATA[
		function initialize ( )
			print();
			print();
			print();
			print("Spinning robot test");
			print();
			print("You should see a spinning robot in the display");
			print();
		end
	]]>
</script>

<Shape id="Rotor" translation="0 -2 0" rotation="0 1 0 0" scale="0.05 0.05 0.05">
	<geometry>
		<MeshInline	url="../assets/robot.mesh">
			<assetURLs>"../assets/Examples.program", "../assets/Example_Basic.cg", "../assets/robot.material"
			</assetURLs>
			<currentAnimations>
				<MeshAnimation name="Walk"/>
			</currentAnimations>
			<timer>
				<Timer loop="true"/>
			</timer>
		</MeshInline>
	</geometry>
</Shape>	

<Timer id="T" interval="30"	loop="true">
	<fraction>
		<do>
			<![CDATA[
				self.Rotor.rotation = { 0, 1, 0, T.fraction*Math.PI*2 }
			]]>
		</do>
	</fraction>
</Timer>

</emma>