Joints - Paddle

byte_wrench

13-06-2007 22:25:25

If anyone could tell me what I am missing, that would be appreciated..

NxRevoluteJointDesc jointDesc;
jointDesc.actor[0] = myCube->mActor;
jointDesc.actor[1] = myOtherCube->mActor;
jointDesc.setGlobalAnchor(NxVec3(0.5,4,0));
jointDesc.setGlobalAxis(NxVec3(0,-1,0));


jointDesc.flags |= NX_RJF_MOTOR_ENABLED;
jointDesc.flags |= NX_RJF_LIMIT_ENABLED;

jointDesc.limit.high.value = 120;
jointDesc.limit.high.restitution = 1;
jointDesc.limit.low.value = -120;
jointDesc.limit.low.restitution = 1;

NxMotorDesc motorDesc;
motorDesc.velTarget = 100;
motorDesc.maxForce = 100;
motorDesc.freeSpin = false;

jointDesc.motor = motorDesc;

mScene->mScene->createJoint(jointDesc);


Trying to figure out how to get a controllable paddle with its joint axis at one end and with stop limits in either direction..

byte_wrench

14-06-2007 15:17:10

Took me a while to get used to positioning the actors (a0 a1) in relation to the joint...


NxRevoluteJoint * CreateRevoluteJoint ( NxActor * a0, NxActor * a1, NxVec3 globalAnchor,
NxVec3 globalAxis )
{
NxRevoluteJointDesc revDesc;
revDesc.actor[0] = a0;
revDesc.actor[1] = a1;
revDesc.setGlobalAnchor(globalAnchor);
revDesc.setGlobalAxis(globalAxis);

revDesc.jointFlags |= NX_JF_COLLISION_ENABLED;

float jointStart = 0.25 * NxPi;
float jointEnd = 0;

revDesc.flags |= NX_RJF_MOTOR_ENABLED;
NxMotorDesc motorDesc;
motorDesc.velTarget = - 50;
motorDesc.maxForce = 10;
motorDesc.freeSpin = false;

revDesc.motor = motorDesc;

flipperActive = false;
return (NxRevoluteJoint * )mScene->mScene->createJoint(revDesc);
}
setup(){
myCube = mScene->createBody("myCube", "flipper_hinge.mesh", new convexShape("flipper_hinge.mesh"), 10.0f,
Vector3(0, flipperYPOS, 0));
myCube->setKinematic(true);

myOtherCube = mScene->createBody(
"myOtherCube",
"flipper_shape.mesh",
new convexShape("flipper_shape.mesh"),
.5,
Vector3(2.5, flipperYPOS, 0));

myOtherCube->setAngularDamping(0.0f);
myOtherCube->setLinearDamping(0.0f);
myOtherCube->mActor->raiseBodyFlag(NX_BF_DISABLE_GRAVITY);

flipperJoint = CreateRevoluteJoint(myCube->mActor, myOtherCube->mActor,
NxVec3(.8, flipperYPOS, 0), NxVec3(0, - 1, 0));
}

johnhpus

14-06-2007 21:30:58

Does this mean you've solved your problem?

If so, thanks for posting the fixed code. It might help someone else.

byte_wrench

15-06-2007 14:39:49

Hey John,
Yup, it is acting more like I need, yet for some reason I cannot get the joint limits to work correctly. Here is what I am currently trying.

NxRevoluteJointDesc revDesc;
revDesc.actor[0] =a0;
revDesc.actor[1] = a1;
revDesc.setGlobalAnchor(globalAnchor);
revDesc.setGlobalAxis(globalAxis);
revDesc.jointFlags |= NX_RJF_LIMIT_ENABLED;
revDesc.limit.high.value = 0.6*NxPi;
revDesc.limit.high.restitution = 0;
revDesc.limit.low.value = 0.1*NxPi;
revDesc.limit.low.restitution = 0;

revDesc.jointFlags |= NX_RJF_MOTOR_ENABLED;
NxMotorDesc motorDesc;
motorDesc.velTarget = - 50;
motorDesc.maxForce = 10;
motorDesc.freeSpin = false;
revDesc.motor = motorDesc;

flipperActive = false;

mWorld->mPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LIMITS, 1);
mWorld->mPhysicsSDK->setParameter(NX_VISUALIZE_JOINT_LOCAL_AXES, 1);


I can see from the visualization, that my paddle is passing the bounds of the joint limits. I know I can have the hinged object collide with the 'anchor' object, yet it would be nice to ficure out how exactly to use the joint limits..