Import from neverball-0.25.0.tar.bz2
[neverball-archive.git] / solid.h
blob6d3b00c6c3937f896688e1463903a69040b5cc10
1 /*
2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 #ifndef SOL_H
16 #define SOL_H
18 #include <SDL.h>
19 #include "glext.h"
21 #define PATHMAX 44
24 * Some might be taken aback at the terseness of the names of the
25 * structure members and the variables used by the functions that
26 * access them. Yes, yes, I know: readability. I contend that once
27 * the naming convention is embraced, the names become more readable
28 * than any verbose alternative, and their brevity and uniformity do
29 * more to augment readability than longVariableNames ever could.
31 * Members and variables are named XY. X determines the type of
32 * structure to which the variable refers. Y determines the usage of
33 * the variable.
35 * The Xs are as documented by struct s_file:
37 * m Material (struct s_mtrl)
38 * v Vertex (struct s_vert)
39 * e Edge (struct s_edge)
40 * s Side (struct s_side)
41 * t Texture coord (struct s_texc)
42 * g Geometry (struct s_geom)
43 * l Lump (struct s_lump)
44 * n Node (struct s_node)
45 * p Path (struct s_path)
46 * b Body (struct s_body)
47 * c Coin (struct s_coin)
48 * z Goal (struct s_goal)
49 * u User (struct s_ball)
50 * a Text (char)
51 * i Index (int)
53 * The Ys are as follows:
55 * c Counter
56 * p Pointer
57 * v Vector (array)
58 * 0 Index of the first
59 * i Index
60 * j Subindex
61 * k Subsubindex
63 * Thus "up" is a pointer to a user structure. "lc" is the number of
64 * lumps. "ei" and "ej" are edge indices into some "ev" edge vector.
65 * An edge is defined by two vertices, so an edge structure consists
66 * of "vi" and "vj". And so on.
68 * Those members that do not conform to this convention are explicitly
69 * documented with a comment.
72 /*---------------------------------------------------------------------------*/
74 struct s_mtrl
76 float a[4]; /* ambient color */
77 float d[4]; /* diffuse color */
78 float s[4]; /* specular color */
79 float e[4]; /* emission color */
80 float h[1]; /* specular exponent */
82 char f[PATHMAX]; /* texture file name */
83 GLuint o; /* OpenGL texture object */
86 struct s_vert
88 double p[3]; /* vertex position */
91 struct s_edge
93 int vi;
94 int vj;
97 struct s_side
99 double n[3]; /* plane normal vector */
100 double d; /* distance from origin */
103 struct s_texc
105 double u[2]; /* texture coordinate */
108 struct s_geom
110 int si;
111 int mi;
112 int ti, vi;
113 int tj, vj;
114 int tk, vk;
117 struct s_lump
119 int fl; /* lump flags */
120 int v0;
121 int vc;
122 int e0;
123 int ec;
124 int g0;
125 int gc;
126 int s0;
127 int sc;
130 struct s_node
132 int si;
133 int ni;
134 int nj;
135 int l0;
136 int lc;
139 struct s_path
141 double p[3]; /* starting position */
142 double t; /* travel time */
144 int pi;
147 struct s_body
149 double t; /* time on current path */
151 GLuint ol; /* opaque geometry list */
152 GLuint tl; /* transparent geometry list */
154 int pi;
155 int ni;
156 int l0;
157 int lc;
160 struct s_coin
162 double p[3]; /* position */
163 int n; /* value */
166 struct s_goal
168 double p[3]; /* position */
169 double r; /* radius */
172 struct s_jump
174 double p[3]; /* position */
175 double q[3]; /* target position */
176 double r; /* radius */
179 struct s_ball
181 double e[3][3]; /* basis of orientation */
182 double p[3]; /* position vector */
183 double v[3]; /* velocity vector */
184 double w[3]; /* angular velocity vector */
185 double r; /* radius */
188 struct s_view
190 double p[3];
191 double q[3];
194 struct s_file
196 int mc;
197 int vc;
198 int ec;
199 int sc;
200 int tc;
201 int gc;
202 int lc;
203 int nc;
204 int pc;
205 int bc;
206 int cc;
207 int zc;
208 int jc;
209 int uc;
210 int wc;
211 int ac;
212 int ic;
214 struct s_mtrl *mv;
215 struct s_vert *vv;
216 struct s_edge *ev;
217 struct s_side *sv;
218 struct s_texc *tv;
219 struct s_geom *gv;
220 struct s_lump *lv;
221 struct s_node *nv;
222 struct s_path *pv;
223 struct s_body *bv;
224 struct s_coin *cv;
225 struct s_goal *zv;
226 struct s_jump *jv;
227 struct s_ball *uv;
228 struct s_view *wv;
229 char *av;
230 int *iv;
233 /*---------------------------------------------------------------------------*/
235 int sol_load(struct s_file *, const char *, int);
236 int sol_stor(struct s_file *, const char *);
237 void sol_free(struct s_file *);
239 void sol_draw(const struct s_file *);
240 double sol_step(struct s_file *, const double *, double);
242 int sol_coin_test(struct s_file *, double *, double);
243 int sol_goal_test(struct s_file *, double *);
244 int sol_jump_test(struct s_file *, double *);
246 /*---------------------------------------------------------------------------*/
248 #endif