コード例 #1
0
 void Start()
 {
     PMT        = PhotonMeshTransfer.getSingleton();
     m_Observer = new SurfaceObserver();
     m_Observer.SetVolumeAsSphere(new Vector3(0.0f, 0.0f, 0.0f), 200.0f);
     SurfacesList     = new List <SurfaceEntry>();
     m_Surfaces       = new Dictionary <int, SurfaceEntry>();
     m_WaitingForBake = false;
     m_lastUpdateTime = 0.0f;
     S = this;
 }
コード例 #2
0
    private void FixedUpdate()
    {
        if (!PhotonNetwork.InRoom)
        {
            return;
        }
        if (PMT == null)
        {
            PMT = PhotonMeshTransfer.getSingleton();
        }
        //DONT PISS OFF PHOTON BY SENDING TOO FREQUENTLY! THEY WILL KICK YOU!
        if (lastMeshDownlinkTime + deltaTimeAveraged + deltaTimeAveraged * 0.001f * lastMeshSize * (ConnectAndJoinSpaace.disconnectCount + 1) < Time.realtimeSinceStartup)
        {
            SurfacesList.Sort();
            // you can't block here and wait for the camera capture.
            // Send the old data and trigger a new capture.
            // NetworkMeshSource.getSingleton()
            for (int index = 0; index < SurfacesList.Count; index++)
            {
                SurfaceEntry item = SurfacesList[index];
                if (item.m_BakedState == BakedState.Baked || item.m_BakedState == BakedState.UpdatePostBake)
                {
                    //Debug.LogWarning("Mesh " + item.m_Id + " has baked state " + item.m_BakedState);
                    GameObject go = item.m_Surface;
                    if (go)
                    {
                        MeshFilter[] meshFilters = go.GetComponents <MeshFilter>();
                        for (int mfi = 0; mfi < meshFilters.Length; mfi++)
                        {
                            MeshFilter MFer = meshFilters[mfi];

                            if (MFer)
                            {
                                //Debug.LogWarning("Mesh " + item.m_Id + " has a mesh filter");
                                Mesh meesh = MFer.mesh;
                                if (meesh && meesh.triangles.Length > 0)
                                {
                                    //Debug.LogWarning("Mesh " + item.m_Id +" is of length "+ meesh.triangles.Length);
                                    if (Time.realtimeSinceStartup - item.lastSentTime > 30.0f)
                                    {
                                        if (PMT == null)
                                        {
                                            Debug.LogWarning("PMT IS NULL! Can't send mesh " + item.m_Id);
                                        }
                                        //just send one and return;
                                        item.lastSentTime = lastMeshDownlinkTime = Time.realtimeSinceStartup;
                                        PMT.sendMesh(go.transform.position, go.transform.rotation, meesh);
                                        lastMeshSize = meesh.triangles.Length;

                                        //add any meshes we send to the minimap
                                        MiniMapHandler.getSingleton().addElement(meesh, go.transform.position, go.transform.rotation);
                                        //Debug.LogWarning("Mesh transer initiated on index " + item.m_Id);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            lastMeshDownlinkTime = Time.realtimeSinceStartup;
        }
    }