Reputation: 9144
Today, I tried to play around Physx and Physx visual debugger and as always, newbies have problems and questions. I'll try to describe my problems as best as I can with my poor english skills.
1) I managed to create a physx scene. added a dynamic actor and manipulated it. I see in Visual Debugger it's motion. It's a standard PxSphereGeometry ball. However, when I add a second ball in the scene, the second one is not visible, but I can see that collision happens. Here's the code and if anyone can point me what's wrong with it I'd be very grateful:
PxMaterial* mMaterial;
mMaterial = mPhysics->createMaterial(0.5f, 0.5f, 0.5f); //static friction, dynamic friction, restitution
if(!mMaterial)
error("createMaterial failed!");
PxVec3 position(0, 50, 0);
PxRigidDynamic* aSphereActor = PxCreateDynamic(*mPhysics, PxTransform(position), PxSphereGeometry(3), *mMaterial, 1.f);
PxRigidDynamic* aTrActor = PxCreateDynamic(*mPhysics, PxTransform(PxVec3(3, 1, 1)), PxSphereGeometry(3), *mMaterial, 1.1f);
if(!aSphereActor)
error("Unable to create sphere actor");
aSphereActor->setMass(1);
aTrActor->setMass(10);
PxRigidStatic* plane = PxCreatePlane(*mPhysics, PxPlane(PxVec3(0,1,0), 0), *mMaterial);
if (!plane)
error("create shape failed!");
mScene->addActor(*plane);
mScene->addActor(*aSphereActor);
mScene->addActor(*aTrActor);
while(true)
{
mScene->simulate(1.0f / 30.0f);
if(!mScene->fetchResults(true))
error("cant fetch result");
Sleep(10);
}
In this scene, aSphereActor collides with aTrActor, but I can't see aTrActor in Visual Debugger, however collision is perfectly visible.
2) Nvidia's documentation is very very poor. It's a torture for newbies like me to find it's way through it. So I wanted to know how can I import a 3d model and add it in the scene. I know there is a Physx plugins for 3ds max, maya etc. Say I have a model exported with this plugin, how can I import it in my app and add it to the scene?
3) During the creation of the scene
sceneDesc.gravity = PxVec3(0.0f, -9.81f, 0.0f);
, what value should I provide to get a real gravity, the one we have on earth
4) I can assign a mass to an actor, however I don't know in which measurement unit the mass is. For example, if I set aSphereActor->setMass(1); will aSphereActor will be 1kg, gram or what?
Thank you very much everyone. I appreciate your help.
Upvotes: 1
Views: 1726
Reputation: 326
First, I am doing my first Physx project this quarter. (read as, I might be making this up)
1)
You don't check aTrActor's creation, but I don't think that's your problem.
Check if aTrActor in your draw/update callback.
2)
Dunno
3)
-9.81 m/s^2 is the acceleration for Earth's gravity.
I'm guessing that the PxVec3 is the gravity with respect to each axis.
So, PxVec3(0.0, -9.81, 0.0) is no x or z acceleration and -9.81 m/s^2 y acceleration.
4)
The answer to #3 would suggest the units are metric.
You can probably throw it all together in standard, but metric > standard imo.
Just looked at the date, this may not help Davita, but hopefully it'll be of some use to someone.
Upvotes: 2