| 90 | } |
| 91 | |
| 92 | void RopeScene::initBodiesPositions() { |
| 93 | |
| 94 | rp3d::Quaternion initOrientation = rp3d::Quaternion::identity(); |
| 95 | |
| 96 | for (int r=0; r < NB_ROPES; r++) { |
| 97 | |
| 98 | rp3d::Vector3 initPosition = rp3d::Vector3(r == 0 ? -5 : 25, 15, 0); |
| 99 | |
| 100 | switch(r) { |
| 101 | case 1: initPosition += rp3d::Vector3(BOX_SIZE, 0, -BOX_SIZE) * 0.5f; break; |
| 102 | case 2: initPosition += rp3d::Vector3(BOX_SIZE, 0, BOX_SIZE) * 0.5f; break; |
| 103 | case 3: initPosition += rp3d::Vector3(-BOX_SIZE, 0, BOX_SIZE) * 0.5f; break; |
| 104 | case 4: initPosition += rp3d::Vector3(-BOX_SIZE, 0, -BOX_SIZE) * 0.5f; break; |
| 105 | default: break; |
| 106 | } |
| 107 | |
| 108 | for (int i=0; i<NB_CAPSULES_PER_ROPE; i++) { |
| 109 | |
| 110 | const uint capsuleIndex = r * NB_CAPSULES_PER_ROPE + i; |
| 111 | |
| 112 | initPosition += rp3d::Vector3(0, - CAPSULE_HEIGHT, 0); |
| 113 | |
| 114 | rp3d::Transform transform(initPosition, initOrientation); |
| 115 | |
| 116 | // Create a box and a corresponding rigid in the physics world |
| 117 | mCapsules[capsuleIndex]->setTransform(transform); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | rp3d::Vector3 box1Position(-5, 15 - NB_CAPSULES_PER_ROPE * CAPSULE_HEIGHT - BOX_SIZE * 0.5, 0); |
| 122 | const rp3d::Transform box1Transform(box1Position, rp3d::Quaternion::identity()); |
| 123 | mBox1->setTransform(box1Transform); |
| 124 | |
| 125 | rp3d::Vector3 box2Position(25, 15 - NB_CAPSULES_PER_ROPE * CAPSULE_HEIGHT - BOX_SIZE * 0.5, 0); |
| 126 | const rp3d::Transform box2Transform(box2Position, rp3d::Quaternion::identity()); |
| 127 | mBox2->setTransform(box2Transform); |
| 128 | |
| 129 | rp3d::Vector3 plankPosition(-9, 5, 0); |
| 130 | const rp3d::Transform plankTransform(plankPosition, rp3d::Quaternion::identity()); |
| 131 | mPlank->setTransform(plankTransform); |
| 132 | } |
| 133 | |
| 134 | // Create the physics world |
| 135 | void RopeScene::createPhysicsWorld() { |
nothing calls this directly
no test coverage detected