Architecture:Map Object Format: Difference between revisions

From Adonthell
Jump to navigation Jump to search
Updated for new 3D shapes
Line 1: Line 1:
== Example Map Object Model ==
== Example Map Object Model ==


The following XML file describes a simple [[Architecture:Map Module#Map Objects|Map Object]] that has been [[Architecture:Base Module#Data Persistance|Serialized]].
The following XML file describes a simple [[Architecture:Map Module#Map Objects and Shapes|Map Object]] that has been [[Architecture:Base Module#Data Persistance|serialized]].


   <?xml version="1.0"?>
   <?xml version="1.0"?>
Line 8: Line 8:
       <string id="state">default</string>
       <string id="state">default</string>
       <list id="default">
       <list id="default">
         <u_int16 id="length">1</u_int16>
         <list id="shape">
        <u_int16 id="height">1</u_int16>
          <u_int16 id="num">1</u_int16>
        <u_int16 id="size">0</u_int16>
          <list id="cube">
        <bool>0</bool>
            <string id="p3d">[0, 0, 0]</string>
        <bool>0</bool>
            <string id="p3d">[40, 0, 0]</string>
        <u_int16 id="x">0</u_int16>
            <string id="p3d">[40, 40, 0]</string>
        <u_int16 id="y">0</u_int16>
            <string id="p3d">[0, 40, 0]</string>
        <u_int16 id="x_off">0</u_int16>
            <string id="p3d">[0, 0, 0]</string>
        <u_int16 id="y_off">0</u_int16>
            <string id="p3d">[40, 0, 0]</string>
            <string id="p3d">[40, 40, 0]</string>
            <string id="p3d">[0, 40, 0]</string>
          </list>
        </list>
       </list>
       </list>
     </list>
     </list>
     <string id="sprite">data/gfx/map/ground/outside/grass/long-grass-tile.xml</string>
     <string id="sprite">data/gfx/map/ground/outside/grass/grass-ground.xml</string>
   </Data>
   </Data>
It is a flat ground tile of size 40x40 and zero height.


== Parameters of a Map Object ==
== Parameters of a Map Object ==


A [[Architecture:Map Module#Map Objects|Map Object]] has two components: the <tt>model</tt> part contains the 'physical' properties of the object, while the <tt>sprite</tt> part contains its graphical representation.  
A [[Architecture:Map Module#Map Objects and Shapes|Map Object]] has two components: the <tt>model</tt> part contains the 'physical' properties of the object, while the <tt>sprite</tt> part contains its graphical representation.
 
The <tt>model</tt> is composed of one or more states that correspond to separate animations in the <tt>sprite</tt>. Associated with each state is a <tt>shape</tt>, which is composed of one or more <tt>cube</tt>s. These are defined by the position of their 8 corner points (in pixels). These positions are given relative to the bottom left corner of the corresponding animation.  


The <tt>model</tt> is composed of one or more states that correspond to separate animations in the <tt>sprite</tt>. Each state requires the following information:
All cubes together, placed inside a bounding box, define the length (extension along the x axis), width (extension along the y axis) and height (extension along the z axis) of the map object.


* '''The Bounding Box''' is a cube defined by <tt>length</tt>, <tt>height</tt> and <tt>size</tt>. Length and height specify the area occupied by a map object in map squares (40x40 pixel). Size is the object's height in pixels.
<!-- It should be noted that it is possible to use "degenerated" cubes, where one or more points may share the same coordinate. -->
* '''The Collision Flags''' are used to turn collision mode individually on (0) or off (1) for each map square the object occupies. This is useful when dealing with objects that are not really square.
* '''The Base Tile''' usually sits in the bottom right corner of a map object. It is used to determine drawing order when multiple objects occupy the same space on the map.
* '''The Pixel Offset''' allows objects to be placed freely on the map, besides the underlying grid. Sensible values are in the range from 0 to 39.


[[Category:Development]]
[[Category:Development]]
[[Category:Architecture]]
[[Category:Architecture]]

Revision as of 21:57, 10 January 2008

Example Map Object Model

The following XML file describes a simple Map Object that has been serialized.

 <?xml version="1.0"?>
 
   <list id="model">
     <string id="state">default</string>
     <list id="default">
       <list id="shape">
         <u_int16 id="num">1</u_int16>
         <list id="cube">
           <string id="p3d">[0, 0, 0]</string>
           <string id="p3d">[40, 0, 0]</string>
           <string id="p3d">[40, 40, 0]</string>
           <string id="p3d">[0, 40, 0]</string>
           <string id="p3d">[0, 0, 0]</string>
           <string id="p3d">[40, 0, 0]</string>
           <string id="p3d">[40, 40, 0]</string>
           <string id="p3d">[0, 40, 0]</string>
         </list>
       </list>
     </list>
   </list>
   <string id="sprite">data/gfx/map/ground/outside/grass/grass-ground.xml</string>
 

It is a flat ground tile of size 40x40 and zero height.

Parameters of a Map Object

A Map Object has two components: the model part contains the 'physical' properties of the object, while the sprite part contains its graphical representation.

The model is composed of one or more states that correspond to separate animations in the sprite. Associated with each state is a shape, which is composed of one or more cubes. These are defined by the position of their 8 corner points (in pixels). These positions are given relative to the bottom left corner of the corresponding animation.

All cubes together, placed inside a bounding box, define the length (extension along the x axis), width (extension along the y axis) and height (extension along the z axis) of the map object.