data format is like the same, but why it`s happens?
Code: Select all
NxActor* Convert(scene::IMeshBuffer *mb)
{
NxBodyDesc bodyDesc;
NxActorDesc actorDesc;
NxTriangleMeshDesc* concaveDesc = NULL;
video::S3DVertex *irrverts = (video::S3DVertex*)mb->getVertices();
NxVec3 *verts = new NxVec3[mb->getVertexCount()];
//={ NxVec3(-boxDim.x, -boxDim.y, -boxDim.z) }; // data format
for(u32 i=0;i<mb->getVertexCount();i++)
verts[i] = NxVec3(irrverts[i].Pos.X,irrverts[i].Pos.Y,irrverts[i].Pos.Z);
NxU32 *indices = (NxU32*)mb->getIndices();
//={ 1,2,3,}; by 3 // data format
// Create descriptor for triangle mesh
if (!concaveDesc)
{
concaveDesc = new NxTriangleMeshDesc();
assert(concaveDesc);
}
concaveDesc->numVertices = 16;
concaveDesc->pointStrideBytes = sizeof(NxVec3);
concaveDesc->points = verts;
concaveDesc->numTriangles = mb->getVertexCount();
concaveDesc->triangles = indices;
concaveDesc->triangleStrideBytes = 3 * sizeof(NxU32);
concaveDesc->flags = 0;
assert(concaveDesc->isValid());
// The actor has one shape, a triangle mesh
NxTriangleMeshShapeDesc concaveShapeDesc;
concaveShapeDesc.localPose.t = NxVec3(0,0,0);//h.y
concaveShapeDesc.userData = concaveDesc;
NxInitCooking();
MemoryWriteBuffer buf;
NxTriangleMesh * pMesh = NULL;
printf("before_ln181\n");
bool status = NxCookTriangleMesh(*concaveDesc, buf); // at this line my programm is crash
printf("after_ln183\n");
assert(status);
pMesh = gps->createTriangleMesh(MemoryReadBuffer(buf.data));
assert(pMesh);
concaveShapeDesc.meshData = pMesh;
NxCloseCooking();
if (pMesh)
{
// Save mesh in userData for drawing
pMesh->saveToDesc(*concaveDesc);
//
assert(concaveShapeDesc.isValid());
actorDesc.shapes.pushBack(&concaveShapeDesc);
//Dynamic triangle mesh don't be supported anymore. So body = NULL
actorDesc.body = NULL;
actorDesc.globalPose.t = NxVec3(-6.0f, 0.0f, 0.0f);
assert(actorDesc.isValid());
NxActor *pActor = scn->createActor(actorDesc);
assert(pActor);
return pActor;
}
return NULL;
}
At picture my mesh buffer is red, why?
when function was started, all been correct
PS this code was based on Lesson102_Mesh_Shapes.doc from PhysX Training Programm