Example #1
0
        /// <summary>
        /// Creates a sphere body.
        /// </summary>
        /// <param name="simulation">The simulation to use.</param>
        /// <param name="position">The position of the body.</param>
        /// <param name="radius">The radius of the sphere.</param>
        /// <returns>The sphere body that was created.</returns>
        public static SphereBody Create(PhysicsSimulation simulation, Vector3 position, float radius)
        {
            var obj = new SphereBody(simulation);

            obj.Position = position;
            obj.Radius   = radius;
            simulation.Register(obj);
            return(obj);
        }
Example #2
0
        /// <summary>
        /// Creates a box body.
        /// </summary>
        /// <param name="simulation">The simulation to use.</param>
        /// <param name="position">The position of the body.</param>
        /// <param name="rotation">The rotation of the body.</param>
        /// <param name="size">The size of the body (length in x, y and z direction).</param>
        /// <returns>The box body that was created.</returns>
        public static BoxBody Create(PhysicsSimulation simulation, Vector3 position, Quaternion rotation, Vector3 size)
        {
            var obj = new BoxBody(simulation);

            obj.Size     = size;
            obj.Position = position;
            obj.Rotation = rotation;
            obj.Vertices = FindVertices(obj);
            simulation.Register(obj);
            return(obj);
        }
Example #3
0
        /// <summary>
        /// Creates a capsule body.
        /// </summary>
        /// <param name="simulation">The simulation to use.</param>
        /// <param name="position">The position of the body.</param>
        /// <param name="rotation">The rotation of the body.</param>
        /// <param name="radius">The radius of the capsule.</param>
        /// <param name="height">The height of the cylinder part of the capsule.</param>
        /// <returns>The capsule body that was created.</returns>
        public static CapsuleBody Create(PhysicsSimulation simulation, Vector3 position, Quaternion rotation,
                                         float radius, float height)
        {
            var obj = new CapsuleBody(simulation);

            obj.Position = position;
            obj.Rotation = rotation;
            obj.Radius   = radius;
            obj.Height   = height;
            simulation.Register(obj);
            return(obj);
        }
Example #4
0
        public static TriggerBox Create(PhysicsSimulation simulation, Vector3 position, Quaternion rotation, Vector3 size)
        {
            var shape = new Box(size.X, size.Y, size.Z);

            var index = simulation.Simulation.Shapes.Add(shape);

            var collidable = new CollidableDescription(index, 0.01f);

            var descriptor = new StaticDescription(position, rotation, collidable);

            var handle = simulation.Simulation.Statics.Add(descriptor);

            var obj = new TriggerBox(simulation, handle);

            simulation.Register(obj);

            return(obj);
        }
Example #5
0
        public static CylinderBody Create(PhysicsSimulation simulation, Vector3 position, Quaternion rotation, Vector2 size)
        {
            var shape = new Cylinder(size.X, size.Y);

            shape.ComputeInertia(1, out var inertia);

            var index = simulation.Simulation.Shapes.Add(shape);

            var collidable = new CollidableDescription(index, 0.1f);

            var activity = new BodyActivityDescription(0);

            var pose = new RigidPose(position, rotation);

            var descriptor = BodyDescription.CreateDynamic(pose, inertia, collidable, activity);

            var handle = simulation.Simulation.Bodies.Add(descriptor);

            var obj = new CylinderBody(simulation, handle);

            simulation.Register(obj);

            return(obj);
        }
Example #6
0
 /// <summary>
 /// Creates a sphere body.
 /// </summary>
 /// <param name="simulation">The simulation to use.</param>
 private SphereBody(PhysicsSimulation simulation) : base(simulation)
 {
 }
Example #7
0
 public CylinderBody(PhysicsSimulation simulation, BodyHandle handle) : base(simulation, handle)
 {
 }
Example #8
0
 public TriggerBox(PhysicsSimulation simulation, StaticHandle handle) : base(simulation, handle)
 {
 }
Example #9
0
 protected PhysicsObject(PhysicsSimulation simulation)
 {
     Simulation = simulation;
 }
Example #10
0
        protected PhysicsBody(PhysicsSimulation simulation, BodyHandle handle) : base(simulation)
        {
            Handle = handle;

            Reference = simulation.Simulation.Bodies.GetBodyReference(handle);
        }
Example #11
0
        public PhysicsStatic(PhysicsSimulation simulation, StaticHandle handle) : base(simulation)
        {
            Handle = handle;

            Reference = simulation.Simulation.Statics.GetStaticReference(handle);
        }
Example #12
0
 public BoxBody(PhysicsSimulation simulation, BodyHandle handle) : base(simulation, handle)
 {
 }
Example #13
0
 /// <summary>
 /// Creates a box body.
 /// </summary>
 /// <param name="simulation">The simulation to use.</param>
 private BoxBody(PhysicsSimulation simulation) : base(simulation)
 {
 }
Example #14
0
 /// <summary>
 /// Creates a capsule body.
 /// </summary>
 /// <param name="simulation">The simulation to use.</param>
 public CapsuleBody(PhysicsSimulation simulation) : base(simulation)
 {
 }
Example #15
0
 public CapsuleBody(PhysicsSimulation simulation, BodyHandle handle) : base(simulation, handle)
 {
 }