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

Method initBodiesPositions

testbed/scenes/cubes/CubesScene.cpp:93–123  ·  view source on GitHub ↗

Initialize the bodies positions

Source from the content-addressed store, hash-verified

91
92// Initialize the bodies positions
93void CubesScene::initBodiesPositions() {
94
95 const float radius = 2.0f;
96
97 // Create all the cubes of the scene
98 std::vector<Box*>::iterator it;
99 int i = 0;
100 for (it = mBoxes.begin(); it != mBoxes.end(); ++it) {
101
102 // Position of the cubes
103 float angle = i * 30.0f;
104 rp3d::Vector3 position;
105
106 if (i == 0) {
107
108 position = rp3d::Vector3(0, 5, 0);
109 }
110 else {
111
112 position = rp3d::Vector3(radius * std::cos(angle),
113 10 + i * (BOX_SIZE.y + 0.3f),
114 0);
115 }
116
117 (*it)->setTransform(rp3d::Transform(position, rp3d::Quaternion::identity()));
118
119 i++;
120 }
121
122 mFloor->setTransform(rp3d::Transform(rp3d::Vector3::zero(), rp3d::Quaternion::identity()));
123}
124
125// Destroy the physics world
126void CubesScene::destroyPhysicsWorld() {

Callers

nothing calls this directly

Calls 5

Vector3Class · 0.50
TransformClass · 0.50
beginMethod · 0.45
endMethod · 0.45
setTransformMethod · 0.45

Tested by

no test coverage detected