Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sat Nov 11, 2017 10:39 pm 
Offline

Joined: Mon Jul 11, 2016 10:36 am
Posts: 6
Hi!

It seems that Bullet Physics defines the vertices and triangles in a btTriangleIndexVertexArray in a way different from the way they are defined in Blender, so the mesh appears scrambled. For illustration, here below 3 cubes rendered as a btBoxShape and a cube rendered as a btGImpactMeshShape based on a btTriangleIndexVertexArray. The .obj cube mesh is exported from Blender and the same for all 4 cubes.

Thus the question, how to export a concave mesh from Blender, so its vertices and triangles can be loaded in Bullet Physics as a btTriangleIndexVertexArray to create a btGImpactMeshShape without the mesh being scrambled, any... silver bullet to do that???

Thanks! ;-)

Attachment:
Blender cube.jpg
Blender cube.jpg [ 636.08 KiB | Viewed 179 times ]


Last edited by LastBlow on Mon Nov 13, 2017 3:13 pm, edited 9 times in total.

Top
 Profile  
 
PostPosted: Sun Nov 12, 2017 1:47 am 
Offline

Joined: Mon Jul 11, 2016 10:36 am
Posts: 6
Alright, just figured it out, so it can help others... Blender names its indices starting at 1 while Bullet Physics starts at 0.

As an example, here below how the vertices and indices for a btTriangleIndexVertexArray should look like for a cube mesh
exported from Blender to render properly in Bullet Physics as a btGImpactMeshShape.

Plus a low-poly rendition of the Standford Bunny who just happened to hop by... ;-)

PS. Related post at stackoverflow: https://stackoverflow.com/questions/24236325/using-bullet-physics-to-load-obj-model-to-btgimpactmeshshape-but-the-result-is-w/47243137#47243137

Code:
const int NUMBER_VERTICES = 8;
const int NUMBER_TRIANGLES = 12;


static btScalar cubeVertices[3 * NUMBER_VERTICES] = {
   1.000000, -1.000000, -1.000000,
   1.000000, -1.000000, 1.000000,
   -1.000000, -1.000000, 1.000000,
   -1.000000, -1.000000, -1.000000,
   1.000000, 1.000000, -0.999999,
   0.999999, 1.000000, 1.000001,
   -1.000000, 1.000000, 1.000000,
   -1.000000, 1.000000, -1.000000
};

static int cubeIndices[NUMBER_TRIANGLES][3] = {
   { 1, 3, 0 },
   { 7, 5, 4 },
   { 4, 1, 0 },
   { 5, 2, 1 },
   { 2, 7, 3 },
   { 0, 7, 4 },
   { 1, 2, 3 },
   { 7, 6, 5 },
   { 4, 5, 1 },
   { 5, 6, 2 },
   { 2, 6, 7 },
   { 0, 3, 7 }
};


Attachments:
the newest family addition.jpg
the newest family addition.jpg [ 380.05 KiB | Viewed 145 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group