//string firstLoadDataPath = "Assets/StreamingAssets/" + Launcher.instance.GetSceneName + "/firstLoad_"; public LocalServer(CloudSocket cloudSocket, CTSMarker ctsMarker) { mCloudSocket = cloudSocket; mCTSMarker = ctsMarker; switch (Launcher.instance.GIMode) { case eGiMode.Enlighten: mRadianceCollector = new EnlightenRadianceCollector(); break; case eGiMode.RSM: break; case eGiMode.LPV: break; case eGiMode.Visible: mRadianceCollector = new VisibleRadianceCollector(); break; } mRadianceCollector.Setup(); GetReuseDataFile(); }
public static void SendRawData(CTSMarker ctsMarker, MsgPrefix msgNote, byte[] protoBytes) { if (m_Server != null) { m_Server.SendRawData(ctsMarker, msgNote, protoBytes); } }
public override void SendRawData(CTSMarker ctsMarker, MsgPrefix msgNote, byte[] protoBytes) { if (m_LcrsService != null) { if (msgNote.MsgID == (UInt16)eMsgID.S2C_RadianceStream) { LCRS.Log("==================================================== Send data with: " + protoBytes.Length); if (m_SessionDataBufferMap.ContainsKey(ctsMarker.sessionId) == false) { m_SessionDataBufferMap.Add(ctsMarker.sessionId, new AccumDataBuffer(m_LcrsService, ctsMarker.sessionId)); } m_SessionDataBufferMap[ctsMarker.sessionId].PushData(protoBytes); } else if (((eMsgID)msgNote.MsgID).ToString().Contains("Json")) { LCRS.Log("==================================================== Send data with: " + protoBytes.Length); m_LcrsService.Sessions.SendTo(ctsMarker.sessionId, protoBytes); } //m_LcrsService.Sessions.SendToAsync(ctsMarker.sessionId, protoBytes, SendAsyncCompleted); // Debug: save the file //string strSaveFile = Application.dataPath + "/rt_" + System.DateTime.Now.Minute + "_" + System.DateTime.Now.Second + "_web.png"; //FileStream fs = File.Open(strSaveFile, FileMode.Create); //fs.Write(protoBytes, 0, protoBytes.Length); //fs.Close(); } }
public void ProcessAttributeStream(CTSMarker ctsMarker, byte[] msgStream) { if (mTcpToCloudSocketMap.ContainsKey(ctsMarker)) { //mTcpToCloudSocketMap[ctsMarker].EnqueueAttributeData(new AttributeData(msgStream)); mTcpToCloudSocketMap[ctsMarker].UpdateList((ClientObjectAttribute)MsgNoteUtils.BytesToStruct(msgStream, typeof(ClientObjectAttribute))); } }
public override void SendRawData(CTSMarker ctsMarker, XPacket msgNote, byte[] protoBytes) { msgNote.msgSize = (ushort)(ctsMarker.tcpSocket.MsgPrefixLength + (protoBytes != null ? protoBytes.Length : 0)); ctsMarker.tcpSocket.SendData(msgNote, protoBytes); Debug.LogError("================================================= Send data to client"); }
public void ProcessAttributeStream(CTSMarker ctsMarker, byte[] msgStream) { if (mTcpToCloudSocketMap.ContainsKey(ctsMarker)) { mTcpToCloudSocketMap[ctsMarker].EnqueueAttributeData(new AttributeData(msgStream)); LCRS.Log("============================================= Enqueue attribute"); } }
public void RemoveConnection(CTSMarker ctsMarker) { if (mMarkerToCloudConnectionMap.ContainsKey(ctsMarker)) { mCloudConnections.Remove(mMarkerToCloudConnectionMap[ctsMarker]); mMarkerToCloudConnectionMap.Remove(ctsMarker); } }
public CloudConnection(CloudSocket cloudSocket, CTSMarker cTSMarker) { mCloudSocket = cloudSocket; mCTSMarker = cTSMarker; mLocalServer = new LocalServer(cloudSocket, cTSMarker); mRemoteClient = new RemoteClient(cloudSocket); }
public void BuildConnection(CloudSocket cloudSocket, CTSMarker ctsMarker) { CloudConnection cloudConnection = new CloudConnection(cloudSocket); mCloudConnections.Add(cloudConnection); mMarkerToCloudConnectionMap.Add(ctsMarker, cloudConnection); mTcpToCloudSocketMap.Add(ctsMarker, cloudSocket); mCloudToTcpSocketMap.Add(cloudSocket, ctsMarker); }
public virtual void SendRadianceData(CTSMarker ctsmarker, ushort header, ushort width, ushort height, HashSet <string> ComponentTransformittedSet, JObject ReuseDataInfoObject, bool firstLoadStore) { RenderTexture.active = mRenderTexture; Texture2D png = new Texture2D(mRenderTexture.width, mRenderTexture.height, TextureFormat.RGB24, false); png.ReadPixels(new Rect(0, 0, mRenderTexture.width, mRenderTexture.height), 0, 0); byte[] dataBytes = png.EncodeToJPG(); RenderTexture.active = null; }
public void RemoveConnection(CTSMarker ctsMarker) { if (mMarkerToCloudConnectionMap.ContainsKey(ctsMarker)) { mCloudConnections.Remove(mMarkerToCloudConnectionMap[ctsMarker]); mMarkerToCloudConnectionMap.Remove(ctsMarker); //1751578 Launcher.instance.history.RemovePath(ctsMarker.sessionId); //1751578 } }
protected override void OnOpen() { //base.OnOpen(); CTSMarker marker = new CTSMarker(null, this.ID); m_MarkerDic.Add(this.ID, marker); Launcher.instance.connectionMgr.BuildConnection(new CloudSocket(), marker); mUserEndPointInfo = this.Context.UserEndPoint.ToString(); LCRS.Log("========================================================== Connect client: " + this.ID + ", " + this.Context.UserEndPoint); Launcher.instance.stats.Log("Build connection with " + this.Context.UserEndPoint); }
public void BuildConnection(CloudSocket cloudSocket, CTSMarker ctsMarker) { CloudConnection cloudConnection = new CloudConnection(cloudSocket, ctsMarker); mCloudConnections.Add(cloudConnection); mMarkerToCloudConnectionMap.Add(ctsMarker, cloudConnection); mTcpToCloudSocketMap.Add(ctsMarker, cloudSocket); mCloudToTcpSocketMap.Add(cloudSocket, ctsMarker); //1751578 string recordPath = Application.streamingAssetsPath + "/" + Launcher.instance.GetSceneName + "/history.txt"; Launcher.instance.history.getPath(recordPath); Launcher.instance.history.NewPath(ctsMarker.sessionId); //1751578 }
public virtual void SendRawData(CTSMarker ctsMarker, MsgPrefix msgNote, byte[] protoBytes) { }
public override void SendRadianceData(CTSMarker ctsmarker, ushort header, ushort width, ushort height, HashSet <string> ComponentTransformittedSet, JObject ReuseDataInfoObject, bool firstLoadStore) { Debug.Log(header + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); if (Launcher.instance.radianceMgr.mIsPrepaed == false) { return; } RenderTexture.active = mRenderTexture; Texture2D png = new Texture2D(mRenderTexture.width, mRenderTexture.height, TextureFormat.RGB24, false); png.ReadPixels(new Rect(0, 0, mRenderTexture.width, mRenderTexture.height), 0, 0); Color32[] visiblePixels = png.GetPixels32(); ///* string visibleIds = ""; string visibleNames = ""; //统计像素频率 Dictionary <string, int> visAccumulatorDic = new Dictionary <string, int>(); ///* Launcher.instance.radianceMgr.ResetAccumulator(); byte[] allByteData = new byte[0]; string lengthList = ""; int count = 0; int index = 1; string firstLoadStorePath = Application.streamingAssetsPath + "/" + Launcher.instance.GetSceneName + "/firstLoad_"; //string firstLoadStorePath = "Assets/StreamingAssets/" + Launcher.instance.GetSceneName + "/firstLoad_"; for (int i = 0; i < visiblePixels.Length; i++) { //send data per 100 if (count >= 10 || i >= visiblePixels.Length) { Debug.Log("Start Sending Components"); //send data if (header == 66) { lengthList += "1"; Debug.Log("++++++++++++++++++++++++++++"); } else { lengthList += "0"; } lengthList += "//"; byte[] byteLength = System.Text.Encoding.UTF8.GetBytes(lengthList); //Debug.Log(byteLength.Length); //Debug.Log("count:" + count); byte[] byteNeedToSend = new byte[300 + allByteData.Length]; System.Buffer.BlockCopy(byteLength, 0, byteNeedToSend, 0, byteLength.Length); System.Buffer.BlockCopy(allByteData, 0, byteNeedToSend, 300, allByteData.Length); if (firstLoadStore) { File.WriteAllBytes(firstLoadStorePath + index + ".bin", byteNeedToSend); index++; } //socket.EnqueueRadianceData(new RadianceData(header, width, height, byteNeedToSend)); NetworkServer.SendRawData(ctsmarker, new XPacket((ushort)eMsgID.S2C_RadianceStream, width, height), byteNeedToSend); //reset count = 0; allByteData = new byte[0]; lengthList = ""; } string name = Launcher.instance.radianceMgr.mVisibleNames[visiblePixels[i].r, visiblePixels[i].g, visiblePixels[i].b]; if (name == null) { continue; } //替换重用构件名 string[] nameArr = name.Split('/'); string reuseName = (string)ReuseDataInfoObject[nameArr[nameArr.Length - 1]]; if (reuseName != null) { name = name.Replace(nameArr[nameArr.Length - 1], reuseName); } if (!ComponentTransformittedSet.Contains(name)) { byte[] temp = GetGlbData(name); //Debug.Log("send glb:" + name); if (temp.Length == 0) { Debug.Log("can't find component: " + name); continue; } //visibleNames += name + "/"; lengthList += temp.Length.ToString() + "/"; count++; if (allByteData.Length == 0) { allByteData = temp; } else { byte[] newData = new byte[allByteData.Length + temp.Length]; System.Buffer.BlockCopy(allByteData, 0, newData, 0, allByteData.Length); System.Buffer.BlockCopy(temp, 0, newData, allByteData.Length, temp.Length); allByteData = newData; } ComponentTransformittedSet.Add(name); } } }
public virtual void SendRawData(CTSMarker ctsMarker, XPacket msgNote, byte[] protoBytes) { }
public void UpdateList(ClientObjectAttribute clientObjectAttribute) { ConnectionMgr connectionMgr = Launcher.instance.connectionMgr; CTSMarker ctsMarker = connectionMgr.cloudToTcpSocketMap[this]; Launcher.instance.history.UpdateCamera(ctsMarker.sessionId, clientObjectAttribute); //clientObjectAttribute.LightPosZ = 66; if (mList.Count <= 0) { EnqueueAttributeData(clientObjectAttribute); mList.Add(clientObjectAttribute); _count = 0; } else { if (!IsEqual(clientObjectAttribute, mList[mList.Count - 1])) { EnqueueAttributeData(clientObjectAttribute); mList.Add(clientObjectAttribute); _count = 0; Debug.Log(clientObjectAttribute.CameraPosX + " " + clientObjectAttribute.CameraPosY + " " + clientObjectAttribute.CameraPosZ); Debug.Log(clientObjectAttribute.CameraRotX + " " + clientObjectAttribute.CameraRotY + " " + clientObjectAttribute.CameraRotZ); if (!_notPredicted) { //做预测的反馈 double score = Compare(clientObjectAttribute, predictObjectAttribute); // Debug.Log(clientObjectAttribute.CameraPosX+" "+clientObjectAttribute.CameraPosY+" "+ // clientObjectAttribute.CameraPosZ); // Debug.Log(clientObjectAttribute.CameraRotX+" "+clientObjectAttribute.CameraRotY+" "+ // clientObjectAttribute.CameraRotZ); // Debug.Log("偏差值: "+(score/128).ToString("0.00")); // Debug.Log(predictObjectAttribute.CameraPosX+" "+predictObjectAttribute.CameraPosY+" "+ // predictObjectAttribute.CameraPosZ); // Debug.Log(predictObjectAttribute.CameraRotX+" "+predictObjectAttribute.CameraRotY+" "+ // predictObjectAttribute.CameraRotZ); _notPredicted = true; } } //1751578 else { _count++; } if (_count > 5 && _notPredicted) { Debug.Log("!!!!!!!!!!!!!Predict!!!!!!!!!!!!!"); //Record a = Launcher.instance.history.getPredict(ctsMarker.sessionId,clientObjectAttribute); predictObjectAttribute.Param = clientObjectAttribute.Param; //predictObjectAttribute.CameraPosX = (float)a.posX; //predictObjectAttribute.CameraPosY = (float)a.posY; //predictObjectAttribute.CameraPosZ = (float)a.posZ; //predictObjectAttribute.CameraRotX = (float)a.rotX; //predictObjectAttribute.CameraRotY = (float)a.rotY; //predictObjectAttribute.CameraRotZ = (float)a.rotZ; //测试数据 predictObjectAttribute.CameraPosX = (float)-9.745914; predictObjectAttribute.CameraPosY = (float)13.74586; predictObjectAttribute.CameraPosZ = (float)6.888044; predictObjectAttribute.CameraRotX = (float)0.3567473; predictObjectAttribute.CameraRotY = (float)-0.7427009; predictObjectAttribute.CameraRotZ = (float)-0.5666805; //测试结束 predictObjectAttribute.LightPosZ = 66; EnqueueAttributeData(predictObjectAttribute); _notPredicted = false; Debug.Log("!!!!!!!!!!!!!Finish!!!!!!!!!!!!!"); } //1751578 } }