Improve HelloWorld
- explain in comments the shape of the ground and better group that code - give enough time for the sphere to hit the ground - don't ask for confirmation to exit, it's annoying
This commit is contained in:
@@ -44,20 +44,24 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
///-----initialization_end-----
|
///-----initialization_end-----
|
||||||
|
|
||||||
///create a few basic rigid bodies
|
|
||||||
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
|
||||||
|
|
||||||
//keep track of the shapes, we release memory at exit.
|
//keep track of the shapes, we release memory at exit.
|
||||||
//make sure to re-use collision shapes among rigid bodies whenever possible!
|
//make sure to re-use collision shapes among rigid bodies whenever possible!
|
||||||
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
btAlignedObjectArray<btCollisionShape*> collisionShapes;
|
||||||
|
|
||||||
|
|
||||||
|
///create a few basic rigid bodies
|
||||||
|
|
||||||
|
//the ground is a cube of side 100 at position y = -56.
|
||||||
|
//the sphere will hit it at y = -6, with center at -5
|
||||||
|
{
|
||||||
|
btCollisionShape* groundShape = new btBoxShape(btVector3(btScalar(50.),btScalar(50.),btScalar(50.)));
|
||||||
|
|
||||||
collisionShapes.push_back(groundShape);
|
collisionShapes.push_back(groundShape);
|
||||||
|
|
||||||
btTransform groundTransform;
|
btTransform groundTransform;
|
||||||
groundTransform.setIdentity();
|
groundTransform.setIdentity();
|
||||||
groundTransform.setOrigin(btVector3(0,-56,0));
|
groundTransform.setOrigin(btVector3(0,-56,0));
|
||||||
|
|
||||||
{
|
|
||||||
btScalar mass(0.);
|
btScalar mass(0.);
|
||||||
|
|
||||||
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
//rigidbody is dynamic if and only if mass is non zero, otherwise static
|
||||||
@@ -113,7 +117,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
|
|
||||||
///-----stepsimulation_start-----
|
///-----stepsimulation_start-----
|
||||||
for (i=0;i<100;i++)
|
for (i=0;i<150;i++)
|
||||||
{
|
{
|
||||||
dynamicsWorld->stepSimulation(1.f/60.f,10);
|
dynamicsWorld->stepSimulation(1.f/60.f,10);
|
||||||
|
|
||||||
@@ -178,9 +182,5 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
//next line is optional: it will be cleared by the destructor when the array goes out of scope
|
//next line is optional: it will be cleared by the destructor when the array goes out of scope
|
||||||
collisionShapes.clear();
|
collisionShapes.clear();
|
||||||
|
|
||||||
///-----cleanup_end-----
|
|
||||||
printf("Press a key to exit\n");
|
|
||||||
getchar();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user