/// <summary> /// We apply a rotation angle equivalent to the projection of the mouse translation to the screen transformation direction. /// </summary> /// <returns></returns> protected override InitialTransformation CalculateTransformation() { var mouseDrag = Input.MousePosition - StartMousePosition; var transformation = new InitialTransformation { Rotation = Quaternion.Identity, Scale = Vector3.One }; // determine the rotation angle var rotationAngle = Vector2.Dot(new Vector2(mouseDrag.X, -mouseDrag.Y), TransformationDirection) * 2.1f * MathUtil.Pi; // half screen size if little bit more Pi // snap the rotation angle if necessary if (UseSnap) { var snapValue = MathUtil.DegreesToRadians(SnapValue); rotationAngle = MathUtil.Snap(rotationAngle, snapValue); } // determine the rotation axis in the Gizmo var rotationAxisGizmo = Vector3.Zero; for (int i = 0; i < 3; i++) { if ((TransformationAxes & ((GizmoTransformationAxes)(1 << i))) != 0) { rotationAxisGizmo[i] = 1; } } rotationAxisGizmo.Normalize(); // set the rotation to apply in the gizmo space transformation.Rotation = Quaternion.RotationAxis(rotationAxisGizmo, rotationAngle); return(transformation); }
/// <summary> /// We apply a rotation angle equivalent to the projection of the mouse translation to the screen transformation direction. /// </summary> /// <returns></returns> protected override InitialTransformation CalculateTransformation() { var transformation = new InitialTransformation { Rotation = Quaternion.Identity, Scale = Vector3.One }; // set the rotation to apply in the gizmo space transformation.Rotation = SceneEditorSettings.UseLinearMovementForRotation.GetValue() ? GetRotationFromLinearMovement() : GetRotationFromCircularMovement(); return transformation; }
protected virtual void OnTransformationStarted(Vector2 mouseDragPixel) { transformationStarted = true; // keep in memory all initial transformation states InitialTransformations.Clear(); foreach (var entity in ModifiedEntities) { // Ensure world matrix is computed entity.Transform.UpdateWorldMatrix(); InitialTransformations[entity] = new InitialTransformation { Scale = entity.Transform.Scale, Translation = entity.Transform.Position, Rotation = entity.Transform.Rotation, InverseParentMatrix = entity.Transform.Parent != null?Matrix.Invert(entity.Transform.Parent.WorldMatrix) : Matrix.Identity }; } }