public ConvexHullAdapter(Game game, BaseObject parent, World physicsWorld, Model drawingModel, RigidBody body, bool hasCharacterController = false) : base(game, parent, physicsWorld, body) { this.drawingModel = drawingModel; ConvexHullShape shape = ConvexHullHelper.BuildConvexHullShape(drawingModel, parent.Scale); body.Shape = shape; //((DrawingObject)parent).Center = -Helper.ToXNAVector(shape.Shift); }
public ConvexHullAdapter(Game game, BaseObject parent, World physicsWorld, Vector3 relativePosition) : base(game, parent, physicsWorld) { this.drawingModel = (parent as DrawingObject).DrawingModel; ConvexHullShape shape = ConvexHullHelper.BuildConvexHullShape(drawingModel, parent.Scale); body = new RigidBody(shape); //DrawingObject obj = parent as DrawingObject; //BoundingBox parentBoundingBox = obj.CreateBoundingBox(); //Vector3 parentShift = obj.Center - new Vector3(0, parentBoundingBox.Min.Y, 0); //RelativePosition = Vector3.Zero; RelativePosition = relativePosition; Rotation = rotation; //body.Position = Helper.ToJitterVector(position); //body.Orientation = Helper.ToJitterMatrix(Matrix.CreateFromQuaternion(rotation)); physicsWorld.AddBody(body); //((DrawingObject)parent).Center = -Helper.ToXNAVector(shape.Shift); }