Code: Select all
                
// Rotation Matrix and quanternion for rotation
                Matrix rotationY = Matrix.CreateFromAxisAngle(Vector3.UnitY, MathHelper.ToRadians(mapObject.gameObject.rotation.Y));
                Matrix rotationZ = Matrix.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.ToRadians(mapObject.gameObject.rotation.Z));
                Quaternion objectAngleY = Quaternion.CreateFromRotationMatrix(rotationY);
                Quaternion objectAngleZ = Quaternion.CreateFromRotationMatrix(rotationZ);
                Quaternion objectAngles = objectAngleY * objectAngleZ;
                // Creates physics object
                Vector3[] vertices;
                int[] indices;
                TriangleMesh.GetVerticesAndIndicesFromModel(mapObject.gameObject.model, out vertices, out indices);
                AffineTransform newATransform = new AffineTransform(new Vector3(mapObject.gameObject.scale), objectAngles, mapObject.gameObject.position);
                mapObject.physicsMesh = new StaticMesh(vertices, indices, newATransform);
                space.Add(mapObject.physicsMesh);