Mesh with offset

Please don't post Bullet support questions here, use the above forums instead.
wh1sp3r
Posts: 4
Joined: Fri Sep 16, 2011 9:04 pm

Mesh with offset

Post by wh1sp3r »

Hello,
I am new here and i have some unanswered questions.

Let's say, i will export a mesh (cube), which has 0,0,0 position outside of cube, so 0,0,0 will not be in center of the cube. if i create a physics object from polygons, what will happend ? will it work ? will it return right transformation like center is in the middle of the cube ?

My second question is about more meshes in model file. How can i "glue" them together , so it will make one collision object (dynamic object) ?

Thank you very much for your answer.
Flix
Posts: 456
Joined: Tue Dec 25, 2007 1:06 pm

Re: Mesh with offset

Post by Flix »

I don't know if this is the proper forum to post Bullet usage related questions, anyway:
wh1sp3r wrote:Let's say, i will export a mesh (cube), which has 0,0,0 position outside of cube, so 0,0,0 will not be in center of the cube. if i create a physics object from polygons, what will happend ? will it work ? will it return right transformation like center is in the middle of the cube ?
It will work, the center of mass of the rigid body will be 0,0,0 inside your cube (i.e. not its center, but outside the cube in your case), and the returned transformations are relative to 0,0,0 inside your cube (i.e. not its center but its center of mass). If your bodies are static, this leads to a more "natural" behaviour, since they're not affected by center of mass offsets, and you can for example model them with 0,0,0 at their bottom, so that they're easier to position in the world.
In short: in your case (dynamic body with 0,0,0 outside the mesh), it should work but it should produce a mesh with a weird physic behaviour (due to its center of mass being outside the mesh).
wh1sp3r wrote:My second question is about more meshes in model file. How can i "glue" them together , so it will make one collision object (dynamic object) ?
Well, usually in Bullet vertices and indices are passed to the physics through a btStridingMeshInterface (or one of its derived classes). This interface supports more than one set of vertices/indices, so that "submeshes" can be placed together (and it's possible to retrieve a submesh index in case of collision too). This refers to btGImpactMeshShapes and btBvhTriangleMeshShapes. In case you need a btConvexHullShape you just need to pass all the vertices to it manually. In case of simpler shapes (btBoxShape,btSphereShape,etc.) you just need to specify their dimensions, as they don't require mesh data.

Hope my answers are correct (and helpful).