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/Lighting/Lighting.h $
15 * Include file for lighting functions
18 * Revision 1.2 2002/06/09 04:41:13 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 4 6/18/99 5:16p Dave
26 * Added real beam weapon lighting. Fixed beam weapon sounds. Added MOTD
27 * dialog to PXO screen.
29 * 3 5/09/99 6:00p Dave
30 * Lots of cool new effects. E3 build tweaks.
32 * 2 10/07/98 10:53a Dave
35 * 1 10/07/98 10:49a Dave
37 * 13 4/10/98 5:20p John
38 * Changed RGB in lighting structure to be ubytes. Removed old
39 * not-necessary 24 bpp software stuff.
41 * 12 2/13/98 5:00p John
42 * Made lighting push functions return number of releveent lights.
44 * 11 1/29/98 8:14a John
45 * Added support for RGB lighting
47 * 10 1/23/98 5:08p John
48 * Took L out of vertex structure used B (blue) instead. Took all small
49 * fireballs out of fireball types and used particles instead. Fixed some
50 * debris explosion things. Restructured fireball code. Restructured
51 * some lighting code. Made dynamic lighting on by default. Made groups
52 * of lasers only cast one light. Made fireballs not cast light.
54 * 9 12/12/97 3:02p John
55 * First Rev of Ship Shadows
57 * 8 11/07/97 7:24p John
58 * changed lighting to take two ranges.
59 * In textest, added test code to draw nebulas
61 * 7 11/04/97 9:19p John
62 * Optimized dynamic lighting more.
64 * 6 10/29/97 5:05p John
65 * Changed dynamic lighting to only rotate and calculate lighting for
66 * point lights that are close to an object. Changed lower framerate cap
69 * 5 4/08/97 5:18p John
70 * First rev of decent (dynamic, correct) lighting in FreeSpace.
72 * 4 2/17/97 5:18p John
73 * Added a bunch of RCS headers to a bunch of old files that don't have
76 * 3 1/30/97 9:35a Hoffoss
77 * Added header for files.
85 // Light stuff works like this:
86 // At the start of the frame, call light_reset.
87 // For each light source, call light_add_??? functions.
88 // To calculate lighting, do:
89 // call light_filter_reset or light_filter.
90 // set up matrices with g3 functions
91 // call light_rotatate_all to rotate all valid
92 // lights into current coordinates.
93 // call light_apply to fill in lighting for a point.
96 void light_set_ambient(float ambient_light);
98 // Intensity - how strong the light is. 1.0 will cast light around 5meters or so.
99 // r,g,b - only used for colored lighting. Ignored currently.
100 void light_add_directional( vector *dir, float intensity, float r, float g, float b );
101 void light_add_point( vector * pos, float r1, float r2, float intensity, float r, float g, float b, int ignore_objnum );
102 void light_add_point_unique( vector * pos, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum);
103 void light_add_tube(vector *p0, vector *p1, float r1, float r2, float intensity, float r, float g, float b, int affected_objnum);
104 void light_rotate_all();
106 // Reset the list of lights to point to all lights.
107 void light_filter_reset();
109 // Makes a list of only the lights that will affect
110 // the sphere specified by 'pos' and 'rad' and 'objnum'.
111 // Returns number of lights active.
112 int light_filter_push( int objnum, vector *pos, float rad );
113 int light_filter_push_box( vector *min, vector *max );
114 void light_filter_pop();
116 // Applies light to a vertex. In order for this to work,
117 // it assumes that one of light_filter or light_filter_reset
118 // have been called. It only uses 'vert' to fill in it's light
119 // fields. 'pos' is position of point, 'norm' is the norm.
120 ubyte light_apply( vector *pos, vector * norm, float static_light_val );
122 // Same as above only does RGB.
123 void light_apply_rgb( ubyte *param_r, ubyte *param_g, ubyte *param_b, vector *pos, vector * norm, float static_light_val );
125 // return the # of global light sources
126 int light_get_global_count();
128 // Fills direction of global light source N in pos.
129 // Returns 0 if there is no global light.
130 int light_get_global_dir(vector *pos, int n);
132 // Set to non-zero if we're in a shadow.
133 void light_set_shadow( int state );