I am using PhysX SDK version 2.8.4 with the Torque 3D game engine in my work to create an articulated suspension system. I’m using multiple joints because as I’ve seen thus far there is nothing that allows me to use one to create steering, wheel rotation, and a suspension spring simultaneously.
The following is the code I’m using for the front wheels in the also following video. The rear wheels are essentially just not using one of the joints and the additional actor. By my understanding, since I’ve locked all directions for the joints for the front wheel, they should remain completely rigid. This happens when I lock them for the rear wheels. However, as you can plainly see in the video, they are not remaining locked at all. I can only assume this has something to do with the additional actor, but I’ve been testing numerous configurations and have made no improvements which is why I’m asking for assistance.
This is the link to the video:
My code is the remainder of this post, thank you in advance.
//Initialize mount joint descriptor
mMountJointDesc = new NxD6JointDesc;
//Wheel Steering
if(mDataBlock->hasSteering)
{
//Create joint combining actor
NxActorDesc actorDesc;
NxBodyDesc bodyDesc;
bodyDesc.mass = 1.0f;
NxBoxShapeDesc boxDesc;
boxDesc.dimensions = NxVec3(0.01f, 0.01f, 0.01f);
actorDesc.shapes.pushBack(&boxDesc);
actorDesc.body = &bodyDesc;
NxMat34 xfm;
xfm.setRowMajor44( newWheelToWorld );
actorDesc.globalPose = xfm;
mActor = mWorld->getScene()->createActor(actorDesc);
mActor->userData = (void*)size_t(2);
//Create and set up Steering Joint
mSteeringJointDesc = new NxD6JointDesc;
mSteeringJointDesc->actor[0] = mChassisBody;
mSteeringJointDesc->actor[1] = mActor;
mSteeringJointDesc->localAnchor[0] = pxCast(springStart);
mSteeringJointDesc->localAnchor[1] = NxVec3(0.0f,0.0f,0.0f);
mSteeringJointDesc->xMotion = NX_D6JOINT_MOTION_LOCKED;
mSteeringJointDesc->yMotion = NX_D6JOINT_MOTION_LOCKED;
mSteeringJointDesc->zMotion = NX_D6JOINT_MOTION_LOCKED;
mSteeringJointDesc->swing1Motion = NX_D6JOINT_MOTION_LOCKED;
mSteeringJointDesc->swing2Motion = NX_D6JOINT_MOTION_LOCKED;
mSteeringJointDesc->twistMotion = NX_D6JOINT_MOTION_LOCKED;
//Add the steering joint to the world
NxJoint* temp1 = mWorld->getScene()->createJoint(*mSteeringJointDesc);
mSteeringJoint = (NxD6Joint*)temp1->is(NX_JOINT_D6);
mSteeringJoint->setUseAccelerationSpring(false);
mWorld->getScene()->setActorPairFlags(*mChassisBody, *wheelRigid, NX_IGNORE_PAIR);
//Set up mount joint
mMountJointDesc->actor[0] = mActor;
mMountJointDesc->actor[1] = wheelRigid;
mMountJointDesc->localAnchor[0] = NxVec3(0.0f,0.0f,0.0f);
mMountJointDesc->localAnchor[1] = NxVec3(0.0f,0.0f,0.0f);
mMountJointDesc->xMotion = NX_D6JOINT_MOTION_LOCKED;
mMountJointDesc->yMotion = NX_D6JOINT_MOTION_LOCKED; //NX_D6JOINT_MOTION_LIMITED;
mMountJointDesc->zMotion = NX_D6JOINT_MOTION_LOCKED;
mMountJointDesc->swing1Motion = NX_D6JOINT_MOTION_LOCKED; //Wheel Steering (Not Used here)
mMountJointDesc->swing2Motion = NX_D6JOINT_MOTION_LOCKED; //NX_D6JOINT_MOTION_FREE; //Wheel Roll
mMountJointDesc->twistMotion = NX_D6JOINT_MOTION_LOCKED; //Wheel Swya
//Add the mount joint to the world
NxJoint* temp2 = mWorld->getScene()->createJoint(*mMountJointDesc);
mMountJoint = (NxD6Joint*)temp2->is(NX_JOINT_D6);
mWorld->getScene()->setActorPairFlags(*wheelRigid, *mActor, NX_IGNORE_PAIR);
mWorld->getScene()->setActorPairFlags(*mChassisBody, *wheelRigid, NX_IGNORE_PAIR);