How to keep my hands with all the weapons ?

Grab your favourite IDE and tinker with the innards of game engines

How to keep my hands with all the weapons ?

Postby Palermo on Mon Apr 23, 2012 9:53 am

I have a problem with the preview of my hands in first person. I use the SDK_Template with teams and classes management. When I change my weapon, I have the model of hands dedicated to the weapon (by example with the crowbar, I have the model Gordon Freeman's hands and when I change weapon to take the pistol, I have the model of hands of CSS). Worse, when I pick up the weapon of the other team, I have the same problem ...

How do you keep all the time the same model of hands according to the team and and for the class selected by the player ?

Thank you in advance for your help :wink:

Sorry for my bad English, but I am a French frog :smt044
User avatar
Palermo
Dumpling
Dumpling
 
Joined: Sun Jul 10, 2011 8:44 pm

Re: How to keep my hands with all the weapons ?

Postby Jordash on Mon Apr 23, 2012 2:47 pm

The hand models are, as you said, specific to the the model, CSS weapon models will have CSS hands and HL2 weapon models will have HL2 hands, the game doesn't magically detect which hand model you want and change them accordingly. You will need to decompile the models and rig new hands for each weapon. You will also need to specify in the code what whether it is a body group change or simply a skin.

The stuff you'll need to do is on the modelling side rather than coding, if you don't want to get into modelling I would stick with one set of hands and just change the skin. This will still require decompiling each model to add skins, an alternative would be setting a texture proxy, which would work as the first person weapon models are only seen by the client.

Look for 'm_nSkin' in the code for some examples of skins and https://developer.valvesoftware.com/wiki/Material_Proxy has some info on proxies
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: How to keep my hands with all the weapons ?

Postby Palermo on Mon Apr 23, 2012 5:46 pm

Thank you very much, I better understand the principle ;)

But there it is about the materials / skins, and not for the use of different models of hands/arms.

In the Insurgency mod, they are dynamic models of hands / arms that are used and not dynamic skins.

Would be better with a system of dynamic model for the model of hands/arms ?
User avatar
Palermo
Dumpling
Dumpling
 
Joined: Sun Jul 10, 2011 8:44 pm

Re: How to keep my hands with all the weapons ?

Postby nub on Tue Apr 24, 2012 1:04 am

Left 4 Dead had unique hand models for each survivor. I didn't really investigate the game files, so I don't know if Valve actually compiled 4 different versions of every single weapon to get the different hands in-game. I imagine that Valve devised a better system when they made L4D, or have at least done so for CSGO. If you look closely, the hands in CSGO change depending on what player model you choose when you join a team. I can't imagine that Valve made 8 different view models for every single weapon just so they could achieve this. I'm guessing they developed a way to combine hand models with gun models on the fly (or used the system they made for L4D, if they even did make such a system).

Some Unreal Engine 3 games even have this feature (Unreal Tournament 3).
User avatar
nub
Veteran
Veteran
 
Joined: Tue Nov 15, 2005 1:11 am
Location: Charlotte, NC, US

Re: How to keep my hands with all the weapons ?

Postby Jordash on Tue Apr 24, 2012 2:28 am

In L4D they have separate models for hands and weapons, I'm not sure how the animations are involved though. If you only have two teams body groups are the way to go

I only told you about skins because unless I'm mistaken, you don't have the skill to rig new hand models yourself, else you wouldn't be here asking about it. Rigging is very difficult and you need to be familiar with a 3d modelling program to even attempt it, and if you did know how to do it you probably wouldn't use your time porting HEV hands to CSS weapons or vis versa.

The reason you need to rig the hands is because the HL2 hands use a different skeleton than the CSS ones, if you simply ported them over they wouldn't animate. Along with the way the files turn out after decompiling It would be a huge undertaking if the only feature you are adding is different hands for your teams. Hell the CSS models you are using only come with one set of hands, you're putting more effort into this than Valve did.

Also is the rest of your code sorted out? This sort of stuff is irrelevant if you don't have a game to put them in, it's good that you have an interest in getting this bit working, but if you don't have a working game it will be a wasted effort on your part.

Do you have a model lined up to replace the default hands with?
Are you familiar with rigging or at least a 3d modelling program?
Is the rest of your gameplay in place?

If you answered no to any of those questions you should rethink trying to do this.
If you still want to go ahead, here is an article on body groups, if you have the hands on different body groups it should work as you require https://developer.valvesoftware.com/wiki/$bodygroup

I might be coming across as harsh, but I'm only saying these things because I've been in your position before and I know how much of a waste of time this will be if you try it without any background in the fields. It's good to make your own mistakes and learn from them, but I suggest going back to basic coding and modelling and work your way up, not try to jump into the middle.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: How to keep my hands with all the weapons ?

Postby Palermo on Tue Apr 24, 2012 7:52 am

Effectively, I have no necessary skills in modelling 3D. But for the moment, it isn't main my problem but rather of my friend 3D artist. I have to answer a technical problèmatique: How to keep my hands with all the weapons? You knew how to direct me with the Material Proxy but this isn't the solution to my problem. With bodygroup, it seems to me the solution.

With the function SetWeaponModel() of the file baseviewmodel_shared.cpp, I could integrate the management of bodygroup depending on the player's team. Afterward, it will be enough to add two bodygroups "hands" in the file .qc of every weapon.

I will try with a model of hands I'll copy it by changing the skin for have two distinct models. If the mechanism works, I could say to my friend that this issue is resolved and now it is his best to manage the modeling and animation.

Jordash, thank you for your answers :smt023
User avatar
Palermo
Dumpling
Dumpling
 
Joined: Sun Jul 10, 2011 8:44 pm

Re: How to keep my hands with all the weapons ?

Postby Atkins on Sun Apr 29, 2012 3:03 pm

I have the same problem.

I added it in the file .qc of my weapons :
Code: Select all
$model "arms" "arms_team_red.smd"
$model "arms" "arms_team_blue.smd"


I have my function SetWeaponModel () in the baseviewmodel.cpp file:

Code: Select all
void CBaseViewModel::SetWeaponModel( const char *modelname, CBaseCombatWeapon *weapon )
{
   m_hWeapon = weapon;

#if defined( CLIENT_DLL )
   SetModel( modelname );
#else
   string_t str;
   if ( modelname != NULL )
   {
      str = MAKE_STRING( modelname );
   }
   else
   {
      str = NULL_STRING;
   }

   if ( str != m_sVMName )
   {
      // Msg( "SetWeaponModel %s at %f\n", modelname, gpGlobals->curtime );
      m_sVMName = str;
      SetModel( STRING( m_sVMName ) );

      // Create any vgui control panels associated with the weapon
      SpawnControlPanels();

      bool showControlPanels = weapon && weapon->ShouldShowControlPanels();
      SetControlPanelsActive( showControlPanels );
   }
#endif
}

I added this portion of code at the end of this function to test the existence of bodygroup 'arms' :
Code: Select all
   int iArmsGroup = FindBodygroupByName( "arms" );

   if( iArmsGroup == -1 )
      return;

Now I would like to retrieve the name of the player's team that has the weapon. It will allow me then to use the bodygroup voucher according to the team.

How can I do this ?
User avatar
Atkins
Dumpling
Dumpling
 
Joined: Tue Mar 27, 2012 11:55 am

Re: How to keep my hands with all the weapons ?

Postby Atkins on Sat May 05, 2012 2:56 pm

Nobody to help me ?
User avatar
Atkins
Dumpling
Dumpling
 
Joined: Tue Mar 27, 2012 11:55 am

Re: How to keep my hands with all the weapons ?

Postby Jordash on Sun May 06, 2012 4:25 am

Code: Select all
   if ( GetOwner() && GetOwner()->IsPlayer() )
   {
      CHL2MP_Player *pPlayer = assert_cast<CHL2MP_Player*>( GetOwner() );
      if ( pPlayer->GetTeamNumber() = TEAM )
         {
         YOUR CODE
         }



This should do the trick
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: How to keep my hands with all the weapons ?

Postby Stormy on Fri May 18, 2012 7:33 am

I have been trying to do this recently, the closest I got was to use the weapon as the base model, then load the hands in as a weapon. in order to have the weapon define the animations of the hands you need to use $definebone to prevent studiomdl from dumping all the bones that aren't assigned to a face. Then in hlmv you load your weapon through the load model option, and load your hands in under load weapon. Provided you can access this functionality through code you should be able to use this to swap out hand models dynamically. I have hit some serious animation issues doing this but I think they are from a dodgily decompiled model, not the technique. If you do happen to have any success with this please let me know. Jordash does this sound like a lead? I got it working in hlmv but I don't know how it would go in code.
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: How to keep my hands with all the weapons ?

Postby Jordash on Fri May 18, 2012 1:28 pm

I've used a similar animation technique to get interchangeable heads working, in the code I set the player as a head model with all the animation included then created an client side entity with the body and told it to follow the player entity, there was a bone merge option (I can't remember exactly, I did this a few years ago) which made the animations sync up.

I haven't played around with view models much, but I assume the same method will work. However unless you have a large variety of hand models just use a bodygroup, it isn't that costly performance wise and is very simple to set up.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Re: How to keep my hands with all the weapons ?

Postby Stormy on Fri May 18, 2012 11:34 pm

In my position I do have a variety of hand models. 5 to 7 different meshes each with 10 skin slots, not necessarily 10 skins though. Is it possible to change the sub-models skin through code as well? Since the hands will be the sub model...
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: How to keep my hands with all the weapons ?

Postby stoopdapoop on Fri May 18, 2012 11:49 pm

what the hell is an assert cast?

I'm guessing it asserts if the cast fails?
I'm Brown
Image
User avatar
stoopdapoop
Veteran
Veteran
 
Joined: Sun Aug 21, 2005 2:14 am
Location: Ann Arbor, MI

Re: How to keep my hands with all the weapons ?

Postby Stormy on Sun May 20, 2012 9:23 am

I think this can be done with $includemodel. You compile your hand model, rigged to your bones but with an empty sequence, and you compile your animations separately, in a shared animations file. You use $definebone to prevent studiomdl from dumping all the unweighted bones (which is all of them because there are no meshes in your animations file, only animation .smd's) in your animations file. Then when you create a new weapon you compile your weapon animations into the shared animations file. I think. I have to test it when I get home but I think it should work.

Thoughts?
User avatar
Stormy
May Contain Skills
May Contain Skills
 
Joined: Sun Nov 28, 2010 6:03 am
Location: Cairns, QLD, AUS

Re: How to keep my hands with all the weapons ?

Postby Jordash on Sun May 20, 2012 10:51 am

I don't know what an assert cast is, I didn't even notice it was there I just copied some old code, it was more to give someone an idea of how to do it, not the only way.

If you have that many models then have them as separate models. The only problem I can see with you shared animations idea is that the rig will have to be the same for every weapon, as far as I know... I'm not familiar different rig animations in one model. That sounds a bit too risky I'm not sure how well it would work code wise, I'd say stick with the weapon model with hand animations with whichever hand model told to follow as a new entity in the code, you can change the skins and any sub models within the hand entity as much as you like, it's a different entity. You could even network it around and call it as pHands.
User avatar
Jordash
Been Here A While
Been Here A While
 
Joined: Mon Sep 21, 2009 10:36 am
Location: Perth, Australia

Return to Programming

Who is online

Users browsing this forum: No registered users