Ejemplo n.º 1
0
        public async void OnGenerateAvatar(int id, AvatarTransform avatarTransform, byte[] avatarData)
        {
            var head      = new GameObject("head");
            var rightHand = new GameObject("rightHand");
            var leftHand  = new GameObject("leftHand");

            head.transform.SetPositionAndRotation(avatarTransform.Head.Position, avatarTransform.Head.Rotation);
            rightHand.transform.SetPositionAndRotation(avatarTransform.RightHand.Position, avatarTransform.RightHand.Rotation);
            leftHand.transform.SetPositionAndRotation(avatarTransform.LeftHand.Position, avatarTransform.LeftHand.Rotation);

            var avatar = new VRMAvatar(head, rightHand, leftHand);
            await avatar.GenerateAvatar(avatarData);

            head.transform.SetParent(avatar.Root.transform);
            rightHand.transform.SetParent(avatar.Root.transform);
            leftHand.transform.SetParent(avatar.Root.transform);

            var synchronizer = avatar.Root.AddComponent <AvatarSynchronizer>();

            synchronizer.SetTargets(avatar.Head, avatar.RightHand, avatar.LeftHand);

            var voiceChat = avatar.Root.AddComponent <VoiceChat>();

            playerSynchronizers[id] = synchronizer;
            playerAvatars[id]       = avatar;
            playerVoiceChats[id]    = voiceChat;
        }
Ejemplo n.º 2
0
 void IGamingHubReceiver.OnSynchronizeAvatar(int id, AvatarTransform transform)
 {
     if (playerSynchronizers.TryGetValue(id, out var synchronizer))
     {
         synchronizer.TargetTransform = transform;
     }
 }
Ejemplo n.º 3
0
        public static AvatarTransform CreateAvatarTransform(Transform headTransform, Transform rightHandTransform, Transform leftHandTransform)
        {
            var head = new ObjectTransform()
            {
                Position = headTransform.position, Rotation = headTransform.rotation
            };
            var rightHand = new ObjectTransform()
            {
                Position = rightHandTransform.position, Rotation = rightHandTransform.rotation
            };
            var leftHand = new ObjectTransform()
            {
                Position = leftHandTransform.position, Rotation = leftHandTransform.rotation
            };
            var avatarTransform = new AvatarTransform()
            {
                Head = head, RightHand = rightHand, LeftHand = leftHand
            };

            return(avatarTransform);
        }
Ejemplo n.º 4
0
 public void SynchronizeAvatar(AvatarTransform avatarTransform)
 {
     hub.SynchronizeAvatarAsync(avatarTransform);
 }