Ejemplo n.º 1
0
        public RigidBody AddRigidBody(float mass, float3 position, float3 orientation, CollisionShape colShape/*, float3 inertia*/)
        {
            /* var meshTrianglesCount = mesh.Triangles.Length;
            int [] meshTrianglesArray = new int[meshTrianglesCount];
            for (int c = 0; c < meshTrianglesCount; c++)
            {
                meshTrianglesArray[c] = Convert.ToInt32(mesh.Triangles[c]);
            }

            int meshVerteciesCount = mesh.Vertices.Length;
            float3[] meshVerteciesArray = new float3[meshVerteciesCount];
            meshVerteciesArray = mesh.Vertices;
            */
            var shapeType = colShape.GetType().ToString();
            IRigidBodyImp rbi;
            switch (shapeType)
            {
                //Primitives
                case "Fusee.Engine.BoxShape":
                    var box =(BoxShape) colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, box.BoxShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.CapsuleShape":
                    var capsule = (CapsuleShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, capsule.CapsuleShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.ConeShape":
                    var cone = (ConeShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, cone.ConeShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.CylinderShape":
                    var cylinder = (CylinderShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, cylinder.CylinderShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.MultiSphereShape":
                    var multiSphere = (MultiSphereShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, multiSphere.MultiSphereShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.SphereShape":
                    var sphere = (SphereShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, sphere.SphereShapeImp/*, inertia*/);
                    break;

                //Misc
                case "Fusee.Engine.CompoundShape":
                    var compShape = (CompoundShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, compShape.CompoundShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.EmptyShape":
                    var empty = (EmptyShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, empty.EmtyShapeImp/*, inertia*/);
                    break;

                //Meshes
                case "Fusee.Engine.ConvexHullShape":
                    var convHullShape = (ConvexHullShape) colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, convHullShape.ConvexHullShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.GImpactMeshShape":
                    var gImpMeshShape = (GImpactMeshShape) colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, gImpMeshShape.GImpactMeshShapeImp/*, inertia*/);
                    break;
                case "Fusee.Engine.StaticPlaneShape": //static Shape
                    var staticPaneShape = (StaticPlaneShape)colShape;
                    rbi = _dwi.AddRigidBody(mass, position, orientation, staticPaneShape.StaticPlaneShapeImp/*, inertia*/);
                    break;
                //Default
                default:
                    var defaultShape = new EmptyShape();
                    Debug.WriteLine("default");
                    rbi = _dwi.AddRigidBody(mass, position, orientation, defaultShape.EmtyShapeImp/*, inertia*/);
                    break;
            }

               // IRigidBodyImp rbi = _dwi.AddRigidBody(mass, worldTransform, /* shape, */inertia);

            var retval = new RigidBody();
            //retval.Mesh = mesh;
            retval._iRigidBodyImp = rbi;
            rbi.UserObject = retval;

            return retval;
        }
Ejemplo n.º 2
0
 public EmptyShape AddEmptyShape()
 {
     IEmptyShapeImp iEmptyShapeImp = _dwi.AddEmptyShape();
     var retval = new EmptyShape();
     retval.EmtyShapeImp = iEmptyShapeImp;
     iEmptyShapeImp.UserObject = retval;
     return retval;
 }