Open source remastering of the Freespace 2 engine
3dsetup.cpp File Reference
#include "graphics/2d.h"
#include "graphics/tmapper.h"
#include "lighting/lighting.h"
#include "render/3dinternal.h"

Go to the source code of this file.


struct  instance_context




int g3_in_frame ()
void g3_start_frame_func (int zbuffer_flag, const char *filename, int lineno)
void g3_end_frame_func (const char *filename, int lineno)
void scale_matrix (void)
void g3_set_view (camera *cam)
void g3_set_view_matrix (const vec3d *view_pos, const matrix *view_matrix, float zoom)
void g3_set_view_angles (const vec3d *view_pos, const angles *view_orient, float zoom)
ubyte g3_rotate_vertex_popped (vertex *dest, const vec3d *src)
void g3_start_instance_matrix (const vec3d *pos, const matrix *orient, bool set_api)
void g3_start_instance_angles (const vec3d *pos, const angles *orient)
void g3_done_instance (bool use_api)
void g3_start_user_clip_plane (const vec3d *plane_point, const vec3d *plane_normal)
void g3_stop_user_clip_plane ()
int g3_point_behind_user_plane (const vec3d *pnt)


matrix View_matrix
vec3d View_position
matrix Unscaled_matrix
matrix Light_matrix
vec3d Light_base
matrix Eye_matrix
vec3d Eye_position
float Eye_fov
float View_zoom
float Proj_fov
vec3d Window_scale
vec3d Matrix_scale
int Canvas_width
int Canvas_height
float Canv_w2
float Canv_h2
vec3d Object_position
matrix Object_matrix
struct instance_context instance_stack [MAX_INSTANCE_DEPTH]
int instance_depth = 0
int G3_count = 0
int G3_frame_count = 0
int Cmdline_nohtl
int G3_user_clip = 0
vec3d G3_user_clip_normal
vec3d G3_user_clip_point

Macro Definition Documentation


Definition at line 46 of file 3dsetup.cpp.

Function Documentation

void g3_done_instance ( bool  use_api)

Pops the old context

Definition at line 341 of file 3dsetup.cpp.

void g3_end_frame_func ( const char *  filename,
int  lineno 

This doesn't do anything, but is here for completeness

Definition at line 126 of file 3dsetup.cpp.

int g3_in_frame ( )

Check if in frame

Definition at line 66 of file 3dsetup.cpp.

int g3_point_behind_user_plane ( const vec3d pnt)

Returns TRUE if point is behind user plane

Definition at line 419 of file 3dsetup.cpp.

ubyte g3_rotate_vertex_popped ( vertex dest,
const vec3d src 

Same as above, only ignores the current instancing

Definition at line 228 of file 3dsetup.cpp.

void g3_set_view ( camera cam)

Set view from camera

Definition at line 137 of file 3dsetup.cpp.

void g3_set_view_angles ( const vec3d view_pos,
const angles view_orient,
float  zoom 

Set view from x,y,z & p,b,h, zoom. Must call one of g3_set_view_*()

Definition at line 182 of file 3dsetup.cpp.

void g3_set_view_matrix ( const vec3d view_pos,
const matrix view_matrix,
float  zoom 

Set view from x,y,z, viewer matrix, and zoom. Must call one of g3_set_view_*()

Definition at line 152 of file 3dsetup.cpp.

void g3_start_frame_func ( int  zbuffer_flag,
const char *  filename,
int  lineno 

Start the frame Pass true for zbuffer_flag to turn on zbuffering

Definition at line 75 of file 3dsetup.cpp.

void g3_start_instance_angles ( const vec3d pos,
const angles orient 

Instance at specified point with specified orientation

If angles==NULL, don't modify matrix. This will be like doing an offset

Definition at line 317 of file 3dsetup.cpp.

void g3_start_instance_matrix ( const vec3d pos,
const matrix orient,
bool  set_api 

nstance at specified point with specified orientation

if matrix==NULL, don't modify matrix. This will be like doing an offset if pos==NULL, no position change

Definition at line 249 of file 3dsetup.cpp.

void g3_start_user_clip_plane ( const vec3d plane_point,
const vec3d plane_normal 

Enables clipping with an arbritary plane.

This will be on until g3_stop_clip_plane is called or until next frame. The points passed should be relative to the instance. Probably that means world coordinates.

This works like any other clip plane... if this is enabled and you rotate a point, the CC_OFF_USER bit will be set in the clipping codes. It is completely handled by most g3_draw primitives, except maybe lines.

As far as performance, when enabled, it will slow down each point rotation (or g3_code_vertex call) by a vec3d subtraction and dot product. It won't slow anything down for polys that are completely clipped on or off by the plane, and will slow each clipped polygon by not much more than any other clipping we do.

Definition at line 381 of file 3dsetup.cpp.

void g3_stop_user_clip_plane ( )

Stops arbritary plane clipping

Definition at line 408 of file 3dsetup.cpp.

void scale_matrix ( void  )

Performs aspect scaling on global view matrix

Definition at line 196 of file 3dsetup.cpp.

Variable Documentation

float Canv_h2

Definition at line 40 of file 3dsetup.cpp.

float Canv_w2

Definition at line 39 of file 3dsetup.cpp.

int Canvas_height

Definition at line 37 of file 3dsetup.cpp.

int Canvas_width

Definition at line 36 of file 3dsetup.cpp.

int Cmdline_nohtl

Definition at line 438 of file cmdline.cpp.

float Eye_fov

Definition at line 28 of file 3dsetup.cpp.

matrix Eye_matrix

Definition at line 26 of file 3dsetup.cpp.

vec3d Eye_position

Definition at line 27 of file 3dsetup.cpp.

int G3_count = 0

Definition at line 59 of file 3dsetup.cpp.

int G3_frame_count = 0

Definition at line 60 of file 3dsetup.cpp.

int G3_user_clip = 0

Definition at line 360 of file 3dsetup.cpp.

vec3d G3_user_clip_normal

Definition at line 361 of file 3dsetup.cpp.

vec3d G3_user_clip_point

Definition at line 362 of file 3dsetup.cpp.

int instance_depth = 0

Definition at line 57 of file 3dsetup.cpp.

struct instance_context instance_stack[MAX_INSTANCE_DEPTH]
vec3d Light_base

Definition at line 24 of file 3dsetup.cpp.

matrix Light_matrix

Definition at line 23 of file 3dsetup.cpp.

vec3d Matrix_scale

Definition at line 34 of file 3dsetup.cpp.

matrix Object_matrix

Definition at line 43 of file 3dsetup.cpp.

vec3d Object_position

Definition at line 42 of file 3dsetup.cpp.

float Proj_fov

Definition at line 31 of file 3dsetup.cpp.

matrix Unscaled_matrix

Definition at line 21 of file 3dsetup.cpp.

matrix View_matrix

Definition at line 19 of file 3dsetup.cpp.

vec3d View_position

Definition at line 20 of file 3dsetup.cpp.

float View_zoom

Definition at line 30 of file 3dsetup.cpp.

vec3d Window_scale

Definition at line 33 of file 3dsetup.cpp.