// 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); }
// 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); }
// 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); }
// 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));