00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \version 2.0.0 $Rev: 251 $ 00018 */ 00019 //=========================================================================== 00020 00021 //--------------------------------------------------------------------------- 00022 #ifndef CVertexH 00023 #define CVertexH 00024 //--------------------------------------------------------------------------- 00025 #include "math/CVector3d.h" 00026 #include "math/CMatrix3d.h" 00027 #include "graphics/CColor.h" 00028 //--------------------------------------------------------------------------- 00029 00030 //=========================================================================== 00038 //=========================================================================== 00039 00040 //=========================================================================== 00050 //=========================================================================== 00051 class cVertex 00052 { 00053 00054 public: 00055 00056 //----------------------------------------------------------------------- 00057 // CONSTRUCTOR & DESTRUCTOR: 00058 //----------------------------------------------------------------------- 00059 00060 //----------------------------------------------------------------------- 00068 //----------------------------------------------------------------------- 00069 cVertex(const double a_x=0.0, const double a_y=0.0, const double a_z=0.0) 00070 : m_localPos(a_x, a_y, a_z), m_globalPos(a_x, a_y, a_z), m_normal(0.0, 0.0, 1.0), 00071 m_index(-1), m_allocated(false), m_nTriangles(0) 00072 {} 00073 00074 00075 //----------------------------------------------------------------------- 00079 //----------------------------------------------------------------------- 00080 ~cVertex() {}; 00081 00082 00083 //----------------------------------------------------------------------- 00084 // METHODS: 00085 //----------------------------------------------------------------------- 00086 00087 //----------------------------------------------------------------------- 00095 //----------------------------------------------------------------------- 00096 inline void setPos(const double& a_x, const double& a_y, const double& a_z) 00097 { 00098 // set local position 00099 m_localPos.set(a_x, a_y, a_z); 00100 } 00101 00102 00103 //----------------------------------------------------------------------- 00109 //----------------------------------------------------------------------- 00110 inline void setPos(const cVector3d& a_pos) 00111 { 00112 m_localPos = a_pos; 00113 } 00114 00115 00116 //----------------------------------------------------------------------- 00122 //----------------------------------------------------------------------- 00123 inline void translate(const cVector3d& a_translation) 00124 { 00125 m_localPos.add(a_translation); 00126 } 00127 00128 00129 //----------------------------------------------------------------------- 00135 //----------------------------------------------------------------------- 00136 inline cVector3d getPos() const { return (m_localPos); } 00137 00139 //----------------------------------------------------------------------- 00146 //----------------------------------------------------------------------- 00147 inline cVector3d getGlobalPos() const { return (m_globalPos); } 00148 00149 00150 //----------------------------------------------------------------------- 00156 //----------------------------------------------------------------------- 00157 inline void setNormal(const cVector3d& a_normal) 00158 { 00159 m_normal = a_normal; 00160 } 00161 00162 00163 //----------------------------------------------------------------------- 00172 //----------------------------------------------------------------------- 00173 inline void setNormal(const double& a_x, const double& a_y, const double& a_z) 00174 { 00175 m_normal.set(a_x, a_y, a_z); 00176 } 00177 00178 00179 //----------------------------------------------------------------------- 00185 //----------------------------------------------------------------------- 00186 inline cVector3d getNormal() const 00187 { 00188 return (m_normal); 00189 } 00190 00191 00193 //----------------------------------------------------------------------- 00199 //----------------------------------------------------------------------- 00200 inline void setTexCoord(const cVector3d& a_texCoord) 00201 { 00202 m_texCoord = a_texCoord; 00203 } 00204 00205 00206 //----------------------------------------------------------------------- 00213 //----------------------------------------------------------------------- 00214 inline void setTexCoord(const double& a_tx, const double& a_ty) 00215 { 00216 m_texCoord.set(a_tx, a_ty, 0.0); 00217 } 00218 00219 00220 //----------------------------------------------------------------------- 00226 //----------------------------------------------------------------------- 00227 inline cVector3d getTexCoord() const { return (m_texCoord); } 00228 00229 00230 //----------------------------------------------------------------------- 00236 //----------------------------------------------------------------------- 00237 inline void setColor(const cColorf& a_color) { m_color = a_color; } 00238 00239 00240 //----------------------------------------------------------------------- 00249 //----------------------------------------------------------------------- 00250 inline void setColor(const float& a_red, const float& a_green, 00251 const float& a_blue, const float a_alpha=1.0 ) 00252 { 00253 m_color.set(a_red, a_green, a_blue, a_alpha); 00254 } 00255 00256 00257 //----------------------------------------------------------------------- 00263 //----------------------------------------------------------------------- 00264 inline void setColor(const cColorb& a_color) 00265 { 00266 m_color = a_color.getColorf(); 00267 } 00268 00269 00270 //----------------------------------------------------------------------- 00278 //----------------------------------------------------------------------- 00279 inline void computeGlobalPosition(const cVector3d& a_globalPos, const cMatrix3d& a_globalRot) 00280 { 00281 a_globalRot.mulr(m_localPos, m_globalPos); 00282 m_globalPos.add(a_globalPos); 00283 } 00284 00285 00286 //----------------------------------------------------------------------- 00287 // MEMBERS: 00288 //----------------------------------------------------------------------- 00289 00291 cVector3d m_localPos; 00292 00294 cVector3d m_globalPos; 00295 00297 cVector3d m_normal; 00298 00300 cVector3d m_texCoord; 00301 00303 cColorf m_color; 00304 00306 int m_index; 00307 00309 bool m_allocated; 00310 00312 int m_nTriangles; 00313 00315 int m_tag; 00316 }; 00317 00318 00319 //--------------------------------------------------------------------------- 00320 #endif 00321 //---------------------------------------------------------------------------