Panda3D
 All Classes Functions Variables Enumerations
physxSphericalJoint.cxx
00001 // Filename: physxSphericalJoint.cxx
00002 // Created by:  enn0x (02Oct09)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #include "physxSphericalJoint.h"
00016 #include "physxSphericalJointDesc.h"
00017 
00018 TypeHandle PhysxSphericalJoint::_type_handle;
00019 
00020 ////////////////////////////////////////////////////////////////////
00021 //     Function: PhysxSphericalJoint::link
00022 //       Access: Public
00023 //  Description: 
00024 ////////////////////////////////////////////////////////////////////
00025 void PhysxSphericalJoint::
00026 link(NxJoint *jointPtr) {
00027 
00028   _ptr = jointPtr->isSphericalJoint();
00029   _ptr->userData = this;
00030   _error_type = ET_ok;
00031 
00032   set_name(jointPtr->getName());
00033 
00034   PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
00035   scene->_joints.add(this);
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: PhysxSphericalJoint::unlink
00040 //       Access: Public
00041 //  Description: 
00042 ////////////////////////////////////////////////////////////////////
00043 void PhysxSphericalJoint::
00044 unlink() {
00045 
00046   _ptr->userData = NULL;
00047   _error_type = ET_released;
00048 
00049   PhysxScene *scene = (PhysxScene *)_ptr->getScene().userData;
00050   scene->_joints.remove(this);
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function : PhysxSphericalJoint::save_to_desc
00055 //       Access : Published
00056 //  Description : Saves the state of the joint object to a 
00057 //                descriptor.
00058 ////////////////////////////////////////////////////////////////////
00059 void PhysxSphericalJoint::
00060 save_to_desc(PhysxSphericalJointDesc &jointDesc) const {
00061 
00062   nassertv(_error_type == ET_ok);
00063   _ptr->saveToDesc(jointDesc._desc);
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function : PhysxSphericalJoint::load_from_desc
00068 //       Access : Published
00069 //  Description : Loads the entire state of the joint from a 
00070 //                descriptor with a single call.
00071 ////////////////////////////////////////////////////////////////////
00072 void PhysxSphericalJoint::
00073 load_from_desc(const PhysxSphericalJointDesc &jointDesc) {
00074 
00075   nassertv(_error_type == ET_ok);
00076   _ptr->loadFromDesc(jointDesc._desc);
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: PhysxSphericalJoint::set_projection_mode
00081 //       Access: Published
00082 //  Description: Sets the joint projection mode.
00083 ////////////////////////////////////////////////////////////////////
00084 void PhysxSphericalJoint::
00085 set_projection_mode(PhysxProjectionMode mode) {
00086 
00087   nassertv(_error_type == ET_ok);
00088   _ptr->setProjectionMode((NxJointProjectionMode)mode);
00089 }
00090 
00091 ////////////////////////////////////////////////////////////////////
00092 //     Function: PhysxSphericalJoint::get_projection_mode
00093 //       Access: Published
00094 //  Description: Returns the current projection mode settings.
00095 ////////////////////////////////////////////////////////////////////
00096 PhysxEnums::PhysxProjectionMode PhysxSphericalJoint::
00097 get_projection_mode() const {
00098 
00099   nassertr(_error_type == ET_ok, PM_none);
00100   return (PhysxProjectionMode)_ptr->getProjectionMode();
00101 }
00102 
00103 ////////////////////////////////////////////////////////////////////
00104 //     Function: PhysxSphericalJoint::set_flag
00105 //       Access: Published
00106 //  Description: Sets or clears a single SphericalJointFlag.
00107 ////////////////////////////////////////////////////////////////////
00108 void PhysxSphericalJoint::
00109 set_flag(PhysxSphericalJointFlag flag, bool value) {
00110 
00111   nassertv(_error_type == ET_ok);
00112   NxU32 flags = _ptr->getFlags();
00113 
00114   if (value == true) {
00115     flags |= flag;
00116   }
00117   else {
00118     flags &= ~(flag);
00119   }
00120 
00121   _ptr->setFlags(flags);
00122 }
00123 
00124 ////////////////////////////////////////////////////////////////////
00125 //     Function: PhysxSphericalJoint::get_flag
00126 //       Access: Published
00127 //  Description: Returns the value of a single SphericalJointFlag.
00128 ////////////////////////////////////////////////////////////////////
00129 bool PhysxSphericalJoint::
00130 get_flag(PhysxSphericalJointFlag flag) const {
00131 
00132   nassertr(_error_type == ET_ok, false);
00133   return (_ptr->getFlags() & flag) ? true : false;
00134 }
00135 
 All Classes Functions Variables Enumerations