Author Topic: Weapons.tbl "Tech Model" documentation request  (Read 2176 times)

0 Members and 1 Guest are viewing this topic.

Offline Galemp

  • Actual father of Samus
  • 212
  • Current projects: GVCa Tanen, Vasudan Imperium
    • Steam
    • User page on the FreeSpace Wiki
Weapons.tbl "Tech Model" documentation request
Hey folks, I've been working with warheads and the $Tech Model system is really irritating me. I'd like some coder to post the relevant portion of the source so modders and modelers can format their stuff properly.

So far as I can tell, the code was built around Freespace missiles having their centers set to the back of the engines. The LOD0 has an offset of 0,0,0 and the Center of Mass and Tech Room Center are all set to 0,0,0. This is the case for both loadout and in-game models.

Consequently, to have the missiles rotate around their centers, the loadout screen automatically rotates at a point halfway down the missile length. How does it calculate this, from the bounding box, or the radius, using toe origin, the Center of Mass or the Tech Room Center? And does the LOD0 offset have anything to do with it?

Also, how does it calculate zoom and view angle? It again seems to be based on the radius or bounding box but it's impossible to tell, since it's not specified in the weapons.tbl like it is in ships.tbl, and it's not documented on the Wiki. I only found one other thread on this issue.

Can we just dispense with this behind-the-scenes auto-centering and have it always use the tech room center rotation point, and specify the zoom values in the weapons.tbl entry? Making this code use the same parameters as the 3D ship selection model code would make things more consistent and therefore easier for all parties.

Finally, I'd like to know if this issue with primary weapon models has been resolved. I'd like to do some spinning guns too.
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: Weapons.tbl "Tech Model" documentation request
Code: [Select]
void draw_model_rotating(int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, vec3d *closeup_pos, float closeup_zoom, float rev_rate, int flags, bool resize)
{
angles rot_angles, view_angles;
matrix model_orient;

// rotate the ship as much as required for this frame
*rotation_buffer += PI2 * flFrametime / rev_rate;
while (*rotation_buffer > PI2){
*rotation_buffer -= PI2;
}

view_angles.p = -0.6f;
view_angles.b = 0.0f;
view_angles.h = 0.0f;
vm_angles_2_matrix(&model_orient, &view_angles);

rot_angles.p = 0.0f;
rot_angles.b = 0.0f;
rot_angles.h = *rotation_buffer;
vm_rotate_matrix_by_angles(&model_orient, &rot_angles);

gr_set_clip(x1, y1, x2, y2, resize);

// render the ship
g3_start_frame(1);
[b]if(closeup_pos != NULL)
{
g3_set_view_matrix(closeup_pos, &vmd_identity_matrix, closeup_zoom);
}
else
{
polymodel *pm = model_get(model_id);
vec3d pos = { { { 0.0f, 0.0f, -(pm->rad * 1.5f) } } };
g3_set_view_matrix(&pos, &vmd_identity_matrix, closeup_zoom);
flags |= MR_IS_MISSILE;
}[/b]

if (!Cmdline_nohtl) {
gr_set_proj_matrix(Proj_fov, gr_screen.clip_aspect, Min_draw_distance, Max_draw_distance);
gr_set_view_matrix(&Eye_position, &Eye_matrix);
}

// lighting for techroom
light_reset();
vec3d light_dir = vmd_zero_vector;
light_dir.xyz.y = 1.0f;
light_add_directional(&light_dir, 0.65f, 1.0f, 1.0f, 1.0f);
light_rotate_all();
// lighting for techroom

model_clear_instance(model_id);
model_set_detail_level(0);
model_render(model_id, &model_orient, &vmd_zero_vector, flags);

if (!Cmdline_nohtl)
{
gr_end_view_matrix();
gr_end_proj_matrix();
}

g3_end_frame();
}

And for weapons, it's called with:
Code: [Select]
static float WeapSelectScreenWeapRot = 0.0f;
wl_icon_info *sel_icon = &Wl_icons[Selected_wl_class];
draw_model_rotating(sel_icon->model_index,
weapon_ani_coords[0],
weapon_ani_coords[1],
gr_screen.res == 0 ? 202 : 332,
gr_screen.res == 0 ? 185 : 304,
&WeapSelectScreenWeapRot);

Default values:
Code: [Select]
void draw_model_rotating(int model_id, int x1, int y1, int x2, int y2, float *rotation_buffer, vec3d *closeup_pos=NULL, float closeup_zoom = .65f, float rev_rate = REVOLUTION_RATE, int flags = MR_LOCK_DETAIL | MR_AUTOCENTER | MR_NO_FOGGING, bool resize=true);
It should be possible to specify the center that the models rotate around; that's 'should' in a 'it's the ideal way to do this and it's not that hard to do' kind of way.

This is the sort of bug I would love to see in mantis. :D
-C

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Current projects: GVCa Tanen, Vasudan Imperium
    • Steam
    • User page on the FreeSpace Wiki
Re: Weapons.tbl "Tech Model" documentation request
As soon as I can, I will. Seems to be down at the moment.

Thanks for posting the code, WMC. I'm not certain what it means (I'll have to ask you to translate for me) but at least it seems simple. Apparently it's based on rotating around a point at the model origin multiplied by a factor of the radius, and a zoom also determined by the radius.

So! Who thinks they can fix the high-poly Crossbow/Harpoon Missile now? :D
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

 

Offline phreak

  • Gun Phreak
  • 211
  • -1
Re: Weapons.tbl "Tech Model" documentation request
does the ACEN chunk work at all?
Offically approved by Ebola Virus Man :wtf:
phreakscp - gtalk
phreak317#7583 - discord

 

Offline Galemp

  • Actual father of Samus
  • 212
  • Current projects: GVCa Tanen, Vasudan Imperium
    • Steam
    • User page on the FreeSpace Wiki
Re: Weapons.tbl "Tech Model" documentation request
Phreak: I wanted to see if Mantis was back up, to post this as a bug.

I clicked the link in your signature.

You are now back on my list of People To Give Noogies To.
"Anyone can do any amount of work, provided it isn't the work he's supposed to be doing at that moment." -- Robert Benchley

Members I've personally met: RedStreblo, Goober5000, Sandwich, Splinter, Su-tehp, Hippo, CP5670, Terran Emperor, Karajorma, Dekker, McCall, Admiral Wolf, mxlm, RedSniper, Stealth, Black Wolf...

  

Offline Nuke

  • Ka-Boom!
  • 212
  • Mutants Worship Me
Re: Weapons.tbl "Tech Model" documentation request
you could try tweaking the radius too. i think pcs2 will let you do that.
I can no longer sit back and allow communist infiltration, communist indoctrination, communist subversion, and the international communist conspiracy to sap and impurify all of our precious bodily fluids.

Nuke's Scripting SVN