Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > bad97183153701b09df5fae1052b1c30 > files > 4433

crystalspace-doc-1.2.1-5mdv2010.0.i586.rpm

<!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"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="mdl2spr.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </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"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </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>&lsquo;CS/apps/import/md32spr/&rsquo;</tt>.  Typing <i><samp>&lsquo;make md32spr&rsquo;</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 &ldquo;Conni&rdquo; model from
<a href="http://www.polycount.com/">http://www.polycount.com/</a>.  The name of the file is
<tt>&lsquo;mdl-conni.zip&rsquo;</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>&lsquo;mdl-conni.zip&rsquo;</tt> into a temporary directory.

</li><li>
Among the contents, find the file named <tt>&lsquo;conni.pk3&rsquo;</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>&lsquo;models/players/conni/&rsquo;</tt>.

</li><li>
Zip the contents of this file using a tool for creating <small>ZIP</small>-style
archives; call this file <tt>&lsquo;conni.zip&rsquo;</tt>.

</li><li>
Copy <tt>&lsquo;conni.zip&rsquo;</tt> to the <tt>&lsquo;CS/data/&rsquo;</tt> directory.

</li><li>
Now run the following command:

<table><tr><td>&nbsp;</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>&lsquo;conni_out.zip&rsquo;</tt> in the
<tt>&lsquo;CS/data/&rsquo;</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>&lsquo;world&rsquo;</tt> file to the archive <tt>&lsquo;conni_out.zip&rsquo;</tt> using a <small>ZIP</small>-capable archiver, and then
issue the following command:
</p>
<table><tr><td>&nbsp;</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>&lsquo;world&rsquo;</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>&lsquo;world&rsquo;</tt> for more
information.  The sample <tt>&lsquo;world&rsquo;</tt> file is also reproduced below for
convenience (see <a href="#Conni-Output">Sample &ldquo;World&rdquo; 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>&lsquo;world&rsquo;</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>&lsquo;conni_out.zip&rsquo;</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>&lsquo;head&rsquo;</tt>, <tt>&lsquo;lower&rsquo;</tt> and <tt>&lsquo;upper&rsquo;</tt> files contain the
<em>meshobjects</em>.  The file <tt>&lsquo;conni.tga&rsquo;</tt> is the texture file.  The files
<tt>&lsquo;head.tag&rsquo;</tt>, <tt>&lsquo;lower.tag&rsquo;</tt> and <tt>&lsquo;upper.tag&rsquo;</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>&nbsp;</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>&lsquo;.tag&rsquo;</tt> extension.  The format of these tags is shown
below.
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">&lt;key name=&quot;md3tag&quot;
  tag=&quot;&lt;tag_name&gt; &lt;frame_num&gt; &lt;tag_num&gt;
       &lt;xpos ypos zpos&gt; &lt;3x3 rotation matrix&gt;&quot; /&gt;
</pre></td></tr></table>
<p>For example:
</p>
<table><tr><td>&nbsp;</td><td><pre class="example">&lt;key name=&quot;md3tag&quot; tag=&quot;tag_torso 0 1  1 0 0 0 1 0 0 0 1  0 0 0&quot; /&gt;
</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 &ldquo;World&rdquo; file </h3>

<p>Here is the sample <tt>&lsquo;world&rsquo;</tt> file for the &ldquo;Conni&rdquo; 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>&nbsp;</td><td><pre class="example">&lt;world&gt;
  &lt;library&gt;lower&lt;/library&gt;
  &lt;library&gt;upper&lt;/library&gt;
  &lt;library&gt;head&lt;/library&gt;
  &lt;textures&gt;
    &lt;texture name=&quot;abstract_a032.gif&quot;&gt;
      &lt;file&gt;/lib/stdtex/abstract_a032.jpg&lt;/file&gt;
    &lt;/texture&gt;
    &lt;texture name=&quot;andrew_wood.gif&quot;&gt;
      &lt;file&gt;/lib/stdtex/andrew_wood.jpg&lt;/file&gt;
    &lt;/texture&gt;
  &lt;/textures&gt;
  &lt;materials&gt;
    &lt;material name=&quot;wood&quot;&gt;
      &lt;texture&gt;andrew_wood.gif&lt;/texture&gt;
    &lt;/material&gt;
  &lt;/materials&gt;
  &lt;sector name=&quot;room&quot;&gt;
    &lt;meshobj name=&quot;walls&quot;&gt;
      &lt;plugin&gt;crystalspace.mesh.loader.thing&lt;/plugin&gt;
      &lt;params&gt;
	&lt;v x=&quot;-10&quot; y=&quot;-1&quot; z=&quot;10&quot; /&gt;
	&lt;v x=&quot;10&quot; y=&quot;-1&quot; z=&quot;10&quot; /&gt;
	&lt;v x=&quot;-10&quot; y=&quot;-1&quot; z=&quot;-10&quot; /&gt;
	&lt;v x=&quot;10&quot; y=&quot;-1&quot; z=&quot;-10&quot; /&gt;
	&lt;v x=&quot;-10&quot; y=&quot;4&quot; z=&quot;10&quot; /&gt;
	&lt;v x=&quot;10&quot; y=&quot;4&quot; z=&quot;10&quot; /&gt;
	&lt;v x=&quot;-10&quot; y=&quot;4&quot; z=&quot;-10&quot; /&gt;
	&lt;v x=&quot;10&quot; y=&quot;4&quot; z=&quot;-10&quot; /&gt;
	&lt;material&gt;wood&lt;/material&gt;
	&lt;texlen&gt;4&lt;/texlen&gt;
	&lt;p name=&quot;up&quot;&gt;
	  &lt;v&gt;6&lt;/v&gt;
	  &lt;v&gt;7&lt;/v&gt;
	  &lt;v&gt;5&lt;/v&gt;
	  &lt;v&gt;4&lt;/v&gt;
	&lt;/p&gt;
	&lt;p name=&quot;down&quot;&gt;
	  &lt;v&gt;3&lt;/v&gt;
	  &lt;v&gt;2&lt;/v&gt;
	  &lt;v&gt;0&lt;/v&gt;
	  &lt;v&gt;1&lt;/v&gt;
	&lt;/p&gt;
	&lt;p name=&quot;back&quot;&gt;
	  &lt;v&gt;7&lt;/v&gt;
	  &lt;v&gt;6&lt;/v&gt;
	  &lt;v&gt;2&lt;/v&gt;
	  &lt;v&gt;3&lt;/v&gt;
	&lt;/p&gt;
	&lt;p name=&quot;front&quot;&gt;
	  &lt;v&gt;4&lt;/v&gt;
	  &lt;v&gt;5&lt;/v&gt;
	  &lt;v&gt;1&lt;/v&gt;
	  &lt;v&gt;0&lt;/v&gt;
	&lt;/p&gt;
	&lt;p name=&quot;left&quot;&gt;
	  &lt;v&gt;6&lt;/v&gt;
	  &lt;v&gt;4&lt;/v&gt;
	  &lt;v&gt;0&lt;/v&gt;
	  &lt;v&gt;2&lt;/v&gt;
	&lt;/p&gt;
	&lt;p name=&quot;right&quot;&gt;
	  &lt;v&gt;5&lt;/v&gt;
	  &lt;v&gt;7&lt;/v&gt;
	  &lt;v&gt;3&lt;/v&gt;
	  &lt;v&gt;1&lt;/v&gt;
	&lt;/p&gt;
      &lt;/params&gt;
      &lt;zfill /&gt;
    &lt;/meshobj&gt;
    &lt;light&gt;
      &lt;center x=&quot;0&quot; y=&quot;0&quot; z=&quot;9&quot; /&gt;
      &lt;radius&gt;40&lt;/radius&gt;
      &lt;color red=&quot;1&quot; green=&quot;1&quot; blue=&quot;1&quot; /&gt;
    &lt;/light&gt;
    &lt;light&gt;
      &lt;center x=&quot;0&quot; y=&quot;0&quot; z=&quot;-9&quot; /&gt;
      &lt;radius&gt;20&lt;/radius&gt;
      &lt;color red=&quot;1&quot; green=&quot;1&quot; blue=&quot;1&quot; /&gt;
    &lt;/light&gt;
    &lt;light&gt;
      &lt;center x=&quot;-9&quot; y=&quot;0&quot; z=&quot;0&quot; /&gt;
      &lt;radius&gt;20&lt;/radius&gt;
      &lt;color red=&quot;1&quot; green=&quot;1&quot; blue=&quot;1&quot; /&gt;
    &lt;/light&gt;
    &lt;light&gt;
      &lt;center x=&quot;9&quot; y=&quot;0&quot; z=&quot;0&quot; /&gt;
      &lt;radius&gt;20&lt;/radius&gt;
      &lt;color red=&quot;1&quot; green=&quot;1&quot; blue=&quot;1&quot; /&gt;
    &lt;/light&gt;
    &lt;meshobj name=&quot;headh_head&quot;&gt;
      &lt;plugin&gt;crystalspace.mesh.loader.sprite.3d&lt;/plugin&gt;
      &lt;params&gt;
	&lt;factory&gt;h_head&lt;/factory&gt;
	&lt;action&gt;default&lt;/action&gt;
      &lt;/params&gt;
      &lt;move&gt;
	&lt;matrix&gt;
	  &lt;rotx&gt;-1.5708&lt;/rotx&gt;
	&lt;/matrix&gt;
	&lt;v x=&quot;-1&quot; y=&quot;0.45&quot; z=&quot;3&quot; /&gt;
      &lt;/move&gt;
    &lt;/meshobj&gt;
    &lt;meshobj name=&quot;upperu_torso&quot;&gt;
      &lt;plugin&gt;crystalspace.mesh.loader.sprite.3d&lt;/plugin&gt;
      &lt;params&gt;
	&lt;factory&gt;u_torso&lt;/factory&gt;
	&lt;action&gt;TORSO_STAND&lt;/action&gt;
      &lt;/params&gt;
      &lt;move&gt;
	&lt;matrix&gt;
	  &lt;rotx&gt;-1.5708&lt;/rotx&gt;
	&lt;/matrix&gt;
	&lt;v x=&quot;-1&quot; y=&quot;0.26&quot; z=&quot;3&quot; /&gt;
      &lt;/move&gt;
    &lt;/meshobj&gt;
    &lt;meshobj name=&quot;lowerl_legs&quot;&gt;
      &lt;plugin&gt;crystalspace.mesh.loader.sprite.3d&lt;/plugin&gt;
      &lt;params&gt;
	&lt;factory&gt;l_legs&lt;/factory&gt;
	&lt;action&gt;LEGS_IDLE&lt;/action&gt;
      &lt;/params&gt;
      &lt;move&gt;
	&lt;matrix&gt;
	  &lt;rotx&gt;-1.5708&lt;/rotx&gt;
	&lt;/matrix&gt;
	&lt;v x=&quot;-1&quot; y=&quot;0&quot; z=&quot;3&quot; /&gt;
      &lt;/move&gt;
    &lt;/meshobj&gt;
  &lt;/sector&gt;
&lt;/world&gt;
</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"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="mdl2spr.html#0" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="Working-with-Engine-Content.html#0" title="Beginning of this chapter or previous chapter"> &lt;&lt; </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"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </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>