Accessing 3D Geometry

Core Library

Geometry access in the SDK isn't as straightforward as declaring a structure and typecasting a vertex data pointer to it, as each draw call for each LOD of a tree model may have a different vertex declaration as decribed by the associated render state's SVertexDecl. However, he SDK does provide a few overloaded functions in SDrawCall to facilitate quick vertex property access. Specifically:

Where eProperty is one of the sixteen pre-defined vertex properties (e.g. VERTEX_PROPERTY_POSITION, VERTEX_PROPERTY_NORMAL, etc), nVertex is which vertex in the buffer to be retrieved, and finally the last parameter will contain the returned value, padded with zeroes if necessary.

The following code loads a tree and prints the position property for every draw call of each LOD. Position is always present in every vertex. When checking for other properties, consider using SVertexDecl::m_asProperties[X].IsPresent() (where X is any EVertexProperty value) to determine if that property is in the vertex data.