$bodygroup: Difference between revisions
TomEdwards (talk | contribs) (bah) |
TomEdwards (talk | contribs) (redone) |
||
Line 1: | Line 1: | ||
'' | '''$bodygroup''' is a [[QC command]] that defines a group of meshes that can be turned on or off. Server code can change their state. | ||
{{note|Bodygroups cannot change [[skeleton]]s or [[collision model]]s.}} | |||
== Example == | |||
= | <source lang=php> | ||
$bodygroup sights | |||
{ | |||
studio "ironsights.smd" | |||
studio "laser_dot.smd" | |||
blank | |||
} | |||
</source> | |||
This bodygroup allows a weapon to have iron sights, laser sights, or no sights at all. | |||
<source lang=php> | |||
$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" | |||
} | |||
</source> | |||
This | This bodygroup defines the entire chest region of the model, which probably spans multiple bones. | ||
{{note|Since polygons never share vertices in Source models, there need not be seams between properly-made components.}} | |||
== Programming == | |||
To change a body group's state: | |||
<source lang=cpp> | |||
static int BodyGroup_Sights = FindBodygroupByName("sights"); // calculate this value once | |||
SetBodygroup( BodyGroup_Sights , 1 ); // laser dot | |||
</source> | |||
By default, <code>[[CBaseAnimating]]</code> supports 4,294,967,296 combinations (32 bits), and <code>[[CBaseViewModel]]</code> supports 256 (8 bits). You can raise either of these by editing the relevant [[SendProp]] for <code>m_nBody</code>. | |||
To | To calculate how many combinations you need, multiply the size of all your bodygroups together. The examples on this page total 3 * 4 = 12...but add two more groups the same size and you're up at 144. The figure grows exponentially. | ||
[[Category:Modeling]] | [[Category:Modeling]] |
Revision as of 05:03, 31 December 2010
$bodygroup is a QC command that defines a group of meshes that can be turned on or off. Server code can change their state.

Example
$bodygroup sights
{
studio "ironsights.smd"
studio "laser_dot.smd"
blank
}
This bodygroup allows a weapon to have iron sights, laser sights, or no sights at all.
$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"
}
This bodygroup defines the entire chest region of the model, which probably spans multiple bones.

Programming
To change a body group's state:
static int BodyGroup_Sights = FindBodygroupByName("sights"); // calculate this value once
SetBodygroup( BodyGroup_Sights , 1 ); // laser dot
By default, CBaseAnimating
supports 4,294,967,296 combinations (32 bits), and CBaseViewModel
supports 256 (8 bits). You can raise either of these by editing the relevant SendProp for m_nBody
.
To calculate how many combinations you need, multiply the size of all your bodygroups together. The examples on this page total 3 * 4 = 12...but add two more groups the same size and you're up at 144. The figure grows exponentially.