Hi, I’m new in PhysX and I’m trying to create static rigidbody with triangle mesh geometry. And on the line:
PxShape* shape = actor->createShape(PxTriangleMeshGeometry(Mesh),*material);
It crash in PxRigidActor on this line:
return createShape(geometry, &materialPtr, 1, shapeFlags);
with:
Unhandled exception at 0x00DD436C in Infinity-Engine.exe: 0xC0000005: Access violation reading location 0x00000000.
This is part of my code:
PxMaterial * material = gPhysicsSDK->createMaterial(0.5f,0.5f,0.1f);
PxTransform planePos = PxTransform(PxVec3(Position.m128_f32[0],Position.m128_f32[1],Position.m128_f32[2]),PxQuat(PxHalfPi, PxVec3(Rotation.x, Rotation.y, Rotation.z)));
PxRigidStatic* actor = gPhysicsSDK->createRigidStatic(planePos);
PX_ASSERT( actor );
PxMeshScale meshScale = PxMeshScale(*new PxVec3(PxReal(1)), PxQuat(PxIdentity));
PxTriangleMesh *Mesh = NULL;
Mesh = GetTriangleMesh(Verticles,Indices,IndicesCount);
PX_ASSERT( Mesh );
<b>PxShape* shape = actor->createShape(PxTriangleMeshGeometry(Mesh),*material);</b> //Here it all crash
PX_ASSERT( shape );
Here is method GetTriangleMesh:
PxTriangleMesh* PhysX::GetTriangleMesh(vector<Vertex> Verticles,vector<int> Indices,int IndicesCount)
{
PxTriangleMeshDesc meshDesc;
meshDesc.points.count = Verticles.capacity();
meshDesc.points.stride = sizeof(PxVec3);
meshDesc.points.data = ConvertFromVectorToPxVec(Verticles);
meshDesc.triangles.count = IndicesCount;
meshDesc.triangles.stride = 3*sizeof(int);
meshDesc.triangles.data = &Indices[0];
PxToolkit::PxDefaultMemoryOutputStream writeBuffer;
bool status = mCooking->cookTriangleMesh(meshDesc, writeBuffer);
if(!status)
return NULL;
PxToolkit::PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());
PxTriangleMesh * c = gPhysicsSDK->createTriangleMesh(readBuffer);
return c;}
And I have included this:
#include "PxPhysicsAPI.h"
#include "PxToolkit.h"
#ifdef _DEBUG //If in 'Debug' load libraries for debug mode
#pragma comment(lib, "PhysX3DEBUG_x86.lib") //Always be needed
#pragma comment(lib, "PhysX3CommonDEBUG_x86.lib") //Always be needed
#pragma comment(lib, "PhysX3ExtensionsDEBUG.lib") //PhysX extended library
#pragma comment(lib, "PhysXVisualDebuggerSDKDEBUG.lib") //For PVD only
#pragma comment(lib, "PhysX3CookingDEBUG_x86.lib") //For Cooking
#else //Else load libraries for 'Release' mode
#pragma comment(lib, "PhysX3_x86.lib")
#pragma comment(lib, "PhysX3Common_x86.lib")
#pragma comment(lib, "PhysX3Extensions.lib")
#pragma comment(lib, "PhysXVisualDebuggerSDK.lib")
#pragma comment(lib, "PhysX3Cooking_x86.lib")
#endif
Please help. I’m trying to get this work for all this holidays and I realy don’t know why. I think I did some terrible mistache.
Thanks all of you.