Пример #1
0
        protected override void ConfigureCollidable(TriangleEntry entry, float dt)
        {
            var shape = entry.Collidable.Shape;

            mesh.Shape.TriangleMesh.Data.GetTriangle(entry.Index, out shape.vA, out shape.vB, out shape.vC);
            Matrix3x3 o;

            Matrix3x3.CreateFromQuaternion(ref mesh.worldTransform.Orientation, out o);
            Matrix3x3.Transform(ref shape.vA, ref o, out shape.vA);
            Matrix3x3.Transform(ref shape.vB, ref o, out shape.vB);
            Matrix3x3.Transform(ref shape.vC, ref o, out shape.vC);
            Vector3 center;

            Vector3.Add(ref shape.vA, ref shape.vB, out center);
            Vector3.Add(ref center, ref shape.vC, out center);
            Vector3.Multiply(ref center, 1 / 3f, out center);
            Vector3.Subtract(ref shape.vA, ref center, out shape.vA);
            Vector3.Subtract(ref shape.vB, ref center, out shape.vB);
            Vector3.Subtract(ref shape.vC, ref center, out shape.vC);

            Vector3.Add(ref center, ref mesh.worldTransform.Position, out center);
            //The bounding box doesn't update by itself.
            entry.Collidable.worldTransform.Position    = center;
            entry.Collidable.worldTransform.Orientation = Quaternion.Identity;
            entry.Collidable.UpdateBoundingBoxInternal(dt);
        }
Пример #2
0
        protected override void ConfigureCollidable(TriangleEntry entry, float dt)
        {
            var shape = entry.Collidable.Shape;
            mesh.Shape.TriangleMesh.Data.GetTriangle(entry.Index, out shape.vA, out shape.vB, out shape.vC);
            Matrix3X3 o;
            Matrix3X3.CreateFromQuaternion(ref mesh.worldTransform.Orientation, out o);
            Matrix3X3.Transform(ref shape.vA, ref o, out shape.vA);
            Matrix3X3.Transform(ref shape.vB, ref o, out shape.vB);
            Matrix3X3.Transform(ref shape.vC, ref o, out shape.vC);
            Vector3 center;
            Vector3.Add(ref shape.vA, ref shape.vB, out center);
            Vector3.Add(ref center, ref shape.vC, out center);
            Vector3.Multiply(ref center, 1 / 3f, out center);
            Vector3.Subtract(ref shape.vA, ref center, out shape.vA);
            Vector3.Subtract(ref shape.vB, ref center, out shape.vB);
            Vector3.Subtract(ref shape.vC, ref center, out shape.vC);

            Vector3.Add(ref center, ref mesh.worldTransform.Position, out center);
            //The bounding box doesn't update by itself.
            entry.Collidable.worldTransform.Position = center;
            entry.Collidable.worldTransform.Orientation = Quaternion.Identity;
            entry.Collidable.UpdateBoundingBoxInternal(dt);
        }
        protected override void ConfigureCollidable(TriangleEntry entry, float dt)
        {

        }