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 #include "utils/RandomRange.h" 22 23 class ship; 24 class object; 25 26 extern bool Nebula_sexp_used; 27 // fog near and far values for rendering the background nebula 28 extern float Neb_backg_fog_near; 29 extern float Neb_backg_fog_far; 30 31 // nebula rendering mode 32 #define NEB2_RENDER_NONE 0 // no rendering 33 #define NEB2_RENDER_POF 1 // background is the nice pof file -- used by FRED 34 #define NEB2_RENDER_HTL 2 // We are using proper fogging now 35 extern int Neb2_render_mode; 36 37 // the AWACS suppresion level for the nebula 38 extern float Neb2_awacs; 39 40 // The visual render distance multipliers for the nebula 41 extern float Neb2_fog_near_mult; 42 extern float Neb2_fog_far_mult; 43 44 #define NEB_FOG_VISIBILITY_MULT_TRAIL 1.0f 45 #define NEB_FOG_VISIBILITY_MULT_THRUSTER 1.5f 46 #define NEB_FOG_VISIBILITY_MULT_WEAPON 1.3f 47 #define NEB_FOG_VISIBILITY_MULT_SHIELD 1.2f 48 #define NEB_FOG_VISIBILITY_MULT_GLOWPOINT 1.2f 49 #define NEB_FOG_VISIBILITY_MULT_BEAM(size) 4.0f + (size / 10) 50 #define NEB_FOG_VISIBILITY_MULT_B_MUZZLE(size) NEB_FOG_VISIBILITY_MULT_BEAM(size) 51 #define NEB_FOG_VISIBILITY_MULT_PARTICLE(size) 1.0f + (size / 12) 52 #define NEB_FOG_VISIBILITY_MULT_SHOCKWAVE 2.5f 53 #define NEB_FOG_VISIBILITY_MULT_FIREBALL(size) 1.2f + (size / 12) 54 55 extern int Neb2_poof_flags; 56 const size_t MAX_NEB2_POOFS = 32; 57 58 #define MAX_NEB2_BITMAPS 10 59 60 // pof texture filenames 61 extern char Neb2_bitmap_filenames[MAX_NEB2_BITMAPS][MAX_FILENAME_LEN]; 62 63 // texture to use for this level 64 extern char Neb2_texture_name[MAX_FILENAME_LEN]; 65 66 typedef struct poof_info { 67 char name[NAME_LENGTH]; 68 char bitmap_filename[MAX_FILENAME_LEN]; 69 int bitmap; 70 ::util::UniformFloatRange scale; 71 float density; // poofs per square meter; can get *really* small but vague approximation is ok at those levels 72 ::util::UniformFloatRange rotation; 73 float view_dist; 74 ::util::UniformFloatRange alpha; 75 poof_infopoof_info76 poof_info() { 77 bitmap_filename[0] = '\0'; 78 bitmap = -1; 79 scale = ::util::UniformFloatRange(175.0f, 175.0f); 80 density = 1 / (110.f * 110.f * 110.f); 81 rotation = ::util::UniformFloatRange(-3.7f, 3.7f); 82 view_dist = 250.f; 83 alpha = ::util::UniformFloatRange(0.8f, 0.8f); 84 } 85 } poof_info; 86 87 extern SCP_vector<poof_info> Poof_info; 88 89 // the color of the fog/background 90 extern ubyte Neb2_fog_color[3]; 91 92 // nebula poofs 93 typedef struct poof { 94 vec3d pt; // point in space 95 size_t poof_info_index; 96 float radius; 97 vec3d up_vec; // to keep track of the poofs rotation 98 // must be the full vector instead of an angle to prevent parallel transport when looking around 99 float rot_speed; // rotation speed, deg/sec 100 float flash; // lightning flash 101 float alpha; // base amount of alpha to start with 102 } poof; 103 104 extern SCP_vector<poof> Neb2_poofs; 105 106 // nebula detail level 107 typedef struct neb2_detail { 108 float max_alpha_glide; // max alpha for this detail level in Glide 109 float max_alpha_d3d; // max alpha for this detail level in D3d 110 float break_alpha; // break alpha (below which, poofs don't draw). this affects the speed and visual quality a lot 111 float cube_dim; // total dimension of player poof cube 112 float cube_inner; // inner radius of the player poof cube 113 float cube_outer; // outer radius of the player pood cube 114 float prad; // radius of the poofs 115 float wj, hj, dj; // width, height, depth jittering. best left at 1.0 116 } neb2_detail; 117 118 119 // -------------------------------------------------------------------------------------------------------- 120 // NEBULA FUNCTIONS 121 // 122 123 // neb2 stuff (specific nebula densities) ----------------------------------- 124 125 // initialize neb2 stuff at game startup 126 void neb2_init(); 127 128 //init neb stuff - WMC 129 void neb2_level_init(); 130 131 // initialize nebula stuff - call from game_post_level_init(), so the mission has been loaded 132 void neb2_post_level_init(); 133 134 // shutdown nebula stuff 135 void neb2_level_close(); 136 137 // call before beginning all rendering 138 void neb2_render_setup(camid cid); 139 140 // turns a poof on or off 141 void neb2_toggle_poof(int poof_idx, bool enabling); 142 143 // render the player nebula 144 void neb2_render_poofs(); 145 146 // get near and far fog values based upon object type and rendering mode 147 void neb2_get_fog_values(float *fnear, float *ffar, object *obj = NULL); 148 149 // get adjusted near and far fog values (allows mission-specific fog adjustments) 150 void neb2_get_adjusted_fog_values(float *fnear, float *ffar, float *fdensity = nullptr, object *obj = nullptr); 151 152 // given a position, returns 0 - 1 the fog visibility of that position, 0 = completely obscured 153 // distance_mult will multiply the result, use for things that can be obscured but can 'shine through' the nebula more than normal 154 float neb2_get_fog_visibility (vec3d* pos, float distance_mult); 155 156 // should we not render this object because its obscured by the nebula? 157 int neb2_skip_render(object *objp, float z_depth); 158 159 // extend LOD 160 float neb2_get_lod_scale(int objnum); 161 162 // fogging stuff -------------------------------------------------- 163 164 void neb2_get_fog_color(ubyte *r, ubyte *g, ubyte *b); 165 166 #endif 167