コード例 #1
0
ファイル: ModelWithPlate.cs プロジェクト: michaliskambi/holo
    public void ClickChangeTransformationState(TransformationState newState)
    {
        bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate;
        bool scaleBoxRigActiveOld    = transformationState == TransformationState.Scale;

        if (newState == transformationState)
        {
            // clicking again on the same sidebar button just toggles it off
            newState = TransformationState.None;
        }
        transformationState = newState;

        HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate);
        HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate);
        HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale);

        // if transform the model: disable clipping plane manipulator
        if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled)
        {
            ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active;
        }

        // turn on/off translation manipulation
        handDraggable.enabled           = newState == TransformationState.Translate;
        handDraggable.IsDraggingEnabled = newState == TransformationState.Translate;

        // turn on/off rotation manipulation

        /*
         * We do not switch BoundingBoxRig enabled now.
         * It would serve no purpose (calling Activate or Deactivate is enough),
         * and it woud actually break Activate (because you cannot call Activate in the same
         * frame as setting enabled=true for the 1st frame, this causes problems in BoundingBoxRig
         * as private "objectToBound" is only assigned in BoundingBoxRig.Start).
         *
         * rotationBoxRig.enabled = newState == TransformationState.Rotate;
         */
        // call rotationBoxRig.Activate or Deactivate
        bool rotationBoxRigActiveNew = newState == TransformationState.Rotate;

        if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null)
        {
            if (rotationBoxRigActiveNew)
            {
                rotationBoxRig.GetComponent <BoundingBoxRig>().Activate();
            }
            else
            {
                rotationBoxRig.GetComponent <BoundingBoxRig>().Deactivate();
            }
        }

        /* As with rotationBoxRig, note that you cannot toggle enabled below.
         * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */
        bool scaleBoxRigActiveNew = newState == TransformationState.Scale;

        if (scaleBoxRigActiveOld != scaleBoxRigActiveNew)
        {
            if (scaleBoxRigActiveNew)
            {
                GetComponent <TwoHandManipulatable>().enabled = true;
            }
            else
            {
                GetComponent <TwoHandManipulatable>().enabled = false;
            }
        }
    }
コード例 #2
0
ファイル: ModelWithPlate.cs プロジェクト: tooploox/holo
    public void ChangeTransformationState(TransformationState newState)
    {
        bool rotationBoxRigActiveOld = transformationState == TransformationState.Rotate;
        bool scaleBoxRigActiveOld    = transformationState == TransformationState.Scale;

        if (newState == transformationState)
        {
            // clicking again on the same sidebar button just toggles it off
            newState = TransformationState.None;
        }
        transformationState = newState;

        HoloUtilities.SetButtonState(ButtonTranslate, newState == TransformationState.Translate);
        HoloUtilities.SetButtonState(ButtonRotate, newState == TransformationState.Rotate);
        HoloUtilities.SetButtonState(ButtonScale, newState == TransformationState.Scale);

        // if transform the model: disable clipping plane manipulator
        if (newState != TransformationState.None && ModelClipPlaneCtrl.ClippingPlaneState != ModelClippingPlaneControl.ClipPlaneState.Disabled)
        {
            ModelClipPlaneCtrl.ClippingPlaneState = ModelClippingPlaneControl.ClipPlaneState.Active;
        }

        if (newState == TransformationState.Translate)
        {
            GetComponent <ObjectManipulator>().enabled = true;
        }
        else
        {
            GetComponent <ObjectManipulator>().enabled = false;
        }

        bool rotationBoxRigActiveNew = newState == TransformationState.Rotate;

        if (rotationBoxRigActiveOld != rotationBoxRigActiveNew && rotationBoxRig != null)
        {
            if (rotationBoxRigActiveNew)
            {
                rotationBoxRig.GetComponent <BoundsControl>().Active = true;
                rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.ZAxis;
                rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = true;
            }
        }

        /* As with rotationBoxRig, note that you cannot toggle enabled below.
         * For now, GetComponent<BoundingBoxRig>() is just enabled all the time. */
        bool scaleBoxRigActiveNew = newState == TransformationState.Scale;

        if (scaleBoxRigActiveOld != scaleBoxRigActiveNew)
        {
            if (scaleBoxRigActiveNew)
            {
                rotationBoxRig.GetComponent <BoundsControl>().Active = true;
                rotationBoxRig.GetComponent <RotationAxisConstraint>().ConstraintOnRotation = AxisFlags.XAxis | AxisFlags.YAxis | AxisFlags.ZAxis;
                rotationBoxRig.GetComponent <MinMaxScaleConstraint>().enabled = false;
            }
        }

        if (!rotationBoxRigActiveNew && !scaleBoxRigActiveNew && rotationBoxRig != null)
        {
            rotationBoxRig.GetComponent <BoundsControl>().Active = false;
        }
    }