Exemplo n.º 1
0
        /// <summary>
        /// 同步动画
        /// </summary>
        /// <param name="type">类型</param>
        /// <param name="objId">对象id, 数字人时穿null</param>
        /// <param name="animId">动画id</param>
        public void SyncAnimation(SyncType type, string objId, int animId)
        {
            string     rid;
            MqttHelper mqttHelper = ChooseMqtt(type, out rid);

            if (mqttHelper == null)
            {
                return;
            }

            SyncAnim syncAnim = new SyncAnim();

            syncAnim.type = type;
            if (type == SyncType.VirtualMan)
            {
                syncAnim.id = this.uid;
            }
            else
            {
                syncAnim.id = objId;
            }
            syncAnim.amimid = animId;
            syncAnim.time   = TimeHelper.GetTimestamp();

            byte[] cmd = EncodeStruct <SyncAnim>(syncAnim);

            SendCmdMessage(mqttHelper, rid, NetCmdIdClient.SyncAnim, cmd);
        }
Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 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;
                }
            }
        }