D6MotionMode pJointD6::getZMotion() { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return D6MM_Locked; joint->saveToDesc(descr); return (D6MotionMode)descr.zMotion; }
int pJointD6::setLinearLimit(pJD6SoftLimit limit) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return -1 ; joint->saveToDesc(descr); NxJointLimitSoftDesc sLimit; sLimit.value = limit.value; sLimit.spring = limit.spring; sLimit.damping = limit.damping; sLimit.restitution = limit.restitution; if (!sLimit.isValid())return -1; descr.linearLimit = sLimit; joint->loadFromDesc(descr); return 1; }
int pJointD6::setSlerpDrive(pJD6Drive drive) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return -1 ; joint->saveToDesc(descr); NxJointDriveDesc sdrive; sdrive.damping = drive.damping; sdrive.spring = drive.spring; sdrive.forceLimit = drive.forceLimit; sdrive.driveType=drive.driveType; descr.slerpDrive = sdrive; descr.flags |=NX_D6JOINT_SLERP_DRIVE; joint->loadFromDesc(descr); return 1; }
void pJointD6::setProjectionAngle(float angle) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); descr.projectionAngle= angle; joint->loadFromDesc(descr); }
void pJointD6::setProjectionMode(ProjectionMode mode) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); descr.projectionMode = (NxJointProjectionMode)mode; joint->loadFromDesc(descr); }
void pJointD6::enableCollision( bool value ) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); if (value) { descr.jointFlags|=NX_JF_COLLISION_ENABLED; }else { descr.jointFlags&=~NX_JF_COLLISION_ENABLED; } joint->loadFromDesc(descr); }
void pJointD6::setRatio(float ratio) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); if (ratio!=0.0f) { descr.jointFlags|=NX_D6JOINT_GEAR_ENABLED; descr.gearRatio = ratio; }else { descr.jointFlags&=~NX_D6JOINT_GEAR_ENABLED; } joint->loadFromDesc(descr); }
void pJointD6::setDrivePosition(VxVector pos) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); joint->setDrivePosition(pMath::getFrom(pos)); descr.drivePosition = (pMath::getFrom(pos)); joint->loadFromDesc(descr); }
pJD6SoftLimit pJointD6::getTwistHighLimit() { NxD6JointDesc descr;NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint());joint->saveToDesc(descr); pJD6SoftLimit result(descr.twistLimit.high.damping,descr.twistLimit.high.spring,descr.twistLimit.high.value,descr.twistLimit.high.restitution); return result; }
void pJointD6::setZMotionMode(D6MotionMode mode) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint());if (!joint)return;joint->saveToDesc(descr); descr.zMotion = (NxD6JointMotion)mode; joint->loadFromDesc(descr); }
void pJointD6::setDriveRotation(VxQuaternion rot) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); joint->setDriveOrientation(pMath::getFrom(rot)); joint->loadFromDesc(descr); }
pJD6SoftLimit pJointD6::getLinearLimit() { NxD6JointDesc descr;NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint());joint->saveToDesc(descr); pJD6SoftLimit result(descr.linearLimit.damping,descr.linearLimit.spring,descr.linearLimit.value,descr.linearLimit.restitution); return result; }
void pJointD6::setDriveLinearVelocity(VxVector linVel) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); //joint->setDriveLinearVelocity(pMath::getFrom(linVel)); descr.driveLinearVelocity = (pMath::getFrom(linVel)); joint->loadFromDesc(descr); }
pJD6Drive pJointD6::getZDrive() { NxD6JointDesc descr;NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint());joint->saveToDesc(descr); pJD6Drive result(descr.zDrive.damping,descr.zDrive.spring,descr.zDrive.forceLimit,descr.zDrive.driveType); return result; }
void pJointD6::setGlobalAxis(VxVector axis) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return ; joint->saveToDesc(descr); joint->setGlobalAxis(pMath::getFrom(axis)); //joint->setGlobalA(pMath::getFrom(anchor)); }
int pJointD6::setZDrive(pJD6Drive drive) { NxD6JointDesc descr; NxD6Joint *joint = static_cast<NxD6Joint*>(getJoint()); if (!joint)return -1 ; joint->saveToDesc(descr); NxJointDriveDesc sdrive; sdrive.damping = drive.damping; sdrive.spring = drive.spring; sdrive.forceLimit = drive.forceLimit; sdrive.driveType=drive.driveType; descr.zDrive = sdrive; joint->loadFromDesc(descr); return 1; }
bool NxuPhysicsExport::Write(NxJoint *j,const char *userProperties,const char *id) { bool ret = false; NxSceneDesc *current = getCurrentScene(); CustomCopy cc(mCollection,current); NxJointDesc *joint = 0; switch ( j->getType() ) { case NX_JOINT_PRISMATIC: if ( 1 ) { ::NxPrismaticJointDesc d1; NxPrismaticJoint *sj = j->isPrismaticJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPrismaticJointDesc *desc = new NxPrismaticJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_REVOLUTE: if ( 1 ) { ::NxRevoluteJointDesc d1; NxRevoluteJoint *sj = j->isRevoluteJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxRevoluteJointDesc *desc = new NxRevoluteJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_CYLINDRICAL: if ( 1 ) { ::NxCylindricalJointDesc d1; NxCylindricalJoint *sj = j->isCylindricalJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxCylindricalJointDesc *desc = new NxCylindricalJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_SPHERICAL: if ( 1 ) { ::NxSphericalJointDesc d1; NxSphericalJoint *sj = j->isSphericalJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxSphericalJointDesc *desc = new NxSphericalJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_POINT_ON_LINE: if ( 1 ) { ::NxPointOnLineJointDesc d1; NxPointOnLineJoint *sj = j->isPointOnLineJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPointOnLineJointDesc *desc = new NxPointOnLineJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_POINT_IN_PLANE: if ( 1 ) { ::NxPointInPlaneJointDesc d1; NxPointInPlaneJoint *sj = j->isPointInPlaneJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPointInPlaneJointDesc *desc = new NxPointInPlaneJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_DISTANCE: if ( 1 ) { ::NxDistanceJointDesc d1; NxDistanceJoint *sj = j->isDistanceJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxDistanceJointDesc *desc = new NxDistanceJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_PULLEY: if ( 1 ) { ::NxPulleyJointDesc d1; NxPulleyJoint *sj = j->isPulleyJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxPulleyJointDesc *desc = new NxPulleyJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_FIXED: if ( 1 ) { ::NxFixedJointDesc d1; NxFixedJoint *sj = j->isFixedJoint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxFixedJointDesc *desc = new NxFixedJointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; case NX_JOINT_D6: if ( 1 ) { ::NxD6JointDesc d1; NxD6Joint *sj = j->isD6Joint(); sj->saveToDesc(d1); addActor( d1.actor[0] ); addActor( d1.actor[1] ); NxD6JointDesc *desc = new NxD6JointDesc; desc->copyFrom(d1,cc); joint = static_cast<NxJointDesc *>(desc); } break; default: break; } //Add Limits // in addition, we also have to write out its limit planes! j->resetLimitPlaneIterator(); if (j->hasMoreLimitPlanes()) { // write limit point joint->mOnActor2 = j->getLimitPoint(joint->mPlaneLimitPoint); NxArray< NxPlaneInfoDesc *> plist; // write the plane normals while (j->hasMoreLimitPlanes()) { NxPlaneInfoDesc *pInfo = new NxPlaneInfoDesc(); #if NX_SDK_VERSION_NUMBER >= 272 j->getNextLimitPlane(pInfo->mPlaneNormal, pInfo->mPlaneD, &pInfo->restitution); #else j->getNextLimitPlane(pInfo->mPlaneNormal, pInfo->mPlaneD); #endif plist.push_back(pInfo); } if ( plist.size() ) { for (int i=plist.size()-1; i>=0; i--) { NxPlaneInfoDesc *p = plist[i]; joint->mPlaneInfo.pushBack(p); } } } if ( joint ) { if ( id ) { joint->mId = id; } else { char scratch[512]; sprintf(scratch,"Joint_%d", current->mJoints.size()); joint->mId = getGlobalString(scratch); joint->mUserProperties = getGlobalString(userProperties); } current->mJoints.push_back(joint); ret = true; } return ret; }