public ConeCollider(RigidBody body) { var shape = (ConeShape)body.CollisionShape; if (shape == null) { throw new ArgumentException("The body shape does not match the collider!", "body.CollisionShape"); } Model = new Model(new Mesh[] { Primitives.Cone(shape.Radius, shape.Height, 20, MeshMaterial.Green) }); Body = body; _radius = shape.Radius; _height = shape.Height; }
public Model CreateModel(Vector3 origin, Vector3 direction, Vector4 color) { // TODO: create Align method for matrices, the same as for quaternions Matrix4 align = Matrix4.CreateTranslation(origin); if (direction != Vector3.UnitY) { align *= Matrix4.CreateFromAxisAngle(Vector3.Cross(Vector3.UnitY, direction), (float)Math.Acos(Vector3.Dot(Vector3.UnitY, direction))); } return(new Model(new Mesh[] { Primitives.Cylinder(0.01f, 0, 1f, 20, new MeshMaterial { Diffuse = color }), Primitives.Cone(0.05f, 0.2f, 20, new MeshMaterial { Diffuse = color }, Vector3.UnitY) }, align * Matrix4.CreateScale(_scale))); }