コード例 #1
0
 private void GizmoRotateEvent(Actor transformable, TransformationEventArgs e)
 {
     gizmo.RotationHelper(transformable, e);
 }
コード例 #2
0
        private void GizmoScaleEvent(Actor transformable, TransformationEventArgs e)
        {
            Vector3 delta = (Vector3)e.Value;

            if (gizmo.ActiveMode == GizmoMode.UniformScale)
                transformable.Scale *= 1 + ((delta.X + delta.Y + delta.Z) / 3);
            else
                transformable.Scale += delta;

            transformable.Scale = Vector3.Clamp(transformable.Scale, Vector3.Zero, transformable.Scale);
        }
コード例 #3
0
        /// <summary>
        /// Helper function to apply rotation to objects using the built-in method.
        /// </summary>
        public void RotationHelper(Actor entity, TransformationEventArgs e)
        {
            Vector3 pos = _position;
              if (ActivePivot == PivotType.ObjectCenter)
            pos = entity.Position;

              Matrix localRot = Matrix.Identity;
              localRot.Forward = entity.Forward;
              localRot.Up = entity.Up;
              localRot.Right = Vector3.Cross(entity.Forward, entity.Up);
              localRot.Right.Normalize();
              localRot.Translation = entity.Position - pos;

              Matrix newRot = localRot * (Matrix)e.Value;

              entity.Forward = newRot.Forward;
              entity.Up = newRot.Up;
              entity.Position = newRot.Translation + pos;
        }