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!
[SOLVED] btGImpactMeshShape scrambled...
-
- Posts: 18
- Joined: Mon Jul 11, 2016 10:36 am
- Location: SAN DIEGO
[SOLVED] btGImpactMeshShape scrambled...
You do not have the required permissions to view the files attached to this post.
Last edited by LastBlow on Mon Nov 13, 2017 3:13 pm, edited 9 times in total.
-
- Posts: 18
- Joined: Mon Jul 11, 2016 10:36 am
- Location: SAN DIEGO
Re: btGImpactMeshShape scrambled...
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/242 ... 7#47243137
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/242 ... 7#47243137
Code: Select all
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 }
};
You do not have the required permissions to view the files attached to this post.