TORCS  1.3.9
The Open Racing Car Simulator
grvtxtable.h
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : grvtxtable.h
4  created : Fri Mar 22 23:16:44 CET 2002
5  copyright : (C) 2001 by Christophe Guionneau
6  version : $Id$
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 /*
20 
21  This class is based on the plib ssgVtxTable and the ssgVtxArray class
22 
23 */
24 /*
25  PLIB - A Suite of Portable Game Libraries
26  Copyright (C) 2001 Steve Baker
27 
28  This library is free software; you can redistribute it and/or
29  modify it under the terms of the GNU Library General Public
30  License as published by the Free Software Foundation; either
31  version 2 of the License, or (at your option) any later version.
32 
33  This library is distributed in the hope that it will be useful,
34  but WITHOUT ANY WARRANTY; without even the implied warranty of
35  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36  Library General Public License for more details.
37 
38  You should have received a copy of the GNU Library General Public
39  License along with this library; if not, write to the Free
40  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
41 
42  For further information visit http://plib.sourceforge.net
43 */
44 
45 #ifndef _GRVTXTABLE_H_
46 #define _GRVTXTABLE_H_
47 #include "grmultitexstate.h"
48 
49 #define LEVELC -1 /* a normal map in LEVEL0 and an env map in LEVEL1 for cars
50  texturecoord of the env map are computed by opengl */
51 #define LEVELC2 -2 /* a normal map in LEVEL0 and an env map in LEVEL2 for cars
52  precomputed and an env map computed by opengl in LEVEL1 */
53 #define LEVELC3 -3 /* a normal map in LEVEL0 and an env map in LEVEL2 for cars
54  precomputed and an shadow env LEVEL1 */
55 #define LEVEL0 1 /* the normal map level */
56 #define LEVEL1 2 /* the high tiled map */
57 #define LEVEL2 4 /* skids and lummy texture */
58 #define LEVEL3 8 /* shadows and other goodies */
59 
60 
61 
62 class grVtxTable : public ssgVtxTable
63 {
67 
68 #define ARRAY 1
69 #define TABLE 2
71 
72 protected:
73  virtual void copy_from ( grVtxTable *src, int clone_flags ) ;
74  ssgIndexArray *indices;
75  ssgIndexArray *stripes;
77  /*virtual void draw_geometry () ;*/
78  /*sgVec2 *texcoords1 ; int num_texcoords1 ; unsigned short *t_index1 ;
79  sgVec2 *texcoords2 ; int num_texcoords2 ; unsigned short *t_index2 ;
80  sgVec2 *texcoords3 ; int num_texcoords3 ; unsigned short *t_index3 ;*/
81 _SSG_PUBLIC:
82  ssgTexCoordArray *texcoords1 ;
83  ssgTexCoordArray *texcoords2 ;
84  ssgTexCoordArray *texcoords3 ;
85 
86 public:
89  int indexCar;
90  virtual ssgBase *clone ( int clone_flags = 0 ) ;
91  /*grVtxTable () ;*/
92  grVtxTable (int _numMapLevel,int _mapLevel) ;
93  grVtxTable ( GLenum ty, ssgVertexArray *vl,
94  ssgNormalArray *nl,
95  ssgTexCoordArray *tl,
96  ssgTexCoordArray *tl1,
97  ssgTexCoordArray *tl2,
98  ssgTexCoordArray *tl3,
99  int _numMapLevel,
100  int _mapLevel,
101  ssgColourArray *cl,
102  int _indexCar ) ;
103  grVtxTable ( GLenum ty, ssgVertexArray *vl,
104  ssgIndexArray * stripeIndex,
105  int _numstripes,
106  ssgIndexArray *il,
107  ssgNormalArray *nl,
108  ssgTexCoordArray *tl,
109  ssgTexCoordArray *tl1,
110  ssgTexCoordArray *tl2,
111  ssgTexCoordArray *tl3,
112  int _numMapLevel,
113  int _mapLevel,
114  ssgColourArray *cl,
115  int _indexCar ) ;
116  grVtxTable (ssgVertexArray *shd_vtx , float initsize, int type);
117 
118  float *getTexCoord1(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
119  return (getNumTexCoords()<=0) ?
120  _ssgTexCoord00 : texcoords1->get(i);}
121  float *getTexCoord2(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
122  return (getNumTexCoords()<=0) ?
123  _ssgTexCoord00 : texcoords2->get(i);}
124  float *getTexCoord3(int i){ if(i>=getNumTexCoords())i=getNumTexCoords()-1;
125  return (getNumTexCoords()<=0) ?
126  _ssgTexCoord00 : texcoords3->get(i);}
127 
128  ssgState *getState1 () { return state1 ; }
129  void setState1 ( ssgState *st );
130  ssgState *getState2 () { return state2 ; }
131  void setState2 ( ssgState *st );
132  ssgState *getState3 () { return state3 ; }
133  void setState3 ( ssgState *st );
134 
135  virtual void draw () ;
136  /*void grVtxTable::draw ();*/
137  void draw_geometry_array();
138  void draw_geometry_multi();
139  void draw_geometry_for_a_car () ;
142  virtual void drawHighlight ( sgVec4 colour ){ssgVtxTable::drawHighlight(colour);} /* doesn't not work */
143  virtual void drawHighlight ( sgVec4 colour, int i ){ssgVtxTable::drawHighlight(colour,i);} /* doesn't work also */
144 
145  virtual void pick ( int baseName ) { ssgVtxTable::pick(baseName);}
146  virtual void transform ( const sgMat4 m ) { ssgVtxTable::transform(m);}
147 
148 
149  int getNumVertices () { return vertices -> getNum () ; }
150  int getNumNormals () { return normals -> getNum () ; }
151  int getNumColours () { return colours -> getNum () ; }
152  int getNumTexCoords () { return texcoords -> getNum () ; }
153 
154  /* the following functions doesn't work with arrays */
155  int getNumTriangles () { return ssgVtxTable::getNumTriangles();}
156  void getTriangle ( int n, short *v1, short *v2, short *v3 ) { ssgVtxTable::getTriangle(n,v1,v2,v3);}
157  int getNumLines () {return ssgVtxTable::getNumLines();}
158  void getLine ( int n, short *v1, short *v2 ) { ssgVtxTable::getLine(n,v1,v2);}
159 
160 
161  virtual ~grVtxTable (void);
162 
163  virtual const char *getTypeName(void) { return ssgVtxTable::getTypeName();}
164 
165  virtual void setVertices ( ssgVertexArray *vl ) { ssgVtxTable::setVertices(vl);}
166  virtual void setNormals ( ssgNormalArray *nl ) { ssgVtxTable::setNormals(nl);}
167  virtual void setTexCoords ( ssgTexCoordArray *tl ) { ssgVtxTable::setTexCoords(tl);}
168  virtual void setColours ( ssgColourArray *cl ) { ssgVtxTable::setColours(cl);}
169 
170  /* the following functions doesn't work with arrays */
171  virtual int load ( FILE *fd ) {return ssgVtxTable::load(fd);}
172  virtual int save ( FILE *fd ) {return ssgVtxTable::save(fd);}
173 };
174 
175 
176 #endif /* _GRVTXTABLE_H_*/
void setState3(ssgState *st)
Definition: grvtxtable.cpp:220
int numStripes
Definition: grvtxtable.h:76
ssgTexCoordArray * texcoords3
Definition: grvtxtable.h:84
void draw_geometry_multi_array()
ssgState * getState3()
Definition: grvtxtable.h:132
ssgTexCoordArray * texcoords2
Definition: grvtxtable.h:83
int getNumTriangles()
Definition: grvtxtable.h:155
void getLine(int n, short *v1, short *v2)
Definition: grvtxtable.h:158
virtual void setNormals(ssgNormalArray *nl)
Definition: grvtxtable.h:166
void draw_geometry_array()
Definition: grvtxtable.cpp:439
virtual void draw()
Definition: grvtxtable.cpp:232
ssgIndexArray * indices
Definition: grvtxtable.h:74
grVtxTable(int _numMapLevel, int _mapLevel)
Definition: grvtxtable.cpp:103
ssgIndexArray * stripes
Definition: grvtxtable.h:75
int getNumColours()
Definition: grvtxtable.h:151
float * getTexCoord3(int i)
Definition: grvtxtable.h:124
grMultiTexState * state3
Definition: grvtxtable.h:66
virtual ssgBase * clone(int clone_flags=0)
Definition: grvtxtable.cpp:95
virtual void transform(const sgMat4 m)
Definition: grvtxtable.h:146
virtual ~grVtxTable(void)
Definition: grvtxtable.cpp:179
int getNumTexCoords()
Definition: grvtxtable.h:152
virtual void pick(int baseName)
Definition: grvtxtable.h:145
virtual void drawHighlight(sgVec4 colour, int i)
Definition: grvtxtable.h:143
int getNumLines()
Definition: grvtxtable.h:157
virtual void setVertices(ssgVertexArray *vl)
Definition: grvtxtable.h:165
float * getTexCoord1(int i)
Definition: grvtxtable.h:118
int mapLevelBitmap
Definition: grvtxtable.h:88
grMultiTexState * state1
Definition: grvtxtable.h:64
void draw_geometry_for_a_car()
Definition: grvtxtable.cpp:346
virtual const char * getTypeName(void)
Definition: grvtxtable.h:163
void getTriangle(int n, short *v1, short *v2, short *v3)
Definition: grvtxtable.h:156
int indexCar
Definition: grvtxtable.h:89
int getNumNormals()
Definition: grvtxtable.h:150
void setState1(ssgState *st)
Definition: grvtxtable.cpp:196
grMultiTexState * state2
Definition: grvtxtable.h:65
virtual int load(FILE *fd)
Definition: grvtxtable.h:171
void draw_geometry_multi()
Definition: grvtxtable.cpp:271
virtual int save(FILE *fd)
Definition: grvtxtable.h:172
virtual void copy_from(grVtxTable *src, int clone_flags)
Definition: grvtxtable.cpp:43
int numMapLevel
Definition: grvtxtable.h:87
ssgState * getState1()
Definition: grvtxtable.h:128
void setState2(ssgState *st)
Definition: grvtxtable.cpp:208
int internalType
Definition: grvtxtable.h:70
void draw_geometry_for_a_car_array()
Definition: grvtxtable.cpp:537
virtual void setColours(ssgColourArray *cl)
Definition: grvtxtable.h:168
virtual void setTexCoords(ssgTexCoordArray *tl)
Definition: grvtxtable.h:167
int getNumVertices()
Definition: grvtxtable.h:149
ssgState * getState2()
Definition: grvtxtable.h:130
virtual void drawHighlight(sgVec4 colour)
Definition: grvtxtable.h:142
float * getTexCoord2(int i)
Definition: grvtxtable.h:121