Body Groups: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(minor cleanup)
Line 1: Line 1:
==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.
''Body Groups'' are sub-meshes of a model that can have changable states. Server code can change the state a model's body groups.


== Syntax ==
To define a body groups, you need to add a lines in the [[.qc]].
To define a body groups, you need to add a lines in the [[.qc]].


Line 12: Line 11:
  }
  }


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


  $bodygroup studio
  $bodygroup studio
Line 27: Line 28:
This example has two body groups numbered 0 and 1. Group 0 uses a single mesh and group 1 uses 2, a model of a pair of glasses (state 0) and the built-in "no-polygons" model (state 1) which is used to "turn-off" the glasses.
This example has two body groups numbered 0 and 1. Group 0 uses a single mesh and group 1 uses 2, a model of a pair of glasses (state 0) and the built-in "no-polygons" model (state 1) which is used to "turn-off" the glasses.


=== Multiple sets ===
You can have multiple entries in a bodygroup, for example you could have 4 different sets of the chest, each with different styles:
You can have multiple entries in a bodygroup, for example you could have 4 different sets of the chest, each with different styles:


Line 40: Line 42:


The models used in bodygroups can span any number of bones.
The models used in bodygroups can span any number of bones.
== Switching groups in code ==


To change a body group's state call <code>CBaseAnimating::SetBodygroup( int iGroup, int iValue )</code> in server code. For example, this would randomly give 1 out of 5 characters glasses:
To change a body group's state call <code>CBaseAnimating::SetBodygroup( int iGroup, int iValue )</code> in server code. For example, this would randomly give 1 out of 5 characters glasses:


  <code>SetBodygroup( 1, ( RandomInt( 1, 5 ) == 1 )?1:0 );</code>
  SetBodygroup( 1, ( RandomInt( 1, 5 ) == 1 )?1:0 );


Bodygroups are limited to 32 bits of combinations, which is a total of 4,294,967,296 combinations.  If you used the above eyewear and chest examples, the total combinations would be eyewear x chest, or 2 x 4, or a total of 8 combinations. Just multiply all your bodygroup combinations together to make sure your total is less than the max.  Weapons by default are limited to 256 combinations, though it's just a network limit which is easy for your mod to change.  See:
Bodygroups are limited to 32 bits of combinations, which is a total of 4,294,967,296 combinations.  If you used the above eyewear and chest examples, the total combinations would be eyewear x chest, or 2 x 4, or a total of 8 combinations. Just multiply all your bodygroup combinations together to make sure your total is less than the max.  Weapons by default are limited to 256 combinations, though it's just a network limit which is easy for your mod to change.  See:


  <code>BEGIN_NETWORK_TABLE_NOBASE(CBaseViewModel, DT_BaseViewModel)
  BEGIN_NETWORK_TABLE_NOBASE(CBaseViewModel, DT_BaseViewModel)
  ...
  ...
  <b>SendPropInt (SENDINFO(m_nBody), 8),</b></code>
  <b>SendPropInt (SENDINFO(m_nBody), 8),</b>


==See also==
==See also==
* [[Skins]]
* [[Skins]]
* DOD Player Models make extensive use of Bodygroups.
* DOD Player Models make extensive use of Bodygroups.
[[Category:Modeling]]
[[Category:Modeling]]

Revision as of 13:58, 28 April 2008

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

Syntax

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

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

Examples

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 uses 2, a model of a pair of glasses (state 0) and the built-in "no-polygons" model (state 1) which is used to "turn-off" the glasses.

Multiple sets

You can have multiple entries in a bodygroup, for example you could have 4 different sets of the chest, each with different styles:

$bodygroup chest
{
	studio "chest_with_no_armor.smd"
	studio "chest_with_light_armor.smd"
	studio "chest_with_heavy_armor.smd"
	studio "chest_with_super_armor.smd"
}

You could also just put the armor pieces in their own group and always draw the underlying chest without armor, but it's less efficient and often there's no clean "base" set, such as if you're using bodygroups to define multiple heads.

The models used in bodygroups can span any number of bones.

Switching groups in code

To change a body group's state call CBaseAnimating::SetBodygroup( int iGroup, int iValue ) in server code. For example, this would randomly give 1 out of 5 characters glasses:

SetBodygroup( 1, ( RandomInt( 1, 5 ) == 1 )?1:0 );

Bodygroups are limited to 32 bits of combinations, which is a total of 4,294,967,296 combinations. If you used the above eyewear and chest examples, the total combinations would be eyewear x chest, or 2 x 4, or a total of 8 combinations. Just multiply all your bodygroup combinations together to make sure your total is less than the max. Weapons by default are limited to 256 combinations, though it's just a network limit which is easy for your mod to change. See:

BEGIN_NETWORK_TABLE_NOBASE(CBaseViewModel, DT_BaseViewModel)
...
SendPropInt		(SENDINFO(m_nBody), 8),

See also

  • Skins
  • DOD Player Models make extensive use of Bodygroups.