示例#1
0
        // Calculates the hand position
        Vector3 GetHandPosition(int index)
        {
            var isLeft = (index == 0);

            // Relative position of the hand.
            var pos = _handPosition;

            if (isLeft)
            {
                pos.x *= -1;
            }

            // Apply the body (hip) transform.
            pos = _animator.bodyRotation * pos + _animator.bodyPosition;

            // Add noise.
            pos += Vector3.Scale(Noise.Float3(_noise, (uint)(4 + index)), _handPositionNoise);

            // Clamping in the local space of the chest bone.
            pos   = _chestMatrixInv * new Vector4(pos.x, pos.y, pos.z, 1);
            pos.y = Mathf.Max(pos.y, 0.2f);
            pos.z = isLeft ? Mathf.Max(pos.z, 0.2f) : Mathf.Min(pos.z, -0.2f);
            pos   = _chestMatrix * new Vector4(pos.x, pos.y, pos.z, 1);

            return(pos);
        }
示例#2
0
        // Spine (spine/chest/upper chest) rotation
        quaternion GetSpineRotation()
        {
            // Constant bending
            var r1 = quaternion.RotateX(deg2rad(_spineBend));

            // Noise
            var r2 = Noise.Rotation(_noise, deg2rad(_spineRotationNoise), 1);

            return(math.mul(r1, r2));
        }
示例#3
0
        // Look at position (for head movement)
        float3 GetLookAtPosition()
        {
            // Z plane constraint noise
            var pos = Noise.Float3(_noise, 6) * _headMove;

            pos.z = 2;

            // Body transform
            pos  = math.mul(_animator.bodyRotation, pos);
            pos += (float3)_animator.bodyPosition;

            return(pos);
        }
示例#4
0
        // Hand positions
        float3 GetHandPosition(Side side)
        {
            // Relative position
            var pos = (float3)_handPosition;

            if (side == Side.Left)
            {
                pos.x *= -1;
            }

            // Noise
            pos += Noise.Float3(_noise, 2 + (uint)side) * _handPositionNoise;

            // Chest transform
            pos = math.mul(_chestMatrix, math.float4(pos, 1)).xyz;

            return(pos);
        }
示例#5
0
        // Body (hip) rotation
        quaternion GetBodyRotation()
        {
            // Base offset
            var r1 = quaternion.RotateY(-math.PI / 2);

            // Right direction vector based on the foot positions
            var right = RightFootPosition - LeftFootPosition;

            right.y = 0;
            right   = math.normalize(right);

            // Horizontal rotation
            var r2 = quaternion.LookRotation(right, Up);

            // Noise
            var r3 = Noise.Rotation(_noise, deg2rad(_hipRotationNoise), 0);

            return(math.mul(math.mul(r1, r2), r3));
        }
示例#6
0
 // Finger rotations
 quaternion GetFingerRotation(Side side)
 => quaternion.Euler
     (Noise.Float3(_noise, 4 + (uint)side)
     * math.float3(0.7f, 0.3f, 0.3f) + math.float3(0.35f, 0, 0));