Ejemplo n.º 1
0
    /// <summary>
    /// Updates the skeleton data from ZEDCamera call and send it to Skeleton Handler script.
    /// </summary>
    private void updateSkeletonData(DetectionFrame dframe)
    {
        #if FAKEMODE
        if (avatarControlList.ContainsKey(0))
        {
            SkeletonHandler handler = avatarControlList[0];
            handler.setFakeTest(indexFakeTest);
        }
        else
        {
            SkeletonHandler handler = ScriptableObject.CreateInstance <SkeletonHandler>();
            handler.Create(Avatar, Vector3.zero);
            avatarControlList.Add(0, handler);
        }
        #else
        List <int>            remainingKeyList = new List <int>(avatarControlList.Keys);
        List <DetectedObject> newobjects       = dframe.GetFilteredObjectList(showON, showSEARCHING, showOFF);

        /*if (dframe.rawObjectsFrame.detectionModel!= sl.DETECTION_MODEL.HUMAN_BODY_ACCURATE &&
         *      dframe.rawObjectsFrame.detectionModel!= sl.DETECTION_MODEL.HUMAN_BODY_FAST)
         * {
         *      Debug.Log("Wrong model selected : " + dframe.rawObjectsFrame.detectionModel);
         * return;
         * }*/

        foreach (DetectedObject dobj in newobjects)
        {
            int person_id = dobj.rawObjectData.id;

            //Avatar controller already exist --> update position
            if (avatarControlList.ContainsKey(person_id))
            {
                SkeletonHandler handler = avatarControlList[person_id];
                UpdateAvatarControl(handler, dobj.rawObjectData, useAvatar);

                // remove keys from list
                remainingKeyList.Remove(person_id);
            }
            else
            {
                SkeletonHandler handler       = ScriptableObject.CreateInstance <SkeletonHandler>();
                Vector3         spawnPosition = zedManager.GetZedRootTansform().TransformPoint(dobj.rawObjectData.rootWorldPosition);
                handler.Create(Avatar, spawnPosition);
                handler.initSkeleton(person_id);
                avatarControlList.Add(person_id, handler);
                UpdateAvatarControl(handler, dobj.rawObjectData, useAvatar);
            }
        }

        foreach (int index in remainingKeyList)
        {
            SkeletonHandler handler = avatarControlList[index];
            handler.Destroy();
            avatarControlList.Remove(index);
        }
                #endif
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        string[] names       = Input.GetJoystickNames();
        bool     hasJoystick = false;

        if (names.Length > 0)
        {
            hasJoystick = names[0].Length > 0;
        }


        /// Adjust Planetarium X/Y/Z position
        float axisH = Input.GetAxis("Horizontal");
        float axisV = Input.GetAxis("Vertical");

        Quaternion gravity = Quaternion.identity;

        gravity = Quaternion.FromToRotation(manager.GetZedRootTansform().up, Vector3.up);
        planetarium.transform.localPosition += manager.GetLeftCameraTransform().right *axisH *speedMove *Time.deltaTime;
        planetarium.transform.localPosition += gravity * manager.GetLeftCameraTransform().forward *axisV *speedMove *Time.deltaTime;

        /// Adjust Scale of Virtual objects,lights, sounds
        bool ScaleUpButton   = Input.GetButton("Fire1") || Input.GetKey(KeyCode.JoystickButton5) || (Input.GetAxis("Fire1") >= 1);
        bool ScaleDownButton = Input.GetButton("Fire2") || (Input.GetAxis("Fire2") >= 1);

        currentscale += System.Convert.ToInt32(ScaleUpButton) * speedGrowth * Time.deltaTime / scaler;
        currentscale -= System.Convert.ToInt32(ScaleDownButton) * speedGrowth * Time.deltaTime / scaler;
        if (currentscale < MIN_LIMIT_SCALE)
        {
            currentscale = MIN_LIMIT_SCALE;
        }
        if (currentscale > MAX_LIMIT_SCALE)
        {
            currentscale = MAX_LIMIT_SCALE;
        }
        planetarium.transform.localScale = new Vector3(currentscale, currentscale, currentscale);
        sunlight.range     = currentlightrange * currentscale;
        spotLightSun.range = currentlightrangesunspot * currentscale;
        halolightsun.range = currentlightrangesunhalo * currentscale;

#if __ENABLE__SOUND__
        jupiterSound.maxDistance = currentMaxSoundDistanceJupiter * currentScale;
        sunSound.maxDistance     = currentMaxSoundDistanceSun * currentScale;
#endif

        /// Adjust Rotation of Planetarium
        if (CheckAxes("DPad X") && hasJoystick)
        {
            float axisX = Input.GetAxis("DPad X"); //multiply by 10 since sensibility is at 0.1 by default
            planetarium.transform.Rotate(gravity * manager.GetLeftCameraTransform().up *axisX *speedRotation, Space.World);
        }
        else
        {
            float axisX = System.Convert.ToInt32(Input.GetKey(KeyCode.R));
            planetarium.transform.Rotate(gravity * manager.GetLeftCameraTransform().up *axisX *speedRotation, Space.World);
        }


        //adjust Height of Planetarium
        if (CheckAxes("DPad Y") && hasJoystick)
        {
            float axisY = Input.GetAxis("DPad Y");
            planetarium.transform.localPosition += gravity * manager.GetLeftCameraTransform().up *axisY *speedMove *Time.deltaTime;
        }
        else
        {
            float axisY = System.Convert.ToInt32(Input.GetKey(KeyCode.PageUp)) - System.Convert.ToInt32(Input.GetKey(KeyCode.PageDown));
            planetarium.transform.localPosition += gravity * manager.GetLeftCameraTransform().up *axisY *speedMove *Time.deltaTime;
        }
    }
Ejemplo n.º 3
0
    private void Update()
    {
        //Reposition the screen in front our the Camera when its ready
        if (ZEDManager.Instance.IsZEDReady && reposition == false)
        {
            transform.position = ZEDManager.Instance.OriginPosition + ZEDManager.Instance.OriginRotation * (Vector3.forward);
            Quaternion newRot = Quaternion.LookRotation(ZEDManager.Instance.OriginPosition - transform.position, Vector3.up);
            transform.eulerAngles = new Vector3(0, newRot.eulerAngles.y + 180, 0);
            reposition            = true;
        }

        Vector3 moveAxis = Vector3.zero;

        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.Q))
        {
            inputRotation = -1 * (RotationSpeed * 50) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.E))
        {
            inputRotation = 1 * (RotationSpeed * 50) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
        {
            moveAxis = Vector3.forward * MovementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
        {
            moveAxis = Vector3.back * MovementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveAxis = Vector3.left * MovementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveAxis = Vector3.right * MovementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.R))
        {
            moveAxis = Vector3.up * MovementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.F))
        {
            moveAxis = Vector3.down * MovementSpeed * Time.deltaTime;
        }

        Quaternion gravity = Quaternion.identity;

        if (!VRControls)
        {
            if (moveAxis != Vector3.zero)
            {
                isMoving = true;
                if (motion == relativeMotion.Itself)
                {
                    transform.Translate(moveAxis.x, moveAxis.y, moveAxis.z);
                }
                else if (motion == relativeMotion.Camera)
                {
                    gravity = Quaternion.FromToRotation(zManager.GetZedRootTansform().up, Vector3.up);
                    transform.localPosition += zManager.GetLeftCameraTransform().right *moveAxis.x;
                    transform.localPosition += zManager.GetLeftCameraTransform().forward *moveAxis.z;
                    transform.localPosition += gravity * zManager.GetLeftCameraTransform().up *moveAxis.y;
                }
            }
            else
            {
                isMoving = false;
            }

            if (Input.GetKey(KeyCode.Mouse0))
            {
                inputScale = 1f;
            }
            else if (Input.GetKey(KeyCode.Mouse1))
            {
                inputScale = -1f;
            }
        }
        else
        {
            if (zManager)
            {
#if ZED_OCULUS
                if (UnityEngine.VR.VRSettings.loadedDeviceName == "Oculus")
                {
                    if (OVRInput.GetConnectedControllers().ToString() == "Touch")
                    {
                        if (objectTrackers.Count > 0)
                        {
                            moveAxis      = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.RTouch);
                            inputRotation = moveAxis.x * RotationSpeed;

                            gravity = Quaternion.FromToRotation(zManager.GetZedRootTansform().up, Vector3.up);
                            transform.localPosition += gravity * zManager.GetLeftCameraTransform().up *moveAxis.y *MovementSpeed *Time.deltaTime;

                            if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.RTouch) > 0.75f)
                            {
                                inputScale = 1f;
                            }
                        }

                        if (objectTrackers.Count > 1)
                        {
                            moveAxis = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.LTouch);
                            if (moveAxis.x != 0 || moveAxis.y != 0)
                            {
                                isMoving = true;
                                gravity  = Quaternion.FromToRotation(zManager.GetZedRootTansform().up, Vector3.up);
                                transform.localPosition += zManager.GetLeftCameraTransform().right *moveAxis.x *MovementSpeed *Time.deltaTime;
                                transform.localPosition += gravity * zManager.GetLeftCameraTransform().forward *moveAxis.y *MovementSpeed *Time.deltaTime;
                            }
                            else
                            {
                                isMoving = false;
                            }

                            if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.LTouch) > 0.75f)
                            {
                                inputScale = -1f;
                            }
                        }
                    }

                    OVRInput.Update();
                }
#endif
#if ZED_STEAM_VR
                if (UnityEngine.VR.VRSettings.loadedDeviceName == "OpenVR")
                {
                    //Looks for any input from this controller through SteamVR
                    if (objectTrackers.Count > 0 && objectTrackers[0].index >= 0)
                    {
                        moveAxis      = SteamVR_Controller.Input((int)objectTrackers[0].index).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
                        inputRotation = moveAxis.x * RotationSpeed;

                        gravity = Quaternion.FromToRotation(zManager.GetZedRootTansform().up, Vector3.up);
                        transform.localPosition += gravity * zManager.GetLeftCameraTransform().up *moveAxis.y *MovementSpeed *Time.deltaTime;

                        if (objectTrackers[0].index > 0 && SteamVR_Controller.Input((int)objectTrackers[0].index).GetHairTrigger())
                        {
                            inputScale = 1f;
                        }
                    }

                    if (objectTrackers.Count > 1 && objectTrackers[1].index >= 0)
                    {
                        moveAxis = SteamVR_Controller.Input((int)objectTrackers[1].index).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

                        if (moveAxis.x != 0 || moveAxis.y != 0)
                        {
                            isMoving = true;
                            gravity  = Quaternion.FromToRotation(zManager.GetZedRootTansform().up, Vector3.up);
                            transform.localPosition += zManager.GetLeftCameraTransform().right *moveAxis.x *MovementSpeed *Time.deltaTime;
                            transform.localPosition += gravity * zManager.GetLeftCameraTransform().forward *moveAxis.y *MovementSpeed *Time.deltaTime;
                        }
                        else
                        {
                            isMoving = false;
                        }

                        if (objectTrackers[1].index > 0 && SteamVR_Controller.Input((int)objectTrackers[1].index).GetHairTrigger())
                        {
                            inputScale = -1f;
                        }
                    }
                }
#endif
            }
        }

        //Rotation
        float h = inputRotation;

        if (invertRotation)
        {
            transform.Rotate(0, h, 0);
        }
        else
        {
            transform.Rotate(0, -h, 0);
        }

        //Reset Rotation for next frame
        inputRotation = 0f;

        //Scale
        float s = ScaleSpeed * (inputScale * Time.deltaTime);

        //Reset scale for next frame
        inputScale = 0f;

        transform.localScale = new Vector3(transform.localScale.x + s,
                                           transform.localScale.y + s,
                                           transform.localScale.z + s);

        if (transform.localScale.x > maxScale)
        {
            transform.localScale = new Vector3(maxScale, maxScale, maxScale);
        }
        else if (transform.localScale.x < minScale)
        {
            transform.localScale = new Vector3(minScale, minScale, minScale);
        }

        //Enable/Disable light
        if (spotLight != null)
        {
            EnableLights();
        }
    }
    private void Update()
    {
        Vector3 moveAxis      = Vector3.zero; //Translation. Used by keyboard only.
        float   inputRotation = 0f;           //Applied rotation, between -1 and 1. Cumulative between keyboard and controllers.
        float   inputScale    = 0f;           //Applied scale change, either -1, 0 or 1. Cumulative between keyboard and controllers.

        //Keyboard inputs.
        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.Q))
        {
            inputRotation = -1 * (rotationSpeed * 360) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.E))
        {
            inputRotation = 1 * (rotationSpeed * 360) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
        {
            moveAxis = Vector3.forward * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
        {
            moveAxis = Vector3.back * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveAxis = Vector3.left * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveAxis = Vector3.right * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.R))
        {
            moveAxis = Vector3.up * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.F))
        {
            moveAxis = Vector3.down * movementSpeed * Time.deltaTime;
        }

        Quaternion gravity = Quaternion.identity;


        if (moveAxis != Vector3.zero)
        {
            isMoving = true;
            if (motion == RelativeMotion.Itself)
            {
                transform.Translate(moveAxis.x, moveAxis.y, moveAxis.z);
            }
            else if (motion == RelativeMotion.Camera)
            {
                gravity = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                transform.localPosition += zedManager.GetMainCameraTransform().right *moveAxis.x;
                transform.localPosition += zedManager.GetMainCameraTransform().forward *moveAxis.z;
                transform.localPosition += gravity * zedManager.GetMainCameraTransform().up *moveAxis.y;
            }
        }
        else
        {
            isMoving = false;
        }

        if (Input.GetKey(KeyCode.Mouse0))
        {
            inputScale = 1f;
        }
        else if (Input.GetKey(KeyCode.Mouse1))
        {
            inputScale = -1f;
        }

        if (zedManager)
        {
            Vector3 moveaxis = new Vector3(); //Position change by controller. Added to keyboard version if both are applied.

            //Looks for any input from this controller through SteamVR.
            //Left controller controls rotation and increasing scale.
            if (objectTrackers.Count > 0)
            {
                moveaxis = objectTrackers[0].CheckNavigateUIAxis();
                if (Mathf.Abs(moveaxis.x) < 0.1f)
                {
                    moveaxis.x = 0;                               //Add slight deadzone.
                }
                if (Mathf.Abs(moveaxis.y) < 0.1f)
                {
                    moveaxis.y = 0;
                }
                inputRotation += moveaxis.x * rotationSpeed * 360f * Time.deltaTime;

                gravity = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                transform.localPosition += gravity * zedManager.GetMainCameraTransform().up *moveaxis.y *movementSpeed *Time.deltaTime;

                if (objectTrackers[0].CheckClickButton(ControllerButtonState.Held))
                {
                    inputScale = 1f;
                }
            }
            //Right controller controls translation and lowering scale.
            if (objectTrackers.Count > 1)
            {
                moveaxis = objectTrackers[1].CheckNavigateUIAxis();
                if (Mathf.Abs(moveaxis.x) < 0.1f)
                {
                    moveaxis.x = 0;                               //Add slight deadzone.
                }
                if (Mathf.Abs(moveaxis.y) < 0.1f)
                {
                    moveaxis.y = 0;
                }
                if (moveaxis.x != 0 || moveaxis.y != 0)
                {
                    isMoving = true;
                    gravity  = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                    transform.localPosition += zedManager.GetMainCameraTransform().right *moveaxis.x *movementSpeed *Time.deltaTime;
                    transform.localPosition += gravity * zedManager.GetMainCameraTransform().forward *moveaxis.y *movementSpeed *Time.deltaTime;
                }
                else
                {
                    isMoving = false;
                }

                if (objectTrackers[1].CheckClickButton(ControllerButtonState.Held))
                {
                    inputScale = -1f;
                }
            }
        }

        //Rotation
        float h = inputRotation;

        if (invertRotation)
        {
            transform.Rotate(0, h, 0);
        }
        else
        {
            transform.Rotate(0, -h, 0);
        }

        //Scale
        float s = scaleSpeed * (inputScale * Time.deltaTime);

        transform.localScale = new Vector3(transform.localScale.x + s,
                                           transform.localScale.y + s,
                                           transform.localScale.z + s);

        if (transform.localScale.x > maxScale)
        {
            transform.localScale = new Vector3(maxScale, maxScale, maxScale);
        }
        else if (transform.localScale.x < minScale)
        {
            transform.localScale = new Vector3(minScale, minScale, minScale);
        }

        //Enable/disable light if moving.
        if (spotLight != null)
        {
            SetMovementLight();
        }
    }
Ejemplo n.º 5
0
    private void Update()
    {
        Vector3 moveAxis      = Vector3.zero; //Translation. Used by keyboard only.
        float   inputRotation = 0f;           //Applied rotation, between -1 and 1. Cumulative between keyboard and controllers.
        float   inputScale    = 0f;           //Applied scale change, either -1, 0 or 1. Cumulative between keyboard and controllers.

        //Keyboard inputs.
        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.Q))
        {
            inputRotation = -1 * (rotationSpeed * 360) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.E))
        {
            inputRotation = 1 * (rotationSpeed * 360) * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.W))
        {
            moveAxis = Vector3.forward * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.S))
        {
            moveAxis = Vector3.back * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.A))
        {
            moveAxis = Vector3.left * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.D))
        {
            moveAxis = Vector3.right * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.R))
        {
            moveAxis = Vector3.up * movementSpeed * Time.deltaTime;
        }
        if (Input.GetKey(KeyCode.F))
        {
            moveAxis = Vector3.down * movementSpeed * Time.deltaTime;
        }

        Quaternion gravity = Quaternion.identity;


        if (moveAxis != Vector3.zero)
        {
            isMoving = true;
            if (motion == RelativeMotion.Itself)
            {
                transform.Translate(moveAxis.x, moveAxis.y, moveAxis.z);
            }
            else if (motion == RelativeMotion.Camera)
            {
                gravity = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                transform.localPosition += zedManager.GetLeftCameraTransform().right *moveAxis.x;
                transform.localPosition += zedManager.GetLeftCameraTransform().forward *moveAxis.z;
                transform.localPosition += gravity * zedManager.GetLeftCameraTransform().up *moveAxis.y;
            }
        }
        else
        {
            isMoving = false;
        }

        if (Input.GetKey(KeyCode.Mouse0))
        {
            inputScale = 1f;
        }
        else if (Input.GetKey(KeyCode.Mouse1))
        {
            inputScale = -1f;
        }

        if (zedManager)
        {
#if ZED_OCULUS
            if (UnityEngine.VR.VRSettings.loadedDeviceName == "Oculus")
            {
                if (OVRInput.GetConnectedControllers().ToString() == "Touch")
                {
                    Vector3 moveaxisoculus = new Vector3(); //Position change by controller. Added to keyboard version if both are applied.

                    if (objectTrackers.Count > 0)
                    {
                        moveaxisoculus = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.RTouch);
                        inputRotation += moveaxisoculus.x * rotationSpeed * 360 * Time.deltaTime;


                        gravity = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                        transform.localPosition += gravity * zedManager.GetLeftCameraTransform().up *moveaxisoculus.y *movementSpeed *Time.deltaTime;

                        if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.RTouch) > 0.75f)
                        {
                            inputScale = 1f;
                        }
                    }

                    if (objectTrackers.Count > 1)
                    {
                        moveaxisoculus = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick, OVRInput.Controller.LTouch);
                        if (moveaxisoculus.x != 0 || moveaxisoculus.y != 0)
                        {
                            isMoving = true;
                            gravity  = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                            transform.localPosition += zedManager.GetLeftCameraTransform().right *moveaxisoculus.x *movementSpeed *Time.deltaTime;
                            transform.localPosition += gravity * zedManager.GetLeftCameraTransform().forward *moveaxisoculus.y *movementSpeed *Time.deltaTime;
                        }
                        else
                        {
                            isMoving = false;
                        }

                        if (OVRInput.Get(OVRInput.Axis1D.PrimaryIndexTrigger, OVRInput.Controller.LTouch) > 0.75f)
                        {
                            inputScale = -1f;
                        }
                    }
                }

                OVRInput.Update();
            }
#endif
#if ZED_STEAM_VR
            if (UnityEngine.XR.XRSettings.loadedDeviceName == "OpenVR")
            {
                Vector3 moveaxissteamvr = new Vector3(); //Position change by controller. Added to keyboard version if both are applied.

                //Looks for any input from this controller through SteamVR.
                if (objectTrackers.Count > 0 && objectTrackers[0].index >= 0)
                {
                    //moveaxissteamvr = SteamVR_Controller.Input((int)objectTrackers[0].index).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
                    moveaxissteamvr = objectTrackers[0].GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

                    inputRotation += moveaxissteamvr.x * rotationSpeed * 360f * Time.deltaTime;

                    gravity = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                    transform.localPosition += gravity * zedManager.GetLeftCameraTransform().up *moveaxissteamvr.y *movementSpeed *Time.deltaTime;

                    //if (objectTrackers[0].index > 0 && SteamVR_Controller.Input((int)objectTrackers[0].index).GetHairTrigger())
                    if (objectTrackers[0].index > 0 && objectTrackers[0].GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x > 0.1f)
                    {
                        inputScale = 1f;
                    }
                }

                if (objectTrackers.Count > 1 && objectTrackers[1].index >= 0)
                {
                    //moveaxissteamvr = SteamVR_Controller.Input((int)objectTrackers[1].index).GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
                    moveaxissteamvr = objectTrackers[1].GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);

                    if (moveaxissteamvr.x != 0 || moveaxissteamvr.y != 0)
                    {
                        isMoving = true;
                        gravity  = Quaternion.FromToRotation(zedManager.GetZedRootTansform().up, Vector3.up);
                        transform.localPosition += zedManager.GetLeftCameraTransform().right *moveaxissteamvr.x *movementSpeed *Time.deltaTime;
                        transform.localPosition += gravity * zedManager.GetLeftCameraTransform().forward *moveaxissteamvr.y *movementSpeed *Time.deltaTime;
                    }
                    else
                    {
                        isMoving = false;
                    }

                    //if (objectTrackers[1].index > 0 && SteamVR_Controller.Input((int)objectTrackers[1].index).GetHairTrigger())
                    if (objectTrackers[1].index > 0 && objectTrackers[1].GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger).x > 0.1f)
                    {
                        inputScale = -1f;
                    }
                }
            }
#endif
        }

        //Rotation
        float h = inputRotation;

        if (invertRotation)
        {
            transform.Rotate(0, h, 0);
        }
        else
        {
            transform.Rotate(0, -h, 0);
        }

        //Scale
        float s = scaleSpeed * (inputScale * Time.deltaTime);

        transform.localScale = new Vector3(transform.localScale.x + s,
                                           transform.localScale.y + s,
                                           transform.localScale.z + s);

        if (transform.localScale.x > maxScale)
        {
            transform.localScale = new Vector3(maxScale, maxScale, maxScale);
        }
        else if (transform.localScale.x < minScale)
        {
            transform.localScale = new Vector3(minScale, minScale, minScale);
        }

        //Enable/disable light if moving.
        if (spotLight != null)
        {
            SetMovementLight();
        }
    }