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