"L. Spiro Engine"
|
00001 00016 #ifndef __LSM_VECTOR3_H__ 00017 #define __LSM_VECTOR3_H__ 00018 00019 #include "../LSMMathLib.h" 00020 #include "LSMVector3Base.h" 00021 00022 namespace lsm { 00023 00030 class CVector3 : public CVector3Base<LSREAL, CVector3> { 00031 public : 00032 // == Various constructors. 00033 LSE_INLINE LSE_CALLCTOR CVector3(); 00034 LSE_INLINE LSE_CALLCTOR CVector3( LSREAL _fX, LSREAL _fY, LSREAL _fZ ); 00035 LSE_INLINE LSE_CALLCTOR CVector3( const CVector3 &_vOther ); 00036 LSE_INLINE LSE_CALLCTOR CVector3( LSREAL * _pfValues ); 00037 00038 00039 // == Functions. 00045 LSE_INLINE LSREAL LSE_FCALL Len() const; 00046 00052 LSE_INLINE LSVOID LSE_FCALL Normalize(); 00053 00059 static LSE_INLINE const CVector3 & LSE_CALL ForwardVector(); 00060 00066 static LSE_INLINE const CVector3 & LSE_CALL UpVector(); 00067 00073 static LSE_INLINE const CVector3 & LSE_CALL RightVector(); 00074 00080 static LSE_INLINE const CVector3 & LSE_CALL ZeroVector(); 00081 00082 00083 protected : 00084 // == Members. 00085 #if LSM_PERFORMANCE <= 0 && (LSM_BASETYPE == LSM_FLOAT || LSM_BASETYPE == LSM_FIXED) 00086 #pragma pack( push, 1 ) 00087 // If ultimate optimization is enabled, add a value that forces an alignment. 00088 private : 00089 LSREAL m_fPad; 00090 protected : 00091 #pragma pack( pop ) 00092 #endif // LSM_PERFORMANCE <= 0 00093 00097 static CVector3 m_vUp; 00098 00102 static CVector3 m_vRight; 00103 00107 static CVector3 m_vForward; 00108 00112 static CVector3 m_vZero; 00113 00114 00115 private : 00116 typedef CVector3Base<LSREAL, CVector3> Parent; 00117 }; 00118 00119 00120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00121 // DEFINITIONS 00122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00123 // == Various constructors. 00124 LSE_INLINE LSE_CALLCTOR CVector3::CVector3() { 00125 } 00126 LSE_INLINE LSE_CALLCTOR CVector3::CVector3( LSREAL _fX, LSREAL _fY, LSREAL _fZ ) : 00127 Parent( _fX, _fY, _fZ ) { 00128 } 00129 LSE_INLINE LSE_CALLCTOR CVector3::CVector3( const CVector3 &_vOther ) : 00130 Parent( _vOther ) { 00131 } 00132 LSE_INLINE LSE_CALLCTOR CVector3::CVector3( LSREAL * _pfValues ) : 00133 Parent( _pfValues ) { 00134 } 00135 00136 // == Functions. 00142 LSE_INLINE LSREAL LSE_FCALL CVector3::Len() const { 00143 register LSREAL fSquared = x * x + y * y + z * z; 00144 return fSquared * CMathLib::InvSqrt( fSquared ); 00145 } 00146 00152 LSE_INLINE LSVOID LSE_FCALL CVector3::Normalize() { 00153 LSREAL fInvLen = CMathLib::InvSqrt( x * x + y * y + z * z ); 00154 x *= fInvLen; 00155 y *= fInvLen; 00156 z *= fInvLen; 00157 } 00158 00164 LSE_INLINE const CVector3 & LSE_CALL CVector3::ForwardVector() { 00165 return m_vForward; 00166 } 00167 00173 LSE_INLINE const CVector3 & LSE_CALL CVector3::UpVector() { 00174 return m_vUp; 00175 } 00176 00182 LSE_INLINE const CVector3 & LSE_CALL CVector3::RightVector() { 00183 return m_vRight; 00184 } 00185 00191 LSE_INLINE const CVector3 & LSE_CALL CVector3::ZeroVector() { 00192 return m_vZero; 00193 } 00194 00195 } // namespace lsm 00196 00197 #endif // __LSM_VECTOR3_H__ 00198