Mesh: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 1: Line 1:
<div style="float:right;padding:0 1em;background:#FFF;">__TOC__</div>
<div style="float:right;padding:0 1em;background:#FFF;">__TOC__</div>
In Source, a [[Mesh]] (sometimes referred to as the ''body'' or ''envelope'' or ''skin'' of the model) defines the ''deformable'' 3D geometry of the model's rendered surface. The Rendered '''[[Skin]]''' is ''[[UV|projected]]'' over the '''[[Mesh]]''' which ''[[enveloped|envelopes]]'' the '''[[Skeleton]]'''.
In Source, each [[Mesh]] (sometimes referred to as the ''envelope'' or ''skin'' of the model) defines a part of the model's Rendering Geometry (or ''Render model''). The Rendered '''[[Skin]]''' is ''[[UV|projected]]'' over the '''[[Mesh]]''' which ''[[enveloped|envelopes]]'' the '''[[Skeleton]]'''.


Each model requires at least one mesh (the ''default mesh'') but may also have additional ''sub-meshes''. Each mesh may also have a number of versions optimised for LOD-substitution.
Each renderable model requires at least one mesh (the ''body mesh'') but may also have additional ''sub-meshes''. Each mesh may also have a number of versions optimised for LOD-substitution.


All '''Mesh data''' is exported from a [[model editor]] as an [[SMD]] file, and then [[Compiling a model|compiled]] to the model's [[VVD]] and [[VTX]] binary files. Mesh data includes (for each triangular polygon) :
All '''Mesh data''' is exported from a [[model editor]] as an [[SMD]] file, and then [[Compiling a model|compiled]] to the model's [[VVD]] and [[VTX]] binary files. Mesh data includes (for each triangular polygon) :
Line 11: Line 11:
{{tip|See [[SMD file format]] for exactly how this data is stored in the <code>triangles</code> block of a "Studio Model Data" file.}}
{{tip|See [[SMD file format]] for exactly how this data is stored in the <code>triangles</code> block of a "Studio Model Data" file.}}


==== Body mesh====


==== Default mesh====
: The "default" '''body mesh''' is rendered unless substituted by a specific ''LOD mesh''. Sometimes it is called the ''Reference mesh'' because it is defined in the model's [[Reference.smd]] and compiled via the [[$body]] or [[$model]] QC command.


: The '''Default mesh''' will be rendered unless substituted by a specific ''LOD mesh''. It may include optional ''sub-meshes'', but always includes the '''Reference mesh''' which is defined in the [[Reference.smd]] and compiled via the [[$body]] or [[$model]] QC command.
==== Sub-mesh====


==== Optional mesh====
: Optional '''Sub-meshes''' can be switched on and off at runtime. Like the ''body mesh'', they are [[enveloped]] to this model's Skeleton, and will deform (stretch and flex) 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; their geometry will be ''moved'' by this skeleton but will not be ''deformed'' by it.  
 
: Optional '''Sub-meshes''' can be switched on and off at runtime. Like the Reference mesh, they are [[enveloped]] to this model's Skeleton, and will deform (stretch and flex) 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; their geometry will be ''moved'' by this skeleton but will not be ''deformed'' by it.  
:* The [[$bodygroup]] configuration allows any number of sub-meshes ([[SMD]]s) to be added to the ''Default mesh''. By setting up multiple [[$bodygroup]]s  sub-mesh switching can be triggered by (code-level) events.  
:* The [[$bodygroup]] configuration allows any number of sub-meshes ([[SMD]]s) to be added to the ''Default mesh''. By setting up multiple [[$bodygroup]]s  sub-mesh switching can be triggered by (code-level) events.  
:* Whereas "Alternative Skins" replace the Default Skin, Optional Meshes do not replace the Default Mesh.
:* Whereas "Alternative Skins" replace the Default Skin, Optional Meshes do not replace the Default Mesh.
:* Sub-meshes do not affect the model's [[collision model]].  
:* Sub-meshes do not affect the model's [[collision model]].  
:* ({{todo|[[$model]]'s face mesh for facial animation ?}})
:* ({{todo|[[$model]]'s face mesh for facial animation ?}})
:* Sub-meshes must be exported in separate .smd files to the ''body mesh'', but they must be [[enveloped]] to the same skeleton so they align correctly with the model (see [[$bonemerge]]).


====LOD mesh====
====LOD mesh====

Revision as of 12:47, 7 May 2008

In Source, each Mesh (sometimes referred to as the envelope or skin of the model) defines a part of the model's Rendering Geometry (or Render model). The Rendered Skin is projected over the Mesh which envelopes the Skeleton.

Each renderable model requires at least one mesh (the body mesh) but may also have additional sub-meshes. Each mesh may also have a number of versions optimised for LOD-substitution.

All Mesh data is exported from a model editor as an SMD file, and then compiled to the model's VVD and VTX binary files. Mesh data includes (for each triangular polygon) :

Tip.pngTip:See SMD file format for exactly how this data is stored in the triangles block of a "Studio Model Data" file.

Body mesh

The "default" body mesh is rendered unless substituted by a specific LOD mesh. Sometimes it is called the Reference mesh because it is defined in the model's Reference.smd and compiled via the $body or $model QC command.

Sub-mesh

Optional Sub-meshes can be switched on and off at runtime. Like the body mesh, they are enveloped to this model's Skeleton, and will deform (stretch and flex) 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; their geometry will be moved by this skeleton but will not be deformed by it.
  • The $bodygroup configuration allows any number of sub-meshes (SMDs) to be added to the Default mesh. By setting up multiple $bodygroups sub-mesh switching can be triggered by (code-level) events.
  • Whereas "Alternative Skins" replace the Default Skin, Optional Meshes do not replace the Default Mesh.
  • Sub-meshes do not affect the model's collision model.
  • (
    Todo: $model's face mesh for facial animation ?
    )
  • Sub-meshes must be exported in separate .smd files to the body mesh, but they must be enveloped to the same skeleton so they align correctly with the model (see $bonemerge).

LOD mesh

Source's LOD system allows a "cheaper" (simplified) version of the Default 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_meshes can be made from pared-down Default meshes, and compiling the lod.SMDs via the $lod configuration. A Default mesh is used when no LOD mesh is active; we could say it amounts to an "lod0" Mesh. See Creating LOD Models.


Disambiguation

  • A Model is a functional set of components, including whatever Skin, Mesh, Skeleton, Collision geometry, associated Animations, Sounds, Physics properties, etc. data it needs to fulfil a given role. Often a particular SMD or MDL file is referred to as a model, for example a "reference model" usually refers to the reference.smd, and a "collision model" (PHY) is a fully rigged version of the visual model (VVD) which is simply "rendered" in the Physics Engine as opposed to the Rendering Engine.
  • A Collision Mesh in Source is a misnomer, because all pieces of 3D collision geometry are rigid Collision Hulls rather than deformable Meshes. A Ragdoll's Collision Model consists of a system of small Rigid Hulls which are moved (but not deformed) by skeletal articulation. The "Rendering Mesh" or "Skin Mesh" is the only type of Mesh used currently for Source Models.