23 #include "Management.h"
45 #include "FredRender.h"
62 static char THIS_FILE[] = __FILE__;
65 #define MAX_FRAMETIME (F1_0/4) // Frametime gets saturated at this.
66 #define MIN_FRAMETIME (F1_0/120)
67 #define LOLLIPOP_SIZE 2.5f
68 #define CONVERT_DEGREES 57.29578f // conversion factor from radians to degrees
118 static vec3d Global_light_world = { 0.208758f, -0.688253f, -0.694782f };
138 #define FRED_COLOUR_WHITE 0xffffff
139 #define FRED_COLOUR_YELLOW 0x9fff00
187 orient->
vec.fvec.xyz.x = orient->
vec.rvec.xyz.x = 0.0f;
189 }
else if (u.
xyz.y) {
190 orient->
vec.fvec.xyz.y = orient->
vec.rvec.xyz.y = 0.0f;
192 }
else if (u.
xyz.z) {
193 orient->
vec.fvec.xyz.z = orient->
vec.rvec.xyz.z = 0.0f;
270 if ((x > y) && (x > z)) {
368 trackball_orient = tempm;
413 vec3d *prev_vec = NULL;
414 for (jj = ii->get_waypoints().begin(); jj != ii->get_waypoints().end(); ++jj)
429 if (prev_vec == NULL)
443 if (prev_vec != NULL)
445 prev_vec = jj->get_pos();
456 if (subsys == NULL) {
457 *world_pos = parent_obj->
pos;
470 if (subsys != NULL) {
604 if (objp != Render_subsys.
ship_obj) {
703 uint debug_flags = 0;
786 int r = 0,
g = 0,
b = 0;
800 r = 0;
g = 127;
b = 0;
803 r = 96;
g = 0;
b = 112;
811 r = 196;
g = 32;
b = 196;
840 uint debug_flags = 0;
930 int r = 0,
g = 0,
b = 0;
945 r = 0;
g = 127;
b = 0;
948 r = 96;
g = 0;
b = 112;
956 r = 196;
g = 32;
b = 196;
1083 ASSERT(ship_type >= 0);
1094 strcpy_s(buf,
"Camera lookat point");
1195 gr_set_color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
1316 raw_key = key & 0xff;
1323 case KEY_A: mvec->
xyz.z += +1.0f;
break;
1324 case KEY_Z: mvec->
xyz.z += -1.0f;
break;
1350 if ((fabs(view_controls.
pitch) > (frametime / 100)) &&
1351 (fabs(view_controls.
vertical) > (frametime / 100)) &&
1352 (fabs(view_controls.
heading) > (frametime / 100)) &&
1353 (fabs(view_controls.
sideways) > (frametime / 100)) &&
1354 (fabs(view_controls.
bank) > (frametime / 100)) &&
1355 (fabs(view_controls.
forward) > (frametime / 100)))
1363 physics_sim(pos, orient, &view_physics, frametime);
1366 vec3d movement_vec, rel_movement_vec;
1390 int i, ncols, nrows;
1407 ncols = gridp->
ncols;
1408 nrows = gridp->
nrows;
1420 for (i=0; i<=ncols; i++)
1426 for (i=0; i<=nrows; i++)
1432 ncols = gridp->
ncols / 2;
1433 nrows = gridp->
nrows / 2;
1441 for (i=0; i<=ncols; i++)
1447 for (i=0; i<=nrows; i++)
1463 int x,
y,
w,
h, inst;
1554 sprintf(buf,
"%s\n%s\n( %.1f , %.1f , %.1f ) \nHeading: %.2f\nPitch: %.2f\nBank: %.2f",
1556 pos.
xyz.x, pos.
xyz.y, pos.
xyz.z, a_deg.
h, a_deg.
p, a_deg.
b);
1562 sprintf(buf,
"%s\nWaypoint %d\n( %.1f , %.1f , %.1f ) ", wp_list->
get_name(), idx + 1, pos.
xyz.x, pos.
xyz.y, pos.
xyz.z);
1565 sprintf(buf,
"Briefing icon\n( %.1f , %.1f , %.1f ) ", pos.
xyz.x, pos.
xyz.y, pos.
xyz.z);
1596 sprintf(buf,
"(%.1f,%.1f,%.1f)", eye_pos.
xyz.x, eye_pos.
xyz.y, eye_pos.
xyz.z);
1617 vec3d viewer_position, control_pos;
1623 viewer_position = my_orient.
vec.fvec;
1655 vec3d delta_pos, leader_old_pos;
1656 matrix leader_orient, leader_transpose, tmp;
1660 leader_old_pos = leader->
pos;
1661 leader_orient = leader->
orient;
1666 control_pos = leader->
pos;
1667 control_orient = leader->
orient;
1765 Last_control_pos = control_pos;
1766 Last_control_orient = control_orient;
1811 for (i=0; i<1 ; i++)
1933 double dist, best_dist = 9e99;
1971 dist = hitpos.
xyz.x * hitpos.
xyz.x + hitpos.
xyz.y * hitpos.
xyz.y + hitpos.
xyz.z * hitpos.
xyz.z;
1972 if (dist < best_dist) {
1997 dist = hitpos.
xyz.x * hitpos.
xyz.x + hitpos.
xyz.y * hitpos.
xyz.y;
1998 if ((dist < 8) && (dist < best_dist)) {
2029 v.
xyz.y = v.
xyz.z = 0.0f;
2037 v.
xyz.x = v.
xyz.z = 0.0f;
2045 v.
xyz.x = v.
xyz.y = 0.0f;
void mc_info_init(mc_info *mc)
void gr_rect(int x, int y, int w, int h, int resize_mode)
int model_collide(mc_info *mc_info_obj)
struct screen3d::@234::@236 xyw
int object_check_collision(object *objp, vec3d *p0, vec3d *p1, vec3d *hitpos)
model_subsystem * system_info
#define MR_SHOW_OUTLINE_HTL
void display_active_ship_subsystem()
float Briefing_window_FOV
matrix * vm_matrix_x_matrix(matrix *dest, const matrix *src0, const matrix *src1)
void draw_orient_sphere(object *obj, int r, int g, int b)
GLfloat GLfloat GLfloat GLfloat h
void vm_vec_scale_add(vec3d *dest, const vec3d *src1, const vec3d *src2, float k)
polymodel * model_get(int model_num)
void process_system_keys(int key)
void gr_string_win(int x, int y, const char *s)
#define BRIEFING_LOOKAT_POINT_ID
#define gr_end_view_matrix
void level_object(matrix *orient)
control_info view_controls
void g3_draw_horizon_line()
matrix * vm_angles_2_matrix(matrix *m, const angles *a)
void object_moved(object *objp)
color * iff_get_color_by_team_and_object(int team, int seen_from_team, int is_bright, object *objp)
waypoint_list * find_waypoint_list_with_instance(int waypoint_instance, int *waypoint_index)
void fred_render_grid(grid *gridp)
const float FRED_DEFAULT_HTL_FOV
void cancel_display_active_ship_subsystem()
void gr_init_alphacolor(color *clr, int r, int g, int b, int alpha, int type)
uint key_get_shift_status()
int subobj_find_2d_bound(float radius, matrix *orient, vec3d *pos, int *x1, int *y1, int *x2, int *y2)
void set_flags(uint flags)
void maybe_create_new_grid(grid *gridp, vec3d *pos, matrix *orient, int force)
struct vec3d::@225::@227 xyz
void model_render_immediate(model_render_params *render_info, int model_num, matrix *orient, vec3d *pos, int render, bool sort)
static CFREDView * GetView()
void rpd_line(vec3d *v0, vec3d *v1)
matrix * vm_copy_transpose(matrix *dest, const matrix *src)
vec3d * vm_vec_rotate(vec3d *dest, const vec3d *src, const matrix *m)
#define END_OF_LIST(head)
void align_vector_to_axis(vec3d *v)
vec3d * get_subsystem_world_pos2(object *parent_obj, ship_subsys *subsys, vec3d *world_pos)
CMainFrame * Fred_main_wnd
matrix Last_control_orient
void vm_vec_scale_add2(vec3d *dest, const vec3d *src, float k)
void gr_set_color_fast(color *dst)
#define MR_DEBUG_BAY_PATHS
waypoint_list * cur_waypoint_list
int g3_draw_line(vertex *p0, vertex *p1)
void verticalize_controlled()
GLfloat GLfloat GLfloat v2
void g3_draw_htl_sphere(const vec3d *position, float radius)
GLenum GLuint GLenum GLsizei const GLchar * buf
grid * create_default_grid(void)
bg_bitmap_dlg * Bg_bitmap_dialog
SCP_list< waypoint_list > Waypoint_lists
#define gr_end_proj_matrix
void render_one_model_nohtl(object *objp)
int double_fine_gridlines
color Fred_grid_bright_aa
void g3_done_instance(bool set_api=false)
void gr_set_color(int r, int g, int b)
int num_initial_asteroids
void vm_fix_matrix(matrix *m)
int query_valid_object(int index)
__inline void gr_set_clip(int x, int y, int w, int h, int resize_mode=GR_RESIZE_FULL)
int vm_matrix_cmp(const matrix *a, const matrix *b)
#define gr_set_view_matrix
int get_subsys_bounding_rect(object *ship_obj, ship_subsys *subsys, int *x1, int *x2, int *y1, int *y2)
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
matrix * vm_transpose(matrix *m)
matrix * vm_vector_2_matrix(matrix *m, const vec3d *fvec, const vec3d *uvec, const vec3d *rvec)
void set_debug_flags(uint flags)
void vm_vec_add2(vec3d *dest, const vec3d *src)
#define gr_set_proj_matrix
void grid_read_camera_controls(control_info *ci, float frametime)
GLdouble GLdouble GLdouble r
struct matrix::@228::@230 vec
int check_mouse_hit(int x, int y)
void vm_vec_scale(vec3d *dest, float s)
int g3_draw_sphere(vertex *pnt, float rad)
GLboolean GLboolean GLboolean GLboolean a
void verticalize_object(matrix *orient)
int rendering_order[MAX_SHIPS]
void physics_sim_editor(vec3d *position, matrix *orient, physics_info *pi, float sim_time)
void g3_set_view_matrix(const vec3d *view_pos, const matrix *view_matrix, float zoom)
void model_clear_instance(int model_num)
void draw_compass_arrow(vec3d *v0)
vec3d gpoints4[MAX_GRIDLINE_POINTS]
void vm_orthogonalize_matrix(matrix *m_src)
sprintf(buf,"(%f,%f,%f)", v3->xyz.x, v3->xyz.y, v3->xyz.z)
vec3d gpoints7[MAX_GRIDLINE_POINTS]
void render_model_x_htl(vec3d *pos, grid *gridp, int col_scheme=0)
ubyte g3_rotate_vertex(vertex *dest, const vec3d *src)
void physics_init(physics_info *pi)
vec3d gpoints5[MAX_GRIDLINE_POINTS]
#define FRED_COLOUR_WHITE
float vm_vec_dist(const vec3d *v0, const vec3d *v1)
angles * vm_extract_angles_matrix(angles *a, const matrix *m)
int Single_axis_constraint
void set_color(color &clr)
int g3_project_vertex(vertex *point)
void jumpnode_render_all()
vec3d * vm_vec_unrotate(vec3d *dest, const vec3d *src, const matrix *m)
void draw_orient_sphere2(int col, object *obj, int r, int g, int b)
GLint GLint GLint GLint GLint x
object Objects[MAX_OBJECTS]
vec3d gpoints6[MAX_GRIDLINE_POINTS]
int fvi_ray_sphere(vec3d *intp, const vec3d *p0, const vec3d *p1, const vec3d *sphere_pos, float sphere_rad)
void set_replacement_textures(int *textures)
#define vm_vec_make(v, _x, _y, _z)
void vm_trackball(int idx, int idy, matrix *RotMat)
vec3d gpoints2[MAX_GRIDLINE_POINTS]
int Fred_grid_colors_inited
physics_info view_physics
vec3d gpoints1[MAX_GRIDLINE_POINTS]
void set_modified(BOOL arg)
__inline void gr_line(int x1, int y1, int x2, int y2, int resize_mode=GR_RESIZE_FULL)
void vm_vec_sub(vec3d *dest, const vec3d *src0, const vec3d *src1)
void physics_read_flying_controls(matrix *orient, physics_info *pi, control_info *ci, float sim_time, vec3d *wash_rot)
int bm_load(const char *real_filename)
Loads a bitmap so we can draw with it later.
GLboolean GLboolean GLboolean b
void physics_sim(vec3d *position, matrix *orient, physics_info *pi, float sim_time)
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void render_one_model_htl(object *objp)
void fredhtl_render_subsystem_bounding_box(subsys_to_render *s2r)
#define FRED_COLOUR_YELLOW
void obj_render_all(void(*render_function)(object *objp), bool *render_viewer_last)
void render_waypoints(void)
void render_one_model_briefing_screen(object *objp)
subsys_to_render Render_subsys
void render_active_rect(void)
fix timer_get_fixed_seconds()
void render_model_x(vec3d *pos, grid *gridp, int col_scheme=0)
void gr_get_string_size(int *w, int *h, const char *text, int len=9999)
char subobj_name[MAX_NAME_LEN]
void stars_draw(int show_stars, int show_suns, int show_nebulas, int show_subspace, int env)
SCP_vector< ship_info > Ship_info
vec3d * vm_vec_avg(vec3d *dest, const vec3d *src0, const vec3d *src1)
void g3_start_instance_matrix(const vec3d *pos, const matrix *orient, bool set_api=true)
int vm_vec_cmp(const vec3d *a, const vec3d *b)
GLsizei GLsizei GLuint * obj
int ENVMAP
References a map that is for environment mapping -Bobboau.
float vm_vec_dot(const vec3d *v0, const vec3d *v1)
void move_mouse(int btn, int mdx, int mdy)
int select_object(int cx, int cy)
void render_one_model(object *objp)
const float FRED_BRIEFING_HTL_FOV
vec3d gpoints3[MAX_GRIDLINE_POINTS]
asteroid_field Asteroid_field
void compute_point_on_plane(vec3d *q, const plane *planep, const vec3d *p)
briefing_editor_dlg * Briefing_dialog
char envmap_name[MAX_FILENAME_LEN]
vec3d gpoints8[MAX_GRIDLINE_POINTS]
void draw_asteroid_field()
void draw_icon(object *objp)
void process_controls(vec3d *pos, matrix *orient, float frametime, int key, int mode=0)
const float FRED_DEAFULT_HTL_DRAW_DIST
void gr_set_font(int fontnum)
void g3_point_to_vec(vec3d *v, int sx, int sy)
void render_compass(void)
void vm_vec_add(vec3d *dest, const vec3d *src0, const vec3d *src1)
void gr_init_color(color *c, int r, int g, int b)
matrix vmd_identity_matrix
void process_movement_keys(int key, vec3d *mvec, angles *angs)
char ship_name[NAME_LENGTH]
#define g3_start_frame(zbuffer_flag)
void g3_draw_htl_line(const vec3d *start, const vec3d *end)