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

Method initPhysics

examples/MultiBody/TestJointTorqueSetup.cpp:48–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46
47
48void TestJointTorqueSetup::initPhysics()
49{
50 int upAxis = 1;
51
52 m_guiHelper->setUpAxis(upAxis);
53
54 btVector4 colors[4] =
55 {
56 btVector4(1, 0, 0, 1),
57 btVector4(0, 1, 0, 1),
58 btVector4(0, 1, 1, 1),
59 btVector4(1, 1, 0, 1),
60 };
61 int curColor = 0;
62
63 this->createEmptyDynamicsWorld();
64 m_guiHelper->createPhysicsDebugDrawer(m_dynamicsWorld);
65 m_dynamicsWorld->getDebugDrawer()->setDebugMode(
66 //btIDebugDraw::DBG_DrawConstraints
67 +btIDebugDraw::DBG_DrawWireframe + btIDebugDraw::DBG_DrawContactPoints + btIDebugDraw::DBG_DrawAabb); //+btIDebugDraw::DBG_DrawConstraintLimits);
68
69 m_dynamicsWorld->getSolverInfo().m_jointFeedbackInWorldSpace = true;
70 m_dynamicsWorld->getSolverInfo().m_jointFeedbackInJointFrame = true;
71
72
73 //create a static ground object
74 if (1)
75 {
76 btVector3 groundHalfExtents(1, 1, 0.2);
77 groundHalfExtents[upAxis] = 1.f;
78 btBoxShape* box = new btBoxShape(groundHalfExtents);
79 box->initializePolyhedralFeatures();
80
81 m_guiHelper->createCollisionShapeGraphicsObject(box);
82 btTransform start;
83 start.setIdentity();
84 btVector3 groundOrigin(-0.4f, 3.f, 0.f);
85 groundOrigin[upAxis] -= .5;
86 groundOrigin[2] -= 0.6;
87 start.setOrigin(groundOrigin);
88 btQuaternion groundOrn(btVector3(0, 1, 0), 0.25 * SIMD_PI);
89
90 // start.setRotation(groundOrn);
91 btRigidBody* body = createRigidBody(0, start, box);
92 body->setFriction(0);
93 btVector4 color = colors[curColor];
94 curColor++;
95 curColor &= 3;
96 m_guiHelper->createRigidBodyGraphicsObject(body, color);
97 }
98
99 {
100 bool floating = false;
101 bool damping = false;
102 bool gyro = false;
103 int numLinks = 2;
104 bool spherical = false; //set it ot false -to use 1DoF hinges instead of 3DoF sphericals
105 bool canSleep = false;

Callers

nothing calls this directly

Calls 15

btVector4Class · 0.85
quatRotateFunction · 0.85
setDebugModeMethod · 0.80
getDebugDrawerMethod · 0.80
setupRevoluteMethod · 0.80
setupFixedMethod · 0.80
setupSphericalMethod · 0.80
getLinkMethod · 0.80
addMultiBodyMethod · 0.80
setJointPosMultiDofMethod · 0.80
getParentMethod · 0.80
btVector3Class · 0.50

Tested by

no test coverage detected