TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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 */
60
62class grVtxTable : public ssgVtxTable
68#define ARRAY 1
69#define TABLE 2
70 int internalType;
72protected:
73 virtual void copy_from ( grVtxTable *src, int clone_flags ) ;
74 ssgIndexArray *indices;
75 ssgIndexArray *stripes;
76 int numStripes;
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 ;
86public:
87 int numMapLevel;
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);}
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 ();*/
138 void draw_geometry_multi();
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);}
149 int getNumVertices () { return vertices -> getNum () ; }
150 int getNumNormals () { return normals -> getNum () ; }
151 int getNumColours () { return colours -> getNum () ; }
152 int getNumTexCoords () { return texcoords -> getNum () ; }
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
161 virtual ~grVtxTable (void);
163 virtual const char *getTypeName(void) { return ssgVtxTable::getTypeName();}
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);}
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_*/
grVtxTable(int _numMapLevel, int _mapLevel)
virtual int load(FILE *fd)
Definition grvtxtable.h:168
grMultiTexState * state1
Definition grvtxtable.h:61
virtual void transform(const sgMat4 m)
Definition grvtxtable.h:143
ssgState * getState3()
Definition grvtxtable.h:129
virtual ssgBase * clone(int clone_flags=0)
virtual int save(FILE *fd)
Definition grvtxtable.h:169
grMultiTexState * state3
Definition grvtxtable.h:63
ssgState * getState2()
Definition grvtxtable.h:127
int getNumVertices()
Definition grvtxtable.h:146
ssgState * getState1()
Definition grvtxtable.h:125
int getNumLines()
Definition grvtxtable.h:154
int numMapLevel
Definition grvtxtable.h:84
ssgTexCoordArray * texcoords3
Definition grvtxtable.h:81
float * getTexCoord2(int i)
Definition grvtxtable.h:118
void getLine(int n, short *v1, short *v2)
Definition grvtxtable.h:155
void draw_geometry_for_a_car_array()
virtual void setTexCoords(ssgTexCoordArray *tl)
Definition grvtxtable.h:164
virtual void setNormals(ssgNormalArray *nl)
Definition grvtxtable.h:163
grMultiTexState * state2
Definition grvtxtable.h:62
int getNumTriangles()
Definition grvtxtable.h:152
int numStripes
Definition grvtxtable.h:73
int getNumNormals()
Definition grvtxtable.h:147
virtual void pick(int baseName)
Definition grvtxtable.h:142
ssgTexCoordArray * texcoords2
Definition grvtxtable.h:80
virtual void drawHighlight(sgVec4 colour)
Definition grvtxtable.h:139
virtual ~grVtxTable(void)
virtual void copy_from(grVtxTable *src, int clone_flags)
void getTriangle(int n, short *v1, short *v2, short *v3)
Definition grvtxtable.h:153
int internalType
Definition grvtxtable.h:67
int getNumTexCoords()
Definition grvtxtable.h:149
void draw_geometry_multi_array()
void setState3(ssgState *st)
float * getTexCoord1(int i)
Definition grvtxtable.h:115
void draw_geometry_for_a_car()
virtual void setVertices(ssgVertexArray *vl)
Definition grvtxtable.h:162
int getNumColours()
Definition grvtxtable.h:148
ssgIndexArray * indices
Definition grvtxtable.h:71
int mapLevelBitmap
Definition grvtxtable.h:85
virtual const char * getTypeName(void)
Definition grvtxtable.h:160
ssgIndexArray * stripes
Definition grvtxtable.h:72
virtual void setColours(ssgColourArray *cl)
Definition grvtxtable.h:165
void draw_geometry_array()
void setState2(ssgState *st)
float * getTexCoord3(int i)
Definition grvtxtable.h:121
void setState1(ssgState *st)
virtual void draw()
void draw_geometry_multi()