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.
19 #include "base_config.h"
22 * Some might be taken aback at the terseness of the names of the
23 * structure members and the variables used by the functions that
24 * access them. Yes, yes, I know: readability. I contend that once
25 * the naming convention is embraced, the names become more readable
26 * than any verbose alternative, and their brevity and uniformity do
27 * more to augment readability than longVariableNames ever could.
29 * Members and variables are named XY. X determines the type of
30 * structure to which the variable refers. Y determines the usage of
33 * The Xs are as documented by struct s_file:
35 * f File (struct s_file)
36 * m Material (struct s_mtrl)
37 * v Vertex (struct s_vert)
38 * e Edge (struct s_edge)
39 * s Side (struct s_side)
40 * t Texture coord (struct s_texc)
41 * g Geometry (struct s_geom)
42 * l Lump (struct s_lump)
43 * n Node (struct s_node)
44 * p Path (struct s_path)
45 * b Body (struct s_body)
46 * h Item (struct s_item)
47 * z Goal (struct s_goal)
48 * j Jump (struct s_jump)
49 * x Switch (struct s_swch)
50 * r Billboard (struct s_bill)
51 * u User (struct s_ball)
52 * w Viewpoint (struct s_view)
53 * 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: c k o q y.
79 /*---------------------------------------------------------------------------*/
81 /* Material type flags */
84 #define M_TRANSPARENT 2
85 #define M_REFLECTIVE 4
86 #define M_ENVIRONMENT 8
90 #define M_TWO_SIDED 128
92 /* Billboard types. */
108 #define ITEM_SHRINK 3
110 /*---------------------------------------------------------------------------*/
114 float d[4]; /* diffuse color */
115 float a[4]; /* ambient color */
116 float s[4]; /* specular color */
117 float e[4]; /* emission color */
118 float h[1]; /* specular exponent */
121 int fl; /* material flags */
123 GLuint o; /* OpenGL texture object */
124 char f[PATHMAX]; /* texture file name */
129 float p[3]; /* vertex position */
140 float n[3]; /* plane normal vector */
141 float d; /* distance from origin */
146 float u[2]; /* texture coordinate */
159 int fl; /* lump flags */
177 float p[3]; /* starting position */
178 float t; /* travel time */
181 int f; /* enable flag */
182 int s; /* smooth flag */
187 float t; /* time on current path */
189 GLuint ol; /* opaque geometry list */
190 GLuint tl; /* transparent geometry list */
191 GLuint rl; /* reflective geometry list */
192 GLuint sl; /* shadowed geometry list */
204 float p[3]; /* position */
211 float p[3]; /* position */
212 float r; /* radius */
217 float p[3]; /* position */
218 float r; /* radius */
219 int pi; /* the linked path */
221 float t0; /* default timer */
222 float t; /* current timer */
223 int f0; /* default state */
224 int f; /* current state */
225 int i; /* is invisible? */
226 int e; /* is a ball inside it? */
227 int b; /* which ball? */
234 float t; /* repeat time interval */
235 float d; /* distance */
237 float w[3]; /* width coefficients */
238 float h[3]; /* height coefficients */
240 float rx[3]; /* X rotation coefficients */
241 float ry[3]; /* Y rotation coefficients */
242 float rz[3]; /* Z rotation coefficients */
249 float p[3]; /* position */
250 float q[3]; /* target position */
251 float r; /* radius */
256 float e[3][3]; /* basis of orientation */
257 float p[3]; /* position vector */
258 float v[3]; /* velocity vector */
259 float w[3]; /* angular velocity vector */
260 float E[3][3]; /* basis of pendulum */
261 float W[3]; /* angular pendulum velocity */
262 float r; /* radius */
263 int P; /* play state */
264 int m; /* is ball mobile? */
265 float O[3]; /* original position */
325 /*---------------------------------------------------------------------------*/
327 void sol_body_p(float p[3], const struct s_file *, const struct s_body *);
329 /*---------------------------------------------------------------------------*/
331 int sol_load_only_file(struct s_file *, const char *);
332 int sol_load_only_head(struct s_file *, const char *);
333 int sol_stor(struct s_file *, const char *);
334 void sol_free(struct s_file *);
336 float sol_step(struct s_file *, const float *, float, int, int *);
338 int sol_jump_test(struct s_file *, float *, int);
339 int sol_swch_test(struct s_file *);
340 int sol_goal_test(struct s_file *, float *, int);
342 struct s_item *sol_item_test(struct s_file *, float *, float);
344 /*---------------------------------------------------------------------------*/
346 void put_file_state(FILE *, struct s_file *);
347 void get_file_state(FILE *, struct s_file *);
349 /*---------------------------------------------------------------------------*/