예제 #1
0
        /// <summary>
        /// 锚点上传完成通知服务器和其他客户端
        /// </summary>
        /// <param name="anchor">锚点名称</param>
        public void UploadAnchorDone(string anchor, float floorY)
        {
            if (spectatorViewNetState == NetState.Connect)
            {
                //SaveRoomCache saveRoomCache = new SaveRoomCache();
                //saveRoomCache.id = (int)NetCmdId.SaveRoomCache;
                //saveRoomCache.data = new SaveRoomCache.ResultBean();
                //saveRoomCache.data.rid = spectatorViewRid;
                //saveRoomCache.data.key = RoomCacheKey.RoomCacheKeyAnchor;
                //saveRoomCache.data.value = anchor;

                //string json = JsonConvert.SerializeObject(saveRoomCache);
                //spectatorViewMqtt.PublishMsg(MessageType.System, SystemTargetId, json, new MqttSendMsgDelegate((bool res) =>
                //{
                //}));

                //SaveRoomCache saveRoomCache = new SaveRoomCache();
                //saveRoomCache.id = (int)NetCmdId.SaveRoomCache;
                //saveRoomCache.data = new SaveRoomCache.ResultBean();
                //saveRoomCache.data.rid = spectatorViewRid;
                //saveRoomCache.data.key = RoomCacheKey.RoomCacheKeyFloorY;
                //saveRoomCache.data.value = floorY.ToString();

                //string json = JsonConvert.SerializeObject(saveRoomCache);
                //spectatorViewMqtt.PublishMsg(MessageType.System, SystemTargetId, json, new MqttSendMsgDelegate((bool res) =>
                //{
                //}));

                //FloorLocated floorLocated = new FloorLocated();
                //floorLocated.rid = spectatorViewRid;
                //floorLocated.y = floorY;
                //byte[] cmd = EncodeStruct<FloorLocated>(floorLocated);

                //SendCmdMessage(spectatorViewMqtt, spectatorViewRid, NetCmdIdClient.FloorLocated, cmd);

                // 通知房间成员下载
                AnchorUploaded anchorUploaded = new AnchorUploaded();
                anchorUploaded.rid    = spectatorViewRid;
                anchorUploaded.anchor = anchor;

                byte[] cmd = EncodeStruct <AnchorUploaded>(anchorUploaded);
                SendCmdMessage(spectatorViewMqtt, spectatorViewRid, NetCmdIdClient.AnchorUploaded, cmd);
                MYDialog.Instance.Write("已通知房间内的所有hololens成员下载 空间锚点 \r\n待其它端hololens文字" +
                                        "\r\n与当前您看到的文字位置相同时,同步锚点完成\r\n锚点同步完成后才可进行生成物体操作" /*+ anchor,false*/);

                //VirtualManManager._instance.ShowMixedMode();
            }
        }
예제 #2
0
        private void NetWork_onReceiveCmd(string rid, NetCmdIdClient cid, object cmd)
        {
            if (rid != null && rid.Equals(this.roomId))
            {
                switch (cid)
                {
                case NetCmdIdClient.None:
                    break;

                case NetCmdIdClient.AnchorUploaded:
                {
                    if (clientType != ClientType.SpectatorViewPc &&
                        clientType != ClientType.IOS)
                    {
                        AnchorUploaded clientCmd = (AnchorUploaded)cmd;


                        this.anchorName = clientCmd.anchor;
                        OperationBean oper = new OperationBean();
                        oper.op    = OperationBean.OpId.DownAnchor;
                        oper.param = anchorName;

                        operationQueue.Enqueue(oper);
                    }
                }
                break;

                case NetCmdIdClient.TakeControlPower:
                {
                    //TakeControlPower clientCmd = (TakeControlPower)cmd;
                }
                break;

                case NetCmdIdClient.SyncPos:
                {
                    SyncPos clientCmd = (SyncPos)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            SpectatorViewPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvPosition(new Vector3(clientCmd.px, clientCmd.py, clientCmd.pz), clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncRotate:
                {
                    SyncRotate clientCmd = (SyncRotate)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            SpectatorViewPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.OnRecvRotation(new Vector3(clientCmd.rx, clientCmd.ry, clientCmd.rz), clientCmd.time);
                            }
                        }
                    }
                }
                break;

                case NetCmdIdClient.SyncAnim:
                {
                    SyncAnim clientCmd = (SyncAnim)cmd;
                    if (clientCmd.type == SyncType.SpectatorView)
                    {
                    }
                }
                break;

                case NetCmdIdClient.OtherCmd:
                {
                    OtherCmd      clientCmd = (OtherCmd)cmd;
                    OperationBean op        = new OperationBean();
                    op.op    = OperationBean.OpId.OtherCmd;
                    op.param = clientCmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.FloorLocated:
                {
                    FloorLocated clientCmd = (FloorLocated)cmd;
                    _lerpStageWithFloor = clientCmd.y;

                    Vector3 v = new Vector3(clientCmd.x, clientCmd.y, clientCmd.z);

                    //TODO---->>>> GeMesCar测试数据
                    //ipad
                    if (clientType == ClientType.IOS)
                    {
                        OperationBean op = new OperationBean();
                        op.op    = OperationBean.OpId.ios_AdjustFloorLocate;
                        op.param = v;
                        operationQueue.Enqueue(op);
                    }
                    else
                    {
                        OperationBean op = new OperationBean();
                        op.op    = OperationBean.OpId.hololens_AdjustFloorLocate;
                        op.param = v;
                        operationQueue.Enqueue(op);
                    }
                    Debug.Log("收到creater定位地面的消息-->>>>>    " + v.ToString());
                }
                break;

                case NetCmdIdClient.MarkerGenerated:
                {
                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.MarkerGenerated;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.MarkerDetected:
                {
                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.MarkerDetected;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;

                case NetCmdIdClient.SyncWorldRoot:
                {
                    Debug.Log("SpectatorViewManager#NetWork_onReceiveCmd#SyncWorldRoot");

                    OperationBean op = new OperationBean();
                    op.op    = OperationBean.OpId.SyncWorldRoot;
                    op.param = cmd;
                    operationQueue.Enqueue(op);
                }
                break;
                }
            }
        }