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.
18 #include "base_config.h"
21 * Some might be taken aback at the terseness of the names of the
22 * structure members and the variables used by the functions that
23 * access them. Yes, yes, I know: readability. I contend that once
24 * the naming convention is embraced, the names become more readable
25 * than any verbose alternative, and their brevity and uniformity do
26 * more to augment readability than longVariableNames ever could.
28 * Members and variables are named XY. X determines the type of
29 * structure to which the variable refers. Y determines the usage of
32 * The Xs are as documented by struct s_base:
34 * f File (struct s_base)
35 * m Material (struct b_mtrl)
36 * v Vertex (struct b_vert)
37 * e Edge (struct b_edge)
38 * s Side (struct b_side)
39 * t Texture coord (struct b_texc)
40 * g Geometry (struct b_geom)
41 * o Offset (struct b_offs)
42 * l Lump (struct b_lump)
43 * n Node (struct b_node)
44 * p Path (struct b_path)
45 * b Body (struct b_body)
46 * h Item (struct b_item)
47 * z Goal (struct b_goal)
48 * j Jump (struct b_jump)
49 * x Switch (struct b_swch)
50 * r Billboard (struct b_bill)
51 * u User (struct b_ball)
52 * w Viewpoint (struct b_view)
53 * d Dictionary (struct b_dict)
57 * The Ys are as follows:
62 * 0 Index of the first
67 * Thus "up" is a pointer to a user structure. "lc" is the number of
68 * lumps. "ei" and "ej" are edge indices into some "ev" edge vector.
69 * An edge is defined by two vertices, so an edge structure consists
70 * of "vi" and "vj". And so on.
72 * Those members that do not conform to this convention are explicitly
73 * documented with a comment.
75 * These prefixes are still available: c k q y.
79 * Additionally, solid data is split into three main parts: static
80 * data (base), simulation data (vary), and rendering data (draw).
83 /*---------------------------------------------------------------------------*/
85 /* Material type flags */
87 #define M_REFLECTIVE (1 << 8)
88 #define M_TRANSPARENT (1 << 7)
89 #define M_SHADOWED (1 << 6)
90 #define M_DECAL (1 << 5)
91 #define M_ENVIRONMENT (1 << 4)
92 #define M_TWO_SIDED (1 << 3)
93 #define M_ADDITIVE (1 << 2)
94 #define M_CLAMP_S (1 << 1)
95 #define M_CLAMP_T (1 << 0)
97 /* Billboard types. */
113 #define ITEM_SHRINK 3
119 /*---------------------------------------------------------------------------*/
123 float d[4]; /* diffuse color */
124 float a[4]; /* ambient color */
125 float s[4]; /* specular color */
126 float e[4]; /* emission color */
127 float h[1]; /* specular exponent */
130 int fl; /* material flags */
132 char f[PATHMAX]; /* texture file name */
137 float p[3]; /* vertex position */
148 float n[3]; /* plane normal vector */
149 float d; /* distance from origin */
154 float u[2]; /* texture coordinate */
170 int fl; /* lump flags */
188 float p[3]; /* starting position */
189 float e[4]; /* orientation (quaternion) */
190 float t; /* travel time */
191 int tm; /* milliseconds */
194 int f; /* enable flag */
195 int s; /* smooth flag */
199 /* TODO: merge enable and smooth into flags. */
214 float p[3]; /* position */
221 float p[3]; /* position */
222 float r; /* radius */
227 float p[3]; /* position */
228 float r; /* radius */
229 int pi; /* the linked path */
231 float t; /* default timer */
232 int tm; /* milliseconds */
233 int f; /* default state */
234 int i; /* is invisible? */
241 float t; /* repeat time interval */
242 float d; /* distance */
244 float w[3]; /* width coefficients */
245 float h[3]; /* height coefficients */
247 float rx[3]; /* X rotation coefficients */
248 float ry[3]; /* Y rotation coefficients */
249 float rz[3]; /* Z rotation coefficients */
256 float p[3]; /* position */
257 float q[3]; /* target position */
258 float r; /* radius */
263 float p[3]; /* position vector */
264 float r; /* radius */
326 /*---------------------------------------------------------------------------*/
328 int sol_load_base(struct s_base *, const char *);
329 int sol_load_meta(struct s_base *, const char *);
330 void sol_free_base(struct s_base *);
331 int sol_stor_base(struct s_base *, const char *);
333 /*---------------------------------------------------------------------------*/