示例#1
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            // if we received new objects build them
            if (m_sceneTransferDirty)
            {
                m_sceneTransferDirty = false;
                print("sceneLoader.createSceneGraph");
                Vector3    scenePos = scene.position;
                Quaternion scenRot  = scene.rotation;
                scene.rotation = Quaternion.identity;
                scene.position = Vector3.zero;
                sceneLoader.createSceneGraph();
                sendUpdateObjects();
                // HACK
                mainController.repositionCamera();
                mainController.SetSceneScale(VPETSettings.Instance.sceneScale);
                // Camera.main.GetComponent<MoveCamera>().calibrate();

                scene.rotation = scenRot;
                scene.position = scenePos;
            }

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as string);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }
            if (camObject != null && camObject.GetComponent <Renderer>().enabled&& (Time.time - lastNcamReceivedTime) > 10)
            {
                camObject.GetComponent <Renderer>().enabled = false;
            }

            currentTimeTime = Time.time;
        }
示例#2
0
        //!
        //! pinch to zoom gesture (called by Mouse or Touch Input)
        //! @param      delta     delta distance between fingers since last frame
        //!
        public void pinchToZoom(float angle, float distance)
        {
#if USE_AR
            if (mainController.arSetupMode && arFoundation)
            {
                if (!mainController.lockARScale)
                {
                    mainController.SetSceneScale(m_initScale * distance);
                }
                if (!mainController.lockARRotation)
                {
                    arFoundation.rotateAnchor(Quaternion.Euler(0, angle, 0));
                }
            }
#endif
        }
示例#3
0
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
#if !SCENE_HOST
            // if we received new objects build them
            if (m_sceneTransferDirty)
            {
                m_sceneTransferDirty = false;
                print("sceneLoader.createSceneGraph");

                Vector3    scenePos = scene.position;
                Quaternion scenRot  = scene.rotation;
                scene.rotation = Quaternion.identity;
                scene.position = Vector3.zero;

                sceneLoader.createSceneGraph();
                SendObjectUpdate(null, ParameterType.RESENDUPDATE);

                int refListCount = SceneLoader.SceneEditableObjects.Count +
                                   SceneLoader.SelectableLights.Count +
                                   SceneLoader.SceneCameraList.Count;

                sceneObjectRefList = new SceneObject[refListCount];

                foreach (GameObject gameObject in SceneLoader.SceneEditableObjects)
                {
                    Debug.Log(gameObject.name);
                    SceneObject sceneObject = gameObject.GetComponent <SceneObject>();
                    Debug.Log(sceneObject.id + " " + sceneObject.name);
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                foreach (GameObject gameObject in SceneLoader.SelectableLights)
                {
                    SceneObject sceneObject = gameObject.GetComponent <SceneObjectLight>();
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                foreach (GameObject gameObject in SceneLoader.SceneCameraList)
                {
                    SceneObject sceneObject = gameObject.GetComponent <SceneObjectCamera>();
                    GameObject  camGeometry = sceneObject.transform.GetChild(0).gameObject;
                    camGeometry.SetActive(mainController.showCam);
                    if (sceneObjectRefList.Length > sceneObject.id)
                    {
                        sceneObjectRefList[sceneObject.id] = sceneObject;
                    }
                }

                mainController.SetSceneScale(VPETSettings.Instance.sceneScale);
                // Camera.main.GetComponent<MoveCamera>().calibrate();

                scene.rotation = scenRot;
                scene.position = scenePos;

                mainController.repositionCamera();
            }
#endif

            if (!deactivateReceive)
            {
                //process all available transforms send by server & delete them from Queue
                int count = 0;
                for (int i = 0; i < receiveMessageQueue.Count; i++)
                {
                    // Debug.Log(receiveMessageQueue[i] as string);
                    try
                    {
                        parseTransformation(receiveMessageQueue[i] as byte[]);
                    }
                    catch
                    {
                        VPETSettings.Instance.msg = "Error: parseTransformation";
                    }
                    count++;
                }
                receiveMessageQueue.RemoveRange(0, count);
            }

            currentTimeTime = Time.time;
        }