예제 #1
0
        public void SendPlayerTransform(MixerUser info)
        {
            NetCommand command = MixerUtils.BuildSendPlayerTransform(info);

            if (null != command)
            {
                AddCommand(command);
            }
        }
예제 #2
0
        public static void SetMasterId(string id)
        {
            MixerUser user = (MixerUser)GlobalState.networkUser;

            if (null == user)
            {
                return;
            }
            user.masterId = id;
        }
예제 #3
0
        public static string GetMasterId()
        {
            MixerUser user = (MixerUser)GlobalState.networkUser;

            if (null == user)
            {
                return("");
            }
            return(user.masterId);
        }
예제 #4
0
        public void SendUserInfo(Vector3 cameraPosition, Vector3 cameraForward, Vector3 cameraUp, Vector3 cameraRight)
        {
            MixerUser user = (MixerUser)GlobalState.networkUser;

            if (null == user)
            {
                return;
            }

            Vector3 upRight     = cameraPosition + cameraForward + cameraUp + cameraRight;
            Vector3 upLeft      = cameraPosition + cameraForward + cameraUp - cameraRight;
            Vector3 bottomRight = cameraPosition + cameraForward - cameraUp + cameraRight;
            Vector3 bottomLeft  = cameraPosition + cameraForward - cameraUp - cameraRight;

            user.corners[0] = SceneManager.RightHanded.InverseTransformPoint(upLeft);
            user.corners[1] = SceneManager.RightHanded.InverseTransformPoint(upRight);
            user.corners[2] = SceneManager.RightHanded.InverseTransformPoint(bottomRight);
            user.corners[3] = SceneManager.RightHanded.InverseTransformPoint(bottomLeft);
            MixerClient.Instance.SendPlayerTransform(user);
        }
예제 #5
0
파일: JsonData.cs 프로젝트: ubisoft/vrtist
        // {
        //     "user_scenes": {
        //         "Scene": {
        //             "frame": 67,
        //             "selected_objects": [],
        //             "views": {
        //                 "1662222059768": {
        //                     "eye": [21.046432495117188, -5.221196174621582, 5.855473041534424],
        //                     "target": [1.233099102973938, 0.9093819260597229, -0.12044590711593628],
        //                     "screen_corners": [
        //                         [20.247392654418945, -5.561498641967773, 5.3597612380981445],
        //                         [20.58077621459961, -4.4979352951049805, 5.345513820648193],
        //                         [20.424291610717773, -4.441169261932373, 5.922540664672852],
        //                         [20.090919494628906, -5.504717826843262, 5.936784267425537]
        //                     ]
        //                 }
        //             }
        //         }
        //     }
        // }
        public static string CreateJsonPlayerInfo(MixerUser user)
        {
            if (null == user.id || null == user.viewId)
            {
                return(null);
            }
            string json = "{\"user_scenes\": {" +
                          "\"Scene\": {" +
                          "\"frame\": 1," +
                          "\"selected_objects\": []," +
                          "\"views\": {" +
                          $"\"{user.viewId}\": {{" +
                          $"\"eye\": [{user.position.ToString().Substring(1, user.position.ToString().Length - 2)}]," +
                          $"\"target\": [{user.target.ToString().Substring(1, user.target.ToString().Length - 2)}]," +
                          "\"screen_corners\": [" +
                          $"[{user.corners[0].ToString().Substring(1, user.corners[0].ToString().Length - 2)}]" +
                          $", [{user.corners[1].ToString().Substring(1, user.corners[1].ToString().Length - 2)}]" +
                          $", [{user.corners[2].ToString().Substring(1, user.corners[2].ToString().Length - 2)}]" +
                          $", [{user.corners[3].ToString().Substring(1, user.corners[3].ToString().Length - 2)}]]" +
                          "}}}}}";

            return(json);
        }
예제 #6
0
        public static void ListAllClients(string json)
        {
            List <ClientInfo> clients = JsonHelper.GetClientsInfo(json);

            foreach (ClientInfo client in clients)
            {
                // Invalid client
                if (!client.id.IsValid)
                {
                    continue;
                }

                // Ignore ourself
                if (client.id.value == GlobalState.networkUser.id)
                {
                    continue;
                }

                if (client.room.IsValid)
                {
                    // Only consider clients in our room
                    if (client.room.value != GlobalState.networkUser.room)
                    {
                        continue;
                    }

                    // Retrieve the viewId (one of possible - required to send data)
                    MixerUser player = (MixerUser)GlobalState.networkUser;
                    if (client.viewId.IsValid && null == player.viewId)
                    {
                        player.viewId = client.viewId.value;
                    }

                    // Add client to the list of connected users in our room
                    if (!GlobalState.HasConnectedUser(client.id.value))
                    {
                        MixerUser newUser = new MixerUser
                        {
                            id = client.id.value
                        };
                        if (client.userName.IsValid)
                        {
                            newUser.name = client.userName.value;
                        }
                        if (client.userColor.IsValid)
                        {
                            newUser.color = client.userColor.value;
                        }
                        if (client.eye.IsValid)
                        {
                            newUser.position = client.eye.value;
                        }
                        if (client.target.IsValid)
                        {
                            newUser.target = client.target.value;
                        }
                        GlobalState.AddConnectedUser(newUser);
                    }
                }
            }
        }
예제 #7
0
        public static void UpdateClient(string json)
        {
            ClientInfo client = JsonHelper.GetClientInfo(json);

            if (client.id.IsValid)
            {
                // Ignore info on ourself
                if (client.id.value == GlobalState.networkUser.id)
                {
                    return;
                }

                if (client.room.IsValid)
                {
                    // A client may leave the room
                    if (client.room.value == "null")
                    {
                        GlobalState.RemoveConnectedUser(client.id.value);
                        return;
                    }

                    // Ignore other room messages
                    if (client.room.value != GlobalState.networkUser.room)
                    {
                        return;
                    }

                    // Add client to the list of connected users in our room
                    if (!GlobalState.HasConnectedUser(client.id.value))
                    {
                        MixerUser newUser = new MixerUser
                        {
                            id = client.id.value
                        };
                        GlobalState.AddConnectedUser(newUser);
                    }
                }

                // Get client connected to our room
                if (!GlobalState.HasConnectedUser(client.id.value))
                {
                    return;
                }
                MixerUser user = (MixerUser)GlobalState.GetConnectedUser(client.id.value);

                // Retrieve the viewId (one of possible - required to send data)
                MixerUser player = (MixerUser)GlobalState.networkUser;
                if (client.viewId.IsValid && null == player.viewId)
                {
                    player.viewId = client.viewId.value;
                }

                if (client.userName.IsValid)
                {
                    user.name = client.userName.value;
                }
                if (client.userColor.IsValid)
                {
                    user.color = client.userColor.value;
                }

                bool changed = false;

                // Get its eye position
                if (client.eye.IsValid)
                {
                    user.position = client.eye.value;
                    changed       = true;
                }

                // Get its target look at
                if (client.target.IsValid)
                {
                    user.target = client.target.value;
                    changed     = true;
                }

                if (changed)
                {
                    GlobalState.UpdateConnectedUser(user);
                }
            }
        }
예제 #8
0
 public static string CreateJsonPlayerInfo(MixerUser playerInfo)
 {
     return(JsonHelper.CreateJsonPlayerInfo(playerInfo));
 }