public void StartTransform() { m_isTransforming = true; m_hasTransformed = false; m_hasSetMouseOffset = false; m_wrapOffset = Vector2.Zero; m_totalTranslation = Vector3.Zero; m_totalRotation = Vector3.Zero; m_currentRotation = Quaterniond.Identity; m_totalScale = Vector3.One; // Set the rotation direction. if (m_mode == FTransformMode.Rotation) { // We need to determine which side of the gizmo they are on, so that goes the expected direction when // we pull up/down in screenspace. Vector3 rotAxis; if (m_selectedAxes == FSelectedAxes.X) { rotAxis = Vector3.UnitX; } if (m_selectedAxes == FSelectedAxes.Y) { rotAxis = Vector3.UnitY; } else { rotAxis = Vector3.UnitZ; } Vector3 dirFromGizmoToHitPoint = (m_hitPoint - m_position).Normalized(); m_moveDir = Vector3.Cross(rotAxis, dirFromGizmoToHitPoint); } // Set the scale direction. else if (m_mode == FTransformMode.Scale) { // If we're transforming only on one axis, then the directon is in the selected axis. if (GetNumSelectedAxes() == 1) { if (ContainsAxis(m_selectedAxes, FSelectedAxes.X)) { m_moveDir = Vector3.Transform(Vector3.UnitX, m_rotation.ToSinglePrecision()); } if (ContainsAxis(m_selectedAxes, FSelectedAxes.Y)) { m_moveDir = Vector3.Transform(Vector3.UnitY, m_rotation.ToSinglePrecision()); } else { m_moveDir = Vector3.Transform(Vector3.UnitZ, m_rotation.ToSinglePrecision()); } } // Two axes however, means interpolate between both. if (GetNumSelectedAxes() == 2) { Vector3 axisA = ContainsAxis(m_selectedAxes, FSelectedAxes.X) ? Vector3.Transform(Vector3.UnitX, m_rotation.ToSinglePrecision()) : Vector3.Transform(Vector3.UnitY, m_rotation.ToSinglePrecision()); Vector3 axisB = ContainsAxis(m_selectedAxes, FSelectedAxes.Z) ? Vector3.Transform(Vector3.UnitZ, m_rotation.ToSinglePrecision()) : Vector3.Transform(Vector3.UnitY, m_rotation.ToSinglePrecision()); m_moveDir = (axisA + axisB) / 2f; } } }