Merci pour les réponse. Alors, Tmyke merci pour les sources.
En fait, entre temps j'ai commencé ça mais ça me déforme les meshs mais sinon tant que c'est un cube ou un cube avec un chanfrein ça marche nickel. J'ai dû faire une erreur mais je ne vois pas.
NewtonCollision* CreateNewtonConvexHull(const NewtonWorld* const World, IMesh *IrrMesh, float tolerance=0.002f)
{
/// Variables
int count = 0;
array<dFloat> vertexCloud;
int strideInBytes = sizeof(float)*3;
int shapeID = -1;
dFloat *offsetMatrix = NULL;
/// pour chaque meshbuffer
for(u32 a=0; a < IrrMesh->getMeshBufferCount(); ++a)
{
/// récupère le buffer
IMeshBuffer *buffer = IrrMesh->getMeshBuffer(a);
/// récpère le nombre de vertices et d'indices
int nb_vertices = buffer->getVertexCount();
int nb_indices = buffer->getIndexCount();
/// récupère le tableau de vertices et d'indices du buffer
array<S3DVertex> tmp;
tmp.set_pointer( (S3DVertex*)buffer->getVertices(), nb_vertices );
array<u16> tmp2;
tmp2.set_pointer( buffer->getIndices(), nb_indices );
/// création de la liste de vertices
for(int a=0; a < nb_indices; ++a)
{
/// on converti le vertex Irrlicht en vertex Newton avec le scale
vertexCloud.push_back( tmp[tmp2[a]].Pos.X * IRR_TO_NEWTON );
vertexCloud.push_back( tmp[tmp2[a]].Pos.Y * IRR_TO_NEWTON );
vertexCloud.push_back( tmp[tmp2[a]].Pos.Z * IRR_TO_NEWTON );
/// on met à jour le nombres de vertices
++count;
}
}
/// création du NewtonMesh
NewtonCollision *maNewtonCollision = NewtonCreateConvexHull(World, count, vertexCloud.pointer(),strideInBytes, tolerance, shapeID, offsetMatrix);
/// on retourne le mesh
return maNewtonCollision;
}
Par contre Gehogor, il y a un truc qui me chiffonne. Moi, la liste de vertices je la créé en prenant les indices et rajoutant un vertex pour chaque indice. Mais toi, tu lui envoie juste la liste de vertex. Comment Newton fait pour trouver les triangles?