Example #1
0
        public void drawCenterMenu(layouts layout)
        {
            centerMenu.reset();
            centerMenu.switchLayout(layout);

            // invoke gravity event
            if (mainController.getCurrentSelection() && mainController.getCurrentSelection().GetComponent <SceneObject>())
            {
                mainController.OnObjectGravityChange.Invoke(!mainController.getCurrentSelection().GetComponent <SceneObject>().lockKinematic);
            }

            centerMenu.show();
        }
Example #2
0
        /*
         *  //!
         *  //! Display the object modification menu with an intial animation.
         *  //! @param      isKinematic     is the objects kinematic state true or false (needed to visualize the kinematic button acordingly)
         *  //! @param      hasAnimation    is the currently selected object animated
         *  //!
         *  public void drawObjectModificationMenu(bool hasAnimation, bool isKinematic)
         *  {
         *      activeMenu = sceneObjectCenterMenu;
         *      activeMenu.reset();
         *      if (!hasAnimation) activeMenu.deactivateButton(8);
         *      if (isKinematic) activeMenu.swapSprites(4);
         *      if (AnimationData.Data.getAnimationClips(mainController.getCurrentSelection().gameObject) != null) activeMenu.deactivateButton(4);
         *      activeMenu.animatedDraw();
         *  }
         *
         *
         *  //!
         *  //! Display the keyframe menu with an intial animation.
         *  //!
         *  public void drawKeyframeMenu()
         *  {
         *      activeMenu = keyframeCenterMenu;
         *      activeMenu.reset();
         *      keyframeCenterMenu.deactivateButton(3);
         *      keyframeCenterMenu.deactivateButton(4);
         *      activeMenu.animatedDraw();
         *  }
         *
         *  //!
         *  //! Display the directional light modification menu with an intial animation.
         *  //!
         *  public void drawDirectionLightModificationMenu()
         *  {
         *      activeMenu = directionalLightCenterMenu;
         *      activeMenu.animatedDraw();
         *  }
         *
         *  //!
         *  //! Display the point light modification menu with an intial animation.
         *  //!
         *  public void drawPointLightModificationMenu()
         *  {
         *      activeMenu = pointLightCenterMenu;
         *      activeMenu.animatedDraw();
         *  }
         *
         *  //!
         *  //! Display the spot light modification menu with an intial animation.
         *  //!
         *  public void drawSpotLightModificationMenu()
         *  {
         *      activeMenu = spotLightCenterMenu;
         *      activeMenu.animatedDraw();
         *  }
         */


        //!
        //! Display the light parameters modification menu.
        //!
        public void drawLightSettingsWidget()
        {
            lightSettingsWidget.gameObject.SetActive(true);
            if (lightSettingsWidget.GetSliderType() == LightSettingsWidget.SliderType.COLOR)
            {
                hideParameterMenu();
                hideRangeSlider();
            }
            lightSettingsWidget.show(mainController.getCurrentSelection().GetComponent <SceneObjectLight>());
        }
Example #3
0
        //!
        //! Wrapper for unity API function GetButtonDown() that does not behave like described on iOS.
        //! Using a dictionary to keep track of the status of controller buttons.
        //! A bool flag gets kept for every button name this function is called for.
        //! The function can be probably removed when the iOS unity API issue was fixed.
        //! @param      buttonName       name of a button like its defined in the Input Manager.
        //! @return     true only for the first time the function gets called for a certain button after the user stated pressing it.
        //!

        /*private bool buttonPressed(string buttonName)
         * {
         *  if (Input.GetButtonDown(buttonName))
         *  {
         *      float buttonPressedTimestamp = 0f;
         *      if (buttonPressedState.TryGetValue(buttonName, out buttonPressedTimestamp))
         *      {
         *          if (buttonPressedTimestamp > 0f)
         *              return false;
         *          else
         *          {
         *              buttonPressedState[buttonName] = Time.time;
         *              return true;
         *          }
         *      }
         *      else
         *      {
         *          buttonPressedState.Add(buttonName, Time.time);
         *          return true;
         *      }
         *  }
         *  else if (Input.GetButtonUp(buttonName) && buttonPressedState.ContainsKey(buttonName))
         *          buttonPressedState[buttonName] = 0f;
         *  return false;
         * }*/

        //!
        //! Function to mesure for how long a button has already been pressed.
        //! In case the given button is not pressed at all ...
        //! @param      buttonName       name of a button like its defined in the Input Manager.
        //! @return     the time in seconds for how long the button has been already pressed or 0 if the button isn't pressed
        //!

        /*private float buttonPressedTime(string buttonName) {
         *  float buttonPressedTimestamp = 0f;
         *  if (!buttonPressedState.TryGetValue(buttonName, out buttonPressedTimestamp)) {
         *      buttonPressed(buttonName);
         *      return buttonPressedTimestamp; // this should be an exception
         *  }
         *  else if (buttonPressedTimestamp > 0f)
         *      return Time.time - buttonPressedTimestamp;
         *  else
         *      return buttonPressedTimestamp;
         * }*/

        //!
        //! all possible inputs
        //! called every frame by MoveCamera (in its update() function)
        //!
        private void getButtonUpdates()
        {
            if (gamepad.leftShoulder.isPressed)
            //if (Input.GetButton("L1"))
            {
                getcurrentCrosshairObject();
                // hide center menu
                mainController.deselect();
                // switch to camera mode
                moveCameraActive   = true;
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                // show crosshair
                crossHair.SetActive(true);

                // initial state, previousCrosshairObject == some object, currentCrosshairObject == null
                if (previousCrosshairObject != null && currentCrosshairObject == null)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // initial state, previousCrosshairObject == some object (previous), currentCrosshairObject == some object new
                else if (currentCrosshairObject != null && previousCrosshairObject != null && currentCrosshairObject != previousCrosshairObject)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // highlight current selection
                else if (currentCrosshairObject)
                {
                    outlineEffect.lineColor0 = new Color(1f, 0.9f, 0.7f);
                    currentCrosshairObject.GetComponent <SceneObject>().callShowHighlighted(currentCrosshairObject);
                }
            }
            else if (gamepad.leftShoulder.wasReleasedThisFrame)
            //else if (Input.GetButtonUp("L1"))
            {
                if (currentCrosshairObject != null)
                {
                    outlineEffect.lineColor0 = new Color(1.0f, 0.8f, 0.3f);
                    mainController.handleSelection(currentCrosshairObject.GetComponent <Transform>());
                }
                crossHair.SetActive(false);
            }
            // enter translation mode
            else if (gamepad.buttonNorth.wasPressedThisFrame)
            //else if (buttonPressed("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter rotation mode
            else if (gamepad.buttonEast.wasPressedThisFrame)
            //else if (buttonPressed("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter scale mode
            else if (gamepad.buttonSouth.wasPressedThisFrame)
            //else if (buttonPressed("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>() is SceneObjectLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
            }
            // toggle configuration window
            else if (gamepad.startButton.wasPressedThisFrame)
            //else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (gamepad.rightShoulder.wasPressedThisFrame && !mainController.arMode)
            {
                //else if (buttonPressed("R1") && !mainController.arMode)
                mainController.repositionCamera();
            }

            // disable tracking
            else if (gamepad.rightTrigger.wasPressedThisFrame && !mainController.arMode)
            //else if (buttonPressed("R2") && !mainController.arMode)
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // deselect or reset current selection
            //TODO: reimplement hold
            if (gamepad.buttonWest.wasPressedThisFrame /*&& buttonPressedTime("Fire2") > 0f && buttonPressedTime("Fire2") < deselectHoldDuration*/)
            //if (!Input.GetButton("Fire2") && buttonPressedTime("Fire2") > 0f && buttonPressedTime("Fire2") < deselectHoldDuration)
            {
                mainController.handleSelection();
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                moveCameraActive   = true;
            }

            /*else if (gamepad.buttonWest.isPressed && buttonPressedTime("Fire2") > deselectHoldDuration) {
             * //else if (Input.GetButton("Fire2") && buttonPressedTime("Fire2") > deselectHoldDuration){
             *  if (mainController.getCurrentSelection())
             *  {
             *      if (mainController.getCurrentSelection().GetComponent<SceneObject>().GetType() == typeof(SceneObjectLight))
             *          mainController.getCurrentSelection().GetComponent<SceneObjectLight>().resetAll();
             *      else
             *          mainController.getCurrentSelection().GetComponent<SceneObject>().resetAll();
             *  }
             * }*/
            if (gamepad.bButton.wasPressedThisFrame)
            {
            }

            // cycle through edit modes
            else if (gamepad.leftTrigger.wasPressedThisFrame)
            //else if (buttonPressed("L2"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
            else if (gamepad.dpad.up.wasPressedThisFrame ||
                     gamepad.dpad.down.wasPressedThisFrame ||
                     gamepad.dpad.left.wasPressedThisFrame ||
                     gamepad.dpad.right.wasPressedThisFrame)
            //else if ( (buttonPressed("DPAD_H")) ||
            //		  (buttonPressed("DPAD_H_neg")) ||
            //		  (buttonPressed("DPAD_V")) ||
            //		  (buttonPressed("DPAD_V_neg")) )
            {
                if (gamepad.dpad.right.wasPressedThisFrame || gamepad.dpad.up.wasPressedThisFrame)
                {
                    //if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
                    DPADdirection = 1;
                }
                else
                {
                    DPADdirection = -1;
                }

                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (gamepad.dpad.y.ReadValue() != 0)
                {
                    //if (Input.GetAxis("DPAD_V") != 0)
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (gamepad.dpad.up.wasPressedThisFrame || gamepad.dpad.down.wasPressedThisFrame)
                {
                    //if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg") )
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                {
                    mainController.buttonScaleClicked(true);
                }
            }
        }
Example #4
0
        //!
        //! activates animation editing for the currently selected object
        //!
        public void activate()
        {
            // Debug.Log("mainController.getCurrentSelection()", mainController.getCurrentSelection().gameObject);

            isActive = true;

            mainController.ActiveMode = MainController.Mode.animationEditing;
            animationTarget           = mainController.getCurrentSelection().gameObject;

            animationTarget.GetComponent <SceneObject>().setKinematic(true, false);
            animationTarget.layer = 13;     //noPhysics layer

            //no animation available yet for this object -> create animation
            if (doCreateClip && animData.getAnimationClips(animationTarget) == null)
            {
                if (!animationTarget.GetComponent <AnimationSerializer>())
                {
                    animationTarget.AddComponent <AnimationSerializer>();
                }


                //create initial animation translation
                AnimationClip  clip        = new AnimationClip();
                AnimationCurve transXcurve = new AnimationCurve();
                AnimationCurve transYcurve = new AnimationCurve();
                AnimationCurve transZcurve = new AnimationCurve();

                // create keys at current time
                transXcurve.AddKey(new Keyframe(0, animationTarget.transform.position.x, -1, 1));
                transYcurve.AddKey(new Keyframe(0, animationTarget.transform.position.y, -1, 1));
                transZcurve.AddKey(new Keyframe(0, animationTarget.transform.position.z, -1, 1));


                /*
                 * transXcurve.AddKey(new Keyframe(1, animationTarget.transform.position.x + 1, 1, -1));
                 * transYcurve.AddKey(new Keyframe(1, animationTarget.transform.position.y + 1, 1, -1));
                 * transZcurve.AddKey(new Keyframe(1, animationTarget.transform.position.z + 1, 1, -1));
                 */

                // timeline.GetComponent<TimelineScript>().updateFrames(transXcurve,clip);
                // timeLine.updateFrames(transXcurve);

                //add animation to runtime data representation
                animData.addAnimationClip(animationTarget, clip);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalPosition.x", transXcurve);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalPosition.y", transYcurve);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalPosition.z", transZcurve);


                //create initial animation Rotation curve
                AnimationCurve rotXcurve = new AnimationCurve();
                AnimationCurve rotYcurve = new AnimationCurve();
                AnimationCurve rotZcurve = new AnimationCurve();
                AnimationCurve rotWcurve = new AnimationCurve();

                // create keys at current time
                rotXcurve.AddKey(new Keyframe(0, animationTarget.transform.rotation.x, -1, 1));
                rotYcurve.AddKey(new Keyframe(0, animationTarget.transform.rotation.y, -1, 1));
                rotZcurve.AddKey(new Keyframe(0, animationTarget.transform.rotation.z, -1, 1));
                rotWcurve.AddKey(new Keyframe(0, animationTarget.transform.rotation.w, -1, 1));

                /*
                 * rotXcurve.AddKey( new Keyframe( 1, animationTarget.transform.rotation.x, -1, 1 ) );
                 * rotYcurve.AddKey( new Keyframe( 1, animationTarget.transform.rotation.y, -1, 1 ) );
                 * rotZcurve.AddKey( new Keyframe( 1, animationTarget.transform.rotation.z, -1, 1 ) );
                 * rotWcurve.AddKey( new Keyframe( 1, animationTarget.transform.rotation.w, -1, 1 ) );
                 */

                // timeline.GetComponent<TimelineScript>().updateFrames( transXcurve, clip );
                // timeLine.updateFrames( transXcurve );


                //add animation to runtime data representation
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalRotation.x", rotXcurve);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalRotation.y", rotYcurve);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalRotation.z", rotZcurve);
                animData.addAnimationCurve(clip, typeof(Transform), "m_LocalRotation.w", rotWcurve);

                animatedObjects.Add(animationTarget.GetComponent <SceneObject>());
            }

            animationTarget.GetComponent <SceneObject>().updateAnimationCurves();


            lineRenderer.SetVertexCount(0);
            lineRenderer.enabled = true;

            updateLine();

            updateTimelineKeys();
        }
Example #5
0
        //!
        //! single touch start (called by Mouse or Touch Input)
        //! @param      pos     screen position of pointer
        //!
        public void singlePointerStarted(Vector3 pos)
        {
            pointerDown = true;

            if (mainController.helpActive)
            {
                helpMenu.initPos(pos);
                return;
            }
            if (!pointerOnGUI())
            {
                //pointToMove active
                if (mainController.ActiveMode == MainController.Mode.pointToMoveMode)
                {
                    Transform selection = mainController.getCurrentSelection();
                    targetPlane = new Plane(Vector3.up, scene.transform.position);
                    mainController.showPointToMoveIdentifier(planeRaycast(pos, targetPlane));
                    return;
                }

                //standard modification modes (modifier active)
                if (mainController.ActiveMode == MainController.Mode.translationMode ||
                    mainController.ActiveMode == MainController.Mode.rotationMode ||
                    mainController.ActiveMode == MainController.Mode.scaleMode ||
                    mainController.ActiveMode == MainController.Mode.animationEditing)
                {
                    //editing mode is active
                    GameObject hitObject = cameraRaycast(pos, 256);                     //raycast only RenderInFront Layer (layer 9 -> 256)
                    if (hitObject)
                    {
                        //Modifier object was hit
                        if (hitObject.tag == "Modifier")
                        {
                            //modifier was hit
                            mainController.handleModifier(hitObject.transform);
                            hitPositionBuffer = planeRaycast(pos, mainController.helperPlane);
                            pointerOnModifier = true;
                        }
                        hitObject = null;
                    }
                    else
                    {
                        //no modifier was hit
                        hitObject = cameraRaycast(pos, defaultLayermask);
                        if (hitObject)
                        {
                            //other object was hit
                            mainController.handleSelection(hitObject.transform);
                            pause     = true;
                            hitObject = null;
                        }
                        else
                        {
                            mainController.handleSelection();
                        }
                    }
                }
            }
            else
            {
                pause = true;
            }
        }
        public void activate(bool updateTimeLine = true)
        {
            if (mainController.getCurrentSelection() == null)
            {
                return;
            }

            animationTarget = mainController.getCurrentSelection().gameObject;

            isActive = true;

            animationTarget.GetComponent <SceneObject>().setKinematic(true, false);

            animationTarget.layer = 13; //noPhysics layer

            switch (mainController.ActiveMode)
            {
            case MainController.Mode.translationMode:
            case MainController.Mode.pointToMoveMode:
            case MainController.Mode.objectLinkCamera:
                animationProperties = new string[] { "m_LocalPosition.x", "m_LocalPosition.y", "m_LocalPosition.z" };
                animationFields     = new PropertyInfo[] { animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateX"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateY"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateZ") };
                animationInstance = animationTarget.GetComponent <SceneObject>();
                break;

            case MainController.Mode.rotationMode:
                animationProperties = new string[] { "m_LocalRotation.x", "m_LocalRotation.y", "m_LocalRotation.z", "m_LocalRotation.w" };
                animationFields     = new PropertyInfo[] { animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatX"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatY"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatZ"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatW") };
                animationInstance = animationTarget.GetComponent <SceneObject>();
                break;

            case MainController.Mode.scaleMode:
                animationProperties = new string[] { "m_LocalScale.x", "m_LocalScale.y", "m_LocalScale.z" };
                animationFields     = new PropertyInfo[] { animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleX"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleY"),
                                                           animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleZ") };
                animationInstance = animationTarget.GetComponent <SceneObject>();
                break;
            }

            print("Activate Animation in Mode: " + mainController.ActiveMode);


            if (updateTimeLine)
            {
                setStartEndTimeline();
            }


            animationTarget.GetComponent <SceneObject>().updateAnimationCurves();

            lineRenderer.SetVertexCount(0);
            lineRenderer.enabled = true;

            updateLine();

            updateTimelineKeys();
        }
Example #7
0
        public void activate(bool updateTimeLine = true)
        {
            if (mainController.getCurrentSelection() == null)
            {
                return;
            }

            animationTarget = mainController.getCurrentSelection().gameObject;

            isActive = true;

            animationTarget.GetComponent <SceneObject>().setKinematic(true, false);

            animationTarget.layer = 13; //noPhysics layer

            animationProperties = new string[] { "m_LocalPosition.x", "m_LocalPosition.y", "m_LocalPosition.z",
                                                 "m_LocalRotation.x", "m_LocalRotation.y", "m_LocalRotation.z", "m_LocalRotation.w",
                                                 "m_LocalScale.x", "m_LocalScale.y", "m_LocalScale.z" };
            animationFields = new PropertyInfo[] { animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateX"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateY"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("TranslateZ"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatX"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatY"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatZ"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("RotateQuatW"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleX"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleY"),
                                                   animationTarget.GetComponent <SceneObject>().GetType().GetProperty("ScaleZ") };
            animationInstance = animationTarget.GetComponent <SceneObject>();

            //
            // this was created on request to keep keys individually from current selection mode but turned out to be not practical,
            // keep for potential future keying options
            //

            /*
             * switch (mainController.ActiveMode)
             * {
             *  case MainController.Mode.translationMode: case MainController.Mode.pointToMoveMode: case MainController.Mode.objectLinkCamera:
             *      animationProperties = new string[] { "m_LocalPosition.x", "m_LocalPosition.y", "m_LocalPosition.z" };
             *      animationFields = new PropertyInfo[] { animationTarget.GetComponent<SceneObject>().GetType().GetProperty("TranslateX")  ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("TranslateY") ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("TranslateZ") };
             *      animationInstance = animationTarget.GetComponent<SceneObject>();
             *      break;
             *  case MainController.Mode.rotationMode:
             *      animationProperties = new string[] { "m_LocalRotation.x", "m_LocalRotation.y", "m_LocalRotation.z", "m_LocalRotation.w" };
             *      animationFields = new PropertyInfo[] { animationTarget.GetComponent<SceneObject>().GetType().GetProperty("RotateQuatX")  ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("RotateQuatY") ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("RotateQuatZ") ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("RotateQuatW") };
             *      animationInstance = animationTarget.GetComponent<SceneObject>();
             *      break;
             *  case MainController.Mode.scaleMode:
             *      animationProperties = new string[] { "m_LocalScale.x", "m_LocalScale.y", "m_LocalScale.z" };
             *      animationFields = new PropertyInfo[] { animationTarget.GetComponent<SceneObject>().GetType().GetProperty("ScaleX")  ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("ScaleY") ,
             *                                           animationTarget.GetComponent<SceneObject>().GetType().GetProperty("ScaleZ") };
             *      animationInstance = animationTarget.GetComponent<SceneObject>();
             *      break;
             * }
             * print("Activate Animation in Mode: " + mainController.ActiveMode);
             */


            if (updateTimeLine)
            {
                setStartEndTimeline();
            }


            animationTarget.GetComponent <SceneObject>().updateAnimationCurves();

            lineRenderer.positionCount = 0;
            lineRenderer.enabled       = true;

            updateAppearance = true;

            updateLine();

            updateTimelineKeys();
        }
Example #8
0
        //!
        //! all possible inputs
        //! called every frame by MoveCamera (in its update() function)
        //!
        public void getButtonUpdates()
        {
            if (Input.GetButton("L1"))
            {
                getcurrentCrosshairObject();
                // hide center menu
                mainController.deselect();
                // switch to camera mode
                moveCameraActive   = true;
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                // show crosshair
                crossHair.SetActive(true);

                // initial state, previousCrosshairObject == some object, currentCrosshairObject == null
                if (previousCrosshairObject != null && currentCrosshairObject == null)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // initial state, previousCrosshairObject == some object (previous), currentCrosshairObject == some object new
                else if (currentCrosshairObject != null && previousCrosshairObject != null && currentCrosshairObject != previousCrosshairObject)
                {
                    previousCrosshairObject.GetComponent <SceneObject>().callShowNormal(previousCrosshairObject);
                }

                // highlight current selection
                else if (currentCrosshairObject)
                {
                    outlineEffect.lineColor0 = new Color(1f, 0.9f, 0.7f);
                    currentCrosshairObject.GetComponent <SceneObject>().callShowHighlighted(currentCrosshairObject);
                }
            }
            else if (Input.GetButtonUp("L1"))
            {
                if (currentCrosshairObject != null)
                {
                    outlineEffect.lineColor0 = new Color(1.0f, 0.8f, 0.3f);
                    mainController.handleSelection(currentCrosshairObject.GetComponent <Transform>());
                }
                crossHair.SetActive(false);
            }
            // enter translation mode
            else if (buttonPressed("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter rotation mode
            else if (buttonPressed("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
            }
            // enter scale mode
            else if (buttonPressed("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                    {
                        if (mainController.arMode)
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT_AR);
                        }
                        else
                        {
                            mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        }
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>() is SceneObjectLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
            }
            // toggle configuration window
            else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (buttonPressed("R1") && !mainController.arMode)
            {
                mainController.repositionCamera();
            }

            // disable tracking
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("R2") < 0 && !hasPressedR2 && !mainController.arMode)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (buttonPressed("R2") && !mainController.arMode)
#endif
            {
                hasPressedR2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // deselect or reset current selection
            if (!Input.GetButton("Fire2") && buttonPressedTime("Fire2") > 0f &&
                buttonPressedTime("Fire2") < deselectHoldDuration)
            {
                mainController.handleSelection();
                moveObjectActive   = false;
                rotateObjectActive = false;
                scaleObjectActive  = false;
                moveCameraActive   = true;
            }
            else if (Input.GetButton("Fire2") && buttonPressedTime("Fire2") > deselectHoldDuration)
            {
                if (mainController.getCurrentSelection())
                {
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().GetType() == typeof(SceneObjectLight))
                    {
                        mainController.getCurrentSelection().GetComponent <SceneObjectLight>().resetAll();
                    }
                    else
                    {
                        mainController.getCurrentSelection().GetComponent <SceneObject>().resetAll();
                    }
                }
            }
            if (buttonPressed("Fire2"))
            {
            }

            // cycle through edit modes
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_LINUX
            else if (Input.GetAxis("L2") > 0 && !hasPressedL2)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (buttonPressed("L2"))
#endif
            {
                hasPressedL2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("DPAD_H") != 0 && !hasPressedDirectionalPad ||
                     Input.GetAxis("DPAD_V") != 0 && !hasPressedDirectionalPad)
            {
                if (Input.GetAxis("DPAD_H") == 1 || Input.GetAxis("DPAD_V") == 1)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if ((buttonPressed("DPAD_H")) ||
                     (buttonPressed("DPAD_H_neg")) ||
                     (buttonPressed("DPAD_V")) ||
                     (buttonPressed("DPAD_V_neg")))
            {
                if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
#endif
                { DPADdirection = 1; }
                else
                {
                    DPADdirection = -1;
                }

                hasPressedDirectionalPad = true;
                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_V") != 0)
                {
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg"))
                {
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObjectLight>())
                {
                    mainController.buttonScaleClicked(true);
                }
            }
            // Dpad and R2 reset
#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetAxis("DPAD_H") == 0 && (Input.GetAxis("DPAD_V") == 0))
            {
                hasPressedDirectionalPad = false;
            }
            if (Input.GetAxis("R2") == 0)
            {
                hasPressedR2 = false;
            }
            if (Input.GetAxis("L2") == 0)
            {
                hasPressedL2 = false;
            }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            if (!buttonPressed("DPAD_H") && !buttonPressed("DPAD_V"))
            {
                hasPressedDirectionalPad = false;
            }
#endif
        }
Example #9
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            mainController.UpdatePropertiesSecondaryCameras();

            //get sensor data from native Plugin on Windows
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
            Marshal.Copy(getOrientationSensorData(), orientationSensorData, 0, 4);
#endif

            if (move)
            {
                //cache rotation of attached gameObjects
                if (this.transform.childCount > 1)
                {
                    childrotationBuffer = this.transform.GetChild(1).rotation;
                }

#if !UNITY_EDITOR
#if (UNITY_ANDROID || UNITY_IOS)
#if USE_TANGO || USE_ARKIT
                newRotation = trackingTransform.rotation;
                newPosition = trackingTransform.position;
#else
                newRotation = gyroAdapter.Rotation;
#endif
#elif UNITY_STANDALONE_WIN
                newRotation = Quaternion.Euler(90, 90, 0) * convertRotation(new Quaternion(orientationSensorData[0], orientationSensorData[1], orientationSensorData[2], orientationSensorData[3]));
#endif
#endif
                if (doApplyRotation)
                {
                    if (!firstApplyTransform)
                    {
                        if (!mainController.arMode)
                        {
                            calibrate(rotationFirst);
                            positionOffset = positionFirst - newPosition;
                        }
                        firstApplyTransform = true;
                    }
                    //grab sensor reading on current platform
#if !UNITY_EDITOR
#if (UNITY_ANDROID) && !(USE_TANGO || UNITY_IOS)
                    transform.localRotation = rotationOffset * Quaternion.Euler(0, 0, 55) * newRotation;
#elif UNITY_STANDALONE_WIN
                    transform.rotation = rotationOffset * newRotation;
#else
                    if (TangoBuild4LenovoPhab2)
                    {
                        transform.rotation = rotationOffset * new Quaternion(-newRotation.y, newRotation.x, newRotation.z, newRotation.w);
                    }
                    else
                    {
                        transform.rotation = rotationOffset * newRotation;
                    }
                    // HACK: to block roll
                    if (!mainController.arMode && mainController.ActiveMode != MainController.Mode.lookThroughLightMode)
                    {
                        transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, 0);
                    }
                    //transform.rotation *= newRotation * Quaternion.Inverse(oldRotation);
#if USE_TANGO || USE_ARKIT
                    cameraParent.position += rotationOffset * (newPosition - oldPosition);
#endif
#endif
#endif
                }
                else if (firstApplyTransform)
                {
                    rotationFirst       = rotationOffset * newRotation;
                    positionFirst       = positionOffset + newPosition;
                    firstApplyTransform = false;
                }

#if USE_TANGO || USE_ARKIT
                oldPosition = trackingTransform.position;
                oldRotation = trackingTransform.rotation;
#endif

                if (joystickAdapter)
                {
                    Vector3 val = joystickAdapter.getTranslation();
                    if (val.magnitude > 0.01)
                    {
                        if (joystickAdapter.moveCameraActive && !mainController.arMode)
                        {
                            mainController.moveCameraObject(val);
                        }
                        if (joystickAdapter.moveObjectActive)
                        {
                            mainController.translateSelectionJoystick(val);
                        }
                        if (joystickAdapter.rotateObjectActive)
                        {
                            mainController.rotateSelectionJoystick(val);
                        }
                        if (joystickAdapter.scaleObjectActive)
                        {
                            mainController.scaleSelectionJoystick(val);
                        }
                        if (mainController.UIAdapter.LayoutUI == layouts.ANIMATION)
                        {
                            mainController.AnimationController.setKeyFrame();
                        }
                    }
                    joystickAdapter.getButtonUpdates();
                }
            }

            //smoothly "fly" the camera to a given position
            if (smoothTranslationActive)
            {
                transform.position = Vector3.Lerp(transform.position, targetTranslation, Time.deltaTime * translationDamping);
                //if the position is nearly reached, stop
                if (Vector3.Distance(transform.position, targetTranslation) < 0.0001f)
                {
                    transform.position      = targetTranslation;
                    smoothTranslationActive = false;
                }
                //if 3 seconds have past, stop (avoids infinit translation for unreachable points)
                if ((Time.time - smoothTranslateTime) > 3.0f)
                {
                    smoothTranslationActive = false;
                }
            }

            if (mainController.ActiveMode == MainController.Mode.lookThroughCamMode ||
                mainController.ActiveMode == MainController.Mode.lookThroughLightMode)
            {
                Transform currentSelectedTransform = mainController.getCurrentSelection().transform;
                currentSelectedTransform.position = this.transform.position;
                currentSelectedTransform.rotation = this.transform.rotation;
            }

            //calculate & display frames per second
            if (VPETSettings.Instance.debugMsg)
            {
                timeleft -= Time.deltaTime;
                accum    += Time.timeScale / Time.deltaTime;
                ++frames;

                // Interval ended - update GUI text and start new interval
                if (timeleft <= 0.0)
                {
                    // display two digits
                    float  fps    = accum / frames;
                    string format = System.String.Format("{0:F2} FPS", fps);
                    fpsText  = format;
                    fpsText += " LiveView IP: " + VPETSettings.Instance.serverIP;
                    fpsText += " State: " + mainController.ActiveMode.ToString();
                    fpsText += " DeviceType: " + SystemInfo.deviceType.ToString();
                    fpsText += " DeviceName: " + SystemInfo.deviceName.ToString();
                    fpsText += " DeviceModel: " + SystemInfo.deviceModel.ToString();
                    fpsText += " SupportGyro: " + SystemInfo.supportsGyroscope.ToString();
                    fpsText += " DataPath: " + Application.dataPath;
                    fpsText += " PersistPath: " + Application.persistentDataPath;
                    fpsText += " Config1: " + Application.dataPath + "/VPET/editing_tool.cfg";
                    fpsText += " Config2: " + Application.persistentDataPath + "/editing_tool.cfg";
                    fpsText += " Mouse Active: " + mainController.MouseInputActive;
                    fpsText += " Touch Active: " + mainController.TouchInputActive;
                    fpsText += " Renderpath:" + Camera.main.renderingPath;
                    fpsText += " ActualRenderpath:" + Camera.main.actualRenderingPath;
                    fpsText += " Msg:" + VPETSettings.Instance.msg;
                    accum    = 0.0f;
                    frames   = 0;
                    timeleft = updateInterval;
                }
            }
            if (supervisedObjects.Count > 0)
            {
                for (int i = supervisedObjects.Count - 1; i >= 0; i--)
                {
                    if (!supervisedObjects[i])
                    {
                        supervisedObjects.RemoveAt(i);
                        continue;
                    }
                    if (Vector3.Distance(supervisedObjects[i].transform.position, this.transform.position) > 300.0f * VPETSettings.Instance.sceneScale)
                    {
                        supervisedObjects[i].SetActive(mainController.showCam);
                        BoxCollider[] col = supervisedObjects[i].GetComponentsInParent <BoxCollider>(true);
                        if (col.Length > 0)
                        {
                            col[0].enabled = mainController.showCam;
                        }
                        supervisedObjects.RemoveAt(i);
                    }
                }
            }
        }
Example #10
0
        //!
        //! all possible inputs
        //!
        public void getButtonUpdates()
        {
            if (Input.GetButtonDown("L1"))
            {
                // toggle gravity
                if (mainController.getCurrentSelection())
                {
                    if (mainController.UIAdapter.CenterMenu.transform.GetChild(4).GetComponent <MenuButtonToggle>().enabled & !(mainController.UIAdapter.LayoutUI == layouts.ANIMATION))
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(4).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    // set keyframe for current selection (translate, rotate, scale)
                    if (mainController.UIAdapter.LayoutUI == layouts.ANIMATION & !moveCameraActive)
                    {
                        mainController.AnimationController.setKeyFrame();
                    }
                }
            }
            // enter translation mode
            else if (Input.GetButtonDown("Fire3"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = true;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // enter rotation mode
            else if (Input.GetButtonDown("Fire1"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // directly enter scale mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = true;
                    scaleObjectActive  = false;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                }
                // enter camera mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // enter scale mode
            else if (Input.GetButtonDown("Fire0"))
            {
                // enter object translation mode
                if (moveCameraActive && mainController.getCurrentSelection())
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter rotation mode
                else if (moveObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(0).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // directly enter scale mode
                else if (rotateObjectActive)
                {
                    moveCameraActive   = false;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = true;
                    mainController.UIAdapter.CenterMenu.transform.GetChild(1).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    if (mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.LIGHT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(7).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                    else
                    {
                        mainController.UIAdapter.drawCenterMenu(layouts.OBJECT);
                        mainController.UIAdapter.CenterMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
                    }
                }
                // enter camera mode
                else if (scaleObjectActive)
                {
                    moveCameraActive   = true;
                    moveObjectActive   = false;
                    rotateObjectActive = false;
                    scaleObjectActive  = false;
                    mainController.handleSelection();
                }
            }
            // toggle configuration window
            else if (Input.GetButtonDown("Settings"))
            {
                mainController.UIAdapter.MainMenu.transform.GetChild(3).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // toggle predefined bookmarks
            else if (Input.GetButtonDown("R1") && !mainController.arMode)
            {
                mainController.repositionCamera();
            }
            // disable tracking
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("R2") < 0 && !hasPressedR2 && !mainController.arMode)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (Input.GetButtonDown("R2") && !mainController.arMode)
#endif
            {
                hasPressedR2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(2).GetComponent <MenuButtonToggle>().OnPointerClick(new PointerEventData(EventSystem.current));
            }
            // reset current selection
            else if (Input.GetButtonDown("Fire2"))
            {
                if (mainController.getCurrentSelection())
                {
                    mainController.getCurrentSelection().GetComponent <SceneObject>().resetAll();
                }
            }
            // cycle through edit modes
#if UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN || UNITY_EDITOR_LINUX
            else if (Input.GetAxis("L2") > 0 && !hasPressedL2)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if (Input.GetButtonDown("L2"))
#endif
            {
                hasPressedL2 = true;
                mainController.UIAdapter.MainMenu.transform.GetChild(1).GetComponent <MenuButtonList>().OnPointerClick(new PointerEventData(EventSystem.current));
            }

            // cycle through object list
#if UNITY_EDITOR || UNITY_STANDALONE
            else if (Input.GetAxis("DPAD_H") != 0 && hasPressedDirectionalPad == false ||
                     Input.GetAxis("DPAD_V") != 0 && hasPressedDirectionalPad == false)
#elif UNITY_IOS || UNITY_STANDALONE_OSX
            else if ((Input.GetButtonDown("DPAD_H")) ||
                     (Input.GetButtonDown("DPAD_H_neg")) ||
                     (Input.GetButtonDown("DPAD_V")) ||
                     (Input.GetButtonDown("DPAD_V_neg")))
#endif
            {
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_H") == 1 || Input.GetAxis("DPAD_V") == 1)
                {
                    DPADdirection = 1;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_H") || Input.GetButtonDown("DPAD_V"))
                {
                    DPADdirection = 1;
                }
#endif
                else
                {
                    DPADdirection = -1;
                }
                hasPressedDirectionalPad = true;
                int  match       = -1;
                bool cycleLights = false;
#if UNITY_EDITOR || UNITY_STANDALONE
                if (Input.GetAxis("DPAD_V") != 0)
                {
                    cycleLights = true;
                }
#elif UNITY_IOS || UNITY_STANDALONE_OSX
                if (Input.GetButtonDown("DPAD_V") || Input.GetButtonDown("DPAD_V_neg"))
                {
                    cycleLights = true;
                }
#endif
                Transform currentSelection = mainController.getCurrentSelection();
                mainController.handleSelection();
                if (cycleLights)
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SelectableLights.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectLight(0);
                    }
                    else
                    {
                        selectLight(match + DPADdirection);
                    }
                }
                else
                {
                    if (currentSelection)
                    {
                        match = SceneLoader.SceneEditableObjects.IndexOf(currentSelection.gameObject);
                    }
                    if (match < 0)
                    {
                        selectObject(0);
                    }
                    else
                    {
                        selectObject(match + DPADdirection);
                    }
                }

                // reactivate last selected edit mode
                if (moveObjectActive)
                {
                    mainController.buttonTranslationClicked(true);
                }
                else if (rotateObjectActive)
                {
                    mainController.buttonRotationClicked(true);
                }
                else if (scaleObjectActive & !mainController.getCurrentSelection().GetComponent <SceneObject>().IsLight)
                {
                    mainController.buttonScaleClicked(true);
                }
            }
            // Dpad and R2 reset
#if UNITY_EDITOR || UNITY_STANDALONE
            if (Input.GetAxis("DPAD_H") == 0 && (Input.GetAxis("DPAD_V") == 0))
            {
                hasPressedDirectionalPad = false;
            }
            if (Input.GetAxis("R2") == 0)
            {
                hasPressedR2 = false;
            }
            if (Input.GetAxis("L2") == 0)
            {
                hasPressedL2 = false;
            }
#endif
        }
Example #11
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            //ArFoundation Hack when Anchors get disabled
            if (!mainController.arMode)
            {
                scene.transform.rotation = Quaternion.identity;
                scene.transform.position = Vector3.zero;
            }

            mainController.UpdatePropertiesSecondaryCameras();

            //get sensor data from native Plugin on Windows
#if UNITY_STANDALONE_WIN && !UNITY_EDITOR
            Marshal.Copy(getOrientationSensorData(), orientationSensorData, 0, 4);
#endif

#if !SCENE_HOST
            if (joystickAdapter.move != move)
            {
                joystickAdapter.move = move;
            }
#endif

            if (move)
            {
                //cache rotation of attached gameObjects
                if (this.transform.childCount > 1)
                {
                    childrotationBuffer = this.transform.GetChild(1).rotation;
                }

#if !UNITY_EDITOR
#if (UNITY_ANDROID || UNITY_IOS)
#if !USE_AR
                newRotation = gyroAdapter.Rotation;
#endif
#elif UNITY_STANDALONE_WIN
                newRotation = Quaternion.Euler(90, 90, 0) * convertRotation(new Quaternion(orientationSensorData[0], orientationSensorData[1], orientationSensorData[2], orientationSensorData[3]));
#endif
#endif
                if (doApplyRotation)
                {
                    if (!firstApplyTransform)
                    {
                        if (!mainController.arMode)
                        {
                            calibrate(rotationFirst);
                            positionOffset = positionFirst - newPosition;
                        }
                        firstApplyTransform = true;
                    }

#if !UNITY_EDITOR && !USE_AR
                    transform.rotation = rotationOffset * newRotation;
#if !UNITY_STANDALONE_WIN
                    // HACK: to block roll
                    if (!mainController.arMode && mainController.ActiveMode != MainController.Mode.lookThroughLightMode)
                    {
                        transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y, 0);
                    }
#endif
#endif
                }
                else if (firstApplyTransform)
                {
                    rotationFirst       = rotationOffset * newRotation;
                    positionFirst       = positionOffset + newPosition;
                    firstApplyTransform = false;
                }

#if USE_AR
                oldPosition = trackingTransform.position;
                oldRotation = trackingTransform.rotation;
#endif
            }

            //smoothly "fly" the camera to a given position
            if (smoothTranslationActive)
            {
                transform.position = Vector3.Lerp(transform.position, targetTranslation, Time.deltaTime * translationDamping);
                //if the position is nearly reached, stop
                if (Vector3.Distance(transform.position, targetTranslation) < 0.0001f)
                {
                    transform.position      = targetTranslation;
                    smoothTranslationActive = false;
                }
                //if 3 seconds have past, stop (avoids infinit translation for unreachable points)
                if ((Time.time - smoothTranslateTime) > 3.0f)
                {
                    smoothTranslationActive = false;
                }
            }

            if (mainController.ActiveMode == MainController.Mode.lookThroughCamMode ||
                mainController.ActiveMode == MainController.Mode.lookThroughLightMode)
            {
                Transform currentSelectedTransform = mainController.getCurrentSelection().transform;
                currentSelectedTransform.position = this.transform.position;
                currentSelectedTransform.rotation = this.transform.rotation;
            }

            //calculate & display frames per second
            if (VPETSettings.Instance.debugMsg)
            {
                timeleft -= Time.deltaTime;
                accum    += Time.timeScale / Time.deltaTime;
                ++frames;

                // Interval ended - update GUI text and start new interval
                if (timeleft <= 0.0)
                {
                    // display two digits
                    float  fps    = accum / frames;
                    string format = System.String.Format("{0:F2} FPS", fps);
                    fpsText  = format;
                    fpsText += " | Server IP: " + VPETSettings.Instance.serverIP + "\n";
                    fpsText += "State: " + mainController.ActiveMode.ToString();
                    fpsText += " | DeviceType: " + SystemInfo.deviceType.ToString();
                    //fpsText += " DeviceName: " + SystemInfo.deviceName.ToString();
                    //fpsText += " DeviceModel: " + SystemInfo.deviceModel.ToString();
                    fpsText += " | SupportGyro: " + SystemInfo.supportsGyroscope.ToString() + "\n";
                    fpsText += "DataPath: " + Application.dataPath + "\n";
                    fpsText += "PersistPath: " + Application.persistentDataPath + "\n";
                    //fpsText += " Config1: " + Application.dataPath + "/VPET/editing_tool.cfg";
                    //fpsText += " Config2: " + Application.persistentDataPath + "/editing_tool.cfg";
                    fpsText += "Mouse Active: " + mainController.MouseInputActive;
                    fpsText += " | Touch Active: " + mainController.TouchInputActive;
                    //fpsText += " | Renderpath:" + Camera.main.renderingPath;
                    fpsText += " | Renderpath:" + Camera.main.actualRenderingPath + "\n";
                    //fpsText += " Msg:" + VPETSettings.Instance.msg;

                    System.Array values = System.Enum.GetValues(typeof(KeyCode));
                    foreach (KeyCode code in values)
                    {
                        if (Input.GetKeyDown(code))
                        {
                            fpsText += "\n" + (System.Enum.GetName(typeof(KeyCode), code));
                        }
                    }

                    if (Input.GetAxis("L1") != 0)
                    {
                        fpsText += "Button L1 \n";
                    }
                    else if (Input.GetButtonUp("L2"))
                    {
                        fpsText += "Button L2 \n";
                    }
                    else if (Input.GetButton("R1"))
                    {
                        fpsText += "Button R1 \n";
                    }
                    else if (Input.GetButtonUp("R2"))
                    {
                        fpsText += "Button R2 \n";
                    }
                    else if (Input.GetButtonDown("Fire3"))
                    {
                        fpsText += "Button Fire3 \n";
                    }
                    else if (Input.GetButtonDown("Fire2"))
                    {
                        fpsText += "Button Fire2 \n";
                    }
                    else if (Input.GetButtonDown("Fire1"))
                    {
                        fpsText += "Button Fire1 \n";
                    }
                    else if (Input.GetButtonDown("Fire0"))
                    {
                        fpsText += "Button Fire0 \n";
                    }
                    else if (Input.GetButtonDown("Settings"))
                    {
                        fpsText += "Button Settings \n";
                    }
                    else if (Input.GetAxis("DPAD_H") != 0)
                    {
                        fpsText += "Button DPAD_H \n";
                    }
                    else if (Input.GetAxis("DPAD_V") != 0)
                    {
                        fpsText += "Button DPAD_V \n";
                    }
                    else if (Input.GetAxis("DPAD_H_neg") != 0)
                    {
                        fpsText += "Button DPAD_H_neg \n";
                    }
                    else if (Input.GetAxis("DPAD_V_neg") != 0)
                    {
                        fpsText += "Button DPAD_V_neg \n";
                    }



                    accum    = 0.0f;
                    frames   = 0;
                    timeleft = updateInterval;
                }
            }
            if (supervisedObjects.Count > 0)
            {
                for (int i = supervisedObjects.Count - 1; i >= 0; i--)
                {
                    if (!supervisedObjects[i])
                    {
                        supervisedObjects.RemoveAt(i);
                        continue;
                    }
                    if (Vector3.Distance(supervisedObjects[i].transform.position, this.transform.position) > 300.0f * VPETSettings.Instance.sceneScale)
                    {
                        supervisedObjects[i].SetActive(mainController.showCam);
                        BoxCollider[] col = supervisedObjects[i].GetComponentsInParent <BoxCollider>(true);
                        if (col.Length > 0)
                        {
                            col[0].enabled = mainController.showCam;
                        }
                        supervisedObjects.RemoveAt(i);
                    }
                }
            }
        }