-
Notifications
You must be signed in to change notification settings - Fork 2
/
course.h
194 lines (171 loc) · 4.67 KB
/
course.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/* --------------------------------------------------------------------
EXTREME TUXRACER
Copyright (C) 1999-2001 Jasmin F. Patry (Tuxracer)
Copyright (C) 2010 Extreme Tuxracer Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
---------------------------------------------------------------------*/
#ifndef COURSE_H
#define COURSE_H
#include "bh.h"
#define FLOATVAL(i) (*(GLfloat*)(vnc_array+idx+(i)*sizeof(GLfloat)))
#define BYTEVAL(i) (*(GLubyte*)(vnc_array+idx+8*sizeof(GLfloat) +\
i*sizeof(GLubyte)))
#define STRIDE_GL_ARRAY (8 * sizeof(GLfloat) + 4 * sizeof(GLubyte))
#define ELEV(x,y) (elevation[(x) + nx*(y)] )
#define NORM_INTERPOL 0.05
#define XCD(x) ((double)(x) / (nx-1.0) * width)
#define ZCD(y) (-(double)(y) / (ny-1.0) * length)
#define NMLPOINT(x,y) MakeVector (XCD(x), ELEV(x,y), ZCD(y) )
#define MAX_COURSES 64
#define MAX_TERR_TYPES 64
#define MAX_COLL 12192
#define MAX_NOCOLL 8192
#define MAX_OBJECTS 16000
#define MAX_OBJECT_TYPES 128
#define MAX_POLY 128
#define MAX_DESCRIPTION_LINES 8
#define COURSE_TEX_SCALE 6
typedef struct {
string name;
string dir;
string author;
string desc[MAX_DESCRIPTION_LINES];
int num_lines;
GLuint preview;
double width;
double length;
double play_width;
double play_length;
double angle;
double scale;
double startx;
double starty;
int env;
int music_theme;
bool use_keyframe;
double finish_brake;
} TCourse;
typedef struct {
string texture;
string sound;
GLuint texid;
TColor3 col;
double friction;
double depth;
int vol_type;
int particles;
int trackmarks;
int starttex;
int tracktex;
int stoptex;
bool shiny;
} TTerrType;
typedef struct {
string name;
string texture;
GLuint texid;
bool collidable;
double above_ground;
int collectable;
bool drawable;
bool reset_point;
bool use_normal;
TVector3 normal;
int num_objects;
int num_trees;
int num_items;
int poly;
} TObjectType;
class CCourse {
private:
int curr_course;
string CourseIndex;
string ObjectIndex;
int numObjects;
string PolyIndex;
string CourseDir;
bool SaveItemsFlag;
int nx;
int ny;
double width;
double length;
double play_width;
double play_length;
double course_angle;
double course_descent;
double elev_scale;
TVector2 start_pt;
int base_height_value;
int env;
int music_theme;
void FreeTerrainTextures ();
void FreeObjectTextures ();
void CalcNormals ();
void MakeCourseNormals ();
bool LoadElevMap ();
void LoadItemList ();
bool LoadObjectMap ();
bool LoadTerrainMap ();
int GetTerrain (unsigned char pixel[]);
void MirrorCourseData ();
public:
CCourse ();
TCourse CourseList[MAX_COURSES];
TTerrType TerrList[MAX_TERR_TYPES];
TObjectType ObjTypes[MAX_OBJECT_TYPES];
TCollidable CollArr[MAX_COLL];
TItem NocollArr [MAX_NOCOLL];
int numCourses;
int numTerr;
int numObjTypes;
int numColl;
int numNocoll;
TPolyhedron PolyArr[MAX_POLY];
int numPolys;
char *terrain;
double *elevation;
TVector3 *nmls;
GLubyte *vnc_array;
void ResetCourse ();
int GetCourseIdx (string dir);
bool LoadCourseList ();
void FreeCourseList ();
bool LoadCourse (int idx);
bool LoadTerrainTypes ();
bool LoadObjectTypes ();
void MakeStandardPolyhedrons ();
void GetGLArrays (GLubyte **vnc_array);
void FillGlArrays();
void EnableGLArrays();
void DisableGLArrays();
void GetDimensions (double *w, double *l);
void GetPlayDimensions (double *pw, double *pl);
void GetDivisions (int *nx, int *ny);
double GetCourseAngle ();
double GetCourseDescent ();
double GetBaseHeight (double distance);
double GetMaxHeight (double distance);
int GetEnv ();
TVector2 GetStartPoint ();
void SetStartPoint (TVector2 p);
TPolyhedron GetPoly (int type);
void MirrorCourse ();
void GetIndicesForPoint (double x, double z, int *x0, int *y0, int *x1, int *y1);
void FindBarycentricCoords (double x, double z,
TIndex2 *idx0, TIndex2 *idx1, TIndex2 *idx2, double *u, double *v);
double GetMinYCoord();
TVector3 FindCourseNormal (double x, double z);
double FindYCoord (double x, double z);
void GetSurfaceType (double x, double z, double weights[]);
int GetTerrainIdx (double x, double z, double level);
TPlane GetLocalCoursePlane (TVector3 pt);
};
extern CCourse Course;
#endif