1
\$\begingroup\$

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();
\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$
    – Grimshaw
    May 11, 2013 at 17:12
  • \$\begingroup\$ @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. \$\endgroup\$
    – Matthias
    May 11, 2013 at 17:18

2 Answers 2

2
\$\begingroup\$

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 :)

\$\endgroup\$
0
\$\begingroup\$

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.

\$\endgroup\$
2
  • \$\begingroup\$ 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? \$\endgroup\$
    – Matthias
    May 11, 2013 at 20:20
  • \$\begingroup\$ 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. \$\endgroup\$
    – Grimshaw
    May 11, 2013 at 23:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .