コード例 #1
0
ファイル: NetworkClient.cs プロジェクト: perdsoul/unityServer
    IEnumerator SyncClientAttribute()
    {
        while (true)
        {
            ClientObjectAttribute clientObjAttribute = new ClientObjectAttribute();

            clientObjAttribute.CameraPosX = Launcher.instance.sceneCamera.transform.position.x;
            clientObjAttribute.CameraPosY = Launcher.instance.sceneCamera.transform.position.y;
            clientObjAttribute.CameraPosZ = Launcher.instance.sceneCamera.transform.position.z;

            clientObjAttribute.CameraRotX = Launcher.instance.sceneCamera.transform.rotation.eulerAngles.x;
            clientObjAttribute.CameraRotY = Launcher.instance.sceneCamera.transform.rotation.eulerAngles.y;
            clientObjAttribute.CameraRotZ = Launcher.instance.sceneCamera.transform.rotation.eulerAngles.z;

            //clientObjAttribute.LightPosX = Launcher.instance.dynLight.transform.position.x;
            //clientObjAttribute.LightPosY = Launcher.instance.dynLight.transform.position.y;
            //clientObjAttribute.LightPosZ = Launcher.instance.dynLight.transform.position.z;

            SendRawData(new XPacket((ushort)eMsgID.C2S_AttributeStream, 300, 300), MsgNoteUtils.StructToBytes(clientObjAttribute));

            yield return(new WaitForSeconds(0.1f));
        }

        yield return(new AsyncOperation());
    }
コード例 #2
0
 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)));
     }
 }
コード例 #3
0
ファイル: LocalServer.cs プロジェクト: 6453Zafir/LightLayout
    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()));
                }
            }
        }
    }