Effectivement, elle est de type void pour la simple et bonne raison qu'il y a trois formats de sortie possibles :
EVT_STANDARD, EVT_2TCOORDS et EVT_TANGENTS. Du coup, lorsque tu charges un modèle, ton mesh sera d'un type ou d'un autre suivant les informations qui sont accessibles. Pour utiliser la fonction getMeshBuffer, tu dois donc savoir de quel type sont tes données et pour y parvenir, il te suffit d'utiliser la fonction getVertexType. A partir de là, tu pourras convertir les données de void* en un des trois types S3DVertex (pour le type EVT_STANDARD), S3DVertex2TCoords (pour le type EVT_2TCOORDS) et S3DVertexTangents (pour le type EVT_TANGENTS). Pour mieux illustrer mes propos, voici le bout de code dans lequel j'utilise cette fonction :
// build the tab of mesh triangles
int cNode::buildMeshTriangles(IMesh* mesh)
{
// Since there is no obvious way to get the triangles
// of a mesh with all their properties, we simply build
// our own triangle tab in which all the parameters
// of all the triangles of a mesh are stored. This triangle
// tab is useful for collision detection, haptic texture
// rendering and all sorts of manipulations where triangle
// parameters are needed.
if(!mesh)
return 0;
IMeshBuffer* mesh_buffer;
u32 nb_mesh_buffers = mesh->getMeshBufferCount();
u32 nb_triangles = 0;
// get the total number of mesh triangles
for(u32 buffer = 0 ; buffer < nb_mesh_buffers ; buffer++)
{
mesh_buffer = mesh->getMeshBuffer(buffer);
nb_triangles += mesh_buffer->getIndexCount();
}
nb_triangles /= 3;
// build and fill the tab of triangles
// getVertices return the vertices of the mesh
// getIndices return the indices of the mesh
// To build all the mesh triangles, we must first gather
// the mesh vertices by groups of three (given by the
// tab of indices).
meshVertexType = mesh->getMeshBuffer(0)->getVertexType();
switch(meshVertexType)
{
// for S3DVertex data
case EVT_STANDARD :
{
// build the tab of triangles with S3DVertex summits
c3DVertexTriangle * triangles = new c3DVertexTriangle [nb_triangles];
u32 count;
u32 nb_indices;
u16 * indices;
S3DVertex * pointer;
S3DVertex s1, s2, s3;
int i1, i2, i3;
if(!triangles)
return 0;
u16 tri = 0;
count = 0;
// for each mesh buffer
for(u32 buffer = 0 ; buffer < nb_mesh_buffers ; buffer++)
{
mesh_buffer = mesh->getMeshBuffer(buffer);
nb_indices = mesh_buffer->getIndexCount();
indices = mesh_buffer->getIndices();
pointer = (S3DVertex *)(mesh_buffer->getVertices());
//for each group of three indices
for(u32 index = 0 ; index < nb_indices ; index += 3)
{
i1 = indices[index + 0];
s1 = pointer[i1];
i2 = indices[index + 1];
s2 = pointer[i2];
i3 = indices[index + 2];
s3 = pointer[i3];
triangles[tri++] = c3DVertexTriangle(count, s1, s2, s3);
count++;
}
}
// return the pointer to the mesh triangles
nbMeshTriangles = nb_triangles;
meshTriangles = (c3DVertexTriangle *) triangles;
}
break;
// for S3DVertex2TCoords data
case EVT_2TCOORDS :
{
// TODO: adapt the previous technique
}
break;
// for S3DVertexTangents data
case EVT_TANGENTS :
{
// TODO: adapt the previous technique
}
break;
}
printf("Succeeded in building tab of mesh triangles : %d triangles\
", (int)nb_triangles);
return 1;
}
Voilà voilà...