Sign in to follow this  

Placing an oriented Capsule in PhysX

Recommended Posts

Placing an oriented Capsule in PhysX


I am using physx to create a rope joined by a lot of capsules. (similar to the rope example in the training program but a loop one with both ends join together and the lope can be around any direction in space). I calculated the global position of all capsules' center position and the directional vectors in Matlab. The position and direction vector datas are verified in Matlab graphics.

I follow the tutorial and write my code as below.But the capsules are not perfectly connected together. Can someone here help me check out my problem in the code? especially in the subfunction, is my understanding with the globalpose wrong?


Capsules = new NxActor*[nbBody];

/*parameters of the capsules are stored in them...
body_cc[nbBody][3];//center coordinates (x,y,z) of the capsule in world axis.
dirvec[nbBody][3];//vector of desired y-axis of the capsule in world axis.
height[nbBody];//capsule height
radius[nbBody];//capsule radius

/*build an orientation matrix from the y-axis vector
NxVec3 axis(dirvec[i][0], dirvec[i][1], dirvec[i][2]);
NxVec3 binormal, normal;
NxNormalToTangents(axis, binormal, normal);
NxMat33 _mat33( normal, axis, binormal);
Capsules[i] = CreateOrientedCapsule( NxMat34(_mat33, NxVec3(body_cc[i][0],body_cc[i][1],body_cc[i][2])), height[i], radius[i], 1);


NxActor* CreateOrientedCapsule(const NxMat34& globalPose, const NxReal height, const NxReal radius, const NxReal density)
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
NxCapsuleShapeDesc capsuleDesc;
capsuleDesc.height = height;
capsuleDesc.radius = radius;


actorDesc.body = &bodyDesc;
actorDesc.density = density;

actorDesc.globalPose = globalPose;
actorDesc.flags |=NX_AF_DISABLE_COLLISION;

return gScene->createActor(actorDesc);

[Edited by - maniac1986 on November 29, 2010 9:52:40 AM]

Share this post

Link to post
Share on other sites
Did you verify, visually, the centerline axis of the capsules in addition to the midpoints, in Matlab? Reason I ask...wanted to know how certain you are that something is up with the PhysX poses? (I am too lazy right now to look at your code.)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this