Forum

Weapon model sway techniques

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Weapon model sway techniques

Postby JasonX » Fri Jan 09, 2015 12:31 pm

I'm trying to create an effect similar to the one implemented in TF2: https://www.youtube.com/watch?v=4wPAzutIVpc

And other titles as well: https://www.youtube.com/watch?v=kjVSLsz8dCs

Note that this is not player model bobbing, it's just a subtle effect on the camera and the model itself, slowly reaching the new view target. I could not find any documentation on this topic around the internet and i suspect there's some heavy math behind this and it would be nice if someone here has any idea on how to implement that kind of code. Or, at least, can give me some good directions on the topic. Thanks!
JasonX
 
Posts: 404
Joined: Tue Apr 21, 2009 2:08 pm

Re: Weapon model sway techniques

Postby r00k » Fri Jan 09, 2015 6:25 pm

darkplaces has something like that

look in the engine source, or the xonotic quakeC source, might have it...
r00k
 
Posts: 1108
Joined: Sat Nov 13, 2004 10:39 pm

Re: Weapon model sway techniques

Postby JasonX » Sat Jan 10, 2015 4:03 pm

Darkplaces has normal bobbing, applied to the camera, but nothing on weapon model sway.
JasonX
 
Posts: 404
Joined: Tue Apr 21, 2009 2:08 pm

Re: Weapon model sway techniques

Postby PrimalLove » Wed Jan 21, 2015 5:23 am

You could make this effect in qc but Darkplaces already has this built into the engine using the cvars cl_leanmodel and cl_followmodel. For more details on these and a few other cvars that let you customize this movement type in console "apropos cl_leanmodel" or "apropos cl_followmodel". It is highly customizable to get the effect you desire. You can even use negative values to change the weapon models react to input movements of the player. No need for qc changes.
PrimalLove
 
Posts: 14
Joined: Sun Oct 19, 2014 2:37 am

Re: Weapon model sway techniques

Postby Spiney » Wed Jan 21, 2015 4:30 pm

The Nazi Zombies PSP mod seems to have a pretty nice implementation.

moddb video
Spiney
 
Posts: 63
Joined: Mon Feb 13, 2012 1:35 pm

Re: Weapon model sway techniques

Postby hogsy » Thu Jan 22, 2015 3:40 pm

Eukos implemented this for OpenKatana sometime ago, might be worth digging through our code to see how it was done.

https://github.com/OldTimes-Software/KatanaEngine/blob/master/engine/EngineClientView.c#L572

I believe it's all within a function called View_ModelDrift.
Last edited by hogsy on Sat Nov 14, 2015 2:53 pm, edited 1 time in total.
User avatar
hogsy
 
Posts: 198
Joined: Wed Aug 03, 2011 3:44 pm
Location: UK

Re: Weapon model sway techniques

Postby JasonX » Sun Feb 08, 2015 9:54 pm

Thanks a lot for the info, guys. The OpenKatana code was very instructive. :D
JasonX
 
Posts: 404
Joined: Tue Apr 21, 2009 2:08 pm

Re: Weapon model sway techniques

Postby JasonX » Mon Oct 05, 2015 2:18 pm

Implementing a subtle https://en.wikipedia.org/wiki/Lissajous_curve for the bobbing was the way to go. And i was inspired by this video to create the "weapon weight" effect:

https://www.youtube.com/watch?v=ay2SMb9-nEE
JasonX
 
Posts: 404
Joined: Tue Apr 21, 2009 2:08 pm

Re: Weapon model sway techniques

Postby mankrip » Wed Oct 07, 2015 1:28 am

Engoo also has a very flexible implementation, with several options.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 908
Joined: Fri Jul 04, 2008 3:02 am

Re: Weapon model sway techniques

Postby JasonX » Wed Oct 07, 2015 2:25 am

It's for camera bob, there's no influence on the weapon model based on player input.
JasonX
 
Posts: 404
Joined: Tue Apr 21, 2009 2:08 pm

Re: Weapon model sway techniques

Postby r00k » Fri Oct 09, 2015 5:57 pm

I have added something like this in Qrack, v_viewmodeldrift # all it does is delay the time the gun moves from when the player changes angles. I'll post some code later but im sure i thought i looked at darkplaces to learn about the effect.
r00k
 
Posts: 1108
Joined: Sat Nov 13, 2004 10:39 pm

Re: Weapon model sway techniques

Postby mankrip » Fri Oct 09, 2015 11:03 pm

JasonX: Get the latest version of Engoo. I'm using version 2.77, and in "Options —> View Options" there are options not only for weapon bobbing, but also for weapon following, weapon leaning, weapon drawing and fall bobbing. The "weapon leaning" option is what you're after.

The latest versions of Engoo did add a lot of features everywhere.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 908
Joined: Fri Jul 04, 2008 3:02 am

Re: Weapon model sway techniques

Postby r00k » Tue Oct 20, 2015 4:41 am

Code: Select all
/*
======
View_ModelDrift -- Eukos from OpenKatana
Adds a delay to the view model (such as a weapon) in the players view.
======
*/
void View_ModelDrift(vec3_t vOrigin,vec3_t vAngles,vec3_t vOldAngles)
{
         int   i;
         float   fScale,fSpeed,fDifference;
   static   vec3_t   svLastFacing;
         vec3_t   vForward, vRight,vUp, vDifference;
   
   AngleVectors(vAngles,vForward,vRight,vUp);

   if (host_frametime != 0.0f)
   {
      VectorSubtract(vForward,svLastFacing,vDifference);
      fSpeed = 6.0f;
      fDifference = VectorLength(vDifference);
      
      if ((fDifference > cl_gun_drift.value ))
         fSpeed *= fScale = fDifference/cl_gun_drift.value;
      
      for (i = 0; i < 3; i++)
         svLastFacing[i] += vDifference[i]*(fSpeed*host_frametime);
         VectorNormalize(svLastFacing);

      for (i = 0; i < 3; i++)
      {
         vOrigin[i] += (vDifference[i]*-1.0f)*5.0f;
         vAngles[ROLL] += vDifference[YAW];
      }
   }
}
r00k
 
Posts: 1108
Joined: Sat Nov 13, 2004 10:39 pm


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest