<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd"> <html> <!-- Created by texi2html 1.76 --> <!-- Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author) Karl Berry <karl@freefriends.org> Olaf Bachmann <obachman@mathematik.uni-kl.de> and many others. Maintained by: Many creative people <dev@texi2html.cvshome.org> Send bugs and suggestions to <users@texi2html.cvshome.org> --> <head> <title>Crystal Space 1.2.1: 5.7 md32spr Tutorial</title> <meta name="description" content="Crystal Space 1.2.1: 5.7 md32spr Tutorial"> <meta name="keywords" content="Crystal Space 1.2.1: 5.7 md32spr Tutorial"> <meta name="resource-type" content="document"> <meta name="distribution" content="global"> <meta name="Generator" content="texi2html 1.76"> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <style type="text/css"> <!-- a.summary-letter {text-decoration: none} pre.display {font-family: serif} pre.format {font-family: serif} pre.menu-comment {font-family: serif} pre.menu-preformatted {font-family: serif} pre.smalldisplay {font-family: serif; font-size: smaller} pre.smallexample {font-size: smaller} pre.smallformat {font-family: serif; font-size: smaller} pre.smalllisp {font-size: smaller} span.sansserif {font-family:sans-serif; font-weight:normal;} ul.toc {list-style: none} --> </style> </head> <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000"> <a name="md32spr-Tutorial"></a> <a name="0"></a> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="lighter2-Developer_0027s-Manual.html#0" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="mdl2spr.html#0" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="Internals.html#0" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> <td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <hr size="1"> <h2 class="section"> 5.7 <code>md32spr</code> Tutorial </h2> <p><em>Written by Manjunath Sripadarao, <a href="mailto:msripada@evl.uic.edu">msripada@evl.uic.edu</a>. Last updated 17 December 2002.</em> </p> <p>This tutorial provides a brief introduction to <code>md32spr</code> application. You can use this application to convert Quake III <small>MD3</small> models to Crystal Space model format. The <code>md32spr</code> source files can be found in <tt>‘CS/apps/import/md32spr/’</tt>. Typing <i><samp>‘make md32spr’</samp></i> should build the application (after configuring Crystal Space for your particular architecture). </p> <a name="1"></a> <h3 class="subheading"> Required Resources </h3> <p>For this tutorial we will be using the “Conni” model from <a href="http://www.polycount.com/">http://www.polycount.com/</a>. The name of the file is <tt>‘mdl-conni.zip’</tt>. Download the file to a local directory. </p> <a name="2"></a> <h3 class="subheading"> Converting the Model </h3> <ul> <li> Unzip the contents of <tt>‘mdl-conni.zip’</tt> into a temporary directory. </li><li> Among the contents, find the file named <tt>‘conni.pk3’</tt> and <em>unzip</em> it using a tool which can unpack <small>ZIP</small>-style archives. (<small>PK3</small> files are just <small>ZIP</small> archives in disguise.) </li><li> Next go to the directory <tt>‘models/players/conni/’</tt>. </li><li> Zip the contents of this file using a tool for creating <small>ZIP</small>-style archives; call this file <tt>‘conni.zip’</tt>. </li><li> Copy <tt>‘conni.zip’</tt> to the <tt>‘CS/data/’</tt> directory. </li><li> Now run the following command: <table><tr><td> </td><td><pre class="example">./md32spr data/conni.zip -o=data/conni_out.zip -scale=4096 </pre></td></tr></table> </li><li> This should give you an output file named <tt>‘conni_out.zip’</tt> in the <tt>‘CS/data/’</tt> directory. </li></ul> <a name="3"></a> <h3 class="subheading"> Loading a Model in Walktest </h3> <p>To load the model into Walktest, copy the sample world file given below to a new file named world. Add this <tt>‘world’</tt> file to the archive <tt>‘conni_out.zip’</tt> using a <small>ZIP</small>-capable archiver, and then issue the following command: </p> <table><tr><td> </td><td><pre class="example">./walktest -recalc data/conni_out.zip </pre></td></tr></table> <p>This will allow you to view the model in Walktest. The <tt>‘world’</tt> file defines a sample map and the <em>mesh objects</em> that make up the model. If you are curious, you can use a text editor to look at the <tt>‘world’</tt> for more information. The sample <tt>‘world’</tt> file is also reproduced below for convenience (see <a href="#Conni-Output">Sample “World” file</a>). </p> <p><strong>Note</strong>: The model here is loaded into walktest for testing purposes. Normally in your application there won't be a <tt>‘world’</tt> file for each of your models. You have to load and animate your models using code. </p> <a name="4"></a> <h3 class="subheading"> Description of Archive Contents </h3> <p>The output sprite archive <tt>‘conni_out.zip’</tt> contains the following files. </p> <ul> <li> <code>head</code> </li><li> <code>upper</code> </li><li> <code>lower</code> </li><li> <code>head.tag</code> </li><li> <code>upper.tag</code> </li><li> <code>lower.tag</code> </li><li> <code>conni.tga</code> </li></ul> <p>The <tt>‘head’</tt>, <tt>‘lower’</tt> and <tt>‘upper’</tt> files contain the <em>meshobjects</em>. The file <tt>‘conni.tga’</tt> is the texture file. The files <tt>‘head.tag’</tt>, <tt>‘lower.tag’</tt> and <tt>‘upper.tag’</tt> contain the <small>MD3</small> tags. </p> <a name="5"></a> <h3 class="subheading"> <small>MD3</small> Tags </h3> <p>The <small>MD3</small> tags are bits of information which specify the spatial location and orientation of the mesh objects for each frame. Here is an example of an <small>MD3</small> tag structure represented as C++ code: </p> <table><tr><td> </td><td><pre class="example">char Name[64]; // Name of the 'tag'. Vec3 Position; // Relative position of tag. Vec3x3 Rotation;// Direction tag faces relative to rest of model. </pre></td></tr></table> <p>In the Crystal Space map format (which is <small>XML</small>), these tags are placed in a separate file with a <tt>‘.tag’</tt> extension. The format of these tags is shown below. </p> <table><tr><td> </td><td><pre class="example"><key name="md3tag" tag="<tag_name> <frame_num> <tag_num> <xpos ypos zpos> <3x3 rotation matrix>" /> </pre></td></tr></table> <p>For example: </p> <table><tr><td> </td><td><pre class="example"><key name="md3tag" tag="tag_torso 0 1 1 0 0 0 1 0 0 0 1 0 0 0" /> </pre></td></tr></table> <p>If your model does not have any animation or your model is made up of only one mesh object, then you may not have these tags. </p> <a name="6"></a> <h3 class="subheading"> Miscellaneous <code>md32spr</code> Information </h3> <p>This section will tell you if there are any special issues to worry about. Currently these are the known issues. If I come across anything else I will amend this section. </p> <ul> <li> Currently, in the mesh object files at the end, there are example mesh objects definition. These are not required to load the model, but they are left there as an example. You should comment it out manually to reduce memory usage. </li><li> Some <small>MD3</small> model converters do not write any frame number information if a model is not animated. This causes garbage numbers to be read from the <small>MD3</small> file. Subsequently, you may end up with a a large number (possibly in the thousands or hundred-thousands) duplicate frames which actually do nothing. Until now I have not been able to find a solution to this problem. Any comments, suggestions or corrections are welcome. </li><li> The loading of Crystal Space format <small>XML</small> models is somewhat slow presently. You can speed it up by converting your models to binary format using <small>VIEWMESH</small>. I have not personally tried it. But if anyone wants any help let me know. </li><li> Type <code>./md32spr</code> without any arguments to get a brief command line help. </li></ul> <p><a name="Conni-Output"></a> </p><a name="7"></a> <h3 class="subheading"> Sample “World” file </h3> <p>Here is the sample <tt>‘world’</tt> file for the “Conni” model. You need to copy this to a new file and add that file to conni_out.zip. For the model to work in Walktest. </p> <table><tr><td> </td><td><pre class="example"><world> <library>lower</library> <library>upper</library> <library>head</library> <textures> <texture name="abstract_a032.gif"> <file>/lib/stdtex/abstract_a032.jpg</file> </texture> <texture name="andrew_wood.gif"> <file>/lib/stdtex/andrew_wood.jpg</file> </texture> </textures> <materials> <material name="wood"> <texture>andrew_wood.gif</texture> </material> </materials> <sector name="room"> <meshobj name="walls"> <plugin>crystalspace.mesh.loader.thing</plugin> <params> <v x="-10" y="-1" z="10" /> <v x="10" y="-1" z="10" /> <v x="-10" y="-1" z="-10" /> <v x="10" y="-1" z="-10" /> <v x="-10" y="4" z="10" /> <v x="10" y="4" z="10" /> <v x="-10" y="4" z="-10" /> <v x="10" y="4" z="-10" /> <material>wood</material> <texlen>4</texlen> <p name="up"> <v>6</v> <v>7</v> <v>5</v> <v>4</v> </p> <p name="down"> <v>3</v> <v>2</v> <v>0</v> <v>1</v> </p> <p name="back"> <v>7</v> <v>6</v> <v>2</v> <v>3</v> </p> <p name="front"> <v>4</v> <v>5</v> <v>1</v> <v>0</v> </p> <p name="left"> <v>6</v> <v>4</v> <v>0</v> <v>2</v> </p> <p name="right"> <v>5</v> <v>7</v> <v>3</v> <v>1</v> </p> </params> <zfill /> </meshobj> <light> <center x="0" y="0" z="9" /> <radius>40</radius> <color red="1" green="1" blue="1" /> </light> <light> <center x="0" y="0" z="-9" /> <radius>20</radius> <color red="1" green="1" blue="1" /> </light> <light> <center x="-9" y="0" z="0" /> <radius>20</radius> <color red="1" green="1" blue="1" /> </light> <light> <center x="9" y="0" z="0" /> <radius>20</radius> <color red="1" green="1" blue="1" /> </light> <meshobj name="headh_head"> <plugin>crystalspace.mesh.loader.sprite.3d</plugin> <params> <factory>h_head</factory> <action>default</action> </params> <move> <matrix> <rotx>-1.5708</rotx> </matrix> <v x="-1" y="0.45" z="3" /> </move> </meshobj> <meshobj name="upperu_torso"> <plugin>crystalspace.mesh.loader.sprite.3d</plugin> <params> <factory>u_torso</factory> <action>TORSO_STAND</action> </params> <move> <matrix> <rotx>-1.5708</rotx> </matrix> <v x="-1" y="0.26" z="3" /> </move> </meshobj> <meshobj name="lowerl_legs"> <plugin>crystalspace.mesh.loader.sprite.3d</plugin> <params> <factory>l_legs</factory> <action>LEGS_IDLE</action> </params> <move> <matrix> <rotx>-1.5708</rotx> </matrix> <v x="-1" y="0" z="3" /> </move> </meshobj> </sector> </world> </pre></td></tr></table> <hr size="1"> <table cellpadding="1" cellspacing="1" border="0"> <tr><td valign="middle" align="left">[<a href="lighter2-Developer_0027s-Manual.html#0" title="Previous section in reading order"> < </a>]</td> <td valign="middle" align="left">[<a href="mdl2spr.html#0" title="Next section in reading order"> > </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> << </a>]</td> <td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Up section"> Up </a>]</td> <td valign="middle" align="left">[<a href="Internals.html#0" title="Next chapter"> >> </a>]</td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left"> </td> <td valign="middle" align="left">[<a href="index.html#SEC_Top" title="Cover (top) of document">Top</a>]</td> <td valign="middle" align="left">[<a href="cs_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td> <td valign="middle" align="left">[<a href="cs_Index.html#0" title="Index">Index</a>]</td> <td valign="middle" align="left">[<a href="cs_abt.html#SEC_About" title="About (help)"> ? </a>]</td> </tr></table> <p> <font size="-1"> This document was generated using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>. </font> <br> </p> </body> </html>