Create the joints
| 56 | |
| 57 | // Create the joints |
| 58 | void BridgeScene::createJoints() { |
| 59 | |
| 60 | for (int b=0; b < NB_BRIDGES; b++) { |
| 61 | |
| 62 | for (int i=0; i < NB_BOXES-1; i++) { |
| 63 | |
| 64 | const uint box1Index = b * NB_BOXES + i; |
| 65 | const uint box2Index = b * NB_BOXES + i + 1; |
| 66 | |
| 67 | // Create the joint info object |
| 68 | rp3d::RigidBody* body1 = mBoxes[box1Index]->getRigidBody(); |
| 69 | rp3d::RigidBody* body2 = mBoxes[box2Index]->getRigidBody(); |
| 70 | rp3d::Vector3 body1Position = body1->getTransform().getPosition(); |
| 71 | const rp3d::Vector3 anchorPointWorldSpace = body1Position + rp3d::Vector3(BOX_SIZE.x / 2.0f, 0, 0); |
| 72 | rp3d::HingeJointInfo jointInfo(body1, body2, anchorPointWorldSpace, rp3d::Vector3(0, 0, 1)); |
| 73 | jointInfo.isCollisionEnabled = false; |
| 74 | rp3d::HingeJoint* joint = dynamic_cast<rp3d::HingeJoint*>(mPhysicsWorld->createJoint(jointInfo)); |
| 75 | mHingeJoints.push_back(joint); |
| 76 | } |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | // Update the physics simulation |
| 81 | void BridgeScene::updatePhysics() { |
nothing calls this directly
no test coverage detected