private void SetHandleByOperation(OperationEnum operation)
        {
            switch (operation)
            {
            case OperationEnum.None:
                ActiveHandle = null;
                break;

            case OperationEnum.Drag:
                foreach (GameObject obj in Interactibles)
                {
                    BoundingBoxHandle h = obj.GetComponent <BoundingBoxHandle>();
                    if (h.HandleType == BoundingBoxHandle.HandleTypeEnum.Drag)
                    {
                        ActiveHandle = h;
                        break;
                    }
                }
                break;

            default:
                foreach (GameObject obj in Interactibles)
                {
                    BoundingBoxHandle h        = obj.GetComponent <BoundingBoxHandle>();
                    OperationEnum     handleOp = GetBoundingBoxOperationFromHandleType(h.HandleType, h.HandleTypeFlattened);
                    if (handleOp == operation)
                    {
                        ActiveHandle = h;
                        break;
                    }
                }
                break;
            }
        }
Beispiel #2
0
        private void SetHandleByOperation(OperationEnum operation)
        {
            switch (operation)
            {
            case OperationEnum.None:
                ActiveHandle = null;
                break;

            case OperationEnum.Drag:
                foreach (GameObject obj in Interactibles)
                {
                    BoundingBoxHandle h = obj.GetComponent <BoundingBoxHandle>();
                    if (h.HandleType == BoundingBoxHandle.HandleTypeEnum.Drag)
                    {
                        ActiveHandle = h;
                        break;
                    }
                }
                break;

            default:
                //TODO link up other operations here
                break;
            }
        }
Beispiel #3
0
        private void RefreshActiveHandles()
        {
            foreach (GameObject handleGo in Interactibles)
            {
                BoundingBoxHandle handle          = handleGo.GetComponent <BoundingBoxHandle>();
                OperationEnum     handleOperation = GetBoundingBoxOperationFromHandleType(handle.HandleType, handle.HandleTypeFlattened);
                bool operationPermitted           = (handleOperation & permittedOperations) != 0;
                bool flattenedTypePermitted       =
                    (FlattenedAxis == FlattenModeEnum.DoNotFlatten && handle.HandleTypeFlattened == BoundingBoxHandle.HandleTypeFlattenedEnum.None) ||
                    (FlattenedAxis != FlattenModeEnum.DoNotFlatten && handle.HandleTypeFlattened != BoundingBoxHandle.HandleTypeFlattenedEnum.None);

                handleGo.SetActive(operationPermitted & flattenedTypePermitted);

                switch (FlattenedAxis)
                {
                case FlattenModeEnum.DoNotFlatten:
                default:
                    break;

                case FlattenModeEnum.FlattenX:
                    handle.RefreshFlattenedPosition(BoundsExtentions.Axis.X);
                    break;

                case FlattenModeEnum.FlattenY:
                    handle.RefreshFlattenedPosition(BoundsExtentions.Axis.Y);
                    break;

                case FlattenModeEnum.FlattenZ:
                    handle.RefreshFlattenedPosition(BoundsExtentions.Axis.Z);
                    break;
                }
            }
        }
Beispiel #4
0
 private void RefreshActiveHandles()
 {
     foreach (GameObject handleGo in Interactibles)
     {
         BoundingBoxHandle handle          = handleGo.GetComponent <BoundingBoxHandle>();
         OperationEnum     handleOperation = GetBoundingBoxOperationFromHandleType(handle.HandleType);
         handleGo.SetActive((handleOperation & permittedOperations) != 0);
     }
 }
        private void TryToSetHandle(GameObject obj, Vector3 position, AFocuser newFocuser)
        {
            if (!acceptInput)
            {
                Debug.Log("Not accepting input");
                return;
            }

            BoundingBoxHandle newHandle = obj.GetComponent <BoundingBoxHandle>();

            if (newHandle != null)
            {
                activeHandle    = newHandle;
                lastNavigatePos = position;
                ManipulatingNow = true;
                focuser         = newFocuser;
                focuser.LockFocus();
            }
        }
        /// <summary>
        /// Stores target under our transform helper and prepares for manipulation
        /// </summary>
        private void StartManipulating()
        {
            // Goes without saying
            if (!acceptInput)
            {
                return;
            }

            if (target == null)
            {
                return;
            }

            if (manipulatingNow)
            {
                return;
            }

            manipulatingNow = true;

            if (!Application.isPlaying)
            {
                return;
            }

            CreateTransforms();

            // Reset the transform helper to 1,1,1 / idenity
            transformHelper.parent     = null;
            transformHelper.localScale = Vector3.one;
            transformHelper.rotation   = Quaternion.identity;
            adjustedScaleTarget        = Vector3.one;
            smoothVelocity             = Vector3.zero;

            // Set up our transforms and gestures based on the operation we're performing
            OperationEnum operation = GetBoundingBoxOperationFromHandleType(ActiveHandle.HandleType, ActiveHandle.HandleTypeFlattened);

            Debug.Log("Operation on start manipulating is " + operation);
            switch (operation)
            {
            case OperationEnum.ScaleUniform:
            case OperationEnum.ScaleX:
            case OperationEnum.ScaleY:
            case OperationEnum.ScaleZ:
                // If we're scaling, move the transform helper to the position OPPOSITE the scale handle
                // That way the object will grow in the right direction
                BoundingBoxHandle oppositeHandle = null;
                BoundingBoxHandle.HandleTypeEnum oppositeHandleType = BoundingBoxHandle.GetOpposingHandle(ActiveHandle.HandleType);
                foreach (GameObject bbhGo in Interactibles)
                {
                    BoundingBoxHandle bbh = bbhGo.GetComponent <BoundingBoxHandle>();
                    if (bbh != null && bbh.HandleType == oppositeHandleType)
                    {
                        oppositeHandle = bbh;
                        break;
                    }
                }
                if (oppositeHandle == null)
                {
                    Debug.LogWarning("Couldn't find opposing handle for type " + ActiveHandle.HandleType);
                    transformHelper.position = transform.position;
                    targetStandIn.position   = target.transform.position;
                }
                else
                {
                    transformHelper.position = oppositeHandle.transform.position;
                    targetStandIn.position   = target.transform.position;
                }
                break;

            case OperationEnum.Drag:
                // If we're rotating or moving, move the transform helper to the center of the gizmo
                transformHelper.position = transform.position;
                targetStandIn.position   = target.transform.position;
                break;

            case OperationEnum.RotateX:
            case OperationEnum.RotateY:
            case OperationEnum.RotateZ:
            default:
                // Rotation
                // If we're rotating or moving, move the transform helper to the center of the gizmo
                transformHelper.position = transform.position;
                targetStandIn.position   = target.transform.position;
                break;
            }

            scaleOnStartManipulation = targetStandIn.localScale;

            if (target != null)
            {
                // Set our transforms to the target immediately
                targetStandIn.position   = target.transform.position;
                targetStandIn.rotation   = target.transform.rotation;
                targetStandIn.localScale = target.transform.lossyScale;
            }
        }