1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
/*
* Copyright (C) Volition, Inc. 1999. All rights reserved.
*
* All source code herein is the property of Volition, Inc. You may not sell
* or otherwise commercially exploit the source or things you created based on the
* source.
*
*/
#ifndef __FS2_NEBULA_LIGHTNING_HEADER_FILE
#define __FS2_NEBULA_LIGHTNING_HEADER_FILE
#include "globalincs/globals.h"
#include "globalincs/pstypes.h"
// ------------------------------------------------------------------------------------------------------
// NEBULA LIGHTNING DEFINES/VARS
//
#define MAX_LIGHTNING_NODES 500
#define MAX_LIGHTNING_BOLTS 10
#define MAX_BOLT_TYPES_PER_STORM 10
#define DEBUG_BOLT 0
// lightning nodes
typedef struct l_node {
vec3d pos; // world position
l_node *links[3]; // 3 links for lightning children
l_node *next, *prev; // for used and free-lists only
} l_node;
// lightning bolts
typedef struct l_bolt {
l_node *head; // head of the lightning bolt
int bolt_life; // remaining life timestamp
ubyte used; // used or not
ubyte first_frame; // if he hasn't been rendered at least once
size_t type; // used as index into Bolt_types
// bolt info
vec3d start, strike, midpoint;
int delay; // delay stamp
int strikes_left; // #of strikes left
float width;
} l_bolt;
// one cross-section of a lightning bolt
typedef struct l_section {
vertex vex[3];
vertex glow_vex[2];
} l_section;
// bolt_type - see lightning.tbl for explanations of these values
typedef struct bolt_type {
char name[NAME_LENGTH];
float b_scale;
float b_shrink;
float b_poly_pct;
float b_add;
float b_rand;
float noise;
int lifetime;
int num_strikes;
float emp_intensity;
float emp_time;
int texture;
int glow;
float b_bright;
} bolt_type;
// storm_type - see lightning.tbl for explanations of these values
typedef struct storm_type {
char name[NAME_LENGTH];
ubyte num_bolt_types; // how many different bolt types you'll see in the nebula
size_t bolt_types[MAX_BOLT_TYPES_PER_STORM]; // indices into Bolt types
vec3d flavor; // flavor of the storm
int min, max; // min and max delay between bolt firing.
int min_count, max_count; // # of bolts spewed
storm_type() : num_bolt_types(0) {}
} storm_type;
extern SCP_vector<storm_type> Storm_types;
extern SCP_vector<bolt_type> Bolt_types;
// nebula lightning intensity (0.0 to 1.0)
extern float Nebl_intensity;
// ------------------------------------------------------------------------------------------------------
// NEBULA LIGHTNING FUNCTIONS
//
// initialize nebula lightning at game startup
void nebl_init();
// initialize lightning before entering a level
void nebl_level_init();
// set the storm (call from mission parse)
void nebl_set_storm(char *name);
// render all lightning bolts
void nebl_render_all();
// process lightning (randomly generate bolts, etc, etc);
void nebl_process();
// create a lightning bolt
void nebl_bolt(size_t type, vec3d *start, vec3d *strike);
// get the current # of active lightning bolts
int nebl_get_active_bolts();
// get the current # of active nodes
int nebl_get_active_nodes();
// "new" a lightning node
l_node *nebl_new();
// "delete" a lightning node
void nebl_delete(l_node *lp);
// free up a the nodes of the passed in bolt
void nebl_release(l_node *bolt_head);
// generate a lightning bolt, returns l_left (the "head") and l_right (the "tail")
int nebl_gen(vec3d *left, vec3d *right, float depth, float max_depth, int child, l_node **l_left, l_node **l_right);
// output top and bottom vectors
// fvec == forward vector (eye viewpoint basically. in world coords)
// pos == world coordinate of the point we're calculating "around"
// w == width of the diff between top and bottom around pos
void nebl_calc_facing_pts_smart(vec3d *top, vec3d *bot, vec3d *fvec, vec3d *pos, float w, float z_add );
// render a section of the bolt
void nebl_render_section(bolt_type *bi, l_section *a, l_section *b);
// generate a section
void nebl_generate_section(bolt_type *bi, float width, l_node *a, l_node *b, l_section *c, l_section *cap, int pinch_a, int pinch_b);
// render the bolt
void nebl_render(bolt_type *bi, l_node *whee, float width, l_section *prev = NULL);
// given a valid, complete bolt, jitter him based upon his noise
void nebl_jitter(l_bolt *b);
// return the index of a given bolt type by name
size_t nebl_get_bolt_index(char *name);
// return the index of a given storm type by name
size_t nebl_get_storm_index(char *name);
#endif
|