PhysX: Failed to Create Actor
Hi everyone, in my project I am using PhysX as my physics engine.But after cooking convex shapes in a seperate application, I failed to create actors.
------------------------------------------------------------------------------
Related codes:
NxConvexMeshDesc convexDesc;
NxConvexShapeDesc convexShapeDesc;
NxBodyDesc bodyDesc;
convexShapeDesc.meshData = m_pNx->createConvexMesh(UserStream("physxbox.bin", true));
convexShapeDesc.localPose.t = NxVec3( 0, 0, 0 );
if (convexShapeDesc.meshData)
cout<<"Succeed in Loading Data from File>>>>>>>>>>>>>>>>>>>"<<endl;
actorDesc.shapes.pushBack(&convexShapeDesc);
actorDesc.body = &bodyDesc
actorDesc.density = 1.0f;
actorDesc.globalPose.t = nxvec;//position Nxvec3
actorDesc.globalPose.M = nxquat;//orientation quaternion
if( actorDesc.isValid() )
cout<<"Actor Description is Valid>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
m_pNxBox = m_pNxScene->createActor(actorDesc);
if( m_pNxBox )
cout<<"NxBox Created>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
else
cout<<"Failed to Create NxBox>>>>>>>>>>>>>>>>>>>>>>>>>>>>"<<endl;
--------------------------------------------------------------------------
when running, the message followed is displayed:
Succeed in Loading Data from File>>>>>>>>>>>>>>>>>
Actor Description is Valid>>>>>>>>>>>>>>>>>>>>>>>>
Failed to Create NxBox>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Help me, please! Any reply is appreciated!
maybe try to implement NxUserOutputStream.. this will help you to find what's wrong...
and then use it during creation of physics sdk:
[Edited by - dopelganger on October 8, 2007 6:10:46 AM]
class PhysXErrorOutput : public NxUserOutputStream{ public: void reportError(NxErrorCode e, const char* message, const char* file, int line) { cout << "Message: " << message << " File: " << file << " Line: " << line << endl; } NxAssertResponse reportAssertViolation(const char* message, const char* file, int line) { cout << "Message: " << message << " File: " << file << " Line: " << line << endl; return NX_AR_CONTINUE; } void print(const char *message) { cout << "Message: " << message << endl; }};
and then use it during creation of physics sdk:
static PhysXErrorOutput gPhysXError;//[...]m_PhysicsSDK = NxCreatePhysicsSDK( version, gPhysXAllocator, &gPhysXErrors );//[...]
[Edited by - dopelganger on October 8, 2007 6:10:46 AM]
I don't see anything obviously wrong with that code. So, the only question I can ask is...do you have the PhysX system software (drivers) installed? Not the SDK, but the system software? You must have the driver installed, or you will see runtime problems such as this.
Thanks for dopelganger and grhodes_at_work!
To dopelganger: I will have a try.
To grhodes_at_work: I have installed the newest PhysX System Software( PhysX_7.09.13), and those example programs with the PhysX sdk can run without error, so I suppose something must be wrong with my program?
I will try to find out!
To dopelganger: I will have a try.
To grhodes_at_work: I have installed the newest PhysX System Software( PhysX_7.09.13), and those example programs with the PhysX sdk can run without error, so I suppose something must be wrong with my program?
I will try to find out!
-_-!!!!!!!
I think I've find the reason. In my program I try to create two or more actors using only one NxActorDesc:
------------------------------------------------------
NxActorDesc actorDesc;
...
m_pNxPlane = m_pNxScene->createActor(actorDesc);
...
m_pNxBox = m_pNxScene->createActor(actorDesc);
...
------------------------------------------------------
I thought, after creating an actor, the actorDesc was not needed any more, so I reused this actorDesc to create another actor, and failed here.
So I guess, this is the reason, hah?
I think I've find the reason. In my program I try to create two or more actors using only one NxActorDesc:
------------------------------------------------------
NxActorDesc actorDesc;
...
m_pNxPlane = m_pNxScene->createActor(actorDesc);
...
m_pNxBox = m_pNxScene->createActor(actorDesc);
...
------------------------------------------------------
I thought, after creating an actor, the actorDesc was not needed any more, so I reused this actorDesc to create another actor, and failed here.
So I guess, this is the reason, hah?
-_-!!! PhysX's really eating me!
In the SDK documentary it says:
"...To avoid overly long parameter lists and receive aid in error checking, the SDK uses descriptor classes to pass creation parameters. The descriptor is a temporary variable only needed for the duration of the creation call. You can allocate it as a stack variable. ..."
But in my program, I failed when trying to create two or more actors using one NxActorDesc. Then I added error reporting, as dopelganger suggested. But alas, the runtime error disappeared! I don't know why.
Rookie...
Programmer I = new Programmer;
:-(
In the SDK documentary it says:
"...To avoid overly long parameter lists and receive aid in error checking, the SDK uses descriptor classes to pass creation parameters. The descriptor is a temporary variable only needed for the duration of the creation call. You can allocate it as a stack variable. ..."
But in my program, I failed when trying to create two or more actors using one NxActorDesc. Then I added error reporting, as dopelganger suggested. But alas, the runtime error disappeared! I don't know why.
Rookie...
Programmer I = new Programmer;
:-(
As you discovered, reusing that descriptor variable shouldn't cause problems. Afraid I can't suggest other possible causes without seeing more of your code. But, at least the error is gone now!?
No, he means the code from dopelganger only outputs via cout... Change it so it writes errors to a file. It's a very simple and easy change in the code and you won't lose the runtime errors PhysX is throwing.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement