Skip to content
davido262 edited this page Nov 10, 2012 · 12 revisions

This page describes the format of an XML scene.

Every scene saved or loaded by the Shoggoth Engine follows a simple format. The scene is described in the tag scene. Inside there should be the root tag, which is an entity of type root-node. All of its children are the rest of the entities describing the scene. A typical root node would look like this:

<**root** type="root-node">
    ...
</**root**>

Every attribute in an XML tag has a default value if not specified.

If a certain tag is of type entity, then the name of the entity is the name of the tag. It is important to note that every entity should have a different name. In the case two entities are named the same it will load the first one, ignore any entity with a repeated name and print a warning. It also includes the position as a 3D vector with format "X Y Z" and the orientation as a quaternion with format "W X Y Z" of the entity. An entity could look like this:

<**entity-name** type="entity" position="0 0 0" orientation="1 0 0 0">
    ...
</**entity-name**>

As children to an entity could be more entities or its components. If it is another entity it will keep reading recursively. If it is of type component, then a new component of type component-name will be created and attached to the current entity. All of the attributes will then be read and set to the component, if no attribute is specified a default value will be used. A component would use the following format:

<**component-name** type="component" attribute1="x" attribute2="y" ... attributeN="n"/>

At least one camera component must be present, otherwise it will fail to load the scene.

Example XML scene:

<?xml version="1.0" encoding="utf-8"?>
<**scene**>
  <**root** type="root-node">
    <**building** type="entity" position="5 4 -10" orientation="1 0 0 0">
      <**renderablemesh** type="component" model="$box 3 9 3"/>
      <**rigidbody** type="component" collisionshape="#box 3 9 3" mass="0"/>
    </**building**>
    <**cube** type="entity" position="-1 8 0" orientation="0.956937 0.168491 0.228949 0.0588568">
      <**renderablemesh** type="component" model="$box 0.5 0.5 0.5"/>
      <**rigidbody** type="component" collisionshape="#box 0.5 0.5 0.5" mass="1"/>
    </**cube**>
    <**floor** type="entity" position="0 -1 0" orientation="1 0 0 0">
      <**renderablemesh** type="component" model="$box 100 1 100"/>
      <**rigidbody** type="component" collisionshape="#box 100 1 100" mass="0"/>
    </**floor**>
    <**light1** type="entity" position="5 5 5" orientation="1 0 0 0">
      <**light** type="component" ambient="0 0 0 1" diffuse="1 1 1 1" specular="1 1 1 1"/>
    </**light1**>
    <**camera1** type="entity" position="0 4 10" orientation="0.995004 -0.0998334 0 0">
      <**camera** type="component" cameratype="1" perspectivefov="45" orthoheight="10" neardistance="0.1" fardistance="1000"/>
    </**camera1**>
  </**root**>
</**scene**>

Clone this wiki locally