Crystal Entity Layer: 4.3.2 Mesh

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

### 4.3.2 Mesh

The mesh property class can be used to assign a 3D model to an entity. This property class defines a visual representation for an entity.

#### Property Class Details

- Name: ``pcmesh'`
- Factory ID: ``cel.pcfactory.mesh'`
- Interface: `iPcMesh`
- Header: ``include/propclass/mesh.h'`

#### General Information

Using this property class one can assign a 3D mesh from Crystal Space to an entity.

#### Setting the Mesh Data

There are a few ways to set the mesh in ``pcmesh'`:

- If you already have a pointer to a mesh wrapper from Crystal Space then you can simply use `iPcMesh->SetMesh()` with the mesh wrapper as a parameter.
- If you know the mesh factory is already loaded in memory then you can set the mesh directly from the mesh factory name by calling `iPcMesh->SetMesh()` with ``factname'` given and ``filename'` equal to ``0'`.
- Otherwise you have to give a valid filename in which case `SetMesh()` will first check to see if the factory is already loaded. If not then it will load it from the given filename. If you call `iPcMesh->SetPath()` then you can also control the VFS path from which the factory file will be loaded.

Note that the file can be either a ``meshfact'` XML file or else a ``library'` XML file.

#### From Mesh to Entity and Back

It is easy to get from the entity to the mesh by using the following code:

    csRef<iPcMesh> pcmesh = CEL_QUERY_PROPCLASS_ENT (entity, iPcMesh);
    iMeshWrapper* mesh = pcmesh->GetMesh ();

But you can also get from the mesh back to the entity very easily because the physical layer maintains a link:

    iMeshWrapper* mesh = ...;
    iCelEntity* entity = pl->FindAttachedEntity (mesh->QueryObject ());

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

This document was generated using texi2html 1.76.