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