This article's documentation is for anything that uses the Source engine. Click here for more information.

$collisionmodel: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Options: added tip for $mass)
No edit summary
 
(53 intermediate revisions by 24 users not shown)
Line 1: Line 1:
The [[QC command]] <code>[[$collisionmodel]]</code> is used to embed a non-animated [[collision mesh]] in a model, for use in [[VPhysics]] calculations.
{{LanguageBar}}
{{this is a|QC command|name=$collisionmodel}}
{{toc-right}}
It is used to embed a static [[collision mesh]] in a model for use in [[VPhysics]] calculations. Animated models (including ones that will become ragdolls) should use {{ent|$collisionjoints}} instead.


{{note|If your model has moving parts that may affect collisions, such as ragdoll limbs, use <code>[[$collisionjoints]]</code> instead.}}
{{warning|Collision meshes should have extremely few polygons. See [[Collision mesh]] for examples.}}
 
{{warning|Older engines automatically optimize meshes that are too dense, merging vertices that are close together. But this also ruins small collisionmodels, as it merges various vertices together that should not be merged.<br>This has been observed in {{hl2series}}.}}
{{note|Collision meshes should be extremely lo-poly in comparison to [[reference mesh]]es, and even [[lod mesh]]es. See [[collision mesh]].}}
{{note|For collision meshes modeled in {{blender|4.1}} or {{softimgmod|4.1}}, ensure that none of the edges are marked as hard/sharp. Hard/sharp edges generate errors in the physbox model.}}


{{tip|Set the Console Variable <code>vcollide_wireframe 1</code> to view collision meshes in-game.}}
{{tip|Set the Console Variable <code>vcollide_wireframe 1</code> to view collision meshes in-game.}}
Line 9: Line 12:
== Syntax ==
== Syntax ==


  [[$collisionmodel]] "<collision mesh SMD>.smd"
  $collisionmodel <collision mesh [[Studiomdl Data|SMD]]/[[DMX|DMX]]>
  {
  {
    <options>
<options>
  }
  }


== Options ==
== Options ==
{{stub}}
{{Note | Missing parameters for some options}}


; <code>$mass <[[float]]|kilograms></code>
; <span id="$mass">{{mono|$mass <[[float]]{{!}}kilograms>}}</span>
: Manually set the mass of the model, in kilograms.
: Manually set the mass of the model, in kilograms. {{tip|By default, the Player can +USE pick up 35KG max. The gravgun can pick up 250KG max. The portal gun can pick up 85KG max.}}
{{tip|By default, the Player can +USE pickup 35kg max. The gravgun can pickup 250kg max.}}
;{{mono|$automass}}
 
;<code>$automass</code>
: Calculate the mass of the model based on the volume of the collision model and the material defined in its [[Prop Data|prop_data]].
: Calculate the mass of the model based on the volume of the collision model and the material defined in its [[Prop Data|prop_data]].
 
; {{mono|$concave }}
; <code>$concave </code>
: By default, studiomdl will generate a single [[Wikipedia:Convex|convex]] hull by 'shrinkwrapping' any [[Wikipedia:Concave polygon|concavities]]. You can create a [[Wikipedia:Concave|concave]] hull by including multiple convex shapes (potentially overlapping) in your collision model, '''smoothing the hulls’ shading''', and passing this command.
: By default, the model compiler will generate a single [[Wikipedia:Convex|convex]] hull by bridging any [[Wikipedia:Concave|concavities]] in a collision SMD. You can create a [[Wikipedia:Concave|concave]] hull by including multiple, overlapping convex meshes in your SMD, and adding the <code>$concave</code> will preserve concavities by using multiple convex pieces. The resulting hull structure is a bit like a ''rigid'' [[$collisionjoints|ragdoll]].
;{{mono|$maxconvexpieces <[[int]]>}} {{{1|}}}{{#if: {{{1|}}} | &nbsp; }}{{since|{{src07}}}}
 
:By default, the model compiler limits a concave collision model to twenty convex pieces (forty in {{src13}}). This command can be used to override the limit if you are creating a [[Costly collision model]]. {{note|Introduced with the Orange Box. In the Ep1 engine, run studiomdl with {{mono|-fullcollide}} instead.}}{{warning|Going past a hundred or so pieces may begin to create server lag when multiple objects are touching the model.}}
;<code>$maxconvexpieces <[[int]]></code>
; {{mono|$masscenter <[[vector]]{{!}}offset>}}
:By default, the model compiler limits a concave collision model to twenty convex pieces. This command can be used to override the limit - for instance if you are creating an unusually large model.
{{note|Introduced with the Orange Box. In the Ep1 engine, run StudioMDL with <code>-fullcollide</code> when compiling instead.}}
 
; <code>$masscenter <[[vector]]|offset></code>
: Override the center of mass, in local coords.
: Override the center of mass, in local coords.
 
; {{mono|$inertia <[[normal]]>}}
; <code>$inertia <[[float]]|scale></code>
: Inertia scale. Higher values will make the physics object more sturdy, while lower values will make it more wobbly.
: Inertia scale.
; {{mono|$damping <[[float]]>}}
 
: Linear damping scale. Affects how quickly an object's velocity drops to zero.
; <code>$damping <[[float]]|scale></code>
; {{mono|$rotdamping <[[float]]>}}
: Linear damping scale.
: Rotational damping scale. Affects how quickly an object's angular velocity drops to zero. {{warning|This affects the pull of gravity on the model and if abused can make it appear to float gently through the air. Valve recommends using "friction" instead.}}
 
; {{mono|$drag <[[normal]]>}}
; <code>$rotdamping <[[float]]|scale></code>
: Scales air resistance. Essentially a more subtle version of $damping.
: Rotational damping scale.
; {{mono|$jointskip}}
 
: Rarely used. Eliminates a joint in the collision model that you don't want to use. (i.e. if you were using a render model as a ragdoll, and it has bones you don't want).
; <code>$drag <[[float]]|scale></code>
; {{mono|$jointmerge}}
: Scales air resistance.
: Merges the vertex assignments for two joints.
; {{mono|$jointinertia}}
: Like $inertia, but per-bone.
; {{mono|$jointdamping}}
: Like $damping, but per-bone.
; {{mono|$jointmassbias}}
: Mass is automatically distributed by volume, this lets you bias it per-bone.
; {{mono|$jointrotdamping}}
: Like $rotdamping, but per-bone.
; {{mono|$jointcollide}}
: If any $jointcollide pairs are specified, only those joints collide with each other.
; {{mono|[[$jointconstrain]]}}
: The limits of the joint's movement.
; {{mono|$rootbone}}
: The parent-most bone that actually has collision geometry.
; {{mono|$noselfcollisions}}
: Turns off all collisions between bones in this model.
; {{mono|$animatedfriction}}
: Used to animate the amount of friction on joints over time.
; {{mono|$addconvexsrc <[[file]]> "offset pos[ <[[float]]> <[[float]]> <[[float]]> ] angle[ <[[float]]> <[[float]]> <[[float]]> ] scale[ <[[float]]> ] concave"}} {{{1|}}}{{#if: {{{1|}}} | &nbsp; }}{{only|{{csgo}}}}
: Adds a convex model onto the collision model with the specified position, angle, and scale. The "concave" option is optional. {{Note|It must be formatted EXACTLY like this!}}
; {{mono|$remove2d}}
: Used to remove flat shaded faces. Off by default.
; {{mono|$weldposition <[[float]]>}}
: The amount of distance tolerance to use when trying to merge vertices of separate concave pieces in order to create a single concave piece.
; {{mono|$weldnormal <[[float]]>}}
: The amount of tolerance to check if the vertice normal is similar enough to consider merging to a unique vertice. Used in conjunction with $weldposition.
; {{mono|$assumeworldspace}}
: Assumes the joints are positioned in world space.


== Example ==
== Example ==


  $collisionmodel "tree_deciduous_01a_physbox.smd"
  $collisionmodel "tree_deciduous_01a_physbox"
  {
  {
  $mass 350.0
  $mass 350.0
Line 54: Line 81:


==See also==
==See also==
 
* [[Collision mesh]]
*[[VPhysics]]
* [[$collisionjoints]]
*[[Physics and Ragdolls]]
* [[Costly collision model]]
*[[$collisionjoints]]
* [[VPhysics]]
 
* [[Physics and Ragdolls]]
[[Category:QC Commands|collisionmodel]]

Latest revision as of 21:26, 16 July 2025

English (en)Translate (Translate)

$collisionmodel is a QC command available in all Source Source games.

It is used to embed a static collision mesh in a model for use in VPhysics calculations. Animated models (including ones that will become ragdolls) should use $collisionjoints instead.

Warning.pngWarning:Collision meshes should have extremely few polygons. See Collision mesh for examples.
Warning.pngWarning:Older engines automatically optimize meshes that are too dense, merging vertices that are close together. But this also ruins small collisionmodels, as it merges various vertices together that should not be merged.
This has been observed in Half-Life 2Half-Life 2: DeathmatchHalf-Life 2: Lost CoastHalf-Life 2: Episode OneHalf-Life 2: Episode Two.
Note.pngNote:For collision meshes modeled in Blender Blender or Softimage Mod Tool Softimage Mod Tool, ensure that none of the edges are marked as hard/sharp. Hard/sharp edges generate errors in the physbox model.
Tip.pngTip:Set the Console Variable vcollide_wireframe 1 to view collision meshes in-game.

Syntax

$collisionmodel	<collision mesh SMD/DMX>
{
	<options>
}

Options

Stub

This article or section is a stub. You can help by expanding it.

Note.pngNote: Missing parameters for some options
$mass <float|kilograms>
Manually set the mass of the model, in kilograms.
Tip.pngTip:By default, the Player can +USE pick up 35KG max. The gravgun can pick up 250KG max. The portal gun can pick up 85KG max.
$automass
Calculate the mass of the model based on the volume of the collision model and the material defined in its prop_data.
$concave
By default, studiomdl will generate a single convex hull by 'shrinkwrapping' any concavities. You can create a concave hull by including multiple convex shapes (potentially overlapping) in your collision model, smoothing the hulls’ shading, and passing this command.
$maxconvexpieces <int> (in all games since Source 2007)
By default, the model compiler limits a concave collision model to twenty convex pieces (forty in Source 2013). This command can be used to override the limit if you are creating a Costly collision model.
Note.pngNote:Introduced with the Orange Box. In the Ep1 engine, run studiomdl with -fullcollide instead.
Warning.pngWarning:Going past a hundred or so pieces may begin to create server lag when multiple objects are touching the model.
$masscenter <vector|offset>
Override the center of mass, in local coords.
$inertia <normal>
Inertia scale. Higher values will make the physics object more sturdy, while lower values will make it more wobbly.
$damping <float>
Linear damping scale. Affects how quickly an object's velocity drops to zero.
$rotdamping <float>
Rotational damping scale. Affects how quickly an object's angular velocity drops to zero.
Warning.pngWarning:This affects the pull of gravity on the model and if abused can make it appear to float gently through the air. Valve recommends using "friction" instead.
$drag <normal>
Scales air resistance. Essentially a more subtle version of $damping.
$jointskip
Rarely used. Eliminates a joint in the collision model that you don't want to use. (i.e. if you were using a render model as a ragdoll, and it has bones you don't want).
$jointmerge
Merges the vertex assignments for two joints.
$jointinertia
Like $inertia, but per-bone.
$jointdamping
Like $damping, but per-bone.
$jointmassbias
Mass is automatically distributed by volume, this lets you bias it per-bone.
$jointrotdamping
Like $rotdamping, but per-bone.
$jointcollide
If any $jointcollide pairs are specified, only those joints collide with each other.
$jointconstrain
The limits of the joint's movement.
$rootbone
The parent-most bone that actually has collision geometry.
$noselfcollisions
Turns off all collisions between bones in this model.
$animatedfriction
Used to animate the amount of friction on joints over time.
$addconvexsrc <file> "offset pos[ <float> <float> <float> ] angle[ <float> <float> <float> ] scale[ <float> ] concave" (only in Counter-Strike: Global Offensive)
Adds a convex model onto the collision model with the specified position, angle, and scale. The "concave" option is optional.
Note.pngNote:It must be formatted EXACTLY like this!
$remove2d
Used to remove flat shaded faces. Off by default.
$weldposition <float>
The amount of distance tolerance to use when trying to merge vertices of separate concave pieces in order to create a single concave piece.
$weldnormal <float>
The amount of tolerance to check if the vertice normal is similar enough to consider merging to a unique vertice. Used in conjunction with $weldposition.
$assumeworldspace
Assumes the joints are positioned in world space.

Example

$collisionmodel "tree_deciduous_01a_physbox"
{
	$mass 350.0
	$concave
}

See also