36 static ubyte Neb2_fog_color_r = 0;
37 static ubyte Neb2_fog_color_g = 0;
38 static ubyte Neb2_fog_color_b = 0;
40 static ubyte *Neb2_htl_fog_data = NULL;
61 "",
"",
"",
"",
"",
""
69 "",
"",
"",
"",
"",
""
78 #define NF_USED (1<<0) // if this nebula slot is used
134 const static float Default_fog_near = 10.0f;
135 const static float Default_fog_far = 500.0f;
138 #define NEB_BACKG_FOG_NEAR_GLIDE 2.5f
139 #define NEB_BACKG_FOG_NEAR_D3D 4.5f
140 #define NEB_BACKG_FOG_FAR_GLIDE 10.0f
141 #define NEB_BACKG_FOG_FAR_D3D 10.0f
172 150.0f, 150.0f / 1.3333f,
183 300.0f, 300.0f / 1.3333f,
194 300.0f, 300.0f / 1.3333f,
205 200.0f, 200.0f / 1.3333f,
261 Neb2_bitmap_count = 0;
268 strcpy_s(Neb2_bitmap_filenames[Neb2_bitmap_count++], name);
291 Assert(Neb2_poof_count == 6);
295 mprintf((
"TABLES: Unable to parse '%s'! Error message = %s.\n",
"nebula.tbl", e.what()));
305 Nd = &Neb2_detail[0];
313 Nd = &Neb2_detail[
level];
321 if (r) *r = Neb2_fog_color_r;
322 if (g) *g = Neb2_fog_color_g;
323 if (b) *b = Neb2_fog_color_b;
362 Neb2_fog_color_r = 30;
363 Neb2_fog_color_g = 52;
364 Neb2_fog_color_b = 157;
367 if (strlen(Neb2_texture_name)) {
368 Neb2_htl_fog_data =
new ubyte[768];
373 for (idx = 0; idx < 768; idx += 3) {
374 if (Neb2_htl_fog_data[idx] || Neb2_htl_fog_data[idx+1] || Neb2_htl_fog_data[idx+2]) {
375 r = r + Neb2_htl_fog_data[
idx];
376 g =
g + Neb2_htl_fog_data[idx+1];
377 b =
b + Neb2_htl_fog_data[idx+2];
383 Neb2_fog_color_r = (
ubyte)(r / pcount);
384 Neb2_fog_color_g = (
ubyte)(
g / pcount);
385 Neb2_fog_color_b = (
ubyte)(
b / pcount);
388 Neb2_fog_color_r = Neb2_fog_color_g = Neb2_fog_color_b = 0;
392 if ( Neb2_htl_fog_data != NULL ) {
393 delete[] Neb2_htl_fog_data;
394 Neb2_htl_fog_data = NULL;
410 pneb_tossed_alpha = 0;
413 neb_tossed_alpha = 0;
415 neb_tossed_count = 0;
457 if (Neb2_htl_fog_data) {
458 delete[] Neb2_htl_fog_data;
459 Neb2_htl_fog_data = NULL;
518 DCF(neb_skip,
"Toggles culling of objects obscured by nebula")
522 dc_printf(
"Using neb object skipping!\n");
524 dc_printf(
"Not using neb object skipping!\n");
529 float fog_near, fog_far;
545 switch( objp->
type ) {
558 if (z_depth >= 500.0
f * Neb2_fog_far_mult) {
600 if (z_depth >= (fog_far * 1.5
f)) {
623 || (
Objects[objnum].instance < 0)
662 if (dist <= inner_radius) {
667 alpha *= (dist - magic_num);
668 return alpha < 0.0f ? 0.0f :
alpha;
672 else if (dist <= outer_radius) {
677 return alpha < 0.0f ? 0.0f : alpha * (outer_radius - dist);
688 float per_pixel_x = incoming_alpha / (
float)Nd->
break_x;
689 float per_pixel_y = incoming_alpha / (
float)Nd->
break_y;
692 float off_x_amount = 0.0f;
693 float off_y_amount = 0.0f;
698 off_x_amount =
fl_abs(sx);
705 off_y_amount =
fl_abs(sy);
714 if (off_y && (off_y_amount > off_x_amount)) {
715 alpha = incoming_alpha - (off_y_amount * per_pixel_y);
717 alpha = incoming_alpha - (off_x_amount * per_pixel_x);
722 alpha = incoming_alpha - (off_y_amount * per_pixel_y);
729 return alpha < 0.0f ? 0.0f :
alpha;
749 if (cube_cen.
xyz.x - eye_pos.
xyz.x > ws) {
751 }
else if (eye_pos.
xyz.x - cube_cen.
xyz.x > ws) {
756 if (cube_cen.
xyz.y - eye_pos.
xyz.y > hs) {
758 }
else if (eye_pos.
xyz.y - cube_cen.
xyz.y > hs) {
763 if (cube_cen.
xyz.z - eye_pos.
xyz.z > ds) {
765 }
else if (eye_pos.
xyz.z - cube_cen.
xyz.z > ds) {
780 Neb2_cubes[dest][idx1][idx2] = Neb2_cubes[
src][idx1][idx2];
787 Neb2_cubes[idx1][dest][idx2] = Neb2_cubes[idx1][
src][idx2];
794 Neb2_cubes[idx1][idx2][dest] = Neb2_cubes[idx1][idx2][
src];
807 float h_incw, h_inch, h_incd;
818 cube_corner = *cube_center;
826 v = &Neb2_cubes[
src][idx1][idx2].
pt;
837 Neb2_cubes[
src][idx1][idx2].
rot = 0.0f;
839 Neb2_cubes[
src][idx1][idx2].
flash = 0.0f;
846 v = &Neb2_cubes[idx1][
src][idx2].
pt;
857 Neb2_cubes[idx1][
src][idx2].
rot = 0.0f;
859 Neb2_cubes[
src][idx1][idx2].
flash = 0.0f;
866 v = &Neb2_cubes[idx1][idx2][
src].
pt;
877 Neb2_cubes[idx1][idx2][
src].
rot = 0.0f;
879 Neb2_cubes[
src][idx1][idx2].
flash = 0.0f;
896 mprintf((
"Regenerating local nebula!\n"));
928 int idx1, idx2, idx3;
954 memset(&p, 0,
sizeof(p));
961 for (idx2=0; idx2<3; idx2++) {
968 for (idx1=Neb2_slices-1; idx1>0; idx1--) {
976 for (idx1=0; idx1<Neb2_slices-1; idx1++) {
984 for (idx1=Neb2_slices-1; idx1>0; idx1--) {
992 for (idx1=0; idx1<Neb2_slices-1; idx1++) {
1000 for (idx1=Neb2_slices-1; idx1>0; idx1--) {
1008 for (idx1=0; idx1<Neb2_slices-1; idx1++) {
1028 if (Neb2_cubes[idx1][idx2][idx3].bmap == -1) {
1036 if (Neb2_cubes[idx1][idx2][idx3].rot >= 360.0
f) {
1037 Neb2_cubes[idx1][idx2][idx3].
rot = 0.0f;
1059 pneb_tossed_alpha++;
1079 pneb_tossed_alpha++;
1094 frames_total += frame_rendered;
1100 #ifdef NEB2_THUMBNAIL
1138 int type_index = -1;
1149 *fnear = Default_fog_near;
1150 *ffar = Default_fog_far;
1157 if(type_index > 0) {
1158 *fnear =
Ship_types[type_index].fog_start_dist;
1159 *ffar =
Ship_types[type_index].fog_complete_dist;
1179 if ((*fnear - *ffar) == 0)
1180 *ffar = *fnear + 1.0f;
1262 #ifdef NEB2_THUMBNAIL
1264 tbmap =
bm_create(16, this_esize, this_esize, tpixels, 0);
1278 if (this_esize != last_esize) {
1291 #define PIXEL_INDEX_SMALL(xv, yv) ( (this_esize * (yv) * gr_screen.bytes_per_pixel) + ((xv) * gr_screen.bytes_per_pixel) )
1304 *r = Neb2_background_color[0];
1305 *g = Neb2_background_color[1];
1306 *b = Neb2_background_color[2];
1318 xs = (
int)(ex_scale * x);
1319 ys = (
int)(ey_scale * y);
1322 if (ys >= (this_esize - 1)) {
1339 if (xs < this_esize - 1) {
1353 if (ys < this_esize - 2) {
1360 if ( (xs > 0) && (ys > 0) ) {
1367 if ( (xs < this_esize - 1) && (ys < this_esize - 1) ) {
1374 if ( (ys > 0) && (xs < this_esize - 1) ) {
1381 if ( (ys < this_esize - 1) && (xs > 0) ) {
1389 rv = (
ubyte)(ra / (
int)avg_count);
1390 gv = (
ubyte)(ga / (
int)avg_count);
1391 bv = (
ubyte)(ba / (
int)avg_count);
1402 *r = Neb2_background_color[0];
1403 *g = Neb2_background_color[1];
1404 *b = Neb2_background_color[2];
1410 Neb2_background_color[0] =
r;
1411 Neb2_background_color[1] =
g;
1412 Neb2_background_color[2] =
b;
1432 static int neb2_choose = 0;
1463 DCF(neb2,
"list nebula console commands")
1471 dc_printf(
"neb2_max_alpha : max alpha value (0.0 to 1.0) for cloud poofs. 0.0 is completely transparent\n");
1472 dc_printf(
"neb2_break_alpha : alpha value (0.0 to 1.0) at which faded polygons are not drawn. higher values generally equals higher framerate, with more visual cloud popping\n");
1473 dc_printf(
"neb2_break_off : how many pixels offscreen (left, right, top, bottom) when a cloud poof becomes fully transparent. Lower values cause quicker fading\n");
1474 dc_printf(
"neb2_smooth : magic fog smoothing modes (0 - 3)\n");
1475 dc_printf(
"neb2_select : <int> <int> where the first # is the bitmap to be adjusting (0 through 5), and the second int is a 0 or 1, to turn off and on\n");
1476 dc_printf(
"neb2_rot : set max rotation speed for poofs\n");
1477 dc_printf(
"neb2_prad : set cloud poof radius\n");
1478 dc_printf(
"neb2_cdim : poof cube dimension\n");
1479 dc_printf(
"neb2_cinner : poof cube inner dimension\n");
1480 dc_printf(
"neb2_couter : poof cube outer dimension\n");
1481 dc_printf(
"neb2_jitter : poof jitter\n");
1482 dc_printf(
"neb2_mode : switch between no nebula, polygon background, pof background, lame, or HTL rendering (0, 1, 2, 3 and 4 respectively)\n\n");
1483 dc_printf(
"neb2_ff : flash fade/sec\n");
1484 dc_printf(
"neb2_background : rgb background color\n");
1485 dc_printf(
"neb2_fog_color : rgb fog color\n");
1490 DCF(neb2_prad,
"set cloud poof radius")
1494 DCF(neb2_cdim,
"poof cube dimension")
1499 DCF(neb2_cinner,
"poof cube inner dimension")
1504 DCF(neb2_couter,
"poof cube outer dimension")
1509 DCF(neb2_jitter,
"poof jitter")
1516 DCF(neb2_max_alpha,
"max alpha value (0.0 to 1.0) for cloud poofs.")
1521 DCF(neb2_break_alpha,
"alpha value (0.0 to 1.0) at which faded polygons are not drawn.")
1526 DCF(neb2_break_off,
"how many pixels offscreen (left, right, top, bottom) when a cloud poof becomes fully transparent.")
1534 DCF(neb2_smooth,
"magic fog smoothing modes (0 - 3)")
1538 if ( (index >= 0) && (index <= 3) ) {
1539 wacky_scheme =
index;
1541 dc_printf(
"Invalid smooth mode %i", index);
1545 DCF(neb2_select,
"Enables/disables a poof bitmap")
1552 if ( (bmap >= 0) && (bmap < Neb2_poof_count) ) {
1559 DCF(neb2_rot,
"set max rotation speed for poofs")
1564 DCF(neb2_ff,
"flash fade/sec")
1569 DCF(neb2_mode,
"Switches nebula render modes")
1601 DCF(neb2_slices,
"Sets how many 'slices' are used in the nebula")
1607 DCF(neb2_background,
"Sets the RGB background color (lame rendering)")
1615 Neb2_background_color[0] =
r;
1616 Neb2_background_color[1] =
g;
1617 Neb2_background_color[2] =
b;
1620 DCF(neb2_fog_color,
"Sets the RGB fog color (HTL)")
1628 Neb2_fog_color_r =
r;
1629 Neb2_fog_color_g =
g;
1630 Neb2_fog_color_b =
b;
ubyte tpixels[ESIZE *ESIZE *4]
void bm_unlock(int handle)
Unlocks a bitmap.
float vm_vec_dot_to_point(const vec3d *dir, const vec3d *p1, const vec3d *p2)
struct screen3d::@234::@236 xyw
float neb2_get_alpha_2shell(float inner_radius, float outer_radius, float magic_num, vec3d *v)
#define MISSION_FLAG_FULLNEB
float frand_range(float min, float max)
Return a floating point number in the range min..max.
void neb2_get_fog_values(float *fnear, float *ffar, object *objp)
float neb2_get_alpha_offscreen(float sx, float sy, float incoming_alpha)
neb2_detail Neb2_detail[MAX_DETAIL_LEVEL]
void stars_set_background_orientation(matrix *orient)
void g3_set_view(camera *cam)
float g3_draw_rotated_bitmap_area(vertex *pnt, float angle, float rad, uint tmap_flags, float area)
#define PIXEL_INDEX_SMALL(xv, yv)
void _cdecl void void _cdecl void _cdecl void _cdecl WarningEx(char *filename, int line, SCP_FORMAT_STRING const char *format,...) SCP_FORMAT_STRING_ARGS(3
void neb2_set_backg_color(int r, int g, int b)
void neb2_render_player()
struct vec3d::@225::@227 xyz
void neb2_get_fog_color(ubyte *r, ubyte *g, ubyte *b)
void neb2_gen_slice(int xyz, int src, vec3d *cube_center)
cube_poof Neb2_cubes[MAX_CPTS][MAX_CPTS][MAX_CPTS]
#define NEB_BACKG_FOG_FAR_D3D
char Neb2_texture_name[MAX_FILENAME_LEN]
void gr_set_bitmap(int bitmap_num, int alphablend_mode, int bitblt_mode, float alpha)
color current_clear_color
DCF(neb_skip,"Toggles culling of objects obscured by nebula")
char Neb2_poof_filenames[MAX_NEB2_POOFS][MAX_FILENAME_LEN]
int bm_release(int handle, int clear_render_targets)
Frees both a bitmap's data and it's associated slot.
void stars_draw_background()
int Neb2_bitmap[MAX_NEB2_BITMAPS]
#define CLAMP(x, min, max)
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void neb2_get_backg_color(int *r, int *g, int *b)
void vm_vec_add2(vec3d *dest, const vec3d *src)
#define GR_ALPHABLEND_FILTER
#define NEB_BACKG_FOG_NEAR_GLIDE
GLdouble GLdouble GLdouble r
struct matrix::@228::@230 vec
float neb2_get_fog_intensity(object *obj)
char Neb2_bitmap_filenames[MAX_NEB2_BITMAPS][MAX_FILENAME_LEN]
void stars_set_background_model(char *model_name, char *texture_name, int flags)
void stuff_string(char *outstr, int type, int len, char *terminators)
int Neb2_poofs[MAX_NEB2_POOFS]
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
int required_string(const char *pstr)
bitmap * bm_lock(int handle, ubyte bpp, ubyte flags, bool nodebug)
Locks down the bitmap indexed by bitmapnum.
int optional_string(const char *pstr)
int pcx_read_header(const char *real_filename, CFILE *img_cfp, int *w, int *h, int *bpp, ubyte *pal)
void read_file_text(const char *filename, int mode, char *processed_text, char *raw_text)
int g3_project_vertex(vertex *point)
float neb2_get_lod_scale(int objnum)
void dc_stuff_ubyte(ubyte *i)
Stuffs an unsigned byte to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats.
GLint GLint GLint GLint GLint x
object Objects[MAX_OBJECTS]
int bm_create(int bpp, int w, int h, void *data, int flags)
int ship_query_general_type(int ship)
int g3_draw_rotated_bitmap(vertex *pnt, float angle, float radius, uint tmap_flags, float depth=0.0f)
#define GM_STANDALONE_SERVER
void dc_stuff_float(float *f)
Stuffs a float to the given variable.
void neb2_render_setup(camid cid)
void reset_parse(char *text)
void dc_stuff_int(int *i)
Stuffs an int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats...
GLuint const GLchar * name
int Neb2_background_color[3]
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
GLboolean GLboolean GLboolean b
void dc_stuff_boolean(bool *b)
stuffs a boolean evaluated integer or string into the given variable.
__inline void gr_fog_set(int fog_mode, int r, int g, int b, float fog_near=-1.0f, float fog_far=-1.0f)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
float vm_vec_dist_quick(const vec3d *v0, const vec3d *v1)
void neb2_pre_render(camid cid)
void neb2_post_level_init()
void bm_page_in_texture(int bitmapnum, int nframes)
Marks a texture as being used for this level.
class camera * getCamera()
int neb2_skip_render(object *objp, float z_depth)
void neb2_get_adjusted_fog_values(float *fnear, float *ffar, object *objp)
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
SCP_vector< ship_info > Ship_info
#define TMAP_FLAG_TEXTURED
void neb2_get_eye_pos(vec3d *eye_vector)
void neb2_get_pixel(int x, int y, int *r, int *g, int *b)
void bm_get_components(ubyte *pixel, ubyte *r, ubyte *g, ubyte *b, ubyte *a)
Gets the RGBA components of a pixel according to the selected mode.
GLsizei GLsizei GLuint * obj
void gr_bitmap(int _x, int _y, int resize_mode)
#define GR_BITBLT_MODE_NORMAL
void dc_printf(const char *format,...)
Prints the given char string to the debug console.
void neb2_set_detail_level(int level)
GLclampf GLclampf GLclampf alpha
void neb2_copy(int xyz, int src, int dest)
#define NEB_BACKG_FOG_FAR_GLIDE
void neb2_get_eye_orient(matrix *eye_matrix)
SCP_vector< ship_type_info > Ship_types
#define BACKGROUND_MODEL_FILENAME
#define g3_start_frame(zbuffer_flag)
void BM_SELECT_SCREEN_FORMAT()
Sets bm_set_components and bm_get_components to reference screen format functions.
#define NEB_BACKG_FOG_NEAR_D3D