00001 00002 // 00003 // ecgeometry 00004 // 00005 // Copyright (c) 2004 Bioware Copr. 00006 // 00007 // The source code included in this file is confidential, 00008 // secret, or propietary information of Bioware Corp. It 00009 // may not be used in whole or in part without express 00010 // written permission from Bioware Corp. 00011 // 00013 // 00017 // 00019 // 00020 // Created On: 11:12:2008 15:39 00021 // 00023 00024 #ifndef _ECGEOMETRY_H 00025 #define _ECGEOMETRY_H 00026 00027 #include <eclipseray/eclipse.h> 00028 #include <eclipseray/yrtypes.h> 00029 00031 // 00036 // 00040 // 00042 class Vector3D : public EclipseObject 00043 { 00044 DECLARE_PYTHON_HEADER; 00045 00046 public: 00047 00048 // ------------------------------------------------------------------------- 00049 // Creation 00050 // ------------------------------------------------------------------------- 00051 00055 Vector3D(); 00056 00060 Vector3D( float a_fX, float a_fY, float a_fZ ); 00061 00065 Vector3D( const YRPoint3D& a_point3D ); 00066 00068 ~Vector3D(){}; 00069 00074 void Normalize(); 00075 00076 // ------------------------------------------------------------------------- 00077 // Python 00078 // ------------------------------------------------------------------------- 00079 00085 static bool PyTypeCheck( PYOBJECT a_pObject ); 00086 00092 virtual PYOBJECT PyAsString(); 00093 00094 // Transforms this vertex by the provided matrix 00095 DECLARE_PYTHON_OBJECT_METHOD( Vector3D, transform ); 00096 00097 // normalizes this vector 00098 DECLARE_PYTHON_OBJECT_METHOD( Vector3D, normalize ); 00099 00100 // ------------------------------------------------------------------------- 00101 // Utils 00102 // ------------------------------------------------------------------------- 00103 00107 inline float* GetComponentsPtr(){ return &m_components[0]; } 00108 00113 void SetComponents( float* a_pValues ); 00114 00118 inline float& x(){ return m_components[0]; } 00119 00123 inline float& y(){ return m_components[1]; } 00124 00128 inline float& z(){ return m_components[2]; } 00129 00133 inline const YRPoint3D& AsYRPoint3D() const { return m_components; } 00134 00135 protected: 00136 00142 virtual void DeleteObject(); 00143 00144 00145 private: 00146 00147 YRPoint3D m_components; 00148 00149 }; 00150 00151 00153 // 00158 // 00160 class Matrix : public EclipseObject 00161 { 00162 DECLARE_PYTHON_HEADER; 00163 00164 public: 00165 00166 // ------------------------------------------------------------------------- 00167 // Creation 00168 // ------------------------------------------------------------------------- 00169 00174 Matrix(); 00175 00180 Matrix( float* a_pValues ); 00181 00185 ~Matrix(){}; 00186 00187 // ------------------------------------------------------------------------- 00188 // Utilities 00189 // ------------------------------------------------------------------------- 00190 00196 void SetRow( int a_nRow, float* a_pValues ); 00197 00201 inline const YRMatrix4x4& AsYRMatrix() const { return m_matrix; } 00202 00206 static const Matrix Identity; 00207 00208 // ------------------------------------------------------------------------- 00209 // Python 00210 // ------------------------------------------------------------------------- 00211 00217 static bool PyTypeCheck( PYOBJECT a_pObject ); 00218 00224 virtual PYOBJECT PyAsString(); 00225 00226 protected: 00227 00233 virtual void DeleteObject(); 00234 00235 private: 00236 00237 YRMatrix4x4 m_matrix; 00238 00239 }; 00240 00247 inline Vector3D operator * ( const Matrix& a_matrix, const Vector3D& a_vector ) 00248 { 00249 return a_matrix.AsYRMatrix() * a_vector.AsYRPoint3D(); 00250 } 00251 00252 00253 #endif