[SOLVED]How to use NxRevoluteJoint setGlobalAnchor in nxogre

mamairaja

13-10-2010 05:52:22

Hello
I have seen that NxOgre Bloodymess does not contain setGlobalAnchor and setGlobalAxis methods(PHYSX NxRevoluteJoint ) in NxOgre RevoluteJointDescription class. Could you please tell me how do I use those methods with nxogre?

And I have noticed that localAnchor and localAxis from PHYSX exist in NxOgre as mLocalAnchor and mLocalAxis.

Is their a way to accomplish the functionality of setGlobalAnchor and setGlobalAxis methods with using mLocalAnchor and mLocalAxis?

Thanx

EDIT : Revolute joint is well explained below

betajaen

13-10-2010 09:25:43

I believe I didn't write them in, because there was no source code given to duplicate the functionality. I may of did something in Detritus (which you should use, since it's better and more modern than BM), but I can't remember.

mamairaja

13-10-2010 12:14:39

No problem.
But I need little more help here.
In physics examples(Chapter 2 joints - Lesson 201 Revolute Joints) which comes with sdk they have used setGlobalAnchor and setGlobalAxis methods. Other than that everything is their in nxogre. So to convert this example to nxogre I need a help.

Now I am trying to use RevoluteJointDescription::mLocalAnchor and RevoluteJointDescription::mLocalAxis to complete the example.

At least please tell me what those two really does? Hard to understand by reading the PhysX documentation.
Why mLocalAnchor[2] and mLocalAxis[2] what does this 2 does? Why need to set two local axises for a single joint
:(

which you should use, since it's better and more modern than BM
Yes I should shift. But for this project it's hard. It's quite big and multiple dependencies.

betajaen

13-10-2010 12:34:27

Okay, picture a door, door hinge and the door frame.

mLocalAnchor[0] is the position to the part of the door hinge attached to the door, it is relative in position to the door. So if the door is 1 metre across, then the position would be (0.5, 0, 0), regardless of where the door is in the world and what direction it's facing.

mLocalAnchor[1] is the position to the part of the door hinge attached to the door frame, again it's relative to the position of the door. Say the door frame is wider than the door; 1.1 metres then that would be (0.55,0,0).

The local axis are again, relative positions of axises, for both of them the joint should swing on the Y+ axis (Up), so it's 0,1,0 for both. Again orientation of the door or doorframe (which should be the same anyway), aren't taken into account because it's a relative axis.


The setGlobalAnchor/setGlobalAxis function is a helper function; Basically what it does is works out where the localAnchor for the door and doorframe should be in the door/door frames relative frame from a global coordinate, same with Axis. Most NxDescription methods usually inline their code, so you can see it in the header file. For some reason they didn't do it with that one. Presumably because of dependencies. I don't have the source code for PhysX, so I have no idea what that code is like.

I think in Detritus, I copied the current RevoluteDescription to a NxRevoluteDescription, ran the two anchor/axis functions for me, then copied everything back into the description. You could alter your RevoluteDescription in BM to do this as well.

mamairaja

13-10-2010 19:31:37

I read the post multiple times , then implemented and managed to get it done. :)
Thank you sir!

This is my code.
OGRE3DKinematicBody* gateFrameBody = mRenderSystem->createKinematicBody(new NxOgre::Box(0.5,1,2), NxOgre::Vec3(555,40,564), "GateFrame.mesh");
OGRE3DBody* gateBody = mRenderSystem->createBody(new NxOgre::Box(0.5,1,2), NxOgre::Vec3(555,40,560), "Gate.mesh");

NxOgre::RevoluteJointDescription revJointDescription;

revJointDescription.mJointFlags |= NxOgre::Enums::JointFlag::JointFlag_CollisionEnabled;

revJointDescription.mLocalAnchor[0] = NxOgre::Vec3(0,0,-1);
revJointDescription.mLocalAnchor[1] = NxOgre::Vec3(0,0,-1.25);

revJointDescription.mLocalAxis[0] = NxOgre::Vec3(0,1,0);
revJointDescription.mLocalAxis[1] = NxOgre::Vec3(0,1,0);

revJointDescription.mProjectionAngle = 0.0872f;
revJointDescription.mProjectionDistance = 1.0f;
revJointDescription.mProjectionMode = NxOgre::Enums::JointProjectionMode_Point_MiniumDistance;

NxOgre::RevoluteJoint* rj = mScene->createRevoluteJoint(gateFrameBody, gateBody, revJointDescription);


I need one more help to make my self comfortable with revolute joints. Could you please tell me what is this projection really means?

Thank you

betajaen

13-10-2010 20:09:48

I don't have PhysX on my computer at the moment, so I don't know without looking it up. It might be about how far the two actors joined together can separate, I'm not sure though.

I reformatted the other week, which is why I don't have PhysX on my computer. :D

[Edit]

NxOgre source code to the rescue! It's do with error correction, but it isn't entirely clear about it. You'll find it out exactly what it is in the PhysX Documentation chm file, or the NxRevoluteJointDesc.h file, specifically the NxJointProjectionMode enum.

/*! enum. JointProjectionMode
desc.
Joint projection is a method for correcting large joint errors.
note.
Compatible with @NxJointProjectionMode@.
enums.
JointProjectionMode_None -- Don't project this joint
JointProjectionMode_Point_MiniumDistance -- Linear and angular minimum distance projection
JointProjectionMode_Linear_MiniumDistance -- Linear only minimum distance projection
*/
enum JointProjectionMode
{
JointProjectionMode_None = 0,
JointProjectionMode_Point_MiniumDistance = 1,
JointProjectionMode_Linear_MiniumDistance = 2
};

mamairaja

14-10-2010 04:44:15

Got it, Thank you sir.