Mesh

From Valve Developer Community
Revision as of 16:08, 3 May 2008 by Beeswax (talk | contribs)
Jump to navigation Jump to search

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 projected over the Mesh which 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.

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.


Default mesh

The Default mesh is the Mesh that will be rendered unless substituted by a specific LOD mesh.

Optional mesh

Optional Sub-meshes can be switched on and off at runtime. Like the Default 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 ?
    )

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_mesh.SMDs are usually created from pared-down versions of the Default mesh and Sub-Meshes, and compiled via the $lod configuration. The Default mesh or Default Sub-mesh is used when no LOD mesh is active; we could say it amounts to an "lod0" Mesh.


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.