コード例 #1
0
ファイル: ServerAdapter.cs プロジェクト: 6eye/VPET
        //!
        //! Update is called once per frame
        //!
        void Update()
        {
            // if we received new objects build them
            if (receiveObjectQueue.Count > 0)
            {
                int count = 0;
                for (int i = 0; i < receiveObjectQueue.Count; i++)
                {
                    try
                    {
                        print("sceneLoader.createSceneGraph ");
                        sceneLoader.createSceneGraph(receiveObjectQueue[i]);

                        // HACK
                        mainController.repositionCamera();
                        // Camera.main.GetComponent<MoveCamera>().calibrate();
                    }
                    catch (IndexOutOfRangeException e)
                    {
                        print("Exception: " + e.ToString());
                    }
                    count++;
                }
                receiveObjectQueue.RemoveRange(0, count);
            }

            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
ファイル: ServerAdapter.cs プロジェクト: SatishGodaPearl/VPET
        //!
        //! 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;
        }
コード例 #3
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");
                sceneLoader.createSceneGraph( );
                sendUpdateObjects();
                // HACK
                mainController.repositionCamera();
                // Camera.main.GetComponent<MoveCamera>().calibrate();
            }

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

            currentTimeTime = Time.time;
        }
コード例 #4
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;
        }