コード例 #1
0
ファイル: AnimationController.cs プロジェクト: k4keshaw/VPET
        //!
        //! switches between play and pause mode of the animation
        //! receiving function of Play/Pause Button
        //!
        public void togglePlayPause()
        {
            if (!playing)
            {
                editingPosition = false;
                mainController.hideModifiers();
                playing          = true;
                systemTimeOffset = Time.time - currentAnimationTime;
                // mainController.liveMode = true;
            }
            else
            {
                // mainController.liveMode = false;
                playing = false;
                // stop all layers
                foreach (AnimationLayer animLayer in animationLayers)
                {
                    animLayer.isPlaying = false;
                }
            }

            foreach (SceneObject obj in animatedObjects)
            {
                obj.isPlayingAnimation = playing;
                serverAdapter.SendObjectUpdate(obj, ParameterType.HIDDENLOCK);
            }

            foreach (AnimationLayer layer in animationLayers)
            {
                //animation is playing but not on this layer
                if (!layer.isPlaying && playing)
                {
                    foreach (SceneObject obj in layer.layerObjects)
                    {
                        obj.isPlayingAnimation = false;
                        serverAdapter.SendObjectUpdate(obj, ParameterType.HIDDENLOCK);
                    }
                }
                else
                {
                    foreach (SceneObject obj in layer.layerObjects)
                    {
                        obj.isPlayingAnimation = playing;
                        serverAdapter.SendObjectUpdate(obj, ParameterType.HIDDENLOCK);
                    }
                }
            }
        }
コード例 #2
0
 void sendAnimation()
 {
     if (!ownSceneObject)
     {
         ownSceneObject        = this.GetComponent <SceneObject>();
         ownSceneObject.locked = true;
     }
     serverAdapter.SendObjectUpdate(ownSceneObject, ParameterType.BONEANIM);
 }
コード例 #3
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            if (lastPosition != target.position)
            {
                lastPosition = target.position;
                translationStillFrameCount = 0;
            }
            else if (translationStillFrameCount < 11)
            {
                translationStillFrameCount++;
            }
            if (lastRotation != target.rotation)
            {
                lastRotation            = target.rotation;
                rotationStillFrameCount = 0;
            }
            else if (rotationStillFrameCount < 11)
            {
                rotationStillFrameCount++;
            }
            if (translationStillFrameCount >= 10 && rotationStillFrameCount >= 10 && tempLock)
            {
                tempLock = false;
            }
            if (!locked && !tempLock)
            {
                //publish translation change
                if (true)                                //mainController.liveMode)
                {
                    if (translationStillFrameCount == 0) //position just changed
                    {
                        if ((Time.time - lastTranslationUpdateTime) >= updateIntervall)
                        {
                            targetSend.localPosition = target.localPosition; //targetSend.localRotation = target.localRotation; targetSend.localScale = target.localScale

                            // serverAdapter.sendTranslation(target, target.position, !selected);
                            //serverAdapter.sendTranslation(targetSend, !selected );

                            //serverAdapter.sendTransform(targetSend, !selected );
                            serverAdapter.SendObjectUpdate(target, !selected);

                            // update collider
                            serverAdapter.sendColliderOffset(targetCollider, target.localPosition);

                            lastTranslationUpdateTime = Time.time;
                            translationUpdateDelayed  = false;
                        }
                        else
                        {
                            translationUpdateDelayed = true;
                        }
                    }
                    else if (translationUpdateDelayed)                   //update delayed, but object not moving
                    {
                        targetSend.localPosition = target.localPosition; //targetSend.localRotation = target.localRotation; targetSend.localScale = target.localScale

                        // serverAdapter.sendTranslation(target, target.position, !selected);
                        //serverAdapter.sendTranslation(targetSend, !selected );
                        serverAdapter.SendObjectUpdate(target, !selected);

                        //serverAdapter.sendTransform(targetSend, !selected );
                        // update collider
                        serverAdapter.sendColliderOffset(targetCollider, target.localPosition);

                        lastTranslationUpdateTime = Time.time;
                        translationUpdateDelayed  = false;
                    }
                }
                else if (translationStillFrameCount == 10)           //object is now no longer moving
                {
                    targetSend.localPosition = target.localPosition; //targetSend.localRotation = target.localRotation; targetSend.localScale = target.localScale

                    // serverAdapter.sendTranslation(target, target.position, !selected);
                    //serverAdapter.sendTranslation(targetSend, !selected );
                    serverAdapter.SendObjectUpdate(target, !selected);

                    //serverAdapter.sendTransform(targetSend, !selected );
                    // update collider
                    serverAdapter.sendColliderOffset(targetCollider, target.localPosition);
                }

                //publish rotation change
                if (true)                             // mainController.liveMode)
                {
                    if (rotationStillFrameCount == 0) //position just changed
                    {
                        if ((Time.time - lastRotationUpdateTime) >= updateIntervall)
                        {
                            // serverAdapter.sendRotation(target, target.rotation, !selected);
                            //serverAdapter.sendRotation(targetSend, !selected );
                            serverAdapter.SendObjectUpdate(target, !selected);

                            //serverAdapter.sendTransform(targetSend, !selected );

                            lastRotationUpdateTime = Time.time;
                            rotationUpdateDelayed  = false;
                        }
                        else
                        {
                            rotationUpdateDelayed = true;
                        }
                    }
                    else if (rotationUpdateDelayed)                     //update delayed, but object not moving
                    {
                        //serverAdapter.sendRotation(target, target.rotation, !selected);
                        //serverAdapter.sendRotation(targetSend, !selected );
                        serverAdapter.SendObjectUpdate(target, !selected);


                        //serverAdapter.sendTransform(targetSend, !selected );

                        lastRotationUpdateTime = Time.time;
                        rotationUpdateDelayed  = false;
                    }
                }
                else if (rotationStillFrameCount == 10)                 //object is now no longer moving
                {
                    // serverAdapter.sendRotation(target, target.rotation, !selected);
                    //serverAdapter.sendRotation(targetSend, !selected );
                    serverAdapter.SendObjectUpdate(target, !selected);

                    //serverAdapter.sendTransform(targetSend, !selected );
                }
            }
        }
コード例 #4
0
        private void checkUpdate()
        {
#if !SCENE_HOST
            if (mainController.ActiveMode != MainController.Mode.objectLinkCamera)
            {
                if (!AlmostEqualPos(lastPosition, target.localPosition, 0.0001f))
                {
                    lastPosition = target.localPosition;
                    translationStillFrameCount = 0;
                }
                else if (translationStillFrameCount < 11)
                {
                    translationStillFrameCount++;
                }
                if (!AlmostEqualRot(lastRotation, target.localRotation, 0.0001f))
                {
                    lastRotation            = target.localRotation;
                    rotationStillFrameCount = 0;
                }
                else if (rotationStillFrameCount < 11)
                {
                    rotationStillFrameCount++;
                }
            }
            else
#endif
            {
                if (!AlmostEqualPos(lastPosition, target.position, 0.0001f))
                {
                    lastPosition = target.position;
                    translationStillFrameCount = 0;
                }
                else if (translationStillFrameCount < 11)
                {
                    translationStillFrameCount++;
                }
                if (!AlmostEqualRot(lastRotation, target.rotation, 0.0001f))
                {
                    lastRotation            = target.rotation;
                    rotationStillFrameCount = 0;
                }
                else if (rotationStillFrameCount < 11)
                {
                    rotationStillFrameCount++;
                }
            }
#if !SCENE_HOST
            if (!locked && !mainController.lockScene)
            {
#else
            if (Array.Exists(UnityEditor.Selection.gameObjects, selection => selection == this.gameObject) && !selected &&
                (translationStillFrameCount == 0 || rotationStillFrameCount == 0))
            {
                this.unlockTime = 0.5f;
                locked          = false;
                selected        = true;
                serverAdapter.SendObjectUpdate(this, ParameterType.LOCK);
            }

            if (!locked)
            {
#endif
#if !SCENE_HOST
                //publish translation change
                if (mainController.liveMode)
#endif
                {
                    if (translationStillFrameCount == 0) //position just changed
                    {
                        if (!selected && !isPlayingAnimation && !isPhysicsActive && !rigidbody.isKinematic)
                        {
                            isPhysicsActive = true;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }

#if !SCENE_HOST
                        if (isAnimatedCharacter)
                        {
                            if (mainController.ActiveMode == MainController.Mode.translationMode &&
                                mainController.isTranslating)
                            {
                                serverAdapter.SendObjectUpdate(this, ParameterType.POS);
                            }
                        }
                        else
#endif
                        serverAdapter.SendObjectUpdate(this, ParameterType.POS);
                    }
                    else  //update delayed, but object not moving
                    {
                        if (isPhysicsActive)
                        {
                            isPhysicsActive = false;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }
                    }
                }
#if !SCENE_HOST
                else if (translationStillFrameCount == 10) //object is now no longer moving
                {
#if !SCENE_HOST
                    if (isAnimatedCharacter)
                    {
                        if (mainController.ActiveMode == MainController.Mode.translationMode &&
                            mainController.isTranslating)
                        {
                            serverAdapter.SendObjectUpdate(this, ParameterType.POS);
                        }
                    }
                    else
#endif
                    serverAdapter.SendObjectUpdate(this, ParameterType.POS);

                    if (isPhysicsActive)
                    {
                        isPhysicsActive = false;
                        serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                        serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                    }
                }

                //publish rotation change
                if (mainController.liveMode)
#endif
                {
                    if (rotationStillFrameCount == 0) //position just changed
                    {
                        if (!selected && !isPlayingAnimation && !isPhysicsActive && !rigidbody.isKinematic)
                        {
                            isPhysicsActive = true;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }

#if !SCENE_HOST
                        if (isAnimatedCharacter)
                        {
                            if (mainController.ActiveMode == MainController.Mode.rotationMode &&
                                mainController.isRotating)
                            {
                                serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                            }
                        }
                        else
#endif
                        serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                    }
                    else  //update delayed, but object not moving
                    {
                        if (isPhysicsActive)
                        {
                            isPhysicsActive = false;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }
                    }
                }
#if !SCENE_HOST
                else if (rotationStillFrameCount == 10) //object is now no longer moving
                {
                    if (isPhysicsActive)
                    {
                        isPhysicsActive = false;
                        serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                        serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                    }

#if !SCENE_HOST
                    if (isAnimatedCharacter)
                    {
                        if (mainController.ActiveMode == MainController.Mode.rotationMode &&
                            mainController.isRotating)
                        {
                            serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                        }
                    }
                    else
#endif
                    serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                }
#endif
            }
        }
コード例 #5
0
ファイル: SceneObject.cs プロジェクト: SatishGodaPearl/VPET
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            if (lastPosition != target.localPosition)
            {
                lastPosition = target.localPosition;
                translationStillFrameCount = 0;
            }
            else if (translationStillFrameCount < 11)
            {
                translationStillFrameCount++;
            }
            if (lastRotation != target.localRotation)
            {
                lastRotation            = target.localRotation;
                rotationStillFrameCount = 0;
            }
            else if (rotationStillFrameCount < 11)
            {
                rotationStillFrameCount++;
            }
            if (translationStillFrameCount >= 10 && rotationStillFrameCount >= 10 && tempLock)
            {
                tempLock = false;
            }
            if (!locked && !tempLock && !mainController.lockScene)
            {
                //publish translation change
                if (mainController.liveMode)
                {
                    if (translationStillFrameCount == 0)                     //position just changed
                    {
                        if ((Time.time - lastTranslationUpdateTime) >= updateIntervall)
                        {
                            // serverAdapter.sendTranslation(target, target.position, !selected);
                            serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);

                            lastTranslationUpdateTime = Time.time;
                            translationUpdateDelayed  = false;
                        }
                        else
                        {
                            translationUpdateDelayed = true;
                        }
                    }
                    else if (translationUpdateDelayed)                     //update delayed, but object not moving
                    {
                        // serverAdapter.sendTranslation(target, target.position, !selected);
                        serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);

                        lastTranslationUpdateTime = Time.time;
                        translationUpdateDelayed  = false;
                    }
                }
                else if (translationStillFrameCount == 10)                 //object is now no longer moving
                {
                    // serverAdapter.sendTranslation(target, target.position, !selected);
                    serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);
                }

                //publish rotation change
                if (mainController.liveMode)
                {
                    if (rotationStillFrameCount == 0)                     //position just changed
                    {
                        if ((Time.time - lastRotationUpdateTime) >= updateIntervall)
                        {
                            // serverAdapter.sendRotation(target, target.rotation, !selected);
                            serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);



                            lastRotationUpdateTime = Time.time;
                            rotationUpdateDelayed  = false;
                        }
                        else
                        {
                            rotationUpdateDelayed = true;
                        }
                    }
                    else if (rotationUpdateDelayed)                     //update delayed, but object not moving
                    {
                        //serverAdapter.sendRotation(target, target.rotation, !selected);
                        serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);

                        lastRotationUpdateTime = Time.time;
                        rotationUpdateDelayed  = false;
                    }
                }
                else if (rotationStillFrameCount == 10)                 //object is now no longer moving
                {
                    // serverAdapter.sendRotation(target, target.rotation, !selected);
                    serverAdapter.SendObjectUpdate(target, !selected && !isPlayingAnimation);
                }
            }

            //turn on highlight modes
            if (selected && drawGlowAgain)
            {
                if (lightGeo)
                {
                    lightGeo.GetComponent <Renderer>().enabled = true;
                    this.showHighlighted(lightGeo.gameObject);
                }
                else
                {
                    this.showHighlighted(this.gameObject);
                }
                drawGlowAgain = false;
            }

            //turn off highlight mode
            else if (!selected && !drawGlowAgain)
            {
                if (lightGeo)
                {
                    lightGeo.GetComponent <Renderer>().enabled = false;
                }

                this.showNormal(this.gameObject);
                drawGlowAgain = true;
            }

            //execute smooth translate
            if (smoothTranslationActive)
            {
                target.position = Vector3.Lerp(target.position, targetTranslation, Time.deltaTime * translationDamping);
                if (Vector3.Distance(target.position, targetTranslation) < 0.0001f)
                {
                    target.position = targetTranslation;
                    // HACK: to key pointToMove
                    //
                    //if ( mainController.UIAdapter.LayoutUI == layouts.ANIMATION )
                    //   animationController.setKeyFrame();
                    smoothTranslationActive = false;
                }
                if ((Time.time - smoothTranslateTime) > 3.0f)
                {
                    smoothTranslationActive = false;
                    // HACK: to key pointToMove
                    //
                    //if (mainController.UIAdapter.LayoutUI == layouts.ANIMATION)
                    //    animationController.setKeyFrame();
                }
            }
        }
コード例 #6
0
ファイル: SceneObject.cs プロジェクト: iVerb/VPET
        //!
        //! Update is called once per frame
        //!
        protected void Update()
        {
#if !SCENE_HOST
            if (mainController.ActiveMode != MainController.Mode.objectLinkCamera)
            {
                if (!AlmostEqualPos(lastPosition, target.localPosition, 0.1f))
                {
                    lastPosition = target.localPosition;
                    translationStillFrameCount = 0;
                }
                else if (translationStillFrameCount < 11)
                {
                    translationStillFrameCount++;
                }
                if (!AlmostEqualRot(lastRotation, target.localRotation, 0.1f))
                {
                    lastRotation            = target.localRotation;
                    rotationStillFrameCount = 0;
                }
                else if (rotationStillFrameCount < 11)
                {
                    rotationStillFrameCount++;
                }
            }
            else
#endif
            {
                if (!AlmostEqualPos(lastPosition, target.position, 0.1f))
                {
                    lastPosition = target.position;
                    translationStillFrameCount = 0;
                }
                else if (translationStillFrameCount < 11)
                {
                    translationStillFrameCount++;
                }
                if (!AlmostEqualRot(lastRotation, target.rotation, 0.1f))
                {
                    lastRotation            = target.rotation;
                    rotationStillFrameCount = 0;
                }
                else if (rotationStillFrameCount < 11)
                {
                    rotationStillFrameCount++;
                }
            }
#if !SCENE_HOST
            if (!locked && !mainController.lockScene)
            {
#else
            if (!locked)
            {
#endif
#if !SCENE_HOST
                //publish translation change
                if (mainController.liveMode)
#endif
                {
                    if (translationStillFrameCount == 0)                     //position just changed
                    {
                        if ((Time.time - lastTranslationUpdateTime) >= updateIntervall)
                        {
                            if (!selected && !isPlayingAnimation && !isPhysicsActive && !rigidbody.isKinematic)
                            {
                                isPhysicsActive = true;
                                serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                                serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                            }

                            serverAdapter.SendObjectUpdate(this, ParameterType.POS);

                            lastTranslationUpdateTime = Time.time;
                            translationUpdateDelayed  = false;
                        }
                        else
                        {
                            translationUpdateDelayed = true;
                        }
                    }
                    else                      //update delayed, but object not moving
                    {
                        if (translationUpdateDelayed)
                        {
                            serverAdapter.SendObjectUpdate(this, ParameterType.POS);

                            lastTranslationUpdateTime = Time.time;
                            translationUpdateDelayed  = false;
                        }
                        if (isPhysicsActive)
                        {
                            isPhysicsActive = false;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }
                    }
                }
#if !SCENE_HOST
                else if (translationStillFrameCount == 10) //object is now no longer moving
                {
                    serverAdapter.SendObjectUpdate(this, ParameterType.POS);

                    if (isPhysicsActive)
                    {
                        isPhysicsActive = false;
                        serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                        serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                    }
                }

                //publish rotation change
                if (mainController.liveMode)
#endif
                {
                    if (rotationStillFrameCount == 0) //position just changed
                    {
                        if ((Time.time - lastRotationUpdateTime) >= updateIntervall)
                        {
                            if (!selected && !isPlayingAnimation && !isPhysicsActive && !rigidbody.isKinematic)
                            {
                                isPhysicsActive = true;
                                serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                                serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                            }

                            serverAdapter.SendObjectUpdate(this, ParameterType.ROT);

                            lastRotationUpdateTime = Time.time;
                            rotationUpdateDelayed  = false;
                        }
                        else
                        {
                            rotationUpdateDelayed = true;
                        }
                    }
                    else  //update delayed, but object not moving
                    {
                        if (rotationUpdateDelayed)
                        {
                            serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                            lastRotationUpdateTime = Time.time;
                            rotationUpdateDelayed  = false;
                        }

                        if (isPhysicsActive)
                        {
                            isPhysicsActive = false;
                            serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                            serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                        }
                    }
                }
#if !SCENE_HOST
                else if (rotationStillFrameCount == 10) //object is now no longer moving
                {
                    if (isPhysicsActive)
                    {
                        isPhysicsActive = false;
                        serverAdapter.SendObjectUpdate(this, ParameterType.HIDDENLOCK);
                        serverAdapter.SendObjectUpdate(this, ParameterType.KINEMATIC);
                    }

                    serverAdapter.SendObjectUpdate(this, ParameterType.ROT);
                }
#endif
            }

            //turn on highlight modes
            if (selected && drawGlowAgain)
            {
                if ((this.GetType() == typeof(SceneObject)) ||
                    (this.GetType() == typeof(SceneObjectCamera)))
                {
                    this.showHighlighted(this.gameObject);
                }
                if (this.GetType() != typeof(SceneObjectLight))
                {
                    drawGlowAgain = false;
                }
            }

            //turn off highlight mode
            else if (!selected && !drawGlowAgain && this.GetType() != typeof(SceneObjectLight))
            {
                this.showNormal(this.gameObject);
                drawGlowAgain = true;
            }

            //execute smooth translate
            if (smoothTranslationActive)
            {
                target.position = Vector3.Lerp(target.position, targetTranslation, Time.deltaTime * translationDamping);
                if (Vector3.Distance(target.position, targetTranslation) < 0.0001f)
                {
                    target.position = targetTranslation;
                    // HACK: to key pointToMove
                    //
                    //if ( mainController.UIAdapter.LayoutUI == layouts.ANIMATION )
                    //   animationController.setKeyFrame();
                    smoothTranslationActive = false;
                }
                if ((Time.time - smoothTranslateTime) > 3.0f)
                {
                    smoothTranslationActive = false;
                    // HACK: to key pointToMove
                    //
                    //if (mainController.UIAdapter.LayoutUI == layouts.ANIMATION)
                    //    animationController.setKeyFrame();
                }
            }
        }
コード例 #7
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            //Camera.main.nearClipPlane = Mathf.Max(0.1f, Vector3.Distance(Camera.main.transform.position, scene.transform.position) - VPETSettings.Instance.maxExtend * VPETSettings.Instance.sceneScale);
            //Camera.main.farClipPlane = Mathf.Max(100f,Mathf.Min(100000f, Vector3.Distance(Camera.main.transform.position, scene.transform.position) + VPETSettings.Instance.maxExtend * VPETSettings.Instance.sceneScale));
            mainController.UpdatePropertiesSecondaryCameras();

            //forward changes of the fov to the secondary (render in front) camera
            Camera frontCamera = this.transform.GetChild(0).GetComponent <Camera>();

            frontCamera.fieldOfView = this.GetComponent <Camera>().fieldOfView;

            //forward changes of the fov to the third (overlay) camera
            if (frontCamera.transform.childCount > 0)
            {
                Camera outlineCamera = frontCamera.transform.GetChild(0).GetComponent <Camera>();
                outlineCamera.fieldOfView = this.GetComponent <Camera>().fieldOfView;
            }

            //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)
                    {
                        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
                //reset rotation of attached gameObjects and send update to server if neccessary
                if (this.transform.childCount > 1)
                {
                    this.transform.GetChild(1).rotation = childrotationBuffer;
                    if (this.transform.GetChild(1).position != lastPosition)
                    {
                        //only sends updates every 30 times per second (at most)
                        if ((Time.time - lastUpdateTime) >= updateIntervall)
                        {
                            lastUpdateTime = Time.time;
                            lastPosition   = this.transform.GetChild(1).position;
                            // serverAdapter.sendTranslation(this.transform.GetChild(1) );
                            serverAdapter.SendObjectUpdate(this.transform.GetChild(1));
                        }
                    }
                }

                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;
                }
            }

            //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;
                }
            }
        }