MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / initBodiesPositions

Method initBodiesPositions

testbed/scenes/pile/PileScene.cpp:182–248  ·  view source on GitHub ↗

Initialize the bodies positions

Source from the content-addressed store, hash-verified

180
181// Initialize the bodies positions
182void PileScene::initBodiesPositions() {
183
184 const float radius = 3.0f;
185
186 for (uint i = 0; i<NB_COMPOUND_SHAPES; i++) {
187
188 // Position
189 float angle = i * 30.0f;
190 rp3d::Vector3 position(radius * std::cos(angle),
191 90 + i * (DUMBBELL_HEIGHT + 0.3f),
192 radius * std::sin(angle));
193
194 mDumbbells[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
195 }
196
197 // Create all the boxes of the scene
198 for (uint i = 0; i<NB_BOXES; i++) {
199
200 // Position
201 float angle = i * 30.0f;
202 rp3d::Vector3 position(radius * std::cos(angle),
203 70 + i * (BOX_SIZE.y + 0.8f),
204 radius * std::sin(angle));
205
206 mBoxes[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
207 }
208
209 // Create all the spheres of the scene
210 for (uint i = 0; i<NB_SPHERES; i++) {
211
212 // Position
213 float angle = i * 35.0f;
214 rp3d::Vector3 position(radius * std::cos(angle),
215 50 + i * (SPHERE_RADIUS + 0.8f),
216 radius * std::sin(angle));
217
218 mSpheres[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
219 }
220
221 // Create all the capsules of the scene
222 for (uint i = 0; i<NB_CAPSULES; i++) {
223
224 // Position
225 float angle = i * 45.0f;
226 rp3d::Vector3 position(radius * std::cos(angle),
227 30 + i * (CAPSULE_HEIGHT + 0.3f),
228 radius * std::sin(angle));
229
230 mCapsules[i]->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
231 }
232
233 // Create all the convex meshes of the scene
234 for (uint i = 0; i<NB_MESHES; i++) {
235
236 // Position
237 float angle = i * 30.0f;
238 rp3d::Vector3 position(radius * std::cos(angle),
239 10 + i * (CAPSULE_HEIGHT + 0.3f),

Callers

nothing calls this directly

Calls 2

TransformClass · 0.50
setTransformMethod · 0.45

Tested by

no test coverage detected