|
Geom.hhGo to the documentation of this file.00001 /* 00002 * Gazebo - Outdoor Multi-Robot Simulator 00003 * Copyright (C) 2003 00004 * Nate Koenig & Andrew Howard 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 /* Desc: Base class for all drawables 00022 * Author: Nate Keonig 00023 * Date: 04 Aug 2003 00024 * CVS: $Id: Geom.hh,v 1.31 2005/01/26 21:08:08 natepak Exp $ 00025 */ 00026 00027 #ifndef GEOM_HH 00028 #define GEOM_HH 00029 00030 #include "GL/gl.h" 00031 #include "Global.hh" 00032 #include "Color.hh" 00033 #include "RenderOptions.hh" 00034 #include "BaseGeom.hh" 00035 00036 // Forward declarations 00037 class GzImage; 00038 00039 // Forward declarations for lib3ds 00040 typedef struct _Lib3dsNode Lib3dsNode; 00041 typedef struct _Lib3dsFile Lib3dsFile; 00042 typedef struct _Lib3dsMesh Lib3dsMesh; 00043 00049 class Geom : public BaseGeom 00050 { 00051 public: Geom(dSpaceID spaceId); 00052 public: virtual ~Geom(); 00053 00054 // Set material properties 00055 public: void SetColor( const GzColor &color ); 00056 public: void SetAmbientColor( const GzColor &color ); 00057 public: void SetDiffuseColor( const GzColor &color ); 00058 public: void SetSpecularColor( const GzColor &color ); 00059 public: void SetEmissionColor( const GzColor &color ); 00060 public: void SetShadeModel( const char *mode ); 00061 public: void SetPolygonMode( const char *mode ); 00062 public: void SetTransparency( bool enable ); 00063 public: void SetShininess( float num ); 00064 public: void SetLaser( float num ); 00065 public: void SetRetro( float num ); 00066 public: void SetFiducial( int id ); 00067 public: void SetPickId( GLuint id ); 00068 00073 public: int SetTexture2D( int width, int height, const uint8_t *data ); 00074 00078 public: int SetTexture2DFile( const char *filename ); 00079 00082 public: void SetTexture2DSize( GzVector size ); 00083 00086 public: int SetSkinFile( const char *filename ); 00087 00093 public: void SetSkinNull(bool enable) {this->skinNull = enable;} 00094 00097 public: void SetSkinPose( GzPose pose ); 00098 00101 public: void SetSkinScale( GzVector scale ); 00102 00104 public: bool HasSkin() {return this->skinFile != NULL;} 00105 00107 public: bool HasSkinNull() {return this->skinNull;} 00108 00109 // Get material properties 00110 public: GzColor GetAmbientColor() const; 00111 public: GzColor GetDiffuseColor() const; 00112 public: GzColor GetSpecularColor() const; 00113 public: float GetTransparency() const; 00114 public: float GetShininess() const; 00115 public: float GetLaser() const; 00116 public: float GetRetro() const; 00117 public: int GetFiducial() const; 00118 public: GLuint GetPickId() const; 00119 00121 protected: void SetList(int camera, GLuint listId, RenderOptions opt); 00122 00124 protected: void GetList(int camera, GLuint *listId, RenderOptions *opt); 00125 00126 // TODO: pass-by-value 00127 // Render the geom (GL) 00128 public: virtual void PreRender(RenderOptions *opt); 00129 public: virtual void Render(RenderOptions *opt); 00130 public: virtual void PostRender(RenderOptions *opt); 00131 00133 public: void RenderSkin(RenderOptions *opt); 00134 00135 // Render a node (recursive) 00136 private: void RenderSkinNode(Lib3dsNode *node); 00137 00138 // Render a mesh 00139 private: void RenderSkinMesh( Lib3dsMesh *mesh ); 00140 00141 // Rendering order 00142 public: int renderOrder; 00143 00144 // Material attributes 00145 protected: bool transparency; 00146 protected: float laser; 00147 protected: float retro; 00148 protected: int fiducial; 00149 protected: GLfloat colorDiffuse[4]; 00150 protected: GLfloat colorAmbient[4]; 00151 protected: GLfloat colorSpecular[4]; 00152 protected: GLfloat colorEmission[4]; 00153 protected: GLfloat shininess; 00154 00156 protected: GzImage *textureImage; 00157 00159 protected: GzVector textureSize; 00160 00161 // ?? 00162 protected: int pick; 00163 00165 private: struct 00166 { 00167 GLuint listId; 00168 RenderOptions opt; 00169 } listList[256]; 00170 00172 private: Lib3dsFile *skinFile; 00173 00175 private: bool skinNull; 00176 00178 private: GzPose skinPose; 00179 private: GzVector skinScale; 00180 private: GLuint meshListId; 00181 00183 protected: bool dirty; 00184 }; 00185 00186 #endif 00187 |