Esempio n. 1
0
 public void HandleMeshMessage(OIMSG msg)
 {
     if (msg.msgFamily != (byte)OI_MSGFAMILY.XR)
     {
         return;
     }
     if (msg.msgType == (byte)OI_MSGTYPE_XR.SPATIAL_MESH_ADD)
     {
         MeshStruct ms       = OIMeshSerializer.OIDeserialize(msg.data);
         Transform  existing = GetMeshObject(ms.ID);
         if (existing != null)   // update
         {
             GameObject.Destroy(existing.gameObject);
         }
         AddMeshObject(ms.mesh, ms.ID);
     }
     else if (msg.msgType == (byte)OI_MSGTYPE_XR.SPATIAL_MESH_REMOVE)
     {
         List <int> remove_ids = new List <int>(IdsSerializer.Deserialize(msg.data));
         foreach (int ID in remove_ids)
         {
             Transform existing = GetMeshObject(ID);
             if (existing != null)
             {
                 Destroy(existing.gameObject);
             }
         }
     }
 }
Esempio n. 2
0
        public static MeshStruct OIDeserialize(byte[] data)
        {
            MeshStruct res = new MeshStruct();

            using (MemoryStream stream = new MemoryStream(data)) {
                using (BinaryReader reader = new BinaryReader(stream)) {
                    res.ID = reader.ReadInt32();
                    while (reader.BaseStream.Length - reader.BaseStream.Position >= HeaderSize)
                    {
                        res.mesh = ReadMesh(reader);
                    }
                }
            }

            return(res);
        }