This commit is contained in:
erwin coumans
2016-05-06 13:58:21 -07:00
9 changed files with 152 additions and 53 deletions

View File

@@ -83,8 +83,10 @@ static ExampleEntry gDefaultExamples[]=
ExampleEntry(0,"API"),
ExampleEntry(1,"Basic Example","Create some rigid bodies using box collision shapes. This is a good example to familiarize with the basic initialization of Bullet. The Basic Example can also be compiled without graphical user interface, as a console application. Press W for wireframe, A to show AABBs, I to suspend/restart physics simulation. Press D to toggle auto-deactivation of the simulation. ", BasicExampleCreateFunc),
ExampleEntry(1,"Rolling Friction", "Damping is often not good enough to keep rounded objects from rolling down a sloped surface. Instead, you can set the rolling friction of a rigid body. Generally it is best to leave the rolling friction to zero, to avoid artifacts.", RollingFrictionCreateFunc),
ExampleEntry(1,"Constraints","Show the use of the various constraints in Bullet. Press the L key to visualize the constraint limits. Press the C key to visualize the constraint frames.",

View File

@@ -44,20 +44,24 @@ int main(int argc, char** argv)
///-----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.
//make sure to re-use collision shapes among rigid bodies whenever possible!
btAlignedObjectArray<btCollisionShape*> collisionShapes;
collisionShapes.push_back(groundShape);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-56,0));
///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);
btTransform groundTransform;
groundTransform.setIdentity();
groundTransform.setOrigin(btVector3(0,-56,0));
btScalar mass(0.);
//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-----
for (i=0;i<100;i++)
for (i=0;i<150;i++)
{
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
collisionShapes.clear();
///-----cleanup_end-----
printf("Press a key to exit\n");
getchar();
}

View File

@@ -1076,6 +1076,20 @@ b3KeyboardCallback X11OpenGLWindow::getKeyboardCallback()
return m_data->m_keyboardCallback;
}
int X11OpenGLWindow::getWidth() const
{
if (m_data)
return m_data->m_glWidth;
return 0;
}
int X11OpenGLWindow::getHeight() const
{
if (m_data)
return m_data->m_glHeight;
return 0;
}
#include <stdio.h>
int X11OpenGLWindow::fileOpenDialog(char* filename, int maxNameLength)

View File

@@ -54,7 +54,7 @@ public:
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
virtual void setWheelCallback(b3WheelCallback wheelCallback);
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
virtual b3MouseMoveCallback getMouseMoveCallback();
virtual b3MouseButtonCallback getMouseButtonCallback();
virtual b3ResizeCallback getResizeCallback();
@@ -65,9 +65,14 @@ public:
virtual void setWindowTitle(const char* title);
virtual int getWidth() const;
virtual int getHeight() const;
int fileOpenDialog(char* filename, int maxNameLength);
};
#endif

View File

@@ -4,7 +4,7 @@ INCLUDE_DIRECTORIES(
${BULLET_PHYSICS_SOURCE_DIR}/src
${BULLET_PHYSICS_SOURCE_DIR}/examples
${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs
/usr/include/python2.7
${PYTHON_INCLUDE_DIRS}
)
SET(pybullet_SRCS
@@ -18,7 +18,7 @@ ADD_LIBRARY(pybullet ${pybullet_SRCS})
SET_TARGET_PROPERTIES(pybullet PROPERTIES VERSION ${BULLET_VERSION})
SET_TARGET_PROPERTIES(pybullet PROPERTIES SOVERSION ${BULLET_VERSION})
TARGET_LINK_LIBRARIES(pybullet BulletExampleBrowserLib BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow gwen Bullet3Common Python)
TARGET_LINK_LIBRARIES(pybullet BulletExampleBrowserLib BulletSoftBody BulletDynamics BulletCollision BulletInverseDynamicsUtils BulletInverseDynamics LinearMath OpenGLWindow gwen Bullet3Common ${PYTHON_LIBRARIES})
ENDIF (BUILD_SHARED_LIBS)