• Advertisement
Sign in to follow this  

tutorial for physics library "bullet"

This topic is 3736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to learn to use bullet. I need a tutorial on how to create the various types of object. How do I: 1) Create static indexed triangle mesh from memory. 2) Create a sphere. 3) Drop the sphere from a height so that it bounces on the trimesh. 4) Access the geometry of both objects in order to render them using my opengl renderer. I'm guessing that this is a simple operation. Does anybody have such a tutorial? [Edited by - shotgunnutter on October 28, 2007 9:50:27 AM]

Share this post


Link to post
Share on other sites
Advertisement
This is not a simple operation.

For operation 1, use a physics library which handles loading meshes from memory.
For operation 2, represent a sphere within that library.
For operation 3, apply gravity and elasticity to the sphere and mesh, using the physics library.
For operation 4, load the mesh using your graphics library and draw it at the correct position.

Share this post


Link to post
Share on other sites
right... I'm using bullet. I can already load meshes from file. Perhaps I should have said that more clearly in the OP. The problem is that there aren't any tutorials that I can find. The demo applications do more than just define the objects and do a simple test between them, they also render the application using glut and have multiple inheritance. I can't glean the library calls used to create the physics objects.


Share this post


Link to post
Share on other sites
Oh, so "bullet" was the name of a library as opposed to the typical gun-delivered projectile. Ignore me, then [smile]

Share this post


Link to post
Share on other sites
Here is a screenshot of my application:
screenshot of game

The character is an md2 mesh. The geometry of the landscape is loaded from disk and stored in memory as a hierarchy of hit boxes. To add the triangles to the physics library, I would recursively scan through the model adding any geometry which is flagged as SOLID to the collision model.

Share this post


Link to post
Share on other sites
Quote:
Original post by ToohrVyk
Oh, so "bullet" was the name of a library as opposed to the typical gun-delivered projectile. Ignore me, then [smile]


yes... curse the naming of libraries and applications. I dread the day I start a thread about GIMP.

Share this post


Link to post
Share on other sites
A bit offtopic, but I am making a library called GIMP ;) hehe

(Gaming Improves with MultiPlayer)

Its gonna be a networking library with some basic start-up, running and shutdown calls so no one needs to do any lowlevel coding. However, more recently (last couple of weeks), I have been adding it to my game engine so it may or may not go public for years lol (sole programmer :( ). And its name has/will be changing...

I should release this part of it though, just for fun.

Share this post


Link to post
Share on other sites
All I want to do is know how to create objects with this library and bang them together, then access their contents so I can render them. Has anybody got a simple piece of code which does this?

Share this post


Link to post
Share on other sites
Quote:
Original post by blackbird04217
A bit offtopic, but I am making a library called GIMP ;) hehe

(Gaming Improves with MultiPlayer)

Its gonna be a networking library with some basic start-up, running and shutdown calls so no one needs to do any lowlevel coding. However, more recently (last couple of weeks), I have been adding it to my game engine so it may or may not go public for years lol (sole programmer :( ). And its name has/will be changing...

I should release this part of it though, just for fun.


I made a library called g_string (my first name is Gavin) which is a C library for handling strings. But I was joking. The people who made GIMP (gnu image manipulation program) must have been serious. I once had to explain in front of an A level class what the alternate meaning of the acronym was, to the teacher for Gods sake.

But anyway... Can somebody answer my original question?

Share this post


Link to post
Share on other sites
Quote:
Original post by shotgunnutter
All I want to do is know how to create objects with this library and bang them together, then access their contents so I can render them. Has anybody got a simple piece of code which does this?


I take it you have read the Bullet User Manual? It seems to go step-by-step through the API calls to do each of the operations you need.

The exception to this is your #4, since almost all physics libraries expect the user to keep their own render-meshes (since you typically want to use much lower-poly meshes for collision than for rendering).

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
Quote:
Original post by shotgunnutter
All I want to do is know how to create objects with this library and bang them together, then access their contents so I can render them. Has anybody got a simple piece of code which does this?


I take it you have read the Bullet User Manual? It seems to go step-by-step through the API calls to do each of the operations you need.

The exception to this is your #4, since almost all physics libraries expect the user to keep their own render-meshes (since you typically want to use much lower-poly meshes for collision than for rendering).


Thanks for the user manual. I couldn't find anything like this. The reason I want to access the contents of the primitives is for debugging purposes. I do intend to keep separate render meshes, and will create the collision meshes separately then superimpose them. I have a system of flags for objects which have been created, so some can be visible, others only for collision, and some both.

Share this post


Link to post
Share on other sites
ok... the user manual doesn't contain what I'm looking for. It details a few things about the library, but as yet I haven't seen anything to do the four steps in the OP. Surely *somebody* has done it before?

Share this post


Link to post
Share on other sites
It means simply instantiating about five objects, and a loop with three lines inside. I'm currently boiling the "demos" down from three classes and six files into one class. I'll report my findings back here. The source distribution has a lot of "demos" but no "examples". They are two different things.

Share this post


Link to post
Share on other sites
You may find that using PAL is easier than using Bullet directly, but I find the Bullet demos pretty self-explanatory.

Share this post


Link to post
Share on other sites

Hi,

It would be better to get Bullet support in the Bullet physics forums. We are working on better documentation, so your input and feedback is very useful.
The things you list seem fairly straightforward, so we should be able to get you up and running fairly quickly.

By the way, Bullet has built-in visual debugging, you can hook-up and implement your own derived class of 'btIDebugDraw'.

Can you please register and post the questions at http://www.bulletphysics.com/Bullet/phpBB3/

Thanks a lot,
Erwin


Share this post


Link to post
Share on other sites

Quote:
Original post by erwincoumans

Can you please register and post the questions at http://www.bulletphysics.com/Bullet/phpBB3/

Thanks a lot,
Erwin


I certainly will. I don't need a tutorial any more, but I have plenty of other questions.

I've boiled one of the simpler demos down to this class:


class phy_demo
{
private:
//calculation objects: used to compare physics entities.
btBroadphaseInterface * m_overlappingPairCache;
btCollisionDispatcher * m_dispatcher;
btConstraintSolver * m_solver;

//entities in world
btCollisionShape * phy_level; //a flat surface to begin with, perhaps upgrading to a trimesh.

btDynamicsWorld * m_dynamicsWorld;
btAlignedObjectArray<btCollisionShape*> m_collisionShapes;
btRigidBody* localCreateRigidBody(float mass, const btTransform& startTransform,btCollisionShape* shape);
public:
phy_demo();
~phy_demo();
void build();
bool test();
void draw(renderer * r);
};




I think that, when all's said and done, I'll write some tutorials for the library, unless I manage to find some. Having everything in one file makes it easier.

The demo's aren't dificult to understand, but they do spread things out over too many files to be a substitute for "tutorials". The demo's look more like production code, to be quite honest. That's my only criticism at the moment. Concentrating them into one class will enable me to better understand this library. It seems to have almost everything covered. I like the challenge of understanding something.

(my game idea is a gta 3 style shooter / driving game, except with accountants, explosions, crystals and ponies involved in the game mechanics.)

Share this post


Link to post
Share on other sites
I have a simple question: Where in the ccd demo does it step through the physics? I want a function I can call from within an existing application loop.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement