VHACD in BulletSharp

Post Reply
Realsphere
Posts: 2
Joined: Mon Jan 09, 2023 6:48 pm

VHACD in BulletSharp

Post by Realsphere »

Howdy!

Im using BulletSharp in my app with VHACD, now when i start my app and use VHACD to generate my Convex Hulls, i get a offset and my objects start floating around.

i dont know why.

This is my code:

Code: Select all

CompoundShape cs = new CompoundShape();
            VHacdSharp.VHacd vhacd = new VHacdSharp.VHacd();
            var result = vhacd.ComputeAsync(go.renderer.Mesh.points.ToArray(), go.renderer.Mesh.tris.ToArray(), defaultvhacdparams).Result;

            foreach (VHacdSharp.ConvexHull hull in result.ConvexHulls)
            {
                List<float> verts = new List<float>();
                foreach (var item in hull.Vertices)
                    verts.AddRange(new float[]
                    {
                        (float)item.X,
                        (float)item.Y,
                        (float)item.Z
                    });
                ConvexHullShape chs = new ConvexHullShape(verts.ToArray());
                cs.AddChildShape(DXConversionHelper.DXToSN(
                    Matrix.Scaling((float)hull.Volume)
                    ), chs);
            }

            return cs;
What am i doing wrong?
Post Reply