#1
07-09-2008 13:45:16
- marco565
- Membres
- Date d'inscription:
- Messages: 25
- IP: 82.250.118.3
- Courriel
bonjour je viens de me mettre a ODE avec irrlicht, j'ai un probleme lors de la création de la géométrie du corps. les cubes passe a travers certain murs.... Voila ma fonction que j'ai recupié du tutoriel officiel avec irrlicht
void setGeomData(scene::IMesh* mesh, scene::ISceneNode *node, dGeomID &geom)
{
if(mesh==NULL) return; // do nothing if the mesh or node is NULL
int i,j,ci,cif,cv;
int indexcount=0;
int vertexcount=0;
// count vertices and indices
for(i=0;i<mesh->getMeshBufferCount();i++){
irr::scene::IMeshBuffer* mb=mesh->getMeshBuffer(i);
indexcount+=mb->getIndexCount();
vertexcount+=mb->getVertexCount();
}
// build structure for ode trimesh geom
dVector3 *vertices=new dVector3[vertexcount];
int *indices=new int[indexcount];
// fill trimesh geom
ci=0;
cif=0;
cv=0;
for(i=0;i<mesh->getMeshBufferCount();i++){
irr::scene::IMeshBuffer* mb=mesh->getMeshBuffer(i);
// fill indices
irr::u16* mb_indices=mb->getIndices();
for(j=0;j<mb->getIndexCount();j++){
indices[ci]=cif+mb_indices[j];
ci++;
}
cif=cif+mb->getVertexCount();
// fill vertices
if(mb->getVertexType()==irr::video::EVT_STANDARD){
irr::video::S3DVertex* mb_vertices=(irr::video::S3DVertex*)mb->getVertices();
for(j=0;j<mb->getVertexCount();j++){
vertices[cv][0]=mb_vertices[j].Pos.X;
vertices[cv][1]=mb_vertices[j].Pos.Y;
vertices[cv][2]=mb_vertices[j].Pos.Z;
cv++;
}
}else if(mb->getVertexType()==irr::video::EVT_2TCOORDS){
irr::video::S3DVertex2TCoords* mb_vertices=(irr::video::S3DVertex2TCoords*)mb->getVertices();
for(j=0;j<mb->getVertexCount();j++){
vertices[cv][0]=mb_vertices[j].Pos.X;
vertices[cv][1]=mb_vertices[j].Pos.Y;
vertices[cv][2]=mb_vertices[j].Pos.Z;
cv++;
}
}
}
irr::core::vector3df pos=node->getPosition();
// build the trimesh data
dTriMeshDataID data=dGeomTriMeshDataCreate();
dGeomTriMeshDataBuildSimple(data,(dReal*)vertices,vertexcount,indices,indexcount);
// build the trimesh geom
geom=dCreateTriMesh(space,data,0,0,0);
// set the geom position
dGeomSetPosition(geom,pos.X,pos.Y,pos.Z);
}Hors ligne



