FS2_Open
Open source remastering of the Freespace 2 engine
neb.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 #ifndef _FS2_NEB2_EFFECT_HEADER_FILE
13 #define _FS2_NEB2_EFFECT_HEADER_FILE
14 
15 // --------------------------------------------------------------------------------------------------------
16 // NEBULA DEFINES/VARS
17 //
18 #include "camera/camera.h"
19 #include "globalincs/globals.h"
20 #include "globalincs/pstypes.h"
21 
22 class ship;
23 class object;
24 
25 extern bool Nebula_sexp_used;
26 // fog near and far values for rendering the background nebula
27 extern float Neb_backg_fog_near;
28 extern float Neb_backg_fog_far;
29 
30 // nebula rendering mode
31 #define NEB2_RENDER_NONE 0 // no rendering
32 #define NEB2_RENDER_POLY 1 // background is the old-school polygons
33 #define NEB2_RENDER_POF 2 // background is the nice pof file
34 #define NEB2_RENDER_LAME 3 // super simple nebula effect
35 #define NEB2_RENDER_HTL 4 // We are using proper fogging now
36 extern int Neb2_render_mode;
37 
38 // the AWACS suppresion level for the nebula
39 extern float Neb2_awacs;
40 
41 // The visual render distance multipliers for the nebula
42 extern float Neb2_fog_near_mult;
43 extern float Neb2_fog_far_mult;
44 
45 #define MAX_NEB2_POOFS 6
46 
47 // poof names and flags (for fred)
49 extern int Neb2_poof_flags;
50 
51 #define MAX_NEB2_BITMAPS 10
52 
53 // pof texture filenames
55 
56 // texture to use for this level
58 
59 // how many "slices" are in the current player nebuls
60 extern int Neb2_slices;
61 
62 // nebula poofs
63 typedef struct cube_poof {
64  vec3d pt; // point in space
65  int bmap; // bitmap in space
66  float rot; // rotation angle
67  float rot_speed; // rotation speed
68  float flash; // lightning flash
69 } cube_poof;
70 #define MAX_CPTS 5 // should always be <= slices
72 
73 // nebula detail level
74 typedef struct neb2_detail {
75  float max_alpha_glide; // max alpha for this detail level in Glide
76  float max_alpha_d3d; // max alpha for this detail level in D3d
77  float break_alpha; // break alpha (below which, poofs don't draw). this affects the speed and visual quality a lot
78  float break_x, break_y; // x and y alpha fade/break values. adjust alpha on the polys as they move offscreen
79  float cube_dim; // total dimension of player poof cube
80  float cube_inner; // inner radius of the player poof cube
81  float cube_outer; // outer radius of the player pood cube
82  float prad; // radius of the poofs
83  float wj, hj, dj; // width, height, depth jittering. best left at 1.0
84 } neb2_detail;
85 
86 
87 // --------------------------------------------------------------------------------------------------------
88 // NEBULA FUNCTIONS
89 //
90 
91 // neb2 stuff (specific nebula densities) -----------------------------------
92 
93 // initialize neb2 stuff at game startup
94 void neb2_init();
95 
96 // set detail level
98 
99 //init neb stuff - WMC
100 void neb2_level_init();
101 
102 // initialize nebula stuff - call from game_post_level_init(), so the mission has been loaded
103 void neb2_post_level_init();
104 
105 // shutdown nebula stuff
106 void neb2_level_close();
107 
108 // create a nebula object, return objnum of the nebula or -1 on fail
109 // NOTE : in most cases you will want to pass -1.0f for outer_radius. Trust me on this
110 int neb2_create(vec3d *offset, int num_poofs, float inner_radius, float outer_radius, float max_poof_radius);
111 
112 // delete a nebula object
113 void neb2_delete(object *objp);
114 
115 // call before beginning all rendering
116 void neb2_render_setup(camid cid);
117 
118 // renders a nebula object
119 void neb2_render(object *objp);
120 
121 // preprocess the nebula object before simulation
122 void neb2_process_pre(object *objp);
123 
124 // process the nebula object after simulating, but before rendering
125 void neb2_process_post(object *objp);
126 
127 // render the player nebula
128 void neb2_render_player();
129 
130 // call this when the player's viewpoint has changed, this will cause the code to properly reset
131 // the eye's local poofs
132 void neb2_eye_changed();
133 
134 // get near and far fog values based upon object type and rendering mode
135 void neb2_get_fog_values(float *fnear, float *ffar, object *obj = NULL);
136 
137 // get adjusted near and far fog values (allows mission-specific fog adjustments)
138 void neb2_get_adjusted_fog_values(float *fnear, float *ffar, object *obj = NULL);
139 
140 // given a position in space, return a value from 0.0 to 1.0 representing the fog level
141 float neb2_get_fog_intensity(object *obj);
143 
144 // should we not render this object because its obscured by the nebula?
145 int neb2_skip_render(object *objp, float z_depth);
146 
147 // extend LOD
148 float neb2_get_lod_scale(int objnum);
149 
150 // fogging stuff --------------------------------------------------
151 
152 // get the color of the pixel in the small pre-rendered background nebula
153 void neb2_get_pixel(int x, int y, int *r, int *g, int *b);
154 
155 // set the background color
156 void neb2_set_backg_color(int r, int g, int b);
157 
158 // get the color to fog the background color to
159 void neb2_get_backg_color(int *r, int *g, int *b);
160 
161 void neb2_get_fog_color(ubyte *r, ubyte *g, ubyte *b);
162 
163 #endif
int neb2_create(vec3d *offset, int num_poofs, float inner_radius, float outer_radius, float max_poof_radius)
char Neb2_poof_filenames[MAX_NEB2_POOFS][MAX_FILENAME_LEN]
Definition: neb.cpp:60
#define MAX_FILENAME_LEN
Definition: pstypes.h:324
float break_alpha
Definition: neb.h:77
float rot
Definition: neb.h:66
int neb2_skip_render(object *objp, float z_depth)
Definition: neb.cpp:527
cube_poof Neb2_cubes[MAX_CPTS][MAX_CPTS][MAX_CPTS]
Definition: neb.cpp:165
void neb2_post_level_init()
Definition: neb.cpp:332
float wj
Definition: neb.h:83
Definition: pstypes.h:88
float neb2_get_lod_scale(int objnum)
Definition: neb.cpp:614
float Neb2_fog_near_mult
Definition: neb.cpp:159
void neb2_process_post(object *objp)
int bmap
Definition: neb.h:65
object * objp
Definition: lua.cpp:3105
float neb2_get_fog_intensity(object *obj)
Definition: neb.cpp:1185
bool Nebula_sexp_used
Definition: neb.cpp:34
float prad
Definition: neb.h:82
float Neb_backg_fog_near
Definition: neb.cpp:142
float Neb_backg_fog_far
Definition: neb.cpp:143
GLintptr offset
Definition: Glext.h:5497
void neb2_process_pre(object *objp)
GLdouble GLdouble GLdouble r
Definition: Glext.h:5337
#define MAX_CPTS
Definition: neb.h:70
GLboolean GLboolean g
Definition: Glext.h:5781
float hj
Definition: neb.h:83
float rot_speed
Definition: neb.h:67
struct neb2_detail neb2_detail
void neb2_get_adjusted_fog_values(float *fnear, float *ffar, object *obj=NULL)
Definition: neb.cpp:1170
void neb2_level_close()
Definition: neb.cpp:432
void neb2_set_backg_color(int r, int g, int b)
Definition: neb.cpp:1408
float max_alpha_glide
Definition: neb.h:75
void neb2_delete(object *objp)
float break_y
Definition: neb.h:78
float cube_outer
Definition: neb.h:81
Definition: ship.h:534
#define MAX_NEB2_BITMAPS
Definition: neb.h:51
Definition: neb.h:63
float dj
Definition: neb.h:83
GLint GLint GLint GLint GLint x
Definition: Glext.h:5182
unsigned char ubyte
Definition: pstypes.h:62
Definition: object.h:141
struct cube_poof cube_poof
float cube_dim
Definition: neb.h:79
char Neb2_texture_name[MAX_FILENAME_LEN]
Definition: neb.cpp:75
void neb2_render_setup(camid cid)
Definition: neb.cpp:464
GLboolean GLboolean GLboolean b
Definition: Glext.h:5781
float break_x
Definition: neb.h:78
void neb2_init()
Definition: neb.cpp:250
Definition: pstypes.h:606
void neb2_set_detail_level(int level)
Definition: neb.cpp:301
vec3d pt
Definition: neb.h:64
float flash
Definition: neb.h:68
void neb2_level_init()
Definition: neb.cpp:326
#define MAX_NEB2_POOFS
Definition: neb.h:45
int Neb2_poof_flags
Definition: neb.cpp:64
char Neb2_bitmap_filenames[MAX_NEB2_BITMAPS][MAX_FILENAME_LEN]
Definition: neb.cpp:68
hull_check pos
Definition: lua.cpp:5050
GLsizei GLsizei GLuint * obj
Definition: Glext.h:5619
float cube_inner
Definition: neb.h:80
float Neb2_fog_far_mult
Definition: neb.cpp:160
void neb2_get_pixel(int x, int y, int *r, int *g, int *b)
Definition: neb.cpp:1292
void neb2_eye_changed()
Definition: neb.cpp:1111
void neb2_get_fog_values(float *fnear, float *ffar, object *obj=NULL)
Definition: neb.cpp:1136
void neb2_get_fog_color(ubyte *r, ubyte *g, ubyte *b)
Definition: neb.cpp:319
void neb2_get_backg_color(int *r, int *g, int *b)
Definition: neb.cpp:1400
float Neb2_awacs
Definition: neb.cpp:156
GLint level
Definition: Glext.h:5180
void neb2_render_player()
Definition: neb.cpp:925
int Neb2_slices
Definition: neb.cpp:163
float max_alpha_d3d
Definition: neb.h:76
void neb2_render(object *objp)
GLint y
Definition: Gl.h:1505
int Neb2_render_mode
Definition: neb.cpp:57