MCPcopy Create free account
hub / github.com/bulletphysics/bullet3 / initPhysics

Method initPhysics

examples/ExtendedTutorials/SimpleBox.cpp:42–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40};
41
42void SimpleBoxExample::initPhysics()
43{
44 m_guiHelper->setUpAxis(1);
45
46 createEmptyDynamicsWorld();
47
48 m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
49
50 if (m_dynamicsWorld->getDebugDrawer())
51 m_dynamicsWorld->getDebugDrawer()->setDebugMode(btIDebugDraw::DBG_DrawWireframe + btIDebugDraw::DBG_DrawContactPoints);
52
53 ///create a few basic rigid bodies
54 btBoxShape* groundShape = createBoxShape(btVector3(btScalar(50.), btScalar(50.), btScalar(50.)));
55 m_collisionShapes.push_back(groundShape);
56
57 btTransform groundTransform;
58 groundTransform.setIdentity();
59 groundTransform.setOrigin(btVector3(0, -50, 0));
60 {
61 btScalar mass(0.);
62 createRigidBody(mass, groundTransform, groundShape, btVector4(0, 0, 1, 1));
63 }
64
65 {
66 //create a few dynamic rigidbodies
67 // Re-using the same collision is better for memory usage and performance
68 btBoxShape* colShape = createBoxShape(btVector3(1, 1, 1));
69
70 m_collisionShapes.push_back(colShape);
71
72 /// Create Dynamic Objects
73 btTransform startTransform;
74 startTransform.setIdentity();
75
76 btScalar mass(1.f);
77
78 //rigidbody is dynamic if and only if mass is non zero, otherwise static
79 bool isDynamic = (mass != 0.f);
80
81 btVector3 localInertia(0, 0, 0);
82 if (isDynamic)
83 colShape->calculateLocalInertia(mass, localInertia);
84
85 startTransform.setOrigin(btVector3(
86 btScalar(0),
87 btScalar(20),
88 btScalar(0)));
89 createRigidBody(mass, startTransform, colShape);
90 }
91
92 m_guiHelper->autogenerateGraphicsObjects(m_dynamicsWorld);
93}
94
95void SimpleBoxExample::renderScene()
96{

Callers

nothing calls this directly

Calls 10

btVector4Class · 0.85
getDebugDrawerMethod · 0.80
setDebugModeMethod · 0.80
btVector3Class · 0.50
setUpAxisMethod · 0.45
push_backMethod · 0.45
setIdentityMethod · 0.45
calculateLocalInertiaMethod · 0.45

Tested by

no test coverage detected