I am using PhysX, OpenGL and assimp. I am getting 'unhandled exception ..... Access violation reading location 0x00000' at the last line
void CreateActor(const aiScene *scene)
{
NxTriangleMeshDesc t;
aiMesh *mesh = scene->mMeshes[0];
t.numVertices = mesh->mNumVertices;
t.points = mesh->mVertices;
t.pointStrideBytes = sizeof(aiVector3D);
t.numTriangles = mesh->mNumFaces;
NxU32 *tr = new NxU32[mesh->mNumFaces*3];
NxU32 k=0;
for(NxU32 i=0;i<mesh->mNumFaces;i++)
for(int j=0;j<3;j++)
tr[k++]=mesh->mFaces[i].mIndices[j];
t.triangles = tr;
t.triangleStrideBytes = sizeof(NxU32)*3;
t.flags=0;
NxTriangleMeshShapeDesc terrainShapeDesc;
// Cooking from memory
InitCooking();
MemoryWriteBuffer buf;
bool status = CookTriangleMesh(t, buf);
MemoryReadBuffer readBuffer(buf.data);
gPhysicsSDK->createTriangleMesh(readBuffer);
}
Using Assimp::Importer I have read a simple cube in .x It has 24 vertices, 12 faces. point of using 2 for loops with 'mesh->mFaces[i].mIndices[j]' is that there is a mNumIndices algong with mIndices
I know the function CreateActor is incomplete, but the error was on the 'createTriangleMesh' (last line) so I omitted rest.