| 303 | #define FIX_BY_ONE_HINGE |
| 304 | #endif |
| 305 | void CPHJoint::CreateFullControl() |
| 306 | { |
| 307 | Fvector pos; |
| 308 | Fmatrix first_matrix, second_matrix; |
| 309 | Fvector axis; |
| 310 | CPHElement* first = (pFirst_element); |
| 311 | CPHElement* second = (pSecond_element); |
| 312 | VERIFY(first); |
| 313 | first->GetGlobalTransformDynamic(&first_matrix); |
| 314 | dBodyID body1 = body_for_joint(first); |
| 315 | VERIFY(second); |
| 316 | second->GetGlobalTransformDynamic(&second_matrix); |
| 317 | dBodyID body2 = body_for_joint(second); |
| 318 | |
| 319 | pos.set(0, 0, 0); |
| 320 | switch (vs_anchor) |
| 321 | { |
| 322 | case vs_first: first_matrix.transform_tiny(pos, anchor); break; |
| 323 | case vs_second: second_matrix.transform_tiny(pos, anchor); break; |
| 324 | case vs_global: pShell->mXFORM.transform_tiny(pos, anchor); break; |
| 325 | default: NODEFAULT; |
| 326 | } |
| 327 | ////////////////////////////////////// |
| 328 | |
| 329 | m_joint = dJointCreateBall(0, 0); |
| 330 | dJointAttach(m_joint, body1, body2); |
| 331 | dJointSetBallAnchor(m_joint, pos.x, pos.y, pos.z); |
| 332 | |
| 333 | m_joint1 = dJointCreateAMotor(0, 0); |
| 334 | dJointSetAMotorMode(m_joint1, dAMotorEuler); |
| 335 | dJointSetAMotorNumAxes(m_joint1, 3); |
| 336 | |
| 337 | dJointAttach(m_joint1, body1, body2); |
| 338 | |
| 339 | ///////////////////////////////////////////// |
| 340 | |
| 341 | Fmatrix first_matrix_inv; |
| 342 | first_matrix_inv.set(first_matrix); |
| 343 | first_matrix_inv.invert(); |
| 344 | Fmatrix rotate; |
| 345 | rotate.mul(first_matrix_inv, second_matrix); |
| 346 | ///////////////////////////////////////////// |
| 347 | |
| 348 | float lo; |
| 349 | float hi; |
| 350 | ////////////////////////////////////////////////////////// |
| 351 | ///////////////////////////////////////////////////////// |
| 352 | axis.set(0, 0, 0); |
| 353 | // axis 0 |
| 354 | CalcAxis(0, axis, lo, hi, first_matrix, second_matrix, rotate); |
| 355 | if (!body1) |
| 356 | axis.invert(); // SwapLimits(lo,hi); |
| 357 | dJointSetAMotorAxis(m_joint1, 0, 1, axis.x, axis.y, axis.z); |
| 358 | dJointSetAMotorParam(m_joint1, dParamLoStop, lo); |
| 359 | dJointSetAMotorParam(m_joint1, dParamHiStop, hi); |
| 360 | |
| 361 | if (!(axes[0].force < 0.f)) |
| 362 | { |
nothing calls this directly
no test coverage detected