Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions code/missionui/missionscreencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,12 +1663,17 @@ void draw_model_icon(int model_id, uint64_t flags, float closeup_zoom, int x, in
gr_reset_clip();
}

void draw_model_rotating(model_render_params *render_info, int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, const vec3d *closeup_pos, float closeup_zoom, float rev_rate, uint64_t flags, int resize_mode, select_effect_params effect_params)
void draw_model_rotating(model_render_params *render_info, int ship_class, int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, const vec3d *closeup_pos, float closeup_zoom, float rev_rate, uint64_t flags, int resize_mode, select_effect_params effect_params)
{
//WMC - Can't draw a non-model
if (model_id < 0)
return;

int model_instance = model_create_instance(model_objnum_special::OBJNUM_NONE, model_id);
if (!(flags & MR_IS_MISSILE) && SCP_vector_inbounds(Ship_info, ship_class)) {
model_set_up_techroom_instance(&Ship_info[ship_class], model_instance);
}

float time = (timer_get_milliseconds()-anim_timer_start)/1000.0f;
angles rot_angles, view_angles;
matrix model_orient;
Expand Down Expand Up @@ -1822,7 +1827,7 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
shadows_start_render(&Eye_matrix, &Eye_position, Proj_fov, gr_screen.clip_aspect, -closeup_pos->xyz.z + pm->rad, -closeup_pos->xyz.z + pm->rad + 200.0f, -closeup_pos->xyz.z + pm->rad + 2000.0f, -closeup_pos->xyz.z + pm->rad + 10000.0f);
}

model_render_immediate(&shadow_render_info, model_id, &model_orient, &vmd_zero_vector);
model_render_immediate(&shadow_render_info, model_id, model_instance, &model_orient, &vmd_zero_vector);
shadows_end_render();

gr_set_clip(x1, y1, x2, y2, resize_mode);
Expand All @@ -1842,14 +1847,14 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,

render_info->set_flags(flags | MR_SHOW_OUTLINE_HTL | MR_NO_POLYS | MR_NO_TEXTURING | MR_NO_LIGHTING);

model_render_immediate(render_info, model_id, &model_orient, &vmd_zero_vector);
model_render_immediate(render_info, model_id, model_instance, &model_orient, &vmd_zero_vector);
}

if (time >= 1.5f) { // Render the ship in Phase 2 onwards
render_info->set_clip_plane(plane_point,ship_normal);
render_info->set_flags(flags);

model_render_immediate(render_info, model_id, &model_orient, &vmd_zero_vector);
model_render_immediate(render_info, model_id, model_instance, &model_orient, &vmd_zero_vector);
}

if (time < 2.5f) { // Render the scanline in Phase 1 and 2
Expand Down Expand Up @@ -1919,7 +1924,7 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
shadow_render_info.set_flags(flags | MR_NO_TEXTURING | MR_NO_LIGHTING);
shadow_render_info.set_detail_level_lock(0);

model_render_immediate(&shadow_render_info, model_id, &model_orient, &vmd_zero_vector);
model_render_immediate(&shadow_render_info, model_id, model_instance, &model_orient, &vmd_zero_vector);
shadows_end_render();
}

Expand All @@ -1937,7 +1942,7 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
render_info->set_flags(flags);
}

model_render_immediate(render_info, model_id, &model_orient, &vmd_zero_vector);
model_render_immediate(render_info, model_id, model_instance, &model_orient, &vmd_zero_vector);

batching_render_all();

Expand All @@ -1948,6 +1953,9 @@ void draw_model_rotating(model_render_params *render_info, int model_id, int x1,
}

shadow_end_frame();
if (model_instance >= 0) {
model_delete_instance(model_instance);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion code/missionui/missionscreencommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ int restore_wss_data(ubyte *data);

class ship_info;
void draw_model_icon(int model_id, uint64_t flags, float closeup_zoom, int x1, int x2, int y1, int y2, ship_info* sip = NULL, int resize_mode = GR_RESIZE_FULL, const vec3d *closeup_pos = &vmd_zero_vector);
void draw_model_rotating(model_render_params *render_info, int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, const vec3d *closeup_pos=nullptr, float closeup_zoom = .65f, float rev_rate = REVOLUTION_RATE, uint64_t flags = MR_AUTOCENTER | MR_NO_FOGGING, int resize_mode=GR_RESIZE_FULL, select_effect_params effect_params = select_effect_params{});
void draw_model_rotating(model_render_params *render_info, int ship_class, int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, const vec3d *closeup_pos=nullptr, float closeup_zoom = .65f, float rev_rate = REVOLUTION_RATE, uint64_t flags = MR_AUTOCENTER | MR_NO_FOGGING, int resize_mode=GR_RESIZE_FULL, select_effect_params effect_params = select_effect_params{});

void common_set_team_pointers(int team);
void common_reset_team_pointers();
Expand Down
1 change: 1 addition & 0 deletions code/missionui/missionshipchoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,6 +1461,7 @@ void ship_select_do(float frametime)

draw_model_rotating(
&render_info,
Selected_ss_class,
ShipSelectModelNum,
Ship_anim_coords[gr_screen.res][0],
Ship_anim_coords[gr_screen.res][1],
Expand Down
12 changes: 10 additions & 2 deletions code/missionui/missionweaponchoice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ void draw_3d_overhead_view(int model_num,
Glowpoint_use_depth_buffer = false;

model_clear_instance(model_num);
int model_instance = model_create_instance(model_objnum_special::OBJNUM_NONE, model_num);
if (model_instance >= 0) {
model_set_up_techroom_instance(sip, model_instance);
}
polymodel* pm = model_get(model_num);

if (sip->replacement_textures.size() > 0) {
Expand All @@ -842,7 +846,7 @@ void draw_3d_overhead_view(int model_num,

render_info.set_flags(MR_NO_TEXTURING | MR_NO_LIGHTING | MR_AUTOCENTER);

model_render_immediate(&render_info, model_num, &object_orient, &vmd_zero_vector);
model_render_immediate(&render_info, model_num, model_instance, &object_orient, &vmd_zero_vector);
shadows_end_render();
gr_set_clip(x1, y1, x2, y2, resize_mode);
}
Expand All @@ -857,13 +861,16 @@ void draw_3d_overhead_view(int model_num,
render_info.set_team_color(tc, "none", 0, 0);
}

model_render_immediate(&render_info, model_num, &object_orient, &vmd_zero_vector);
model_render_immediate(&render_info, model_num, model_instance, &object_orient, &vmd_zero_vector);

Glowpoint_use_depth_buffer = true;

batching_render_all();

shadow_end_frame();
if (model_instance >= 0) {
model_delete_instance(model_instance);
}

// NOW render the lines for weapons
gr_reset_clip();
Expand Down Expand Up @@ -2832,6 +2839,7 @@ void weapon_select_do(float frametime)

model_render_params render_info;
draw_model_rotating(&render_info,
-1,
modelIdx,
weapon_ani_coords[0],
weapon_ani_coords[1],
Expand Down
1 change: 1 addition & 0 deletions code/scripting/api/objs/shipclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,7 @@ ADE_FUNC(renderSelectModel,
params.fs2_wireframe_color = sip->fs2_effect_wireframe_color;

draw_model_rotating(&render_info,
idx,
modelNum,
x1,
y1,
Expand Down
1 change: 1 addition & 0 deletions code/scripting/api/objs/weaponclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ ADE_FUNC(renderSelectModel,
params.fs2_wireframe_color = wip->fs2_effect_wireframe_color;

draw_model_rotating(&render_info,
-1,
modelNum,
x1,
y1,
Expand Down