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

7.9.18 Thing Mesh Object

Written by Jorrit Tyberghein, (jorrit.tyberghein@uz.kuleuven.ac.be).

This mesh object represents a 'thing' which is a very often used geometry object in Crystal Space. Things are often used to mark the bounding geometry of a sector so that it represents a closed space. Things are not very dynamic in nature (although you can have things that move) so they are most often used for static geometry.

Things support polygons. Things also support portals which means that they can be used to define transition polygons between adjacent or non-adjacent sectors.

There is also a howto on creating things (see section 5.9.5 Creating a Thing Mesh).

Basic Structure

The following SCF class names are used (for CS_LOAD_PLUGIN()):

Objects in this plugin implement the following SCF interfaces (get with SCF_QUERY_INTERFACE()):

State Interfaces

`iThingFactoryState' is the SCF interface that you can use to set/get settings for a thing. The definition of this interface can be found in `CS/include/imesh/thing/thing.h' and that is also the include file you need to include in your applications to use this plugin. Using this interface you can access the vertices, polygons, materials, and various other configuration parameters for a thing.

`iThingState' is for thing instances.

All include files for the thing mesh can be found in the `CS/include/imesh/thing' directory. There are include files for lightmaps, polygons, portals, ...

Factory and Object Loader

At load time a thing can be constructed from several thing parts. At run time these parts will all be combined into one big thing but at load time it is sometimes easy to be able to split the thing in parts so that you can have a more logical grouping of thing data. The important feature of parts is that the vertex table starts from zero again. This means that you can define vertices in a part and then use them in polygons in that part as if the vertex table starts at 0 again. This is useful because then you can more easily add new parts and even move around parts without having to change all vertex indices. Note that it is no problem to have duplicate vertices between different parts as they will be combined in a post-processing pass anyway. The table below describes everything which you can use in a single part which is also what you can use in the top level thing definition.

A given polygon (inside the `polygon' keyword) is defined as follows:

<material>materialName</material>
The material to use for this polygon. If not given then the default material will be used.
<texmap> ...
This keyword can be used to define additional texture mapping parameters.
<lighting>yes/no</lighting>
Should this polygon use lighting or not. By default this is enabled. If disabled the texture on this polygon will be rendered using original colors (i.e. full-bright texture).
<portal><sector>sectorName</sector></portal>
If you use this keyword then this polygon is a portal to the given sector.
<warp> ... FIXME: still existing ?
This keyword can be used to define additional parameters for the portal. More on this later.
shading(shadingParm) FIXME: still existing ?
This describes the kind of shading to use for this polygon. Possible values are: `none', `flat', `gouraud', or `lightmap'. Default is `lightmap'.
vertices <v v1="" ... />
The vertices of the polygon. This is a list of vertex indices local to the part this polygon is in. In combination with the `vblock' or `vroom' commands this command can also contain something with the name: `w', `e', `n', `s', `u', or `d' (for west, east, north, south, up, or down). This will then create vertices according to the last `vblock' or `vroom'. Note that there should be no other vertex generating command between the `vblock' or `vroom' and this polygon command! You can also give the first index of the `vblock' or `vroom' generated vertices with a notation like this: `vertices (w,8)'.
<uv u1="" v1="" ... />
If you use this keyword the polygon will be gouraud shaded and not lightmapped. This keyword allows you to describe the uv coordinates for the polygon with gouraud shading. Currently a gouraud shaded polygon is limited to three vertices. This limitation will be removed in the future. But for now it means that uv will be followed by six parameters (three u,v coordinate sets).
<uva u1="" v1="" a1="" ... />
Similar to `uv' but uses another technique to describe the coordinates using angle.
<color red="" green="" blue="" ... />
When using `uv' you can use this command to give colors (r,g,b) for every vertex.
colldet(boolean)
Enable/disable collision detection for this polygon. By default a normal polygon will have collision detection enabled. If the polygon has a portal then collision detection will be disabled unless the portal is a mirror in which case it will be enabled again. But using `colldet' allows you to override all this.
viscull(boolean)
Enable/disable visibility culling for this polygon. By default a normal polygon will have visibility culling enabled. If the polygon has alpha then it will be disabled. However if the polygon uses a transparent texture then CS cannot easily detect that so in that case you have to disable it manually. This flag tells the visibility culler that this polygon should NOT be used to cull other objects (i.e. to block visibility).
<alpha>alphaValue</alpha>
Using this you can set the alpha transparency factor of this polygon. This is a value between 0 and 100.
<mixmode><mode /></mixmode>
With this you can control more blending options for the polygon. One of `add', `alpha', `copy', `keycolor', `multiply2', `multiply', or `transparent'.
len(scale) FIXME: obsolete ?
This is similar to the `texlen' command in the part and also to the `len' command in the texture definition but it is repeated here as a short-hand for `texture (len (...))'.
plane(planeName) FIXME: no shortcut anymore ?
This is a shorthand for `texture (plane (...))'.

A texture mapping specification (the `texture' keyword in a polygon) has the following parameters:

<orig x="" y="" z="" />
The origin for texture mapping (3D coord).
<first x="" y="" z="" />
The u-axis coordinate for texture mapping (3D coord).
<second x="" y="" z="" />
The v-axis coordinate for texture mapping (3D coord).
<firstlen>scale</firstlen>
Scale along the u-axis.
<secondlen>scale</secondlen>
Scale along the v-axis.
<uvec x="" y="" z="" />
Similar to `first' with `firstlen' set to length of vector (`first'-`orig').
<vvec x="" y="" z="" />
Similar to `second' with `secondlen' set to length of vector (`second'-`orig').
<matrix> ...
Most general way to describe texture mapping using the transformation matrix.
<v x="" y="" z="" />
Most general way to describe texture mapping using the transformation vector.
len(scale) FIXME: obsolete ?
Use this as an easier way to describe texture scale (i.e. instead of all the above).
<uv idx1="" u1="" v1="" idx2="" u2="" v2="" idx3="" u3="" v3="" />
Directly specify u,v mapping coordinates for three given vertices.
uv_shift(ushift,vshift) FIXME: where is this now ?
Given the mapping described above, further shift with the given u,v shift value.
<plane>planeName</plane>
Use the given texture mapping plane instead of all the above. See how to define planes later.

The `warp' keyword as used in a polygon has the following keywords:

<matrix> ...
The matrix to use for space warping the portal.
<v x="" y="" z="" />
The vector to use for space warping before the matrix is applied.
<w x="" y="" z="" />
The vector to use for space warping after the matrix is applied. If not given this is the same as `v'.
<mirror />
Short-hand to generate a mirror portal. This will automatically calculate `matrix', `v', and `w'.
<static /> FIXME: does it still exist ?
When this item is given the portal destination will be static. This means that the portal will point to the same location even if the portal polygon moves. Otherwise the portal destination will move accordingly.
<zfill />
Set this option on a portal that floats in the middle of a room. It will make sure that the Z-buffer is filled AFTER rendering all objects seen through the portal.
<clip />
Set this option on a portal that points to the middle of a room. It will make sure that all geometry in the destination sector is correctly clipped to the portal so that it is not rendered in this sector.

Plane Add-on Loader

The thing loader plugin also supports an additional plugin which can load plane definitions. A plane definition is used for texture mapping. It is an optional (but very useful) feature which allows you to define texture mapping planes for polygons that share the same texture mapping.

The following keywords are supported by the plane loader:

<orig x="" y="" z="" />
The origin for texture mapping (3D coord).
<first x="" y="" z="" />
The u-axis coordinate for texture mapping (3D coord).
<second x="" y="" z="" />
The v-axis coordinate for texture mapping (3D coord).
<firstlen>scale</firstlen>
Scale along the u-axis.
<secondlen>scale</secondlen>
Scale along the v-axis.
<uvec x="" y="" z="" />
Similar to `first' with `firstlen' set to length of vector (`first'-`orig').
<vvec x="" y="" z="" />
Similar to `second' with `secondlen' set to length of vector (`second'-`orig').
<matrix> ...
Most general way to describe texture mapping using the transformation matrix.
<v x="" y="" z="" />
Most general way to describe texture mapping using the transformation vector.


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

This document was generated using texi2html