FS2_Open
Open source remastering of the Freespace 2 engine
starfield.cpp File Reference
#include <limits.h>
#include "cmdline/cmdline.h"
#include "debugconsole/console.h"
#include "freespace2/freespace.h"
#include "hud/hud.h"
#include "hud/hudtarget.h"
#include "io/timer.h"
#include "lighting/lighting.h"
#include "math/vecmat.h"
#include "mission/missionparse.h"
#include "model/modelrender.h"
#include "nebula/neb.h"
#include "parse/parselo.h"
#include "render/3d.h"
#include "starfield/nebula.h"
#include "starfield/starfield.h"
#include "starfield/supernova.h"

Go to the source code of this file.

Classes

struct  old_debris
 
struct  flare_info
 
struct  flare_bitmap
 
struct  starfield_bitmap
 
struct  starfield_bitmap_instance
 
struct  star
 
struct  vDist
 
struct  debris_vclip
 

Macros

#define MAX_DEBRIS_VCLIPS   4
 
#define DEBRIS_ROT_MIN   10000
 
#define DEBRIS_ROT_RANGE   8
 
#define DEBRIS_ROT_RANGE_SCALER   10000
 
#define RND_MAX_MASK   0x3fff
 
#define HALF_RND_MAX   0x2000
 
#define MAX_FLARE_COUNT   10
 
#define MAX_FLARE_BMP   6
 
#define CHECK_END()
 
#define STAR_AMOUNT_DEFAULT   0.75f
 
#define STAR_DIM_DEFAULT   7800.0f
 
#define STAR_CAP_DEFAULT   75.0f
 
#define STAR_MAX_LENGTH_DEFAULT   0.04f
 
#define STAR_FLAG_TAIL   (1<<0)
 
#define STAR_FLAG_DIM   (1<<1)
 
#define STAR_FLAG_ANTIALIAS   (1<<2)
 
#define STAR_FLAG_DEFAULT   (STAR_FLAG_TAIL | STAR_FLAG_DIM)
 

Typedefs

typedef struct flare_info flare_info
 
typedef struct flare_bitmap flare_bitmap
 
typedef struct starfield_bitmap starfield_bitmap
 
typedef struct starfield_bitmap_instance starfield_bitmap_instance
 
typedef struct star star
 
typedef struct vDist vDist
 
typedef struct debris_vclip debris_vclip
 

Functions

void stars_release_debris_vclips (debris_vclip *vclips)
 
void stars_load_debris_vclips (debris_vclip *vclips)
 
void stars_load_debris (int fullneb=0)
 
void stars_project_2d_onto_sphere (vec3d *pnt, float rho, float phi, float theta)
 
void parse_startbl (const char *filename)
 
void stars_load_all_bitmaps ()
 
void stars_clear_instances ()
 
void stars_init ()
 
void stars_close ()
 
void stars_pre_level_init (bool clear_backgrounds)
 
void stars_post_level_init ()
 
 DCF (stars,"Set parameters for starfield")
 
void stars_camera_cut ()
 
void stars_get_sun_pos (int sun_n, vec3d *pos)
 
void stars_draw_sun (int show_sun)
 
void stars_draw_lens_flare (vertex *sun_vex, int sun_n)
 
void stars_draw_sun_glow (int sun_n)
 
void stars_draw_bitmaps (int show_bitmaps)
 
 DCF (subspace_set,"Set parameters for subspace effect")
 
void subspace_render ()
 
void stars_draw_stars ()
 
void stars_draw_debris ()
 
void stars_draw (int show_stars, int show_suns, int show_nebulas, int show_subspace, int env)
 
void stars_preload_sun_bitmap (char *fname)
 
void stars_preload_background_bitmap (char *fname)
 
void stars_page_in ()
 
void stars_draw_background ()
 
void stars_set_background_model (char *model_name, char *texture_name, int flags)
 
void stars_set_background_orientation (matrix *orient)
 
int stars_find_bitmap (char *name)
 
int stars_find_sun (char *name)
 
int stars_add_sun_entry (starfield_list_entry *sun_ptr)
 
int stars_add_bitmap_entry (starfield_list_entry *sle)
 
int stars_get_num_entries (bool is_a_sun, bool bitmap_count)
 
starfield_bitmapstars_get_bitmap_entry (int index, bool is_a_sun)
 
bool stars_sun_has_glare (int index)
 
starfield_bitmap_instancestars_get_instance (int index, bool is_a_sun)
 
void stars_mark_instance_unused (int index, bool is_a_sun)
 
const char * stars_get_name_from_instance (int index, bool is_a_sun)
 
void stars_set_nebula (bool activate)
 
const char * stars_get_name_FRED (int index, bool is_a_sun)
 
void stars_modify_entry_FRED (int index, const char *name, starfield_list_entry *sbi_new, bool is_a_sun)
 
void stars_delete_entry_FRED (int index, bool is_a_sun)
 
void stars_load_first_valid_background ()
 
int stars_get_first_valid_background ()
 
void stars_load_background (int background_idx)
 
void stars_copy_background (background_t *dest, background_t *src)
 
void stars_swap_backgrounds (int idx1, int idx2)
 
bool stars_background_empty (int idx)
 
void stars_pack_backgrounds ()
 

Variables

const int MAX_DEBRIS = 200
 
const int MAX_STARS = 2000
 
const float MAX_DIST = 50.0f
 
const float MAX_DIST_RANGE = 60.0f
 
const float MIN_DIST_RANGE = 14.0f
 
const float BASE_SIZE = 0.12f
 
float BASE_SIZE_NEB = 0.5f
 
int Num_stars = 500
 
fix starfield_timestamp = 0
 
int Num_backgrounds = 0
 
int Cur_background = -1
 
background_t Backgrounds [MAX_BACKGROUNDS]
 
int last_stars_filled = 0
 
color star_colors [8]
 
color star_aacolors [8]
 
star Stars [MAX_STARS]
 
old_debris odebris [MAX_DEBRIS]
 
debris_vclip Debris_vclips_normal [] = { { -1, -1, "debris01" }, { -1, -1, "debris02" }, { -1, -1, "debris03" }, { -1, -1, "debris04" } }
 
debris_vclip Debris_vclips_nebula [] = { { -1, -1, "nebdeb01" }, { -1, -1, "nebdeb02" }, { -1, -1, "nebdeb03" }, { -1, -1, "nebdeb04" } }
 
debris_vclipDebris_vclips = Debris_vclips_normal
 
int stars_debris_loaded = 0
 
int Stars_background_inited = 0
 
int Nmodel_num = -1
 
int Nmodel_instance_num = -1
 
matrix Nmodel_orient = IDENTITY_MATRIX
 
int Nmodel_flags = DEFAULT_NMODEL_FLAGS
 
int Nmodel_bitmap = -1
 
int Num_debris_normal = 0
 
int Num_debris_nebula = 0
 
bool Dynamic_environment = false
 
bool Motion_debris_override = false
 
const int MAX_PERSPECTIVE_DIVISIONS = 5
 
const float p_phi = 10.0f
 
const float p_theta = 10.0f
 
objectPlayer_obj
 
float Star_amount = STAR_AMOUNT_DEFAULT
 
float Star_dim = STAR_DIM_DEFAULT
 
float Star_cap = STAR_CAP_DEFAULT
 
float Star_max_length = STAR_MAX_LENGTH_DEFAULT
 
uint Star_flags = STAR_FLAG_DEFAULT
 
int reload_old_debris = 1
 
int Sun_drew
 
int Interp_subspace
 
float Interp_subspace_offset_u
 
float Interp_subspace_offset_v
 
float subspace_offset_u = 0.0f
 
float subspace_offset_u_inner = 0.0f
 
float subspace_offset_v = 0.0f
 
float subspace_u_speed = 0.07f
 
float subspace_v_speed = 0.05f
 
int Subspace_glow_bitmap = -1
 
float Subspace_glow_frame = 0.0f
 
float Subspace_glow_rate = 1.0f
 

Macro Definition Documentation

#define CHECK_END ( )
Value:
{ \
if (in_check) { \
required_string("#end"); \
in_check = false; \
run_count = 0; \
} \
}
int required_string(const char *pstr)
Definition: parselo.cpp:468
if(aifft_max_checks<=0)
Definition: aiturret.cpp:1581

Definition at line 395 of file starfield.cpp.

#define DEBRIS_ROT_MIN   10000

Definition at line 32 of file starfield.cpp.

#define DEBRIS_ROT_RANGE   8

Definition at line 33 of file starfield.cpp.

#define DEBRIS_ROT_RANGE_SCALER   10000

Definition at line 34 of file starfield.cpp.

#define HALF_RND_MAX   0x2000

Definition at line 36 of file starfield.cpp.

#define MAX_DEBRIS_VCLIPS   4

Definition at line 31 of file starfield.cpp.

#define MAX_FLARE_BMP   6

Definition at line 62 of file starfield.cpp.

#define MAX_FLARE_COUNT   10

Definition at line 61 of file starfield.cpp.

#define RND_MAX_MASK   0x3fff

Definition at line 35 of file starfield.cpp.

#define STAR_AMOUNT_DEFAULT   0.75f

Definition at line 859 of file starfield.cpp.

#define STAR_CAP_DEFAULT   75.0f

Definition at line 861 of file starfield.cpp.

#define STAR_DIM_DEFAULT   7800.0f

Definition at line 860 of file starfield.cpp.

#define STAR_FLAG_ANTIALIAS   (1<<2)

Definition at line 871 of file starfield.cpp.

#define STAR_FLAG_DEFAULT   (STAR_FLAG_TAIL | STAR_FLAG_DIM)

Definition at line 872 of file starfield.cpp.

#define STAR_FLAG_DIM   (1<<1)

Definition at line 870 of file starfield.cpp.

#define STAR_FLAG_TAIL   (1<<0)

Definition at line 869 of file starfield.cpp.

#define STAR_MAX_LENGTH_DEFAULT   0.04f

Definition at line 862 of file starfield.cpp.

Typedef Documentation

typedef struct debris_vclip debris_vclip
typedef struct flare_bitmap flare_bitmap
typedef struct flare_info flare_info
typedef struct star star
typedef struct vDist vDist

Function Documentation

DCF ( stars  ,
"Set parameters for starfield"   
)

Definition at line 877 of file starfield.cpp.

DCF ( subspace_set  ,
"Set parameters for subspace effect"   
)

Definition at line 1315 of file starfield.cpp.

void parse_startbl ( const char *  filename)

Definition at line 403 of file starfield.cpp.

int stars_add_bitmap_entry ( starfield_list_entry sle)

Definition at line 2347 of file starfield.cpp.

int stars_add_sun_entry ( starfield_list_entry sun_ptr)

Definition at line 2256 of file starfield.cpp.

bool stars_background_empty ( int  idx)

Definition at line 2744 of file starfield.cpp.

void stars_camera_cut ( )

Definition at line 1005 of file starfield.cpp.

void stars_clear_instances ( )

Definition at line 681 of file starfield.cpp.

void stars_close ( )

Definition at line 706 of file starfield.cpp.

void stars_copy_background ( background_t dest,
background_t src 
)

Definition at line 2728 of file starfield.cpp.

void stars_delete_entry_FRED ( int  index,
bool  is_a_sun 
)

Definition at line 2616 of file starfield.cpp.

void stars_draw ( int  show_stars,
int  show_suns,
int  show_nebulas,
int  show_subspace,
int  env 
)

Definition at line 1813 of file starfield.cpp.

void stars_draw_background ( )

Definition at line 2153 of file starfield.cpp.

void stars_draw_bitmaps ( int  show_bitmaps)

Definition at line 1222 of file starfield.cpp.

void stars_draw_debris ( )

Definition at line 1738 of file starfield.cpp.

void stars_draw_lens_flare ( vertex sun_vex,
int  sun_n 
)

Definition at line 1104 of file starfield.cpp.

void stars_draw_stars ( )

Definition at line 1646 of file starfield.cpp.

void stars_draw_sun ( int  show_sun)

Definition at line 1038 of file starfield.cpp.

void stars_draw_sun_glow ( int  sun_n)

Definition at line 1154 of file starfield.cpp.

int stars_find_bitmap ( char *  name)

Definition at line 2217 of file starfield.cpp.

int stars_find_sun ( char *  name)

Definition at line 2236 of file starfield.cpp.

starfield_bitmap* stars_get_bitmap_entry ( int  index,
bool  is_a_sun 
)

Definition at line 2429 of file starfield.cpp.

int stars_get_first_valid_background ( )

Definition at line 2643 of file starfield.cpp.

starfield_bitmap_instance* stars_get_instance ( int  index,
bool  is_a_sun 
)

Definition at line 2455 of file starfield.cpp.

const char* stars_get_name_FRED ( int  index,
bool  is_a_sun 
)

Definition at line 2543 of file starfield.cpp.

const char* stars_get_name_from_instance ( int  index,
bool  is_a_sun 
)

Definition at line 2495 of file starfield.cpp.

int stars_get_num_entries ( bool  is_a_sun,
bool  bitmap_count 
)

Definition at line 2407 of file starfield.cpp.

void stars_get_sun_pos ( int  sun_n,
vec3d pos 
)

Definition at line 1016 of file starfield.cpp.

void stars_init ( )

Definition at line 693 of file starfield.cpp.

void stars_load_all_bitmaps ( )

Definition at line 596 of file starfield.cpp.

void stars_load_background ( int  background_idx)

Definition at line 2690 of file starfield.cpp.

void stars_load_debris ( int  fullneb = 0)

Definition at line 217 of file starfield.cpp.

void stars_load_debris_vclips ( debris_vclip vclips)

Definition at line 193 of file starfield.cpp.

void stars_load_first_valid_background ( )

Definition at line 2636 of file starfield.cpp.

void stars_mark_instance_unused ( int  index,
bool  is_a_sun 
)

Definition at line 2472 of file starfield.cpp.

void stars_modify_entry_FRED ( int  index,
const char *  name,
starfield_list_entry sbi_new,
bool  is_a_sun 
)

Definition at line 2563 of file starfield.cpp.

void stars_pack_backgrounds ( )

Definition at line 2750 of file starfield.cpp.

void stars_page_in ( )

Definition at line 1905 of file starfield.cpp.

void stars_post_level_init ( )

Definition at line 782 of file starfield.cpp.

void stars_pre_level_init ( bool  clear_backgrounds)

Definition at line 714 of file starfield.cpp.

void stars_preload_background_bitmap ( char *  fname)

Definition at line 1889 of file starfield.cpp.

void stars_preload_sun_bitmap ( char *  fname)

Definition at line 1873 of file starfield.cpp.

void stars_project_2d_onto_sphere ( vec3d pnt,
float  rho,
float  phi,
float  theta 
)

Definition at line 1419 of file 3ddraw.cpp.

void stars_release_debris_vclips ( debris_vclip vclips)

Definition at line 178 of file starfield.cpp.

void stars_set_background_model ( char *  model_name,
char *  texture_name,
int  flags 
)

Definition at line 2172 of file starfield.cpp.

void stars_set_background_orientation ( matrix orient)

Definition at line 2207 of file starfield.cpp.

void stars_set_nebula ( bool  activate)

Definition at line 2514 of file starfield.cpp.

bool stars_sun_has_glare ( int  index)

Definition at line 2448 of file starfield.cpp.

void stars_swap_backgrounds ( int  idx1,
int  idx2 
)

Definition at line 2735 of file starfield.cpp.

void subspace_render ( )

Definition at line 1359 of file starfield.cpp.

Variable Documentation

Definition at line 125 of file starfield.cpp.

const float BASE_SIZE = 0.12f

Definition at line 51 of file starfield.cpp.

float BASE_SIZE_NEB = 0.5f

Definition at line 52 of file starfield.cpp.

int Cur_background = -1

Definition at line 124 of file starfield.cpp.

Definition at line 159 of file starfield.cpp.

debris_vclip Debris_vclips_nebula = { { -1, -1, "nebdeb01" }, { -1, -1, "nebdeb02" }, { -1, -1, "nebdeb03" }, { -1, -1, "nebdeb04" } }

Definition at line 158 of file starfield.cpp.

debris_vclip Debris_vclips_normal = { { -1, -1, "debris01" }, { -1, -1, "debris02" }, { -1, -1, "debris03" }, { -1, -1, "debris04" } }

Definition at line 157 of file starfield.cpp.

bool Dynamic_environment = false

Definition at line 175 of file starfield.cpp.

int Interp_subspace

Definition at line 798 of file modelinterp.cpp.

float Interp_subspace_offset_u

Definition at line 1298 of file starfield.cpp.

float Interp_subspace_offset_v

Definition at line 800 of file modelinterp.cpp.

int last_stars_filled = 0

Definition at line 127 of file starfield.cpp.

const int MAX_DEBRIS = 200

Definition at line 46 of file starfield.cpp.

const float MAX_DIST = 50.0f

Definition at line 48 of file starfield.cpp.

const float MAX_DIST_RANGE = 60.0f

Definition at line 49 of file starfield.cpp.

const int MAX_PERSPECTIVE_DIVISIONS = 5

Definition at line 237 of file starfield.cpp.

const int MAX_STARS = 2000

Definition at line 47 of file starfield.cpp.

const float MIN_DIST_RANGE = 14.0f

Definition at line 50 of file starfield.cpp.

bool Motion_debris_override = false

Definition at line 176 of file starfield.cpp.

int Nmodel_bitmap = -1

Definition at line 170 of file starfield.cpp.

int Nmodel_flags = DEFAULT_NMODEL_FLAGS

Definition at line 169 of file starfield.cpp.

int Nmodel_instance_num = -1

Definition at line 167 of file starfield.cpp.

int Nmodel_num = -1

Definition at line 166 of file starfield.cpp.

matrix Nmodel_orient = IDENTITY_MATRIX

Definition at line 168 of file starfield.cpp.

int Num_backgrounds = 0

Definition at line 123 of file starfield.cpp.

int Num_debris_nebula = 0

Definition at line 173 of file starfield.cpp.

int Num_debris_normal = 0

Definition at line 172 of file starfield.cpp.

int Num_stars = 500

Definition at line 58 of file starfield.cpp.

Definition at line 144 of file starfield.cpp.

const float p_phi = 10.0f

Definition at line 238 of file starfield.cpp.

const float p_theta = 10.0f

Definition at line 238 of file starfield.cpp.

object* Player_obj

Definition at line 56 of file object.cpp.

int reload_old_debris = 1

Definition at line 1001 of file starfield.cpp.

color star_aacolors[8]

Definition at line 129 of file starfield.cpp.

float Star_amount = STAR_AMOUNT_DEFAULT

Definition at line 864 of file starfield.cpp.

float Star_cap = STAR_CAP_DEFAULT

Definition at line 866 of file starfield.cpp.

color star_colors[8]

Definition at line 128 of file starfield.cpp.

float Star_dim = STAR_DIM_DEFAULT

Definition at line 865 of file starfield.cpp.

uint Star_flags = STAR_FLAG_DEFAULT

Definition at line 874 of file starfield.cpp.

float Star_max_length = STAR_MAX_LENGTH_DEFAULT

Definition at line 867 of file starfield.cpp.

fix starfield_timestamp = 0

Definition at line 59 of file starfield.cpp.

star Stars[MAX_STARS]

Definition at line 142 of file starfield.cpp.

int Stars_background_inited = 0

Definition at line 165 of file starfield.cpp.

int stars_debris_loaded = 0

Definition at line 162 of file starfield.cpp.

int Subspace_glow_bitmap = -1

Definition at line 1308 of file starfield.cpp.

float Subspace_glow_frame = 0.0f

Definition at line 1310 of file starfield.cpp.

float Subspace_glow_rate = 1.0f

Definition at line 1311 of file starfield.cpp.

float subspace_offset_u = 0.0f

Definition at line 1301 of file starfield.cpp.

float subspace_offset_u_inner = 0.0f

Definition at line 1302 of file starfield.cpp.

float subspace_offset_v = 0.0f

Definition at line 1303 of file starfield.cpp.

float subspace_u_speed = 0.07f

Definition at line 1305 of file starfield.cpp.

float subspace_v_speed = 0.05f

Definition at line 1306 of file starfield.cpp.

int Sun_drew

Definition at line 31 of file fredstubs.cpp.