]> icculus.org git repositories - taylor/freespace2.git/blob - include/starfield.h
Initial revision
[taylor/freespace2.git] / include / starfield.h
1 /*
2  * $Logfile: /Freespace2/code/Starfield/StarField.h $
3  * $Revision$
4  * $Date$
5  * $Author$
6  *
7  * Code to handle and draw starfields, background space image bitmaps, floating
8  * debris, etc.
9  *
10  * $Log$
11  * Revision 1.1  2002/05/03 03:28:12  root
12  * Initial revision
13  *
14  * 
15  * 11    7/21/99 8:10p Dave
16  * First run of supernova effect.
17  * 
18  * 10    6/03/99 6:37p Dave
19  * More TNT fun. Made perspective bitmaps more flexible.
20  * 
21  * 9     5/09/99 6:00p Dave
22  * Lots of cool new effects. E3 build tweaks.
23  * 
24  * 8     5/07/99 1:59p Johnson
25  * Tweaked background bitmaps a bit.
26  * 
27  * 7     4/23/99 5:53p Dave
28  * Started putting in new pof nebula support into Fred.
29  * 
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.
34  * 
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.
38  * 
39  * 4     11/14/98 5:33p Dave
40  * Lots of nebula work. Put in ship contrails.
41  * 
42  * 3     11/05/98 5:55p Dave
43  * Big pass at reducing #includes
44  * 
45  * 2     10/07/98 10:54a Dave
46  * Initial checkin.
47  * 
48  * 1     10/07/98 10:51a Dave
49  * 
50  * 21    4/11/98 6:53p John
51  * Added first rev of subspace effect.
52  * 
53  * 20    4/07/98 4:17p John
54  * Made Fred be able to move suns.  Made suns actually affect the lighting
55  * in the game.
56  * 
57  * 19    3/21/98 7:36p Lawrance
58  * Move jump nodes to own lib.
59  * 
60  * 18    3/19/98 12:29p Lawrance
61  * Fix jumpnode targeting bug on the target monitor
62  * 
63  * 17    3/15/98 3:41p Allender
64  * new sexpression to gauge whether a ship warped out in proximity of jump
65  * node
66  * 
67  * 16    3/11/98 5:33p Lawrance
68  * Support rendering and targeting of jump nodes
69  * 
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).
73  * 
74  * 14    3/06/98 5:30p Hoffoss
75  * Added jump node rendering code to FreeSpace.
76  * 
77  * 13    2/26/98 10:08p Hoffoss
78  * Rewrote state saving and restoring to fix bugs and simplify the code.
79  * 
80  * 12    2/06/98 3:08p Mike
81  * More asteroid stuff, including resolving conflicts between the two
82  * asteroid_field structs!
83  * 
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.
87  * 
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.
91  * 
92  * 9     8/05/97 10:18a Lawrance
93  * my_rand() being used temporarily instead of rand()
94  * 
95  * 8     2/17/97 3:06p Hoffoss
96  * Changed header description.
97  * 
98  * 7     2/14/97 3:29p Hoffoss
99  * Added header for MSDEV to fill in.
100  *
101  * $NoKeywords: $
102  */
103
104 #ifndef _STARFIELD_H
105 #define _STARFIELD_H
106
107 #include "parselo.h"
108 #include "cfile.h"
109
110 #define MAX_STARFIELD_BITMAP_LISTS      1
111 #define MAX_STARFIELD_BITMAPS                   60
112 #define MAX_ASTEROID_FIELDS                     4
113
114 // nice low polygon background
115 #define BACKGROUND_MODEL_FILENAME                                       "spherec.pof"
116
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
123         int xparent;    
124         float r, g, b, i;                                                                               // only for suns
125 } starfield_bitmap;
126
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;
134
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;
139
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];
143 extern int Num_suns;
144
145 extern const int MAX_STARS;
146 extern int Num_stars;
147
148 // call on game startup
149 void stars_init();
150
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();
153
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);
159
160 // draw the corresponding glow for sun_n
161 void stars_draw_sun_glow(int sun_n);
162
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();
166
167 // call this to set a specific model as the background model
168 void stars_set_background_model(char *model_name, char *texture_name);
169
170 // lookup a starfield bitmap, return index or -1 on fail
171 int stars_find_bitmap(char *name);
172
173 // lookup a sun by bitmap filename, return index or -1 on fail
174 int stars_find_sun(char *name);
175
176 // get the world coords of the sun pos on the unit sphere.
177 void stars_get_sun_pos(int sun_n, vector *pos);
178
179 #endif
180