Пример #1
0
    void receiveMeshData(Vector3 pos, Quaternion rot, Vector3[] verts, int[] indecieies)
    {
        Debug.Log(pos);
        Debug.Log(verts[2]);
        Debug.Log(indecieies[3]);

        GameObject newMesh = GameObject.Instantiate(meshPrefab);

        newMesh.transform.position = pos;
        newMesh.transform.rotation = rot;
        Mesh meesh = new Mesh();

        meesh.vertices = verts;
        meesh.SetIndices(indecieies, MeshTopology.Triangles, 0);
        meesh.RecalculateBounds();
        meesh.RecalculateNormals();
        meesh.RecalculateTangents();
        newMesh.GetComponent <MeshFilter>().mesh       = meesh;
        newMesh.GetComponent <MeshRenderer>().material = meshMaterial;
        MiniMapHandler.getSingleton().addElement(meesh, pos, rot);
    }
Пример #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;
        }
    }