Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 04-23-2012, 02:50 AM   #1
LtPalermo
 
Join Date: Jul 2011
Reputation: 0
Posts: 12
Question How to keep my hands with all the weapons ?

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

Sorry for my bad English, but I am a French frog
LtPalermo is offline  
Reply With Quote
Old 04-23-2012, 03:00 AM   #2
tingtom
 
Join Date: Mar 2011
Reputation: 38
Posts: 387
the weapon viewmodel handles the hands not the player model.

To have the freeman HEV hands you need to add them yourself by decompiling the model and rigging the HEV hands. if you want the hands team based you could use a material proxy.
tingtom is offline   Reply With Quote
Old 04-23-2012, 04:15 AM   #3
LtPalermo
 
Join Date: Jul 2011
Reputation: 0
Posts: 12
Thank you for the answer !!!

But I do not see the connection between the proxy material and the model of hands.

I have several different models of hands according to the different classes of both teams.

This would be possible to have a concrete example ?
LtPalermo is offline   Reply With Quote
Old 04-23-2012, 09:29 AM   #4
tingtom
 
Join Date: Mar 2011
Reputation: 38
Posts: 387
add a proxy material to the hands texture then in code make the proxy change the material depending on the local players team, this is from a search post look at the post for the material file(link at bottom):

Quote:
#include "cbase.h"

#include "proxyentity.h"
#include "materialsystem/IMaterial.h"
#include "materialsystem/IMaterialVar.h"
#include "materialsystem/ITexture.h"
#include "keyvalues.h"

#include "c_world.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "memdbgon.h"

class CCamoSkinProxy : public CEntityMaterialProxy
{
DECLARE_CLASS( CCamoSkinProxy, CEntityMaterialProxy )

public:
CCamoSkinProxy();

virtual bool Init( IMaterial *pMaterial, KeyValues *pKeyValues );
virtual void OnBind( CBaseEntity *pEnt );
virtual void Release( void );
virtual IMaterial *GetMaterial() { return m_pBaseTexture->GetOwningMaterial(); }

private:
IMaterialVar *m_pBaseTexture;
ITexture *m_pDefaultTexture;
ITexture *m_pNewTexture;
};

//-----------------------------------------------------------------------------
// Purpose: Basic constructor
//-----------------------------------------------------------------------------
CCamoSkinProxy::CCamoSkinProxy()
{
m_pBaseTexture = NULL;
m_pDefaultTexture = m_pNewTexture = NULL;
}

//-----------------------------------------------------------------------------
// Purpose: Release the proxy (like a destructor)
//-----------------------------------------------------------------------------
void CCamoSkinProxy::Release()
{
m_pBaseTexture = NULL;
m_pDefaultTexture = m_pNewTexture = NULL;
delete this;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
bool CCamoSkinProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues )
{
bool bFound;
m_pBaseTexture = pMaterial->FindVar( "$basetexture", &bFound );

if ( !m_pBaseTexture || !bFound )
return false;

m_pDefaultTexture = m_pBaseTexture->GetTextureValue();

if ( IsErrorTexture(m_pDefaultTexture) )
return false;

return true;
}

//-----------------------------------------------------------------------------
// Purpose: Render
//-----------------------------------------------------------------------------
void CCamoSkinProxy::OnBind( CBaseEntity *pEnt )
{
if ( !m_pBaseTexture )
return;

//IMaterial *pMaterial = GetMaterial();
//CBasePlayer *pPlayer = ToBasePlayer( pEnt );

string_t iszCamo = GetClientWorldEntity()->GetCamoType();

char skin[256] = "models/weapons/v_models/hands/v_hands";

if ( iszCamo )
{
if ( FStrEq(iszCamo, "arctic") )
{
V_strcat( skin, "_arctic", sizeof(skin) );
}
else if ( FStrEq(iszCamo, "woodland") )
{
V_strcat( skin, "_woodland", sizeof(skin) );
}
else if ( FStrEq(iszCamo, "urban") )
{
V_strcat( skin, "_urban", sizeof(skin) );
}
else if ( FStrEq(iszCamo, "desert") )
{
V_strcat( skin, "_desert", sizeof(skin) );
}
else if ( FStrEq(iszCamo, "night") )
{
V_strcat( skin, "_night", sizeof(skin) );
}
}

m_pNewTexture = materials->FindTexture( skin, NULL );
m_pBaseTexture->SetTextureValue( m_pNewTexture );
//GetMaterial()->RecomputeStateSnapshots(); -- crash?
}

EXPOSE_INTERFACE( CCamoSkinProxy, IMaterialProxy, "CamoSkin" IMATERIAL_PROXY_INTERFACE_VERSION );
aVoX:http://forums.steampowered.com/forum...proxy+material

Last edited by tingtom: 04-23-2012 at 09:31 AM.
tingtom is offline   Reply With Quote
Old 04-23-2012, 10:44 AM   #5
LtPalermo
 
Join Date: Jul 2011
Reputation: 0
Posts: 12
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.

Would be better with a system of dynamic model for the model of hands/arms ?

In the Insurgency mod, they are dynamic models of hands / arms that are used and not dynamic skins.
LtPalermo is offline   Reply With Quote
Old 04-23-2012, 03:28 PM   #6
tingtom
 
Join Date: Mar 2011
Reputation: 38
Posts: 387
there are other options such as bodygroups maybe and skins which can be accessed through code.
tingtom is offline   Reply With Quote
Old 04-24-2012, 12:04 AM   #7
LtPalermo
 
Join Date: Jul 2011
Reputation: 0
Posts: 12
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.

tingtom, thank you for your answers
LtPalermo is offline   Reply With Quote
Old 04-29-2012, 06:21 AM   #8
Atkins
 
Join Date: Mar 2012
Reputation: 0
Posts: 2
I have the same problem.

I added it in the file .qc of my weapons :
Code:
$model "arms" "arms_team_red.smd"
$model "arms" "arms_team_blue.smd"
I have my function SetWeaponModel () in the baseviewmodel.cpp file:

Code:
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:
	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 ?
Atkins is offline   Reply With Quote
Old 05-05-2012, 07:56 AM   #9
Atkins
 
Join Date: Mar 2012
Reputation: 0
Posts: 2
Nobody to help me?
Atkins is offline   Reply With Quote
Old 05-08-2012, 02:42 PM   #10
tingtom
 
Join Date: Mar 2011
Reputation: 38
Posts: 387
use the weapon to get the owner ( GetOwner() ) then use the player to get the team number ( GetTeamNumber() ) depending on if your on hl2mp or scratch.
tingtom is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 01:45 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2012, All Rights Reserved.