Beispiel #1
0
        /// <summary>
        /// Syncs the rotation.
        /// </summary>
        /// <returns>The rotation.</returns>
        /// <param name="targetId">Target identifier.</param>
        /// <param name="type">Type.</param>
        /// <param name="objId">Object identifier.</param>
        /// <param name="rotation">Rotation.</param>
        public void SyncRotation(string targetId, SyncType type, string objId, Vector3 rotation)
        {
            string     rid;
            MqttHelper mqttHelper = ChooseMqtt(type, out rid);

            if (mqttHelper == null)
            {
                return;
            }

            SyncRotate headRotate = new SyncRotate();

            headRotate.type = type;
            headRotate.id   = objId;
            headRotate.rx   = rotation.x;
            headRotate.ry   = rotation.y;
            headRotate.rz   = rotation.z;
            headRotate.time = TimeHelper.GetTimestamp();

            //Debug.Log("SyncRotation type:" + type + "objid:" + objId + " rot:" + rotation + " time:" + headRotate.time);
            if (_lastRotTime >= headRotate.time)
            {
                Debug.Log("SyncRotation 顺序错误 cur:" + headRotate.time + " last:" + _lastRotTime);
            }
            _lastRotTime = headRotate.time;
            byte[] cmd = EncodeStruct <SyncRotate>(headRotate);
            if (targetId == null)
            {
                SendCmdMessage(mqttHelper, rid, NetCmdIdClient.SyncRotate, cmd);
            }
            else
            {
                SendCmdMessage(mqttHelper, targetId, NetCmdIdClient.SyncRotate, cmd);
            }
        }
Beispiel #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;
                }
            }
        }
Beispiel #3
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:
                {
                    //AnchorUploaded clientCmd = (AnchorUploaded)cmd;
                }
                break;

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

                case NetCmdIdClient.SyncPos:
                {
                    SyncPos clientCmd = (SyncPos)cmd;
                    if (clientCmd.type == SyncType.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            VirtualManPlayer 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))
                        {
                            VirtualManPlayer 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.VirtualMan)
                    {
                        if (PlayerUserList.ContainsKey(clientCmd.id))
                        {
                            VirtualManPlayer player;
                            PlayerUserList.TryGetValue(clientCmd.id, out player);
                            if (player)
                            {
                                player.onRecvAnimation(clientCmd.amimid, clientCmd.time);
                            }
                        }
                    }
                }
                break;

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