Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Being new to 3d programming and bullet physics in particular, I am wondering how a 3d model or the mesh generated out of it effects the accuracy of bullet physics simulation.

I have written a small Ogre 3d application in C++, including/using bullet for physics. In a small scene I add a plane as ground and three boxes (simple blender objects that come with Ogre) that have their initial position a bit over that ground. So after starting the application those three boxes fall down until they hit the ground plane, where they move a bit, depending on their initial height and rotation, until they come to a halt.

Watching that scene the bullet physics simulation looks very accurate and realistic, also the boxes seem to touch the ground very exactly.

Ok, then I have created a box model in Sketchup 8 and exported it to an Ogre .mesh file. Then I use this model instead for those three boxes in my scene. The C++ code itself is not changed at all (except that I load the new .mesh file for the boxes).

However, even though on the screen those new box models look exactly as the original ones, their movement is not correct any more. They fall to the ground plane fine, but then they move very weird, it looks not as realistic as before. Even worse, after they have stopped their movement those three boxes now "float" a bit over the ground plane, they do not touch it. I can also see their shadow now below the box on the plane, so they are really not touching the ground plane.

TL;DR: Scene with three boxes, falling down to the ground, simulated by bullet. That works fine with default Ogre (blender) .mesh files for the boxes. But with custom Sketchup models (.mesh files) instead for the boxes, but the same code, the bullet simulation does not work correctly any more.

My question is: how does the mesh of a model impact the accuracy of bullet?
And: what can I do to solve that issue with my custom Sketchup models?

PS: I load the .mesh file and convert it to a bullet rigid body as following:

m_pSceneMgr->createEntity("Cube1", "Cube.mesh");
...
BtOgre::StaticMeshToShapeConverter converter(m_pSceneMgr->getEntity("Cube1"));
btCollisionShape* colShape = converter.createBox();
share|improve this question
    
Ogre's box was probably an actual bullet physics box, and when you loaded the model it was used as a convex mesh. This could change the behavior slightly but the movement should still appear correct. –  Grimshaw May 11 '13 at 17:12
    
@DevilWithin: Maybe I have misunderstood your comment, but I simply load the .mesh file and then convert the entity to a bullet rigid. I have updated the original question accordingly to show some code. –  Matthias May 11 '13 at 17:18
add comment

2 Answers

up vote 2 down vote accepted

Found the solution to my problem. I simply needed to set model's origin in Sketchup to its bounding box's center, now bullet works correctly in my scene again :)

share|improve this answer
add comment

I am not a Ogre user, but I really think your problem is related to the createBox() call.

Since you loaded your later cube from a mesh file, it is a regular convex mesh, not necessarily interpretable as a box by BtOgre. Calling createConvex() instead would probably fix it.

This is because the loaded cube would be now treated as a mesh, which happens to be a box.

share|improve this answer
    
Thanks, but unfortunately that does not help. Changing the createBox() call to createConvex() had an interesting effect on the boxes: they now balance on one of their edges after falling down to the ground. What bugs me is the fact that the original Ogre (Blender) meshes do work fine with the createBox() call. I would like to know: what (kind of) information can be (and is) encoded in those Ogre/Blender meshes, which my custom Sketchup models/meshes do not have? –  Matthias May 11 '13 at 20:20
    
I wonder, probably nothing special. The role of that wrapper should be to transform a convex mesh into a convex bullet shape.. Thats what you should be aiming for I believe.. Its weird it doesnt work out of the box. –  Grimshaw May 11 '13 at 23:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.