# Placing an oriented Capsule in PhysX

This topic is 2785 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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[0], dirvec[1], dirvec[2]);
NxVec3 binormal, normal;
axis.normalize();
NxNormalToTangents(axis, binormal, normal);
NxMat33 _mat33( normal, axis, binormal);
*/
Capsules = CreateOrientedCapsule( NxMat34(_mat33, NxVec3(body_cc[0],body_cc[1],body_cc[2])), height, radius, 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
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.)

1. 1
2. 2
Rutin
19
3. 3
JoeJ
16
4. 4
5. 5

• 35
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631702
• Total Posts
3001812
×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!