00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "physxJointDesc.h"
00016 #include "physxManager.h"
00017
00018
00019
00020
00021
00022
00023 void PhysxJointDesc::
00024 set_name(const char *name) {
00025
00026 _name = name ? name : "";
00027 ptr()->name = _name.c_str();
00028 }
00029
00030
00031
00032
00033
00034
00035 void PhysxJointDesc::
00036 set_max_force(float force) {
00037
00038 ptr()->maxForce = force;
00039 }
00040
00041
00042
00043
00044
00045
00046
00047
00048 void PhysxJointDesc::
00049 set_max_torque(float torque) {
00050
00051 ptr()->maxTorque = torque;
00052 }
00053
00054
00055
00056
00057
00058
00059
00060 void PhysxJointDesc::
00061 set_solver_extrapolation_factor(float factor) {
00062
00063 ptr()->solverExtrapolationFactor = factor;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 void PhysxJointDesc::
00073 set_actor(unsigned int idx, const PhysxActor &actor) {
00074
00075 nassertv_always(idx < 2);
00076 ptr()->actor[idx] = actor.ptr();
00077 }
00078
00079
00080
00081
00082
00083
00084
00085
00086 void PhysxJointDesc::
00087 set_local_normal(unsigned int idx, const LVector3f &normal) {
00088
00089 nassertv_always(idx < 2);
00090 ptr()->localNormal[idx] = PhysxManager::vec3_to_nxVec3(normal);
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100 void PhysxJointDesc::
00101 set_local_axis(unsigned int idx, const LVector3f &axis) {
00102
00103 nassertv_always(idx < 2);
00104 ptr()->localAxis[idx] = PhysxManager::vec3_to_nxVec3(axis);
00105 }
00106
00107
00108
00109
00110
00111
00112
00113 void PhysxJointDesc::
00114 set_local_anchor(unsigned int idx, const LPoint3f &anchor) {
00115
00116 nassertv_always(idx < 2);
00117 ptr()->localAnchor[idx] = PhysxManager::point3_to_nxVec3(anchor);
00118 }
00119
00120
00121
00122
00123
00124
00125 void PhysxJointDesc::
00126 set_joint_flag(PhysxJointFlag flag, bool value) {
00127
00128 if (value == true) {
00129 ptr()->jointFlags |= flag;
00130 }
00131 else {
00132 ptr()->jointFlags &= ~(flag);
00133 }
00134 }
00135
00136
00137
00138
00139
00140
00141 void PhysxJointDesc::
00142 set_global_axis(const LVector3f &axis) {
00143
00144 ptr()->setGlobalAxis(PhysxManager::vec3_to_nxVec3(axis));
00145 }
00146
00147
00148
00149
00150
00151
00152 void PhysxJointDesc::
00153 set_global_anchor(const LPoint3f &anchor) {
00154
00155 ptr()->setGlobalAnchor(PhysxManager::point3_to_nxVec3(anchor));
00156 }
00157
00158
00159
00160
00161
00162
00163 const char *PhysxJointDesc::
00164 get_name() const {
00165
00166 return ptr()->name;
00167 }
00168
00169
00170
00171
00172
00173
00174 float PhysxJointDesc::
00175 get_max_force() const {
00176
00177 return ptr()->maxForce;
00178 }
00179
00180
00181
00182
00183
00184
00185 float PhysxJointDesc::
00186 get_max_torque() const {
00187
00188 return ptr()->maxTorque;
00189 }
00190
00191
00192
00193
00194
00195
00196 float PhysxJointDesc::
00197 get_solver_extrapolation_factor() const {
00198
00199 return ptr()->solverExtrapolationFactor;
00200 }
00201
00202
00203
00204
00205
00206
00207 LVector3f PhysxJointDesc::
00208 get_local_normal(unsigned int idx) const {
00209
00210 nassertr_always(idx < 2, LVector3f::zero());
00211 return PhysxManager::nxVec3_to_vec3(ptr()->localNormal[idx]);
00212 }
00213
00214
00215
00216
00217
00218
00219 LVector3f PhysxJointDesc::
00220 get_local_axis(unsigned int idx) const {
00221
00222 nassertr_always(idx < 2, LVector3f::zero());
00223 return PhysxManager::nxVec3_to_vec3(ptr()->localAxis[idx]);
00224 }
00225
00226
00227
00228
00229
00230
00231 LPoint3f PhysxJointDesc::
00232 get_local_anchor(unsigned int idx) const {
00233
00234 nassertr_always(idx < 2, LPoint3f::zero());
00235 return PhysxManager::nxVec3_to_point3(ptr()->localAnchor[idx]);
00236 }
00237
00238
00239
00240
00241
00242
00243 bool PhysxJointDesc::
00244 get_joint_flag(const PhysxJointFlag flag) const {
00245
00246 return (ptr()->jointFlags & flag) ? true : false;
00247 }
00248
00249
00250
00251
00252
00253
00254 PhysxActor *PhysxJointDesc::
00255 get_actor(unsigned int idx) const {
00256
00257 nassertr_always(idx < 2, NULL);
00258
00259 NxActor *actorPtr = ptr()->actor[idx];
00260 if (actorPtr == NULL) {
00261 return NULL;
00262 }
00263 else {
00264 return (PhysxActor *)(actorPtr->userData);
00265 }
00266 }
00267