I’m trying to mount wheels using joints to a vehicle. The following code I’ve written fails a PhysX joint validity check with a code #7. I would also like to add springs to this later.
I could use some help pointing out my mistakes and perhaps giving me a couple pointers including on how to do springs with this type of joint. Thank you in advance.
//Convert variables for easier use
Point3F wheelOffset = nodeInfo[num].wheelTorqueOffset;
Point3F springPos = nodeInfo[num].springPos;
//Update the wheel's location to spring node position in world space
MatrixF newWheelToWorld;
mChassisBody->getGlobalPose().getColumnMajor44(newWheelToWorld);
Point3F chassisPos = newWheelToWorld.getPosition();
Point3F newWheelPos = chassisPos + springPos;
newWheelToWorld.setPosition(newWheelPos);
wheel->setTransform(newWheelToWorld);
//Set up connection point on chassis
Point3F axis;
newWheelToWorld.getColumn(1, &axis);
mMountJointDesc[0] = new NxD6JointDesc;
mMountJointDesc[0]->actor[0] = mChassisBody;
mMountJointDesc[0]->localAnchor[0] = pxCast(nodeInfo[num].springPos);
mMountJointDesc[0]->localNormal[0] = pxCast(axis);
mMountJointDesc[0]->actor[1] = wheelRigid;
mMountJointDesc[0]->localAnchor[1] = NxVec3(0.0f,0.0f,0.0f);
mMountJointDesc[0]->localNormal[1] = pxCast(nodeInfo[num].wheelRotation);
mMountJointDesc[0]->xMotion = NX_D6JOINT_MOTION_FREE;
mMountJointDesc[0]->yMotion = NX_D6JOINT_MOTION_FREE;
mMountJointDesc[0]->zMotion = NX_D6JOINT_MOTION_FREE;
mMountJointDesc[0]->swing2Motion = NX_D6JOINT_MOTION_LIMITED;
mMountJointDesc[0]->swing2Limit.value = 0.0f;
mMountJointDesc[0]->twistMotion = NX_D6JOINT_MOTION_LIMITED;
mMountJointDesc[0]->twistLimit.high.value = nodeInfo[num].steeringAngleLimit;
mMountJointDesc[0]->twistLimit.low.value = -nodeInfo[num].steeringAngleLimit;
//Add the joint to the world
mMountJoint[0] = mWorld->getScene()->createJoint(*mMountJointDesc[0]);
wheel->setPhysicMounted(true);