ent_buffers(ENTITY* ent, var num, var lod, void** ppVerts, void** ppTris, void** ppAttribs);
Returns the vertex, index, and attribute buffer of the entity mesh. The buffers can be used to read or manipulate the entity mesh on a lower level than with ent_setvertex.
Parameters:
ent - model, terrain, or wmb entity pointer, or level_ent for level blocks.
num - number of the terrain chunk or level block, beginning with 0.
lod - number of the lod step for the mesh, 0..3.
ppVerts - Pointer to a D3DVERTEX* pointer that is set to the mesh vertex buffer, or NULL.
ppTris - Pointer to a short* pointer pointer that is set to the mesh triangle buffer, or NULL.
ppAttribs - Pointer to a long* pointer that is set to the mesh attribute buffer, or NULL.
Returns
0 when the pointers could not be set, otherwise the number of triangles of the mesh.
Speed:
Medium
Version
A7.79 LC
Remarks:
- The vertex buffer is a list of D3DVERTEX structs, with a size determined by number_of_vertices*ent_status(ent,22). The number of vertices is ent_status(ent,1) for a model, and the maximum index number in the triangle buffer for level blocks or multi-mesh entities. Note that D3DVERTEX uses DirectX coordinates where the y and z axes are swapped. The D3DVERTEX format is described in the shader section, and defined in the atypes.h file in the lite-C include directory.
- The triangle buffer is a list of triangles that each consist of the 3 index numbers of the corner vertices, and has (on the main mesh) a size of number_of_triangles*3*sizeof(short). The number of triangles is ent_status(ent,4) for a model, or the value returned by ent_buffers for level blocks or multi-mesh entities.
- The attribute buffer contains the mesh subset number (i.e. the number of the skin set assigned to the triangle, starting with 0) of every triangle, and has a size of number_of_triangles*sizeof(long). The number of subsets is ent_status(ent,9).
- For retrieving the buffers, the entity mesh is internally locked. It is automatically unlocked at the end of the frame cycle. Therefore the buffers only remain valid until the next frame cycle. If they are needed again, they must be retrieved again with a new ent_buffers() call.
- The vertex and triangle buffers can also be retrieved when the engine was started without a DirectX device, f.i. in stand-alone server mode.
Example (lite-C):
D3DVERTEX* vbuffer;
short* ibuffer;
if (ent_buffers(my,0,0,&vbuffer,&ibuffer,NULL)) {
... // read information from the buffers
See also:
ent_status, vec_for_mesh, ent_getvertex, ent_getmesh, ent_status
► latest version online