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.3 2003/05/25 02:30:42 taylor
22 * Revision 1.2 2002/06/09 04:41:15 relnev
23 * added copyright header
25 * Revision 1.1.1.1 2002/05/03 03:28:12 root
29 * 11 7/21/99 8:10p Dave
30 * First run of supernova effect.
32 * 10 6/03/99 6:37p Dave
33 * More TNT fun. Made perspective bitmaps more flexible.
35 * 9 5/09/99 6:00p Dave
36 * Lots of cool new effects. E3 build tweaks.
38 * 8 5/07/99 1:59p Johnson
39 * Tweaked background bitmaps a bit.
41 * 7 4/23/99 5:53p Dave
42 * Started putting in new pof nebula support into Fred.
44 * 6 4/07/99 6:22p Dave
45 * Fred and Freespace support for multiple background bitmaps and suns.
46 * Fixed link errors on all subprojects. Moved encrypt_init() to
47 * cfile_init() and lcl_init(), since its safe to call twice.
49 * 5 3/31/99 8:24p Dave
50 * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
51 * and background nebulae. Added per-ship non-dimming pixel colors.
53 * 4 11/14/98 5:33p Dave
54 * Lots of nebula work. Put in ship contrails.
56 * 3 11/05/98 5:55p Dave
57 * Big pass at reducing #includes
59 * 2 10/07/98 10:54a Dave
62 * 1 10/07/98 10:51a Dave
64 * 21 4/11/98 6:53p John
65 * Added first rev of subspace effect.
67 * 20 4/07/98 4:17p John
68 * Made Fred be able to move suns. Made suns actually affect the lighting
71 * 19 3/21/98 7:36p Lawrance
72 * Move jump nodes to own lib.
74 * 18 3/19/98 12:29p Lawrance
75 * Fix jumpnode targeting bug on the target monitor
77 * 17 3/15/98 3:41p Allender
78 * new sexpression to gauge whether a ship warped out in proximity of jump
81 * 16 3/11/98 5:33p Lawrance
82 * Support rendering and targeting of jump nodes
84 * 15 3/10/98 4:26p Hoffoss
85 * Changed jump node structure to include a name. Position is now taken
86 * from the object (each jump node has an associated object now).
88 * 14 3/06/98 5:30p Hoffoss
89 * Added jump node rendering code to FreeSpace.
91 * 13 2/26/98 10:08p Hoffoss
92 * Rewrote state saving and restoring to fix bugs and simplify the code.
94 * 12 2/06/98 3:08p Mike
95 * More asteroid stuff, including resolving conflicts between the two
96 * asteroid_field structs!
98 * 11 1/18/98 4:24p John
99 * Detect when view camera "cuts" and tell the star code about it so it
100 * won't blur stars and debris between the last frame and this frame.
102 * 10 8/25/97 5:56p Hoffoss
103 * Added multiple asteroid field support, loading and saving of asteroid
104 * fields, and ship score field to Fred.
106 * 9 8/05/97 10:18a Lawrance
107 * my_rand() being used temporarily instead of rand()
109 * 8 2/17/97 3:06p Hoffoss
110 * Changed header description.
112 * 7 2/14/97 3:29p Hoffoss
113 * Added header for MSDEV to fill in.
124 #define MAX_STARFIELD_BITMAP_LISTS 1
125 #define MAX_STARFIELD_BITMAPS 60
126 #define MAX_ASTEROID_FIELDS 4
128 // nice low polygon background
129 #define BACKGROUND_MODEL_FILENAME "spherec.pof"
131 // global info (not individual instances)
132 typedef struct starfield_bitmap {
133 char filename[MAX_FILENAME_LEN+1]; // bitmap filename
134 char glow_filename[MAX_FILENAME_LEN+1]; // only for suns
135 int bitmap; // bitmap handle
136 int glow_bitmap; // only for suns
138 float r, g, b, i; // only for suns
141 // starfield bitmap instance
142 typedef struct starfield_bitmap_instance {
143 char filename[MAX_FILENAME_LEN+1]; // used to match up into the starfield_bitmap array
144 float scale_x, scale_y; // x and y scale
145 int div_x, div_y; // # of x and y divisions
146 angles ang; // angles from fred
148 matrix m; // straight matrix instead of angles to matrix
149 int sun_light; // FIXME: not sure what this is supposed to do
150 float rot; // rotation rate - always 0?
152 } starfield_bitmap_instance;
154 // background bitmaps
155 extern starfield_bitmap Starfield_bitmaps[MAX_STARFIELD_BITMAPS];
156 extern starfield_bitmap_instance Starfield_bitmap_instance[MAX_STARFIELD_BITMAPS];
157 extern int Num_starfield_bitmaps;
159 // sun bitmaps and sun glow bitmaps
160 extern starfield_bitmap Sun_bitmaps[MAX_STARFIELD_BITMAPS];
161 extern starfield_bitmap_instance Suns[MAX_STARFIELD_BITMAPS];
164 extern const int MAX_STARS;
165 extern int Num_stars;
167 // call on game startup
170 // call this in game_post_level_init() so we know whether we're running in full nebula mode or not
171 void stars_level_init();
173 // This *must* be called to initialize the lighting.
174 // You can turn off all the stars and suns and nebulas, though.
175 void stars_draw(int show_stars, int show_suns, int show_nebulas, int show_subspace);
176 // void calculate_bitmap_matrix(starfield_bitmaps *bm, vector *v);
177 // void calculate_bitmap_points(starfield_bitmaps *bm, float bank = 0.0f);
179 // draw the corresponding glow for sun_n
180 void stars_draw_sun_glow(int sun_n);
182 // Call when the viewer camera "cuts" so stars and debris
183 // don't draw incorrect blurs between last frame and this frame.
184 void stars_camera_cut();
186 // call this to set a specific model as the background model
187 void stars_set_background_model(const char *model_name, const char *texture_name);
189 // lookup a starfield bitmap, return index or -1 on fail
190 int stars_find_bitmap(const char *name);
192 // lookup a sun by bitmap filename, return index or -1 on fail
193 int stars_find_sun(const char *name);
195 // get the world coords of the sun pos on the unit sphere.
196 void stars_get_sun_pos(int sun_n, vector *pos);