BvhTriangleMeshShape problem

Post Reply
vbprogr
Posts: 5
Joined: Tue Jan 28, 2014 11:38 am

BvhTriangleMeshShape problem

Post by vbprogr »

Obj: https://www.dropbox.com/s/hmf0yh6lweocw7m/file.obj

I load all meshes and use CompounedShape.

How it should look:

Convas (but I want to use BvhTriangleMeshShape):
Image

Code: Select all

                            ConvexShape tmpConvexShape = new ConvexTriangleMeshShape(trimesh);

                            //create a hull approximation
                            ShapeHull hull = new ShapeHull(tmpConvexShape);
                            float margin = tmpConvexShape.Margin;
                            hull.BuildHull(margin);
                            tmpConvexShape.UserObject = hull;

                            ConvexHullShape convexShape = new ConvexHullShape();
                            foreach (Vector3 v in hull.Vertices)
                            {
                                convexShape.AddPoint(v);
                            }

                            convexShape.LocalScaling = new Vector3(0.25f, 0.25f, 0.25f);

                            tmpConvexShape.Dispose();


                            CollisionShapes.Add(convexShape);
Concave (BvhTriangleMeshShape):
Image

Code: Select all

                            bool useQuantization = false;

                            CollisionShape concaveShape = new BvhTriangleMeshShape(trimesh, useQuantization);

                            CollisionShapes.Add(concaveShape);
At the end:

Code: Select all

                var cShape = new CompoundShape();
                foreach (CollisionShape shape in CollisionShapes)
                    cShape.AddChildShape(Matrix.Identity, shape);
                LocalCreateRigidBody(0, pos, cShape);
Am I doing something wrong?
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: BvhTriangleMeshShape problem

Post by anthrax11 »

The Wavefront loader in BulletSharp demos is very basic. It didn't know how to read faces with 4 vertices. Should be fixed with this commit:
https://code.google.com/p/bulletsharp/s ... tail?r=580
vbprogr
Posts: 5
Joined: Tue Jan 28, 2014 11:38 am

Re: BvhTriangleMeshShape problem

Post by vbprogr »

Thanks, I used the latest version and it helped! Actually I didn't use that obj importer before because it didn't work at all with my obj file so I tried to use Assimp importer. It seems like Assimp needs the same improvement.
anthrax11
Posts: 72
Joined: Wed Feb 24, 2010 9:49 pm

Re: BvhTriangleMeshShape problem

Post by anthrax11 »

Well, the .obj spec allows more than 3 vertices per face, but doesn't specify the ordering of additional vertices. So there's two ways you can build 2 triangles from 4 points if you think about it.
That's why I'd stick to using 3-vertex faces where possible.
Post Reply