Body Groups: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
Line 7: Line 7:
  $bodygroup (name)
  $bodygroup (name)
  {
  {
  studio (modelname)
studio (modelname)
  ["studio" modelname]
["studio" modelname]
  [blank]
[blank]
  }
  }


Line 16: Line 16:
  $bodygroup studio
  $bodygroup studio
  {
  {
  studio "dude.smd"
studio "dude.smd"
  }
  }
   
   
  $bodygroup eyewear
  $bodygroup eyewear
  {
  {
  studio "glasses.smd"
studio "glasses.smd"
  blank
blank
  }
  }


This example has two body groups numbered 0 and 1. Group 0 uses a single mesh and group 1 can be a visible glasses model (state 0) or invisible (state 1).
This example has two body groups numbered 0 and 1. Group 0 uses a single mesh and group 1 can be a visible glasses model (state 0) or invisible (state 1).


To change a body group's state simply call CBaseAnimating::SetBodygroup( int iGroup, int iValue ) in server code. For example, this would randomly give 1 out of 5 characters glasses:
To change a body group's state simply call CBaseAnimating::SetBodygroup( int iGroup, int iValue ) in server code. For example, this would randomly give 1 out of 2 characters glasses with a 20% chance for the second type:


  if ( RandInt( 1, 5 ) == 1 )
  SetBodyGroup( 1, ( RandInt( 1, 5 ) == 1 )?1:0 );
  SetBodyGroup( 1, 1 );
==Calculating the Bodygroup Integer==
else
{{TODO|content}}
  SetBodyGroup( 1, 0 );
==See also==
* [[Skins]]
[[Category:Modeling]]

Revision as of 21:06, 15 November 2005

Body Groups

Body Groups are sub meshes of a model that can have changable states. Server code can change the state a model's body groups.

To define a body groups, you need to add a lines in the .qc file.

$bodygroup (name)
{
	studio (modelname)
	["studio" modelname]
	[blank]
}

For example (a single .mdl could be used for characters with and without glasses):

$bodygroup studio
{
	studio "dude.smd"
}

$bodygroup eyewear
{
	studio "glasses.smd"
	blank
}

This example has two body groups numbered 0 and 1. Group 0 uses a single mesh and group 1 can be a visible glasses model (state 0) or invisible (state 1).

To change a body group's state simply call CBaseAnimating::SetBodygroup( int iGroup, int iValue ) in server code. For example, this would randomly give 1 out of 2 characters glasses with a 20% chance for the second type:

SetBodyGroup( 1, ( RandInt( 1, 5 ) == 1 )?1:0 );

Calculating the Bodygroup Integer

Todo: content

See also