Exemplo n.º 1
0
        /// <summary>
        /// Rotates the entity using roll, yaw and pitch values.
        /// </summary>
        /// <param name="x">The angle used to roll the entity in radians (rotate around x-Axis).</param>
        /// <param name="y">The angle used to yaw the entity in radians (rotate around y-Axis).</param>
        /// <param name="z">The angle used to pitch the entity in radians (rotate around z-Axis).</param>
        /// <param name="space">The coordinate system that should be used to rotate the entity: local or world space.</param>
        public void Rotate(float x, float y, float z, TransformationSpace space)
        {
            // Perform rotation
            Quaternion rotate = Quaternion.CreateFromYawPitchRoll(y, x, z);

            switch (space)
            {
                case TransformationSpace.Local:
                    Quaternion.Multiply(ref _rotation, ref rotate, out _rotation);
                    break;
                case TransformationSpace.World:
                    Quaternion.Multiply(ref rotate, ref _rotation, out _rotation);
                    break;
            }

            // Accumulate for numerical errors
            _rotation.Normalize();

            // Force an update of dependent properties
            _dirtyFlag |= (DirtyFlags.LocalAxis | DirtyFlags.Transform);
            _propertyChangedFlag |= PropertyChangedFlag.Orientation;
        }
Exemplo n.º 2
0
 /// <summary>
 /// Rotates the entity using euler angles in radians.
 /// </summary>
 /// <param name="eulerAngles">The angles to rotate the entity in radians.</param>
 /// <param name="space">The coordinate system that should be used to rotate the entity: local or world space.</param>
 public void Rotate(Vector3 eulerAngles, TransformationSpace space)
 {
     Rotate(eulerAngles.X, eulerAngles.Y, eulerAngles.Z, space);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Moves the entity the specified amount into the specified
 /// direction.
 /// </summary>
 /// <param name="translation">The amount and direction to move to.</param>
 /// <param name="space">The coordinate system that should be used to move the entity: local or world space.</param>
 public void Move(Vector3 translation, TransformationSpace space)
 {
     Move(translation, 1f, space);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Moves the entity the specified amount into the specified
        /// direction.
        /// </summary>
        /// <param name="direction">The direction to move.</param>
        /// <param name="amount">The amount to move the entity into that direction.</param>
        /// <param name="space">The coordinate system that should be used to move the entity: local or world space.</param>
        public void Move(Vector3 direction, float amount, TransformationSpace space)
        {
            if (space == TransformationSpace.Local)
            {
                Vector3.Transform(ref direction, ref _rotation, out direction);
                direction.Normalize();
            }

            _translation += direction * amount;
            _dirtyFlag |= DirtyFlags.Transform;
            _propertyChangedFlag |= PropertyChangedFlag.Translation;
        }
Exemplo n.º 5
0
 public void SetSpace(TransformationSpace space)
 {
     Space = space;
 }