public void Update() { if (mRadianceCollector != null) { AttributeData attributeData = null; while ((attributeData = mCloudSocket.DequeueAttributeData()) != null) { var msgHeader = MsgNoteUtils.GetMessageHead(attributeData.RawData); LCRS.Log("msgHeader: " + msgHeader); if (msgHeader == eMsgID.C2S_DGI_Init) { Baker.Instance.Init(); Baker.Instance.SetLightMap(); //不需要传ST了:导出json的时候已经计算好了 //mCloudSocket.EnqueueJsonData(new LightmapSTJsonData(Object.FindObjectsOfType<MeshRenderer>(), eMsgID.S2C_Json_LightmapST)); mCloudSocket.EnqueueJsonData(new LightmapArrayJsonData(eMsgID.S2C_Json_LightmapArray)); } else if (msgHeader == eMsgID.C2D_DGI_RecalcLightmap) { Baker.Instance.Init(); Baker.Instance.SetLightMap(); mCloudSocket.EnqueueJsonData(new LightmapArrayJsonData(eMsgID.S2C_Json_LightmapArray)); } else if (msgHeader == eMsgID.C2S_Json_UpdateObjectPosition) { byte[] clientObjBytes = MsgNoteUtils.GetMessageBody(attributeData.RawData); string jsonStr = Encoding.UTF8.GetString(clientObjBytes); JsonMapper.RegisterExporter <float>((obj, writer) => writer.Write(Convert.ToDouble(obj))); JsonMapper.RegisterImporter <double, float>(input => Convert.ToSingle(input)); ClientSyncObjectData syncObject = JsonMapper.ToObject <ClientSyncObjectData>(jsonStr); Baker.Instance.SyncObjectPosition(syncObject); Baker.Instance.Init(); Baker.Instance.SetLightMap(); mCloudSocket.EnqueueJsonData(new LightmapArrayJsonData(eMsgID.S2C_Json_LightmapArray)); } else { ClientObjectAttribute clientObjAttribute = (ClientObjectAttribute)MsgNoteUtils.BytesToStruct(attributeData.RawData, typeof(ClientObjectAttribute)); int height = (int)clientObjAttribute.Param % mWebClientExchangeCode; int width = (int)clientObjAttribute.Param / mWebClientExchangeCode; LCRS.Log("===================================================== Log: " + width + "==324234234235^%$^%@#R@3: " + (ushort)clientObjAttribute.LightPosZ); // mRadianceCollector.Collect(width, height, clientObjAttribute); // mCloudSocket.EnqueueRadianceData(new RadianceData((ushort)clientObjAttribute.LightPosZ, (ushort)width, (ushort)height, mRadianceCollector.GetRadianceDataInPng())); } } } }
public void Update() { if (mRadianceCollector != null) { if (mCloudSocket.AttributeDataListLength > 0) { Debug.Log("Start Syn View Point"); ClientObjectAttribute clientObjAttribute = mCloudSocket.DequeueAttributeData(); int height = (int)clientObjAttribute.Param % mWebClientExchangeCode; int width = (int)clientObjAttribute.Param / mWebClientExchangeCode; //Debug.Log("Param:" + (int)clientObjAttribute.Param + " ExchangeCode:" + mWebClientExchangeCode); //Debug.Log("Width:" + width +" Height:"+ height); if (times == 1 && File.Exists(firstLoadDataPath + index + ".bin")) { while (File.Exists(firstLoadDataPath + index + ".bin")) { byte[] data = File.ReadAllBytes(firstLoadDataPath + index + ".bin"); //mCloudSocket.EnqueueRadianceData(new RadianceData((ushort)clientObjAttribute.LightPosZ, (ushort)width, (ushort)height, data)); NetworkServer.SendRawData(mCTSMarker, new XPacket((ushort)eMsgID.S2C_RadianceStream, (ushort)width, (ushort)height), data); index++; } } else if (times == 1) { mRadianceCollector.Collect(width, height, clientObjAttribute); mRadianceCollector.SendRadianceData(mCTSMarker, (ushort)clientObjAttribute.LightPosZ, (ushort)width, (ushort)height, ComponentTransformittedSet, ReuseDataInfoObj, true); } else { mRadianceCollector.Collect(width, height, clientObjAttribute); mRadianceCollector.SendRadianceData(mCTSMarker, (ushort)clientObjAttribute.LightPosZ, (ushort)width, (ushort)height, ComponentTransformittedSet, ReuseDataInfoObj, false); } times++; } } }