예제 #1
0
    public bool ApplyChanges(GameObject pointOfCollision, bool alreadyMoving, Selection controller)
    {
        if (!alreadyMoving)
        {
            //connectedModelingObject.HideBoundingBox (false);
        }

        switch (typeOfHandle)
        {
        case handleType.ScaleFace:
            ScaleFace(pointOfCollision);
            break;

        case handleType.PositionCenter:
            MoveCenterPosition(pointOfCollision);
            break;

        case handleType.Height:
            ChangeHeight(pointOfCollision);
            break;

        case handleType.Rotation:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                connectedModelingObject.CalculateBoundingBox();
                connectedModelingObject.CalculateBoundingBoxWorld();
                handles.HideScalingHandlesExcept(null);
                TouchElements.Instance.Hide();
                newRotation = true;
            }

            Rotate(pointOfCollision, controller, true);

            connectedModelingObject.PositionHandles(true);
            connectedModelingObject.RotateHandles();
            handles.HideRotationHandlesExcept(null);
            handles.HideScalingHandlesExcept(this);

            break;

        case handleType.ScaleX:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(1f, 0f, 0f));
            break;

        case handleType.ScaleY:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(0f, 1f, 0f));
            break;

        case handleType.ScaleZ:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(0f, 0f, 1f));
            break;

        case handleType.ScaleMinusX:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(1f, 0f, 0f));
            break;

        case handleType.ScaleMinusY:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(0f, 1f, 0f));
            break;

        case handleType.ScaleMinusZ:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleNonUniform(pointOfCollision, new Vector3(0f, 0f, 1f));
            break;

        case handleType.MoveY:
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newMovement = true;
            }
            MoveYPosition(pointOfCollision);
            handles.HideRotationHandlesExcept(null);
            handles.HideScalingHandlesExcept(this);
            break;

        case handleType.UniformScale:
            Debug.Log("already moving " + alreadyMoving);
            if (!alreadyMoving)
            {
                handles.HideRotationHandlesExcept(null);
                handles.HideScalingHandlesExcept(this);
                newScaling = true;
            }
            ScaleUniform(pointOfCollision);
            handles.HideRotationHandlesExcept(null);
            handles.HideScalingHandlesExcept(this);
            break;

        case handleType.RotationHandleToggle:
            //handles.ToggleOnOffRotationHandles ();
            break;
        }

        connectedModelingObject.RecalculateSideCenters();
        connectedModelingObject.RecalculateNormals();

        //handles.HideRotationHandlesExcept (null);
        //handles.HideScalingHandlesExcept (this);


        //connectedModelingObject.ShowBoundingBox ();
        //connectedModelingObject.ShowBoundingBox ();

        return(true);
    }