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