-------------------------------------------------------------------------------- Description: Depending on the type of the system bone, we calculate a new transform for it and apply it. All of this is highly "hard-coded", but there are some variables in there, so we can customize the tracking to individual turrets. The modification should pay attention the amount of modification needed, stored in
| 1727 | // rotation - the bone rotation that needs to get modified |
| 1728 | // -------------------------------------------------------------------------------- |
| 1729 | void EveTurretSet::ModifySystemBoneTransform( SystemBones bone, const Vector3* target, const Matrix* localTransform, Vector3& position, Quaternion& rotation ) const |
| 1730 | { |
| 1731 | switch( bone ) |
| 1732 | { |
| 1733 | case SYSBONE_INVALID: |
| 1734 | break; |
| 1735 | case SYSBONE_ROTATION: |
| 1736 | case SYSBONE_ROTATION01: |
| 1737 | case SYSBONE_ROTATION02: { |
| 1738 | // rotation of turret 360 degress, alpha is between -pi and pi |
| 1739 | float alpha = atan2( target->x, target->z ); |
| 1740 | // never forget do apply influence! |
| 1741 | alpha *= m_trackingInfluence; |
| 1742 | // 1st: make quaternion |
| 1743 | Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); |
| 1744 | // 2nd: apply this quat after the original one |
| 1745 | quat = rotation * quat; |
| 1746 | // 3rd: make granny_transform from quat |
| 1747 | rotation = quat; |
| 1748 | } |
| 1749 | break; |
| 1750 | case SYSBONE_COUNTER_ROTATION: { |
| 1751 | // inverse(!!) rotation of turret 360 degress, alpha is between -pi and pi |
| 1752 | float alpha = -1.f * atan2( target->x, target->z ); |
| 1753 | // never forget do apply influence! |
| 1754 | alpha *= m_trackingInfluence; |
| 1755 | // 1st: make quaternion |
| 1756 | Quaternion quat = RotationQuaternion( alpha, 0.f, 0.f ); |
| 1757 | // 2nd: apply this quat after the original one |
| 1758 | quat = rotation * quat; |
| 1759 | // 3rd: make granny_transform from quat |
| 1760 | rotation = quat; |
| 1761 | } |
| 1762 | break; |
| 1763 | case SYSBONE_PITCH: |
| 1764 | case SYSBONE_PITCH1: |
| 1765 | case SYSBONE_PITCH2: { |
| 1766 | CalcTransformForPitchBone( target, XMConvertToRadians( m_sysBonePitchMin ), XMConvertToRadians( m_sysBonePitchMax ), bone, localTransform, rotation ); |
| 1767 | } |
| 1768 | break; |
| 1769 | case SYSBONE_SCALED_HEIGHT: { |
| 1770 | // pitch of barrel 90 degrees |
| 1771 | Vector3 dirNrm = Normalize( *target ); |
| 1772 | float height = TriClamp( dirNrm.y, 0.f, 1.f ); |
| 1773 | // never forget do apply influence! |
| 1774 | height *= m_trackingInfluence; |
| 1775 | // it's a pos extension with a scale |
| 1776 | Vector3 pos = Vector3( 0.f, height * m_sysBoneHeight, 0.f ) + position; |
| 1777 | position = pos; |
| 1778 | } |
| 1779 | break; |
| 1780 | case SYSBONE_SCALED_PITCH01: |
| 1781 | case SYSBONE_SCALED_PITCH02: |
| 1782 | case SYSBONE_SCALED_PITCH03: |
| 1783 | case SYSBONE_SCALED_PITCH04: |
| 1784 | case SYSBONE_SCALED_PITCH05: |
| 1785 | case SYSBONE_SCALED_PITCH06: { |
| 1786 | CalcTransformForPitchBone( target, 0.f, XMConvertToRadians( m_sysBonePitchMax ), bone, nullptr, rotation ); |