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.
20 #include "base_config.h"
23 * Some might be taken aback at the terseness of the names of the
24 * structure members and the variables used by the functions that
25 * access them. Yes, yes, I know: readability. I contend that once
26 * the naming convention is embraced, the names become more readable
27 * than any verbose alternative, and their brevity and uniformity do
28 * more to augment readability than longVariableNames ever could.
30 * Members and variables are named XY. X determines the type of
31 * structure to which the variable refers. Y determines the usage of
34 * The Xs are as documented by struct s_file:
36 * f File (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 * j Jump (struct s_jump)
50 * x Switch (struct s_swch)
51 * r Billboard (struct s_bill)
52 * u User (struct s_ball)
53 * w Viewpoint (struct s_view)
54 * d Dictionary (struct s_dict)
58 * The Ys are as follows:
63 * 0 Index of the first
68 * Thus "up" is a pointer to a user structure. "lc" is the number of
69 * lumps. "ei" and "ej" are edge indices into some "ev" edge vector.
70 * An edge is defined by two vertices, so an edge structure consists
71 * of "vi" and "vj". And so on.
73 * Those members that do not conform to this convention are explicitly
74 * documented with a comment.
76 * These prefixes are still available: h k o q y.
79 /*---------------------------------------------------------------------------*/
81 /* Material type flags */
84 #define M_TRANSPARENT 2
85 #define M_REFLECTIVE 4
86 #define M_ENVIRONMENT 8
89 #define M_SHADOWED (M_OPAQUE | M_REFLECTIVE | M_ENVIRONMENT)
91 /* Billboard types. */
101 /*---------------------------------------------------------------------------*/
105 float a[4]; /* ambient color */
106 float d[4]; /* diffuse color */
107 float s[4]; /* specular color */
108 float e[4]; /* emission color */
109 float h[1]; /* specular exponent */
111 int fl; /* material flags */
113 GLuint o; /* OpenGL texture object */
114 char f[PATHMAX]; /* texture file name */
119 float p[3]; /* vertex position */
130 float n[3]; /* plane normal vector */
131 float d; /* distance from origin */
136 float u[2]; /* texture coordinate */
149 int fl; /* lump flags */
167 float p[3]; /* starting position */
168 float t; /* travel time */
171 int f; /* enable flag */
176 float t; /* time on current path */
178 GLuint ol; /* opaque geometry list */
179 GLuint tl; /* transparent geometry list */
180 GLuint rl; /* reflective geometry list */
181 GLuint sl; /* shadowed geometry list */
193 float p[3]; /* position */
199 float p[3]; /* position */
200 float r; /* radius */
205 float p[3]; /* position */
206 float r; /* radius */
209 float t0; /* default timer */
210 float t; /* current timer */
211 int f0; /* default state */
212 int f; /* current state */
219 float t; /* repeat time interval */
220 float d; /* distance */
222 float w[3]; /* width coefficients */
223 float h[3]; /* height coefficients */
225 float rx[3]; /* X rotation coefficients */
226 float ry[3]; /* Y rotation coefficients */
227 float rz[3]; /* Z rotation coefficients */
232 float p[3]; /* position */
233 float q[3]; /* target position */
234 float r; /* radius */
239 float e[3][3]; /* basis of orientation */
240 float p[3]; /* position vector */
241 float v[3]; /* velocity vector */
242 float w[3]; /* angular velocity vector */
243 float r; /* radius */
302 /*---------------------------------------------------------------------------*/
304 int sol_load_only_file(struct s_file *, const char *);
305 int sol_load(struct s_file *, const char *, int, int);
306 int sol_stor(struct s_file *, const char *);
307 void sol_free(struct s_file *);
309 void sol_back(const struct s_file *, float, float, float);
310 void sol_refl(const struct s_file *);
311 void sol_draw(const struct s_file *);
312 void sol_shad(const struct s_file *);
314 float sol_step(struct s_file *, const float *, float, int, int *);
316 int sol_coin_test(struct s_file *, float *, float);
317 int sol_goal_test(struct s_file *, float *, int);
318 int sol_jump_test(struct s_file *, float *, int);
319 int sol_swch_test(struct s_file *, int, int);
321 /*---------------------------------------------------------------------------*/
323 void put_file_state(FILE *, struct s_file *);
324 void get_file_state(FILE *, struct s_file *);
326 /*---------------------------------------------------------------------------*/