Crystal Space: iThingState Struct Reference (Crystal Space Public API Reference)

| ## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# iThingState Struct Reference
[Mesh plugins]

This is the state interface to access the internals of a thing mesh object. More...

`#include <imesh/thing.h>`

Inheritance diagram for iThingState:

[legend]
List of all members.

## Public Member Functions
virtual void | ClearReplacedMaterials ()=0
| Clear all replaced materials (i.e.
virtual csPtr< iPolygonHandle > | CreatePolygonHandle (int polygon_idx)=0
| Create a polygon handle that can be used to refer to some polygon.
virtual uint | GetMixMode () const =0
| Get mix mode.
virtual int | GetMovingOption () const =0
| Get the moving option.
virtual const csPlane3 & | GetPolygonWorldPlane (int polygon_idx)=0
| Get world space plane of the specified polygon.
virtual iMaterialWrapper * | GetReplacedMaterial (iMaterialWrapper *oldMat)=0
| Return the material `oldMat` was replaced with (or 0 if it wasn't).
virtual const csVector3 & | GetVertexW (int idx) const =0
| Get the given vertex coordinates in world space.
virtual const csVector3 * | GetVerticesW () const =0
| Get the vertex coordinates in world space.
virtual void | Prepare ()=0
| Prepare the thing to be ready for use.
virtual void | ReplaceMaterial (iMaterialWrapper *oldmat, iMaterialWrapper *newmat)=0
| Scan all polygons and replace the given material with a new material.
virtual void | SetMixMode (uint mode)=0
| Set mix mode.
virtual void | SetMovingOption (int opt)=0
| Control how this thing will be moved.
virtual void | Unprepare ()=0
| Reset the prepare flag so that this Thing can be re-prepared.
Lightmap query
virtual csPtr< iImage > | GetPolygonLightmap (int polygon_idx)=0
| Get the lightmap for a specific polygon.
virtual bool | GetPolygonPDLight (int polygon_idx, size_t pdlight_index, csRef< iImage > &map, iLight *&light)=0
| Query for pseudo-static lightmaps.

## Detailed Description

This is the state interface to access the internals of a thing mesh object.

Main creators of instances implementing this interface:

- Thing mesh object plugin (crystalspace.mesh.object.thing)
- iMeshObjectFactory::NewInstance()

Main ways to get pointers to this interface:

- scfQueryInterface() on iMeshWrapper::GetMeshObject()

Main users of this interface:

- Thing Loader plugin (crystalspace.mesh.loader.thing)

Definition at line 694 of file thing.h.

## Member Function Documentation

virtual void iThingState::ClearReplacedMaterials | ( |  | ) | `[pure virtual]`

Clear all replaced materials (i.e.

reset to default materials from factory).

virtual csPtr<iPolygonHandle> iThingState::CreatePolygonHandle | ( | int | polygon_idx | ) | `[pure virtual]`

Create a polygon handle that can be used to refer to some polygon.

This can be useful in situations where an SCF handle is required to be able to reference a polygon. The thing will not keep a reference to this handle so you are fully responsible for it after calling this function.

Parameters:

  | polygon_idx | is a polygon index. CS_POLYINDEX_LAST is NOT supported here!

virtual uint iThingState::GetMixMode | ( |  | ) | const`[pure virtual]`

Get mix mode.

virtual int iThingState::GetMovingOption | ( |  | ) | const`[pure virtual]`

Get the moving option.

virtual csPtr<iImage> iThingState::GetPolygonLightmap | ( | int | polygon_idx | ) | `[pure virtual]`

Get the lightmap for a specific polygon.

virtual bool iThingState::GetPolygonPDLight | ( | int | polygon_idx,
|  | size_t | pdlight_index,
|  | csRef< iImage > & | map,
|  | iLight *& | light |
| ) |  |  | `[pure virtual]`

Query for pseudo-static lightmaps.

virtual const csPlane3& iThingState::GetPolygonWorldPlane | ( | int | polygon_idx | ) | `[pure virtual]`

Get world space plane of the specified polygon.

Parameters:

  | polygon_idx | is a polygon index. CS_POLYINDEX_LAST is NOT supported here!

virtual iMaterialWrapper* iThingState::GetReplacedMaterial | ( | iMaterialWrapper * | oldMat | ) | `[pure virtual]`

Return the material `oldMat` was replaced with (or 0 if it wasn't).

virtual const csVector3& iThingState::GetVertexW | ( | int | idx | ) | const`[pure virtual]`

Get the given vertex coordinates in world space.

virtual const csVector3* iThingState::GetVerticesW | ( |  | ) | const`[pure virtual]`

Get the vertex coordinates in world space.

virtual void iThingState::Prepare | ( |  | ) | `[pure virtual]`

Prepare the thing to be ready for use.

Normally this doesn't have to be called as the engine will call this function automatically as soon as the object is rendered. However, to avoid the (sometimes long) setup time for an object while walking around an application can choose to call this function manually in order to increase load time but decrease the time need to setup things later.

virtual void iThingState::ReplaceMaterial | ( | iMaterialWrapper * | oldmat,
|  | iMaterialWrapper * | newmat |
| ) |  |  | `[pure virtual]`

Scan all polygons and replace the given material with a new material.

Note that the new material MUST have the same size as the old material! If 'newmat' == 0 then the default from the factory will be used again. Note that 'oldmat' will always be compared from the factory and not from the current material the polygon has!

virtual void iThingState::SetMixMode | ( | uint | mode | ) | `[pure virtual]`

Set mix mode.

virtual void iThingState::SetMovingOption | ( | int | opt | ) | `[pure virtual]`

Control how this thing will be moved.

There are currently two options.

- CS_THING_MOVE_NEVER: this option is set for a thing that cannot move at all. In this case the movable will be ignored and only hard transforms can be used to move a thing with this flag. This setting is both efficient for memory (object space coordinates are equal to world space coordinates so only one array is kept) and render speed (only the camera transform is needed). This option is very useful for static geometry like walls. This option is default.
- CS_THING_MOVE_OCCASIONAL: this option is set for a thing that is movable but doesn't move all the time usually. Setting this option means that the world space vertices will be cached (taking up more memory that way) but the coordinates will be recalculated only at rendertime (and cached at that time). This option has the same speed efficiency as MOVE_NEVER when the object doesn't move but more memory is used as all the vertices are duplicated. Use this option for geometry that is not too big (in number of vertices) and only moves occasionally like doors of elevators.

Note: it is no longer needed to manually set this option. By default things will use CS_THING_MOVE_NEVER and they will automatically switch to the slightly less efficient CS_THING_MOVE_OCCASIONAL if needed.

virtual void iThingState::Unprepare | ( |  | ) | `[pure virtual]`

Reset the prepare flag so that this Thing can be re-prepared.

Among other things this will allow cached lightmaps to be recalculated.

The documentation for this struct was generated from the following file:

- imesh/thing.h