Esempio n. 1
0
        /// <summary>
        /// Creates a cylinder shape in the world
        /// </summary>
        /// <param name="cylinderDescription"></param>
        /// <param name="colliderDescription"> </param>
        /// <returns></returns>
        public IWorldObject CreateWorldObject(CylinderDescription cylinderDescription, ColliderDescription colliderDescription)
        {
            lock (this)
            {
                var rigidBody = new RuneRigidbody(new RuneCapsuleShape(cylinderDescription.Radius, cylinderDescription.Length))
                {
                    Pose  = new Pose(cylinderDescription.Position.ToRuneVector(), cylinderDescription.Rotation.ToRuneQuaternion()),
                    Scale = cylinderDescription.Scale.ToRuneVector(),
                };
                UpdateRigidbodyCollisionSettings(rigidBody, ref colliderDescription);
                this.simulation.RigidBodies.Add(rigidBody);

                return(rigidBody);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a sphere shape in the world
        /// </summary>
        /// <param name="sphereDescription"></param>
        /// <param name="colliderDescription"> </param>
        /// <returns></returns>
        public IWorldObject CreateWorldObject(SphereDescription sphereDescription, ColliderDescription colliderDescription)
        {
            lock (this)
            {
                var rigidBody = new RuneRigidbody(new RuneSphereShape(sphereDescription.Radius))
                {
                    Pose  = new Pose(sphereDescription.Position.ToRuneVector(), sphereDescription.Rotation.ToRuneQuaternion()),
                    Scale = sphereDescription.Scale.ToRuneVector(),
                };
                UpdateRigidbodyCollisionSettings(rigidBody, ref colliderDescription);
                this.simulation.RigidBodies.Add(rigidBody);

                return(rigidBody);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a box shape in the world
        /// </summary>
        /// <param name="boxDescription"></param>
        /// <param name="colliderDescription"> </param>
        /// <returns></returns>
        public IWorldObject CreateWorldObject(BoxDescription boxDescription, ColliderDescription colliderDescription)
        {
            lock (this)
            {
                var size      = boxDescription.Size;
                var rigidBody = new RuneRigidbody(new RuneBoxShape(size.X, size.Y, size.Z))
                {
                    Pose  = new Pose(boxDescription.Position.ToRuneVector(), boxDescription.Rotation.ToRuneQuaternion()),
                    Scale = boxDescription.Scale.ToRuneVector(),
                };
                UpdateRigidbodyCollisionSettings(rigidBody, ref colliderDescription);
                this.simulation.RigidBodies.Add(rigidBody);

                return(rigidBody);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a height field object in the world
        /// </summary>
        /// <param name="heightFieldDescription"> </param>
        /// <returns></returns>
        public IWorldObject CreateHeightField(HeightFieldDescription heightFieldDescription)
        {
            lock (this)
            {
                var heightField = new RuneHeightField(heightFieldDescription.WidthX, heightFieldDescription.WidthZ, heightFieldDescription.Heights);
                var rigidBody   = new RuneRigidbody(heightField)
                {
                    Pose = new Pose(heightFieldDescription.Position.ToRuneVector(), QuaternionF.Identity),
                };
                rigidBody.CollisionObject.CollisionGroup = CollisionGroupObject;
                rigidBody.MotionType = MotionType.Static;
                this.simulation.RigidBodies.Add(rigidBody);

                return(rigidBody);
            }
        }