public static void Unquantize(ref AvatarStateQuantized q, out AvatarState s)
 {
     s.clientId     = q.clientId;
     s.headPosition = new Vector3(q.headPositionX, q.headPositionY, q.headPositionZ) * 1.0f / UnitsPerMeter;
     SetQuaternion(out s.headRotation, q.headRotationLargest, q.headRotationX, q.headRotationY, q.headRotationZ);
     s.leftHandPosition           = new Vector3(q.leftHandPositionX, q.leftHandPositionY, q.leftHandPositionZ) * 1.0f / UnitsPerMeter;
     s.leftHandRotation           = SmallestThreeToQuaternion(q.leftHandRotationLargest, q.leftHandRotationX, q.leftHandRotationY, q.leftHandRotationZ);
     s.leftHandGripTrigger        = q.leftHandGripTrigger * 1.0f / MaxTrigger;
     s.leftHandIdTrigger          = q.leftHandIdTrigger * 1.0f / MaxTrigger;
     s.isLeftHandPointing         = q.isLeftHandPointing;
     s.areLeftHandThumbsUp        = q.areLeftHandThumbsUp;
     s.isLeftHandHoldingCube      = q.isLeftHandHoldingCube;
     s.leftHandCubeId             = q.leftHandCubeId;
     s.leftHandOwnershipId        = q.leftHandOwnershipSequence;
     s.leftHandAuthorityId        = q.leftHandAuthoritySequence;
     s.leftHandCubeLocalPosition  = new Vector3(q.leftHandCubeLocalPositionX, q.leftHandCubeLocalPositionY, q.leftHandCubeLocalPositionZ) * 1.0f / UnitsPerMeter;
     s.leftHandCubeLocalRotation  = SmallestThreeToQuaternion(q.leftHandCubeLocalRotationLargest, q.leftHandCubeLocalRotationX, q.leftHandCubeLocalRotationY, q.leftHandCubeLocalRotationZ);
     s.rightHandPosition          = new Vector3(q.rightHandPositionX, q.rightHandPositionY, q.rightHandPositionZ) * 1.0f / UnitsPerMeter;
     s.rightHandRotation          = SmallestThreeToQuaternion(q.rightHandRotationLargest, q.rightHandRotationX, q.rightHandRotationY, q.rightHandRotationZ);
     s.rightHandGripTrigger       = q.rightHandGripTrigger * 1.0f / MaxTrigger;
     s.rightHandIdTrigger         = q.rightHandIndexTrigger * 1.0f / MaxTrigger;
     s.isRightHandPointing        = q.isRightHandPointing;
     s.areRightHandThumbsUp       = q.areRightHandThumbsUp;
     s.isRightHandHoldingCube     = q.isRightHandHoldingCube;
     s.rightHandCubeId            = q.rightHandCubeId;
     s.rightHandOwnershipId       = q.rightHandOwnershipSequence;
     s.rightHandAuthorityId       = q.rightHandAuthoritySequence;
     s.rightHandCubeLocalPosition = new Vector3(q.rightHandCubeLocalPositionX, q.rightHandCubeLocalPositionY, q.rightHandCubeLocalPositionZ) * 1.0f / UnitsPerMeter;
     s.rightHandCubeLocalRotation = SmallestThreeToQuaternion(q.rightHandCubeLocalRotationLargest, q.rightHandCubeLocalRotationX, q.rightHandCubeLocalRotationY, q.rightHandCubeLocalRotationZ);
     s.voiceAmplitude             = q.voiceAmplitude * 1.0f / MaxVoice;
 }
Exemplo n.º 2
0
    public static void Unquantize(ref AvatarStateQuantized quantized, out AvatarState state)
    {
        state.client_index = quantized.client_index;

        state.head_position = new Vector3(quantized.head_position_x, quantized.head_position_y, quantized.head_position_z) * 1.0f / Constants.UnitsPerMeter;

        state.head_rotation = Snapshot.SmallestThreeToQuaternion(quantized.head_rotation_largest,
                                                                 quantized.head_rotation_a,
                                                                 quantized.head_rotation_b,
                                                                 quantized.head_rotation_c);

        state.left_hand_position = new Vector3(quantized.left_hand_position_x, quantized.left_hand_position_y, quantized.left_hand_position_z) * 1.0f / Constants.UnitsPerMeter;

        state.left_hand_rotation = Snapshot.SmallestThreeToQuaternion(quantized.left_hand_rotation_largest,
                                                                      quantized.left_hand_rotation_a,
                                                                      quantized.left_hand_rotation_b,
                                                                      quantized.left_hand_rotation_c);

        state.left_hand_grip_flex  = quantized.left_hand_grip_flex * 1.0f / Constants.FlexMaximum;
        state.left_hand_index_flex = quantized.left_hand_index_flex * 1.0f / Constants.FlexMaximum;
        state.left_hand_pointing   = quantized.left_hand_pointing;
        state.left_hand_thumbs_up  = quantized.left_hand_thumbs_up;

        state.left_hand_holding_cube       = quantized.left_hand_holding_cube;
        state.left_hand_cube_id            = quantized.left_hand_cube_id;
        state.left_hand_ownership_sequence = quantized.left_hand_ownership_sequence;
        state.left_hand_authority_sequence = quantized.left_hand_authority_sequence;

        state.left_hand_cube_local_position = new Vector3(quantized.left_hand_cube_local_position_x, quantized.left_hand_cube_local_position_y, quantized.left_hand_cube_local_position_z) * 1.0f / Constants.UnitsPerMeter;
        state.left_hand_cube_local_rotation = Snapshot.SmallestThreeToQuaternion(quantized.left_hand_cube_local_rotation_largest, quantized.left_hand_cube_local_rotation_a, quantized.left_hand_cube_local_rotation_b, quantized.left_hand_cube_local_rotation_c);

        state.right_hand_position = new Vector3(quantized.right_hand_position_x, quantized.right_hand_position_y, quantized.right_hand_position_z) * 1.0f / Constants.UnitsPerMeter;

        state.right_hand_rotation = Snapshot.SmallestThreeToQuaternion(quantized.right_hand_rotation_largest,
                                                                       quantized.right_hand_rotation_a,
                                                                       quantized.right_hand_rotation_b,
                                                                       quantized.right_hand_rotation_c);

        state.right_hand_grip_flex  = quantized.right_hand_grip_flex * 1.0f / Constants.FlexMaximum;
        state.right_hand_index_flex = quantized.right_hand_index_flex * 1.0f / Constants.FlexMaximum;
        state.right_hand_pointing   = quantized.right_hand_pointing;
        state.right_hand_thumbs_up  = quantized.right_hand_thumbs_up;

        state.right_hand_holding_cube       = quantized.right_hand_holding_cube;
        state.right_hand_cube_id            = quantized.right_hand_cube_id;
        state.right_hand_ownership_sequence = quantized.right_hand_ownership_sequence;
        state.right_hand_authority_sequence = quantized.right_hand_authority_sequence;

        state.right_hand_cube_local_position = new Vector3(quantized.right_hand_cube_local_position_x, quantized.right_hand_cube_local_position_y, quantized.right_hand_cube_local_position_z) * 1.0f / Constants.UnitsPerMeter;
        state.right_hand_cube_local_rotation = Snapshot.SmallestThreeToQuaternion(quantized.right_hand_cube_local_rotation_largest, quantized.right_hand_cube_local_rotation_a, quantized.right_hand_cube_local_rotation_b, quantized.right_hand_cube_local_rotation_c);

        state.voice_amplitude = quantized.voice_amplitude * 1.0f / Constants.VoiceMaximum;
    }
Exemplo n.º 3
0
    public static void Quantize(ref AvatarState state, out AvatarStateQuantized quantized)
    {
        quantized.client_index = state.client_index;

        quantized.head_position_x = (int)Math.Floor(state.head_position.x * Constants.UnitsPerMeter + 0.5f);
        quantized.head_position_y = (int)Math.Floor(state.head_position.y * Constants.UnitsPerMeter + 0.5f);
        quantized.head_position_z = (int)Math.Floor(state.head_position.z * Constants.UnitsPerMeter + 0.5f);

        Snapshot.QuaternionToSmallestThree(state.head_rotation,
                                           out quantized.head_rotation_largest,
                                           out quantized.head_rotation_a,
                                           out quantized.head_rotation_b,
                                           out quantized.head_rotation_c);

        quantized.left_hand_position_x = (int)Math.Floor(state.left_hand_position.x * Constants.UnitsPerMeter + 0.5f);
        quantized.left_hand_position_y = (int)Math.Floor(state.left_hand_position.y * Constants.UnitsPerMeter + 0.5f);
        quantized.left_hand_position_z = (int)Math.Floor(state.left_hand_position.z * Constants.UnitsPerMeter + 0.5f);

        Snapshot.QuaternionToSmallestThree(state.left_hand_rotation,
                                           out quantized.left_hand_rotation_largest,
                                           out quantized.left_hand_rotation_a,
                                           out quantized.left_hand_rotation_b,
                                           out quantized.left_hand_rotation_c);

        quantized.left_hand_grip_flex  = (int)Math.Floor(state.left_hand_grip_flex * Constants.FlexMaximum + 0.5f);
        quantized.left_hand_index_flex = (int)Math.Floor(state.left_hand_index_flex * Constants.FlexMaximum + 0.5f);
        quantized.left_hand_pointing   = state.left_hand_pointing;
        quantized.left_hand_thumbs_up  = state.left_hand_thumbs_up;

        if (state.left_hand_holding_cube)
        {
            quantized.left_hand_holding_cube = true;

            quantized.left_hand_cube_id            = state.left_hand_cube_id;
            quantized.left_hand_authority_sequence = state.left_hand_authority_sequence;
            quantized.left_hand_ownership_sequence = state.left_hand_ownership_sequence;

            quantized.left_hand_cube_local_position_x = (int)Math.Floor(state.left_hand_cube_local_position.x * Constants.UnitsPerMeter + 0.5f);
            quantized.left_hand_cube_local_position_y = (int)Math.Floor(state.left_hand_cube_local_position.y * Constants.UnitsPerMeter + 0.5f);
            quantized.left_hand_cube_local_position_z = (int)Math.Floor(state.left_hand_cube_local_position.z * Constants.UnitsPerMeter + 0.5f);

            Snapshot.QuaternionToSmallestThree(state.left_hand_cube_local_rotation,
                                               out quantized.left_hand_cube_local_rotation_largest,
                                               out quantized.left_hand_cube_local_rotation_a,
                                               out quantized.left_hand_cube_local_rotation_b,
                                               out quantized.left_hand_cube_local_rotation_c);
        }
        else
        {
            quantized.left_hand_holding_cube                = false;
            quantized.left_hand_cube_id                     = -1;
            quantized.left_hand_authority_sequence          = 0;
            quantized.left_hand_ownership_sequence          = 0;
            quantized.left_hand_cube_local_position_x       = 0;
            quantized.left_hand_cube_local_position_y       = 0;
            quantized.left_hand_cube_local_position_z       = 0;
            quantized.left_hand_cube_local_rotation_largest = 0;
            quantized.left_hand_cube_local_rotation_a       = 0;
            quantized.left_hand_cube_local_rotation_b       = 0;
            quantized.left_hand_cube_local_rotation_c       = 0;
        }

        quantized.right_hand_position_x = (int)Math.Floor(state.right_hand_position.x * Constants.UnitsPerMeter + 0.5f);
        quantized.right_hand_position_y = (int)Math.Floor(state.right_hand_position.y * Constants.UnitsPerMeter + 0.5f);
        quantized.right_hand_position_z = (int)Math.Floor(state.right_hand_position.z * Constants.UnitsPerMeter + 0.5f);

        Snapshot.QuaternionToSmallestThree(state.right_hand_rotation,
                                           out quantized.right_hand_rotation_largest,
                                           out quantized.right_hand_rotation_a,
                                           out quantized.right_hand_rotation_b,
                                           out quantized.right_hand_rotation_c);

        quantized.right_hand_grip_flex  = (int)Math.Floor(state.right_hand_grip_flex * Constants.FlexMaximum + 0.5f);
        quantized.right_hand_index_flex = (int)Math.Floor(state.right_hand_index_flex * Constants.FlexMaximum + 0.5f);
        quantized.right_hand_pointing   = state.right_hand_pointing;
        quantized.right_hand_thumbs_up  = state.right_hand_thumbs_up;

        if (state.right_hand_holding_cube)
        {
            quantized.right_hand_holding_cube = true;

            quantized.right_hand_cube_id            = state.right_hand_cube_id;
            quantized.right_hand_authority_sequence = state.right_hand_authority_sequence;
            quantized.right_hand_ownership_sequence = state.right_hand_ownership_sequence;

            quantized.right_hand_cube_local_position_x = (int)Math.Floor(state.right_hand_cube_local_position.x * Constants.UnitsPerMeter + 0.5f);
            quantized.right_hand_cube_local_position_y = (int)Math.Floor(state.right_hand_cube_local_position.y * Constants.UnitsPerMeter + 0.5f);
            quantized.right_hand_cube_local_position_z = (int)Math.Floor(state.right_hand_cube_local_position.z * Constants.UnitsPerMeter + 0.5f);

            Snapshot.QuaternionToSmallestThree(state.right_hand_cube_local_rotation,
                                               out quantized.right_hand_cube_local_rotation_largest,
                                               out quantized.right_hand_cube_local_rotation_a,
                                               out quantized.right_hand_cube_local_rotation_b,
                                               out quantized.right_hand_cube_local_rotation_c);
        }
        else
        {
            quantized.right_hand_holding_cube                = false;
            quantized.right_hand_cube_id                     = -1;
            quantized.right_hand_authority_sequence          = 0;
            quantized.right_hand_ownership_sequence          = 0;
            quantized.right_hand_cube_local_position_x       = 0;
            quantized.right_hand_cube_local_position_y       = 0;
            quantized.right_hand_cube_local_position_z       = 0;
            quantized.right_hand_cube_local_rotation_largest = 0;
            quantized.right_hand_cube_local_rotation_a       = 0;
            quantized.right_hand_cube_local_rotation_b       = 0;
            quantized.right_hand_cube_local_rotation_c       = 0;
        }

        quantized.voice_amplitude = (int)Math.Floor(state.voice_amplitude * Constants.VoiceMaximum + 0.5f);

        // clamp everything

        Snapshot.ClampPosition(ref quantized.head_position_x, ref quantized.head_position_y, ref quantized.head_position_z);

        Snapshot.ClampPosition(ref quantized.left_hand_position_x, ref quantized.left_hand_position_y, ref quantized.left_hand_position_z);

        Snapshot.ClampPosition(ref quantized.right_hand_position_x, ref quantized.right_hand_position_y, ref quantized.right_hand_position_z);

        if (quantized.left_hand_holding_cube)
        {
            Snapshot.ClampLocalPosition(ref quantized.left_hand_cube_local_position_x, ref quantized.left_hand_cube_local_position_y, ref quantized.left_hand_cube_local_position_z);
        }

        if (quantized.right_hand_holding_cube)
        {
            Snapshot.ClampLocalPosition(ref quantized.right_hand_cube_local_position_x, ref quantized.right_hand_cube_local_position_y, ref quantized.right_hand_cube_local_position_z);
        }
    }
    public static void Quantize(ref AvatarState s, out AvatarStateQuantized q)
    {
        q.clientId      = s.clientId;
        q.headPositionX = (int)Floor(s.headPosition.x * UnitsPerMeter + 0.5f);
        q.headPositionY = (int)Floor(s.headPosition.y * UnitsPerMeter + 0.5f);
        q.headPositionZ = (int)Floor(s.headPosition.z * UnitsPerMeter + 0.5f);
        SetSmallestThree(s.headRotation, out q.headRotationLargest, out q.headRotationX, out q.headRotationY, out q.headRotationZ);

        q.leftHandPositionX = (int)Floor(s.leftHandPosition.x * UnitsPerMeter + 0.5f);
        q.leftHandPositionY = (int)Floor(s.leftHandPosition.y * UnitsPerMeter + 0.5f);
        q.leftHandPositionZ = (int)Floor(s.leftHandPosition.z * UnitsPerMeter + 0.5f);
        SetSmallestThree(s.leftHandRotation, out q.leftHandRotationLargest, out q.leftHandRotationX, out q.leftHandRotationY, out q.leftHandRotationZ);

        q.leftHandGripTrigger = (int)Floor(s.leftHandGripTrigger * MaxTrigger + 0.5f);
        q.leftHandIdTrigger   = (int)Floor(s.leftHandIdTrigger * MaxTrigger + 0.5f);
        q.isLeftHandPointing  = s.isLeftHandPointing;
        q.areLeftHandThumbsUp = s.areLeftHandThumbsUp;

        if (s.isLeftHandHoldingCube)
        {
            q.isLeftHandHoldingCube      = true;
            q.leftHandCubeId             = s.leftHandCubeId;
            q.leftHandAuthoritySequence  = s.leftHandAuthorityId;
            q.leftHandOwnershipSequence  = s.leftHandOwnershipId;
            q.leftHandCubeLocalPositionX = (int)Floor(s.leftHandCubeLocalPosition.x * UnitsPerMeter + 0.5f);
            q.leftHandCubeLocalPositionY = (int)Floor(s.leftHandCubeLocalPosition.y * UnitsPerMeter + 0.5f);
            q.leftHandCubeLocalPositionZ = (int)Floor(s.leftHandCubeLocalPosition.z * UnitsPerMeter + 0.5f);
            SetSmallestThree(s.leftHandCubeLocalRotation, out q.leftHandCubeLocalRotationLargest, out q.leftHandCubeLocalRotationX, out q.leftHandCubeLocalRotationY, out q.leftHandCubeLocalRotationZ);
        }
        else
        {
            q.isLeftHandHoldingCube            = false;
            q.leftHandCubeId                   = -1;
            q.leftHandAuthoritySequence        = 0;
            q.leftHandOwnershipSequence        = 0;
            q.leftHandCubeLocalPositionX       = 0;
            q.leftHandCubeLocalPositionY       = 0;
            q.leftHandCubeLocalPositionZ       = 0;
            q.leftHandCubeLocalRotationLargest = 0;
            q.leftHandCubeLocalRotationX       = 0;
            q.leftHandCubeLocalRotationY       = 0;
            q.leftHandCubeLocalRotationZ       = 0;
        }

        q.rightHandPositionX = (int)Floor(s.rightHandPosition.x * UnitsPerMeter + 0.5f);
        q.rightHandPositionY = (int)Floor(s.rightHandPosition.y * UnitsPerMeter + 0.5f);
        q.rightHandPositionZ = (int)Floor(s.rightHandPosition.z * UnitsPerMeter + 0.5f);
        SetSmallestThree(s.rightHandRotation, out q.rightHandRotationLargest, out q.rightHandRotationX, out q.rightHandRotationY, out q.rightHandRotationZ);

        q.rightHandGripTrigger  = (int)Floor(s.rightHandGripTrigger * MaxTrigger + 0.5f);
        q.rightHandIndexTrigger = (int)Floor(s.rightHandIdTrigger * MaxTrigger + 0.5f);
        q.isRightHandPointing   = s.isRightHandPointing;
        q.areRightHandThumbsUp  = s.areRightHandThumbsUp;

        if (s.isRightHandHoldingCube)
        {
            q.isRightHandHoldingCube      = true;
            q.rightHandCubeId             = s.rightHandCubeId;
            q.rightHandAuthoritySequence  = s.rightHandAuthorityId;
            q.rightHandOwnershipSequence  = s.rightHandOwnershipId;
            q.rightHandCubeLocalPositionX = (int)Floor(s.rightHandCubeLocalPosition.x * UnitsPerMeter + 0.5f);
            q.rightHandCubeLocalPositionY = (int)Floor(s.rightHandCubeLocalPosition.y * UnitsPerMeter + 0.5f);
            q.rightHandCubeLocalPositionZ = (int)Floor(s.rightHandCubeLocalPosition.z * UnitsPerMeter + 0.5f);
            SetSmallestThree(s.rightHandCubeLocalRotation, out q.rightHandCubeLocalRotationLargest, out q.rightHandCubeLocalRotationX, out q.rightHandCubeLocalRotationY, out q.rightHandCubeLocalRotationZ);
        }
        else
        {
            q.isRightHandHoldingCube            = false;
            q.rightHandCubeId                   = -1;
            q.rightHandAuthoritySequence        = 0;
            q.rightHandOwnershipSequence        = 0;
            q.rightHandCubeLocalPositionX       = 0;
            q.rightHandCubeLocalPositionY       = 0;
            q.rightHandCubeLocalPositionZ       = 0;
            q.rightHandCubeLocalRotationLargest = 0;
            q.rightHandCubeLocalRotationX       = 0;
            q.rightHandCubeLocalRotationY       = 0;
            q.rightHandCubeLocalRotationZ       = 0;
        }

        q.voiceAmplitude = (int)Floor(s.voiceAmplitude * MaxVoice + 0.5f);
        ClampPosition(ref q.headPositionX, ref q.headPositionY, ref q.headPositionZ);
        ClampPosition(ref q.leftHandPositionX, ref q.leftHandPositionY, ref q.leftHandPositionZ);
        ClampPosition(ref q.rightHandPositionX, ref q.rightHandPositionY, ref q.rightHandPositionZ);

        if (q.isLeftHandHoldingCube)
        {
            ClampLocalPosition(ref q.leftHandCubeLocalPositionX, ref q.leftHandCubeLocalPositionY, ref q.leftHandCubeLocalPositionZ);
        }

        if (q.isRightHandHoldingCube)
        {
            ClampLocalPosition(ref q.rightHandCubeLocalPositionX, ref q.rightHandCubeLocalPositionY, ref q.rightHandCubeLocalPositionZ);
        }
    }
Exemplo n.º 5
0
    void ReadAvatar(ReadStream s, out AvatarStateQuantized a)
    {
        s.Int(out a.clientId, 0, MaxClients - 1);
        s.Int(out a.headPositionX, MinPositionXZ, MaxPositionXZ);
        s.Int(out a.headPositionY, MinPositionY, MaxPositionY);
        s.Int(out a.headPositionZ, MinPositionXZ, MaxPositionXZ);
        s.Bits(out a.headRotationLargest, 2);
        s.Bits(out a.headRotationX, RotationBits);
        s.Bits(out a.headRotationY, RotationBits);
        s.Bits(out a.headRotationZ, RotationBits);
        s.Int(out a.leftHandPositionX, MinPositionXZ, MaxPositionXZ);
        s.Int(out a.leftHandPositionY, MinPositionY, MaxPositionY);
        s.Int(out a.leftHandPositionZ, MinPositionXZ, MaxPositionXZ);
        s.Bits(out a.leftHandRotationLargest, 2);
        s.Bits(out a.leftHandRotationX, RotationBits);
        s.Bits(out a.leftHandRotationY, RotationBits);
        s.Bits(out a.leftHandRotationZ, RotationBits);
        s.Int(out a.leftHandGripTrigger, MinTrigger, MaxTrigger);
        s.Int(out a.leftHandIdTrigger, MinTrigger, MaxTrigger);
        s.Bool(out a.isLeftHandPointing);
        s.Bool(out a.areLeftHandThumbsUp);
        s.Bool(out a.isLeftHandHoldingCube);

        if (a.isLeftHandHoldingCube)
        {
            s.Int(out a.leftHandCubeId, 0, MaxCubes - 1);
            s.Bits(out a.leftHandAuthoritySequence, 16);
            s.Bits(out a.leftHandOwnershipSequence, 16);
            s.Int(out a.leftHandCubeLocalPositionX, MinLocalPosition, MaxLocalPosition);
            s.Int(out a.leftHandCubeLocalPositionY, MinLocalPosition, MaxLocalPosition);
            s.Int(out a.leftHandCubeLocalPositionZ, MinLocalPosition, MaxLocalPosition);
            s.Bits(out a.leftHandCubeLocalRotationLargest, 2);
            s.Bits(out a.leftHandCubeLocalRotationX, RotationBits);
            s.Bits(out a.leftHandCubeLocalRotationY, RotationBits);
            s.Bits(out a.leftHandCubeLocalRotationZ, RotationBits);
        }
        else
        {
            a.leftHandCubeId                   = 0;
            a.leftHandAuthoritySequence        = 0;
            a.leftHandOwnershipSequence        = 0;
            a.leftHandCubeLocalPositionX       = 0;
            a.leftHandCubeLocalPositionY       = 0;
            a.leftHandCubeLocalPositionZ       = 0;
            a.leftHandCubeLocalRotationLargest = 0;
            a.leftHandCubeLocalRotationX       = 0;
            a.leftHandCubeLocalRotationY       = 0;
            a.leftHandCubeLocalRotationZ       = 0;
        }

        s.Int(out a.rightHandPositionX, MinPositionXZ, MaxPositionXZ);
        s.Int(out a.rightHandPositionY, MinPositionY, MaxPositionY);
        s.Int(out a.rightHandPositionZ, MinPositionXZ, MaxPositionXZ);
        s.Bits(out a.rightHandRotationLargest, 2);
        s.Bits(out a.rightHandRotationX, RotationBits);
        s.Bits(out a.rightHandRotationY, RotationBits);
        s.Bits(out a.rightHandRotationZ, RotationBits);
        s.Int(out a.rightHandGripTrigger, MinTrigger, MaxTrigger);
        s.Int(out a.rightHandIndexTrigger, MinTrigger, MaxTrigger);
        s.Bool(out a.isRightHandPointing);
        s.Bool(out a.areRightHandThumbsUp);
        s.Bool(out a.isRightHandHoldingCube);

        if (a.isRightHandHoldingCube)
        {
            s.Int(out a.rightHandCubeId, 0, MaxCubes - 1);
            s.Bits(out a.rightHandAuthoritySequence, 16);
            s.Bits(out a.rightHandOwnershipSequence, 16);
            s.Int(out a.rightHandCubeLocalPositionX, MinLocalPosition, MaxLocalPosition);
            s.Int(out a.rightHandCubeLocalPositionY, MinLocalPosition, MaxLocalPosition);
            s.Int(out a.rightHandCubeLocalPositionZ, MinLocalPosition, MaxLocalPosition);
            s.Bits(out a.rightHandCubeLocalRotationLargest, 2);
            s.Bits(out a.rightHandCubeLocalRotationX, RotationBits);
            s.Bits(out a.rightHandCubeLocalRotationY, RotationBits);
            s.Bits(out a.rightHandCubeLocalRotationZ, RotationBits);
        }
        else
        {
            a.rightHandCubeId                   = 0;
            a.rightHandAuthoritySequence        = 0;
            a.rightHandOwnershipSequence        = 0;
            a.rightHandCubeLocalPositionX       = 0;
            a.rightHandCubeLocalPositionY       = 0;
            a.rightHandCubeLocalPositionZ       = 0;
            a.rightHandCubeLocalRotationLargest = 0;
            a.rightHandCubeLocalRotationX       = 0;
            a.rightHandCubeLocalRotationY       = 0;
            a.rightHandCubeLocalRotationZ       = 0;
        }
        s.Int(out a.voiceAmplitude, MinVoice, MaxVoice);
    }
Exemplo n.º 6
0
    void WriteAvatar(WriteStream w, ref AvatarStateQuantized s)
    {
        w.Int(s.clientId, 0, MaxClients - 1);
        w.Int(s.headPositionX, MinPositionXZ, MaxPositionXZ);
        w.Int(s.headPositionY, MinPositionY, MaxPositionY);
        w.Int(s.headPositionZ, MinPositionXZ, MaxPositionXZ);
        w.Bits(s.headRotationLargest, 2);
        w.Bits(s.headRotationX, RotationBits);
        w.Bits(s.headRotationY, RotationBits);
        w.Bits(s.headRotationZ, RotationBits);
        w.Int(s.leftHandPositionX, MinPositionXZ, MaxPositionXZ);
        w.Int(s.leftHandPositionY, MinPositionY, MaxPositionY);
        w.Int(s.leftHandPositionZ, MinPositionXZ, MaxPositionXZ);
        w.Bits(s.leftHandRotationLargest, 2);
        w.Bits(s.leftHandRotationX, RotationBits);
        w.Bits(s.leftHandRotationY, RotationBits);
        w.Bits(s.leftHandRotationZ, RotationBits);
        w.Int(s.leftHandGripTrigger, MinTrigger, MaxTrigger);
        w.Int(s.leftHandIdTrigger, MinTrigger, MaxTrigger);
        w.Bool(s.isLeftHandPointing);
        w.Bool(s.areLeftHandThumbsUp);
        w.Bool(s.isLeftHandHoldingCube);

        if (s.isLeftHandHoldingCube)
        {
            w.Int(s.leftHandCubeId, 0, MaxCubes - 1);
            w.Bits(s.leftHandAuthoritySequence, 16);
            w.Bits(s.leftHandOwnershipSequence, 16);
            w.Int(s.leftHandCubeLocalPositionX, MinLocalPosition, MaxLocalPosition);
            w.Int(s.leftHandCubeLocalPositionY, MinLocalPosition, MaxLocalPosition);
            w.Int(s.leftHandCubeLocalPositionZ, MinLocalPosition, MaxLocalPosition);
            w.Bits(s.leftHandCubeLocalRotationLargest, 2);
            w.Bits(s.leftHandCubeLocalRotationX, RotationBits);
            w.Bits(s.leftHandCubeLocalRotationY, RotationBits);
            w.Bits(s.leftHandCubeLocalRotationZ, RotationBits);
        }

        w.Int(s.rightHandPositionX, MinPositionXZ, MaxPositionXZ);
        w.Int(s.rightHandPositionY, MinPositionY, MaxPositionY);
        w.Int(s.rightHandPositionZ, MinPositionXZ, MaxPositionXZ);
        w.Bits(s.rightHandRotationLargest, 2);
        w.Bits(s.rightHandRotationX, RotationBits);
        w.Bits(s.rightHandRotationY, RotationBits);
        w.Bits(s.rightHandRotationZ, RotationBits);
        w.Int(s.rightHandGripTrigger, MinTrigger, MaxTrigger);
        w.Int(s.rightHandIndexTrigger, MinTrigger, MaxTrigger);
        w.Bool(s.isRightHandPointing);
        w.Bool(s.areRightHandThumbsUp);
        w.Bool(s.isRightHandHoldingCube);

        if (s.isRightHandHoldingCube)
        {
            w.Int(s.rightHandCubeId, 0, MaxCubes - 1);
            w.Bits(s.rightHandAuthoritySequence, 16);
            w.Bits(s.rightHandOwnershipSequence, 16);
            w.Int(s.rightHandCubeLocalPositionX, MinLocalPosition, MaxLocalPosition);
            w.Int(s.rightHandCubeLocalPositionY, MinLocalPosition, MaxLocalPosition);
            w.Int(s.rightHandCubeLocalPositionZ, MinLocalPosition, MaxLocalPosition);
            w.Bits(s.rightHandCubeLocalRotationLargest, 2);
            w.Bits(s.rightHandCubeLocalRotationX, RotationBits);
            w.Bits(s.rightHandCubeLocalRotationY, RotationBits);
            w.Bits(s.rightHandCubeLocalRotationZ, RotationBits);
        }
        w.Int(s.voiceAmplitude, MinVoice, MaxVoice);
    }