Reference mesh: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(cleanup the intro; some stuff was a bit off)
m (→‎top: clean up, replaced: {{Source| → {{src|)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
In Source, a [[Reference mesh]] (sometimes called the ''body'' or ''envelope'' or ''skin'' of the model) defines some or all of a model's rendered geometry. A model needs at least one reference mesh or it will not be visible in the world. It is [[enveloped]] to the bones of a model's [[Skeleton]] and moves with them. It is commonly replaced by lower-detail meshes at distances with <code>[[$lod]]</code>.
In {{src|4}}, a [[Reference mesh]] (sometimes '''body''', '''envelope''' or '''skin''') defines some or all of a model's rendered geometry. It is stored in a 'reference [[Studiomodel Data|SMD]]' file together with [[skeleton]] and [[UV map]] data.


A reference mesh includes:
== Facets ==


;Geometry data
;UV maps
:Vertex Coordinates (relative to a specific [[Parentbone]]) for each triangular polygon,
:The [[UV map]] defines how the mesh's [[material]] is deformed to fit it.
;[[Smoothing group]] data
;Levels of detail
:Normal vector (relative to a specific [[Parentbone]]) at each vertex,
:A reference mesh is commonly replaced by lower-detail meshes at distances with <code>[[$lod]]</code> to improve performance. See [[LOD Models]].
;[[Skinning]]
;Envelopes
:[[UV map]] coordinates and [[Default Skinname]](s),
:A reference mesh is [[enveloped]] to the bones of a model's [[skeleton]] to allow for animation.
;[[Envelope]] data
;Weight maps
:[[Weight map]] values and [[Parentbone]] for each vertex.
:See [[weight map]].


{{tip|See [[SMD file format]] for exactly how this data is stored in the <code>triangles</code> block of a "Studio Model Data" file.}}
== Implementation ==


There are three [[:Category:QC Commands|QC commands]] related to reference meshes:


== Default mesh ==
;<code>[[$body]]</code>
: The '''Default mesh''' is the Mesh that will be rendered unless substituted by a specific ''LOD mesh'', and/or modified by a specific ''Sub-mesh''.
:A basic reference mesh.
:* It is defined in the [[Reference.smd]] and compiled to the [[VVD]] and [[VTX]] binaries via the [[$body]] or [[$model]] QC command.  
;<code>[[$model (QC)|$model]]</code>
:A reference mesh with [[facial animation]].
;<code>[[$bodygroup]]</code>
:A reference mesh or group of reference meshes that can be switched between or off.
;<code>[[$lod]] replacemodel</code>
:A low-detail reference mesh that replaces another at the $lod's specified distance and above.


== Sub-mesh ==
[[Category:Source]]
: '''Sub-meshes''' can be switched on and off at runtime. Like the Default mesh, they are [[enveloped]] to the model's Skeleton, and will deform (stretch and bend) as if part of the Default mesh. Specific pieces of clothing are good candidates for switchable sub-meshes; eg different types of body armor or headgear. By contrast ''Sub-models'' (eg weapons) can be attached to specific [[$attachment]] points on this skeleton, but they remain ''enveloped'' to their own skeleton; they will move with this skeleton but will not be deform by it.


:* The [[$bodygroup]] configuration allows any number of sub-meshes ([[SMD]]s) to be added to the ''Default mesh''. Setting up multiple [[$bodygroup]]s allows sub-mesh switching to be triggered by (code-level) events.
[[Category:Modeling]]
:* Sub-meshes do not affect the model's collision model.
:* ({{todo|[[$model]]'s face mesh for facial animation ?}})
 
== LOD mesh ==
: Source's [[LOD system]] allows a "cheaper" (simplified) version of the Mesh(es) to be ''rendered'' at a distance where the loss of "expensive" detail is not noticeable to the Viewer. Any number of replacement [[LOD Models|LOD_Mesh.SMD]]s are usually created from pared-down versions of the Default Mesh and Sub-Meshes, but they are compiled into the main MDL's [[VVD]] and [[VTX]] files via the QC [[$lod]] configuration. The Default Mesh (including Sub-Meshes) is used when no LOD Mesh is active, we could say it amounts to an "lod0" Mesh.
 
== See also ==
 
*[[$body]] / [[$model]]
*[[$bodygroup]]
*[[$lod]]
 
[[category:Modeling]]
[[category:Modelling Glossary]]

Latest revision as of 04:02, 4 January 2024

In Source Source, a Reference mesh (sometimes body, envelope or skin) defines some or all of a model's rendered geometry. It is stored in a 'reference SMD' file together with skeleton and UV map data.

Facets

UV maps
The UV map defines how the mesh's material is deformed to fit it.
Levels of detail
A reference mesh is commonly replaced by lower-detail meshes at distances with $lod to improve performance. See LOD Models.
Envelopes
A reference mesh is enveloped to the bones of a model's skeleton to allow for animation.
Weight maps
See weight map.

Implementation

There are three QC commands related to reference meshes:

$body
A basic reference mesh.
$model
A reference mesh with facial animation.
$bodygroup
A reference mesh or group of reference meshes that can be switched between or off.
$lod replacemodel
A low-detail reference mesh that replaces another at the $lod's specified distance and above.