2 * $Logfile: /Freespace2/code/Starfield/StarField.h $
7 * Code to handle and draw starfields, background space image bitmaps, floating
11 * Revision 1.1 2002/05/03 03:28:12 root
15 * 11 7/21/99 8:10p Dave
16 * First run of supernova effect.
18 * 10 6/03/99 6:37p Dave
19 * More TNT fun. Made perspective bitmaps more flexible.
21 * 9 5/09/99 6:00p Dave
22 * Lots of cool new effects. E3 build tweaks.
24 * 8 5/07/99 1:59p Johnson
25 * Tweaked background bitmaps a bit.
27 * 7 4/23/99 5:53p Dave
28 * Started putting in new pof nebula support into Fred.
30 * 6 4/07/99 6:22p Dave
31 * Fred and Freespace support for multiple background bitmaps and suns.
32 * Fixed link errors on all subprojects. Moved encrypt_init() to
33 * cfile_init() and lcl_init(), since its safe to call twice.
35 * 5 3/31/99 8:24p Dave
36 * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
37 * and background nebulae. Added per-ship non-dimming pixel colors.
39 * 4 11/14/98 5:33p Dave
40 * Lots of nebula work. Put in ship contrails.
42 * 3 11/05/98 5:55p Dave
43 * Big pass at reducing #includes
45 * 2 10/07/98 10:54a Dave
48 * 1 10/07/98 10:51a Dave
50 * 21 4/11/98 6:53p John
51 * Added first rev of subspace effect.
53 * 20 4/07/98 4:17p John
54 * Made Fred be able to move suns. Made suns actually affect the lighting
57 * 19 3/21/98 7:36p Lawrance
58 * Move jump nodes to own lib.
60 * 18 3/19/98 12:29p Lawrance
61 * Fix jumpnode targeting bug on the target monitor
63 * 17 3/15/98 3:41p Allender
64 * new sexpression to gauge whether a ship warped out in proximity of jump
67 * 16 3/11/98 5:33p Lawrance
68 * Support rendering and targeting of jump nodes
70 * 15 3/10/98 4:26p Hoffoss
71 * Changed jump node structure to include a name. Position is now taken
72 * from the object (each jump node has an associated object now).
74 * 14 3/06/98 5:30p Hoffoss
75 * Added jump node rendering code to FreeSpace.
77 * 13 2/26/98 10:08p Hoffoss
78 * Rewrote state saving and restoring to fix bugs and simplify the code.
80 * 12 2/06/98 3:08p Mike
81 * More asteroid stuff, including resolving conflicts between the two
82 * asteroid_field structs!
84 * 11 1/18/98 4:24p John
85 * Detect when view camera "cuts" and tell the star code about it so it
86 * won't blur stars and debris between the last frame and this frame.
88 * 10 8/25/97 5:56p Hoffoss
89 * Added multiple asteroid field support, loading and saving of asteroid
90 * fields, and ship score field to Fred.
92 * 9 8/05/97 10:18a Lawrance
93 * my_rand() being used temporarily instead of rand()
95 * 8 2/17/97 3:06p Hoffoss
96 * Changed header description.
98 * 7 2/14/97 3:29p Hoffoss
99 * Added header for MSDEV to fill in.
110 #define MAX_STARFIELD_BITMAP_LISTS 1
111 #define MAX_STARFIELD_BITMAPS 60
112 #define MAX_ASTEROID_FIELDS 4
114 // nice low polygon background
115 #define BACKGROUND_MODEL_FILENAME "spherec.pof"
117 // global info (not individual instances)
118 typedef struct starfield_bitmap {
119 char filename[MAX_FILENAME_LEN+1]; // bitmap filename
120 char glow_filename[MAX_FILENAME_LEN+1]; // only for suns
121 int bitmap; // bitmap handle
122 int glow_bitmap; // only for suns
124 float r, g, b, i; // only for suns
127 // starfield bitmap instance
128 typedef struct starfield_bitmap_instance {
129 char filename[MAX_FILENAME_LEN+1]; // used to match up into the starfield_bitmap array
130 float scale_x, scale_y; // x and y scale
131 int div_x, div_y; // # of x and y divisions
132 angles ang; // angles from fred
133 } starfield_bitmap_instance;
135 // background bitmaps
136 extern starfield_bitmap Starfield_bitmaps[MAX_STARFIELD_BITMAPS];
137 extern starfield_bitmap_instance Starfield_bitmap_instance[MAX_STARFIELD_BITMAPS];
138 extern int Num_starfield_bitmaps;
140 // sun bitmaps and sun glow bitmaps
141 extern starfield_bitmap Sun_bitmaps[MAX_STARFIELD_BITMAPS];
142 extern starfield_bitmap_instance Suns[MAX_STARFIELD_BITMAPS];
145 extern const int MAX_STARS;
146 extern int Num_stars;
148 // call on game startup
151 // call this in game_post_level_init() so we know whether we're running in full nebula mode or not
152 void stars_level_init();
154 // This *must* be called to initialize the lighting.
155 // You can turn off all the stars and suns and nebulas, though.
156 void stars_draw(int show_stars, int show_suns, int show_nebulas, int show_subspace);
157 // void calculate_bitmap_matrix(starfield_bitmaps *bm, vector *v);
158 // void calculate_bitmap_points(starfield_bitmaps *bm, float bank = 0.0f);
160 // draw the corresponding glow for sun_n
161 void stars_draw_sun_glow(int sun_n);
163 // Call when the viewer camera "cuts" so stars and debris
164 // don't draw incorrect blurs between last frame and this frame.
165 void stars_camera_cut();
167 // call this to set a specific model as the background model
168 void stars_set_background_model(char *model_name, char *texture_name);
170 // lookup a starfield bitmap, return index or -1 on fail
171 int stars_find_bitmap(char *name);
173 // lookup a sun by bitmap filename, return index or -1 on fail
174 int stars_find_sun(char *name);
176 // get the world coords of the sun pos on the unit sphere.
177 void stars_get_sun_pos(int sun_n, vector *pos);