Exemple #1
0
 /// <returns>An instance with the default values</returns>
 public static MeshInputState GetInstance()
 {
     return(new MeshInputState
     {
         VisibleSelectionMask = uint.MaxValue,
         HarmonicShowDisplacement = true,
         Shared = InputManager.State,
         SharedPrev = InputManager.StatePrev,
         TransformDeltaJoint = TransformDelta.Identity()
     });
 }
Exemple #2
0
        /// <summary>
        /// Consumes the state for the transformations
        /// </summary>
        private void ConsumeTransform()
        {
            // Consume transform if we are in the Select tool
            if (InputManager.State.ActiveTool == ToolType.Select)
            {
                TransformDeltaJoint = TransformDelta.Identity();
                TransformDeltaL     = TransformDelta.Identity();
                TransformDeltaR     = TransformDelta.Identity();
            }

            DoTransformLPrev = DoTransformL;
            DoTransformL     = false;
            DoTransformRPrev = DoTransformR;
            DoTransformR     = false;
        }
Exemple #3
0
        /// <summary>
        /// Gets and consumes the transformation, applying it to the LibiglMesh <see cref="Transform"/>.
        /// </summary>
        private void ApplyTransformToMesh()
        {
            if (!_doTransformL && !_doTransformR)
            {
                return;
            }

            var transformDelta = TransformDelta.Identity();

            if (transformDelta.Mode == PivotMode.Selection)
            {
                Debug.LogWarning(
                    "Invalid pivot mode PivotMode.Selection for transforming the mesh, using PivotMode.Hand.");
                transformDelta.Mode = PivotMode.Hand;
            }

            // Get & Consume the transformation
            GetTransformDelta(true, ref transformDelta, Space.World, InputManager.State.TransformWithRotate,
                              _isTwoHandedTransformation, _firstTransformHand);

            // Apply it to the mesh
            var uTransform = Mesh.transform;

            uTransform.Translate(transformDelta.Translate, Space.World);
            uTransform.localScale *= transformDelta.Scale;

            var pivotLocal = uTransform.localScale.CwiseMul(uTransform.InverseTransformPoint(transformDelta.Pivot));

            if (transformDelta.Mode != PivotMode.Mesh &&
                InputManager.State.ToolTransformMode != ToolTransformMode.TransformingLr)
            {
                uTransform.position += uTransform.rotation * pivotLocal;
            }

            uTransform.rotation = transformDelta.Rotate * uTransform.rotation;

            if (transformDelta.Mode != PivotMode.Mesh &&
                InputManager.State.ToolTransformMode != ToolTransformMode.TransformingLr)
            {
                uTransform.position -= uTransform.rotation * pivotLocal;
            }

            // This should draw a line from the mesh center to the pivot
            // Debug.DrawRay(transformDelta.Pivot, uTransform.rotation * -pivotLocal, Color.magenta);
        }