torcs - 1.2.2

src/modules/graphic/ssggraph/grvtxtable.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     file                 : grvtxtable.h
00004     created              : Fri Mar 22 23:16:44 CET 2002
00005     copyright            : (C) 2001 by Christophe Guionneau
00006     version              : $Id: grvtxtable.h,v 1.2 2002/12/20 22:05:12 torcs Exp $
00007 
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 /* 
00020 
00021    This class is based on the plib ssgVtxTable and the ssgVtxArray class 
00022 
00023 */
00024 /*
00025      PLIB - A Suite of Portable Game Libraries
00026      Copyright (C) 2001  Steve Baker
00027  
00028      This library is free software; you can redistribute it and/or
00029      modify it under the terms of the GNU Library General Public
00030      License as published by the Free Software Foundation; either
00031      version 2 of the License, or (at your option) any later version.
00032  
00033      This library is distributed in the hope that it will be useful,
00034      but WITHOUT ANY WARRANTY; without even the implied warranty of
00035      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00036      Library General Public License for more details.
00037  
00038      You should have received a copy of the GNU Library General Public
00039      License along with this library; if not, write to the Free
00040      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00041  
00042      For further information visit http://plib.sourceforge.net
00043 */
00044 
00045 #ifndef _GRVTXTABLE_H_
00046 #define _GRVTXTABLE_H_
00047 #include "grmultitexstate.h"
00048 
00049 #define LEVELC  -1     /* a normal map in LEVEL0 and an env map in LEVEL1 for cars
00050                           texturecoord of the env map are computed by opengl      */
00051 #define LEVELC2  -2     /* a normal map in LEVEL0 and an env map in LEVEL2 for cars
00052                            precomputed and an env map computed by opengl in LEVEL1  */
00053 #define LEVELC3  -3     /* a normal map in LEVEL0 and an env map in LEVEL2 for cars
00054                            precomputed and an shadow env  LEVEL1  */
00055 #define LEVEL0  1      /* the normal map level      */
00056 #define LEVEL1  2      /* the high tiled map        */
00057 #define LEVEL2  4      /* skids and lummy texture   */
00058 #define LEVEL3  8      /* shadows and other goodies */
00059 
00060 
00061 
00062 class grVtxTable : public ssgVtxTable
00063 {
00064   grMultiTexState *state ;
00065   grMultiTexState *state1 ;
00066   grMultiTexState *state2 ;
00067   grMultiTexState *state3 ;
00068 
00069 #define ARRAY 1
00070 #define TABLE 2
00071   int internalType;
00072 
00073 protected:
00074   virtual void copy_from ( grVtxTable *src, int clone_flags ) ;
00075   ssgIndexArray      *indices;
00076   ssgIndexArray      *stripes;
00077   int                 numStripes;
00078   /*virtual void draw_geometry () ;*/
00079   /*sgVec2 *texcoords1 ; int num_texcoords1 ; unsigned short *t_index1 ;
00080     sgVec2 *texcoords2 ; int num_texcoords2 ; unsigned short *t_index2 ;
00081     sgVec2 *texcoords3 ; int num_texcoords3 ; unsigned short *t_index3 ;*/
00082 _SSG_PUBLIC:  
00083   ssgTexCoordArray *texcoords1 ;
00084   ssgTexCoordArray *texcoords2 ;
00085   ssgTexCoordArray *texcoords3 ;
00086     
00087 public:
00088   int numMapLevel;
00089   int mapLevelBitmap;
00090   int indexCar;
00091   virtual ssgBase *clone ( int clone_flags = 0 ) ;
00092   /*grVtxTable () ;*/
00093   grVtxTable (int _numMapLevel,int _mapLevel) ;
00094   grVtxTable ( GLenum ty, ssgVertexArray   *vl,
00095                            ssgNormalArray   *nl,
00096                            ssgTexCoordArray *tl,
00097                            ssgTexCoordArray *tl1,
00098                            ssgTexCoordArray *tl2,
00099                            ssgTexCoordArray *tl3,
00100                            int _numMapLevel,
00101                            int _mapLevel,
00102                            ssgColourArray   *cl, 
00103                            int _indexCar ) ;
00104   grVtxTable ( GLenum ty, ssgVertexArray   *vl,
00105                ssgIndexArray    * stripeIndex,
00106                int _numstripes,
00107                ssgIndexArray    *il,
00108                ssgNormalArray   *nl,
00109                ssgTexCoordArray *tl,
00110                ssgTexCoordArray *tl1,
00111                ssgTexCoordArray *tl2,
00112                ssgTexCoordArray *tl3,
00113                int _numMapLevel,
00114                int _mapLevel,
00115                ssgColourArray   *cl, 
00116                int _indexCar ) ;
00117   grVtxTable (ssgVertexArray    *shd_vtx , float initsize, int type);
00118 
00119   float *getTexCoord1(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
00120                              return (getNumTexCoords()<=0) ?
00121                                     _ssgTexCoord00  : texcoords1->get(i);}
00122   float *getTexCoord2(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
00123                              return (getNumTexCoords()<=0) ?
00124                                     _ssgTexCoord00  : texcoords2->get(i);}
00125   float *getTexCoord3(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
00126                              return (getNumTexCoords()<=0) ?
00127                                     _ssgTexCoord00  : texcoords3->get(i);}
00128 
00129   ssgState *getState1 () { return state1 ; }
00130   void      setState1 ( ssgState *st );
00131   ssgState *getState2 () { return state2 ; }
00132   void      setState2 ( ssgState *st );
00133   ssgState *getState3 () { return state3 ; }
00134   void      setState3 ( ssgState *st );
00135 
00136   virtual void draw () ;
00137   /*void grVtxTable::draw ();*/
00138   void draw_geometry_array();
00139   void draw_geometry_multi();
00140   void draw_geometry_for_a_car () ;
00141   void draw_geometry_multi_array();
00142   void draw_geometry_for_a_car_array () ;
00143   virtual void drawHighlight ( sgVec4 colour ){ssgVtxTable::drawHighlight(colour);}  /* doesn't not work */
00144   virtual void drawHighlight ( sgVec4 colour, int i ){ssgVtxTable::drawHighlight(colour,i);} /* doesn't work also */
00145 
00146   virtual void pick ( int baseName )  { ssgVtxTable::pick(baseName);}
00147   virtual void transform ( const sgMat4 m )  { ssgVtxTable::transform(m);}
00148 
00149 
00150   int getNumVertices  () { return vertices  -> getNum () ; }
00151   int getNumNormals   () { return normals   -> getNum () ; }
00152   int getNumColours   () { return colours   -> getNum () ; }
00153   int getNumTexCoords () { return texcoords -> getNum () ; }
00154 
00155   /* the following functions doesn't work with arrays */
00156   int getNumTriangles ()  { return ssgVtxTable::getNumTriangles();}
00157   void getTriangle ( int n, short *v1, short *v2, short *v3 )  { ssgVtxTable::getTriangle(n,v1,v2,v3);}
00158   int  getNumLines ()  {return ssgVtxTable::getNumLines();}
00159   void getLine ( int n, short *v1, short *v2 )  { ssgVtxTable::getLine(n,v1,v2);}
00160 
00161 
00162   virtual ~grVtxTable (void);
00163 
00164   virtual const char *getTypeName(void)  { return ssgVtxTable::getTypeName();}
00165 
00166   virtual void setVertices  ( ssgVertexArray   *vl ) {  ssgVtxTable::setVertices(vl);}
00167   virtual void setNormals   ( ssgNormalArray   *nl ) {  ssgVtxTable::setNormals(nl);}
00168   virtual void setTexCoords ( ssgTexCoordArray *tl ) {  ssgVtxTable::setTexCoords(tl);}
00169   virtual void setColours   ( ssgColourArray   *cl ) {  ssgVtxTable::setColours(cl);}
00170 
00171   /* the following functions doesn't work with arrays */
00172   virtual void print ( FILE *fd = stderr, char *indent = "", int how_much = 2) { ssgVtxTable::print(fd,indent,how_much);}
00173   virtual int load ( FILE *fd )  {return  ssgVtxTable::load(fd);}
00174   virtual int save ( FILE *fd )  {return  ssgVtxTable::save(fd);}
00175 };
00176 
00177 
00178 #endif /* _GRVTXTABLE_H_*/

Generated at Thu Feb 26 21:52:29 2004 for torcs by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-1999
TORCS © Eric Espié 1999, 2002.