# Placing an oriented Capsule in PhysX

## Recommended Posts

maniac1986    100
Placing an oriented Capsule in PhysX

Hi,

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
*/
for(i=0;i<nbBody;i++){

/*build an orientation matrix from the y-axis vector
NxVec3 axis(dirvec[i][0], dirvec[i][1], dirvec[i][2]);
NxVec3 binormal, normal;
axis.normalize();
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;

actorDesc.shapes.pushBack(&capsuleDesc);

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 on other sites
grhodes_at_work    1385
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.)

## 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