[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.16 Importing Model Files

Crystal Space is able to read other file formats than the native world files. For example, it is possible to read a file in the common `3ds' file format from 3d Studio and build mesh objects from it. This happens in two steps: First the file is read and the data is stored in a format-independent, meshobject-independent structure. Then this structure is used to build a mesh object. In this section, I will call this structure IDS (independent data structure). The details of the IDS are explained in the next section.

Loading a file is done by the converter plugins. There are different converters for different file formats, but not for different types of mesh objects. This is not needed as the converters don't deal with mesh objects but only create the IDS. Converters can also provide file saving in their formats. Using this feature you can for example convert files of different formats into another format, such as to convert a `3ds' file into a `pov' file.

After loading a model you will usually need to prepare the data a bit. This is needed because the IDS is not completely independent. In some cases this was not possible, while in others this makes things faster and more simple. However, Crystal Space provides functions to do this preparation for you. They are grouped together in a namespace wrapper called csModelDataTools. As an example, this includes a function to split objects using more than one material into objects that don't. 3d sprites in Crystal Space are limited to one material per sprite.

Finally, you have to build a mesh object from the IDS. This is done using the so-called cross-builder plugin (historical name, I don't know why the original author used it :-). I have not tried yet to find a nice and common-for-all-meshes interface, so currently the crossbuilder is simply a set of three functions: The first function builds a simple thing mesh from a single IDS sub-object, the second function does the same for sprites, and the third one creates a hierarchy of sprites from all objects in an IDS.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated using texi2html 1.76.