Hey,
I’m new to PhysX and I’ve already ran into some trouble when trying to create a connection to the PVD.
Before I start, I’ve noticed several errors in the PVD log that show up right after starting it:
- Error: Failed to start Pvd Console
- The system cannot find the file specified. (Exception from HRESULT: 0x80070002): Failed to start Pvd Console
- The system cannot find the file specified. (Exception from HRESULT: 0x80070002): Failed to start Pvd Console
Almost all of the options in the task bar are greyed out as well, however I’m not sure if that’s not simply because there’s no connection at this point.
That brings me to my next issue. I’ve been following the instructions in the PhysX guide to create the connection to the PVD. According to the callbacks it’s connecting successfully, however it tells me that even if the PVD isn’t even running.
Either way, if the PVD is running there is no chance whatsoever after the connection has been established and none of the test-actors I’ve created show up either.
I’m somewhat clueless as to what’s going on, as I said these are my first steps with PhysX.
I’m using PhysX-3.3.0_Beta-2 on Windows 8.1 with Visual Studio Ultimate 2013. I’m using the CHECKED libraries.
Any help would be much appreciated.
Here’s some of the code that might be relevant (Not showing things like simulation stepping):
Initializing PhysX:
Con::cout<<"Initializing PhysX..."<<Con::endl;
static WVPxErrorCallback gDefaultErrorCallback;
static physx::PxDefaultAllocator gDefaultAllocatorCallback;
m_pxFoundation = PxCreateFoundation(PX_PHYSICS_VERSION,gDefaultAllocatorCallback,gDefaultErrorCallback);
if(m_pxFoundation == NULL)
{
Con::cerr<<"ERROR: Unable to create PhysX foundation!"<<Con::endl;
CriticalFailure()
}
m_physics = PxCreatePhysics(PX_PHYSICS_VERSION,*m_pxFoundation,physx::PxTolerancesScale());
if(m_physics == NULL)
{
Con::cerr<<"ERROR: Unable to create top-level PhysX Object!"<<Con::endl;
CriticalFailure();
}
Creating the scene:
physx::PxPhysics *physics = state->GetPhysics();
physx::PxSceneDesc sceneDesc(physics->getTolerancesScale());
sceneDesc.gravity = physx::PxVec3(0.0f,-9.81f,0.0f);
if(sceneDesc.cpuDispatcher == NULL)
{
physx::PxDefaultCpuDispatcher *dispatcher = physx::PxDefaultCpuDispatcherCreate(1);
if(dispatcher == NULL)
{
Con::cerr<<"Unable to create PhysX CPU Dispatcher"<<Con::endl;
CriticalFailure();
}
sceneDesc.cpuDispatcher = dispatcher;
}
if(sceneDesc.filterShader == NULL)
sceneDesc.filterShader = physx::PxDefaultSimulationFilterShader;
if(!sceneDesc.isValid())
{
Con::cerr<<"PhysX Simulation Filter Shader is invalid"<<Con::endl;
CriticalFailure();
}
m_pxScene = physics->createScene(sceneDesc);
if(m_pxScene == NULL)
{
Con::cerr<<"Unable to create PhysX scene"<<Con::endl;
CriticalFailure();
}
Creating the test actors:
float radius = 20.0f;
float density = 10.0f;
physx::PxMaterial *aMaterial = physics->createMaterial(0.5f,0.5f,0.1f); //static friction, dynamic friction, restitution
physx::PxRigidDynamic *aSphereActor = physics->createRigidDynamic(physx::PxTransform(physx::PxVec3(0,0,0)));
physx::PxShape *aSphereShape = aSphereActor->createShape(physx::PxSphereGeometry(radius),*aMaterial);
physx::PxRigidBodyExt::updateMassAndInertia(*aSphereActor,density);
aSphereActor->setLinearVelocity(physx::PxVec3(50,0,0));
m_pxScene->addActor(*aSphereActor);
physx::PxRigidStatic *plane = physx::PxCreatePlane(*physics,physx::PxPlane(physx::PxVec3(0,1,0),0),*aMaterial);
m_pxScene->addActor(*plane);
// Dummy connection handler:
struct MyConnectionHandler : public physx::debugger::comm::PvdConnectionHandler
{
virtual void onPvdSendClassDescriptions( physx::debugger::comm::PvdConnection& inFactory )
{
}
virtual void onPvdConnected( physx::debugger::comm::PvdConnection &con )
{
Con::cwar<<"Successfully connected to PVD!"<<Con::endl;
}
virtual void onPvdDisconnected( physx::debugger::comm::PvdConnection&)
{
Con::cwar<<"Disconnected from PVD!"<<Con::endl;
}
};
// Opening the connection:
if(m_physics->getPvdConnectionManager() == NULL || m_pxPvdConnection != NULL)
return;
physx::PxVisualDebuggerConnectionFlags flags = physx::PxVisualDebuggerConnectionFlag::eDEBUG;
m_pxPvdConnection = physx::PxVisualDebuggerExt::createConnection(m_physics->getPvdConnectionManager(),"C:\Path\To\Aplication\pvdout.txt",flags);
MyConnectionHandler myConnectionHandler;
if(m_physics->getPvdConnectionManager())
m_physics->getPvdConnectionManager()->addHandler(myConnectionHandler);
m_physics->getVisualDebugger()->setVisualizeConstraints(true);
m_physics->getVisualDebugger()->setVisualDebuggerFlag(physx::PxVisualDebuggerFlag::eTRANSMIT_CONTACTS,true);
I’d also like to mention that even though the connection is successful, trying to release the connection (m_pxPvdConnection->release();) raises an exception.