Page 1 of 1

BvhTriangleMeshShape problem

Posted: Tue Jan 28, 2014 11:45 am
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?

Re: BvhTriangleMeshShape problem

Posted: Sat Feb 01, 2014 1:26 am
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

Re: BvhTriangleMeshShape problem

Posted: Mon Feb 03, 2014 6:07 pm
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.

Re: BvhTriangleMeshShape problem

Posted: Thu Feb 06, 2014 1:06 pm
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.