Reference model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (comment made no sense without subject)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{stub}}
<!--
The plan is to break out this stuff (Reference Model section) when it's finished. --[[User:Beeswax|Beeswax]] 19:08, 1 May 2008 (PDT)
The plan took too long to finish, I uncommented the section. brandished 14:49, 20 January 2009 (UTC)
-->
 
=Reference Model=
 
The Reference Model is the basic template or foundation to which a models properties are added. It comprises the Render Geometry and the Rigged Skeleton, and by implication includes the:
* Default Pose/Animation (Rigid)
* Default CollisionProperty (NotSolid)
* Default Appearance (no Skin or Mesh variants)
* Default LOD threshhold (lod0)


== Reference.mdl ==
'''Animation model''' : "Reference model" is a term used by animators to distinguish the un-animated model's ''deformable'' 3D rendering data from the the actual animated sequence (deformation) data that can be applied to it. This includes the model's basic Rig (Skeleton) and Render Surface (Mesh & Skin). It's like a puppet before the puppeteer gets his hands on it. Without animation or [[propdata]] for physics, the reference model is unable to move.
The Reference.mdl, conventionally named <code><modelname>.mdl</code>, contains a range of key information for an in game model:
* The model's Filename, used to identify vital data stored in the model's [[VTX]], [[VVD]], [[PHY]] files.
* The names of any Sound WAV files used by this model.
* The names of the Skin VMT files used by this model(or is this in VTX / VVD files ?)
* The names of any Animation Sequences used by this model.  
* The names of any Animation Library MDL files used by this model.  
* Any [[propdata]] attributes this model may have, including
* The names of any Gib MDL files used by this model.
<!--  //Hmmm. this one needs work!
* The model's Origin, used to align its rendermodels, collisionmodel, gibs, etc to the Model Entity's position in the World.
-->
* etc


Each model's 3D Rendering data is stored in the [[VVD]] and [[VTX]] files, and its Collisionmodel data in its [[PHY]] file.
'''Collision model''' defines the Solidity of the model. Because Source is a little more than a simple animation renderer, most models also require a separate [[Physics model]] for collision detection, etc. Although not Rendered on screen, the Physics model is also a kind of Reference model because it too may be ''deformed'' by skeletal animation, and contains its own Rigging and (Rigid) Mesh data. The only difference between the "physics" model and the "render" model is that one is used by the Physics Engine, and the other is used by the Rendering Engine... so Physics or Collision models don't have Skins. Collision models are deformed by skeletal animation (ragdolls) but are generally not altered for LOD or visual variations.


== Reference.smd ==
'''LOD models''' : are "cheaper" versions of the render model - using a simplified Mesh, Skin and/or Skeletal structure for rendering at a distance where the loss of detail is not visible. LOD models are deformed by the same animations as the Reference model.
The reference.smd is traditionally named <code>"modelname_ref.smd"</code> to distinguish it from <code>"modelname_anim.smd"</code> files. It is also distinct from the <code>"modelname_phys.smd"</code> which contains only collisionmodel reference data.


The reference.smd contains the model's "default" Rendering data for animation files to manipulate.
'''Variant models''' visual variations such as optional Skins or optional sub-meshes, are an efficient way to introduce variety or runtime alterations to the render model. Variant models are deformed by the same animations, and are subject to the same LOD version considerations as the Reference model.
* The '''Reference Skeleton''' (<code>nodes</code> block) is used by animations or ragdoll physics to manipulate the mesh, collisionmodel, hitboxset, etc. It can be modified by [[$lod]] bonetreecollapse (etc)
* The '''Reference Pose''' (<code>skeleton</code> block) is used when no animation or vphysics is applied to the skeleton.
* The '''Reference Mesh''' (<code>triangles</code> block) is the Mesh that will be Rendered unless replaced by an [[$lod]] configuration.
* The '''Reference Skin''' is only the ''filename'' of the VMT whose VTFs will be used on the Mesh unless overridden by [[$texturegroup]] skinfamilies options and/or [[$lod]] configuration.  


; Reference Mesh:
So the "Reference model"'s properties add up to an un-animated, not solid, lod_0, single-skinned and single-meshed model.
In Source, the Reference Mesh (also called the ''body'' or ''envelope'' or ''skin'') includes:
* [[Geometry]] data : Vertex Coordinates (in relation to the model's [[$origin]]) for each triangular polygon,
* [[Smoothing group]] data : Normal vector {{confirm|(in relation to the model's [[$origin]])}} for each vertex,
* [[Skin]] data : [[UV map]] coordinates and Default "Skinname(s)",
* [[Envelope]] data : [[Weight map]] values and "Bonename(s)".


<!--
=Compiling a Model=
probable destination for this section is an introduction to Compiling models for Source. 3rd party MDL compilers often provide a different GUI to the QC file than StudioMDL, so a checklist of "things you should already have done" would be relevant to all MDL compiler docs. It includes model anatomy/glossary definitions for #REDIRECTs ?


:;Sub-meshes: [[$bodygroup]] allows additional sub-meshes (.smd) to be added to the main [[$body]] mesh. It also allows the model to switch between rendered [[$bodygroup]]s during runtime. Some good candidates for switchable sub-meshes would be different types of body armor or headgear. [[$bodygroup]] sub-meshes are [[enveloped]] to the reference skeleton, and will deform (stretch and bend) as part of the mesh. Sub-meshes are not added to the model's $collisionmodel. ({{todo|[[$model]]'s face mesh for facial animation ?}})
== Reference.smd ==
* The Reference.smd is traditionally named <code>"modelname_ref.smd"</code>.
* It defines the model's [http://en.wikipedia.org/wiki/Frame_of_reference Reference] Skeleton and its "default" 3D Rendering Geometry:
** <!--smd|nodes & skeleton-->The '''Reference Skeleton''' is the key for all of the model's geometry: vertex data for the render mesh, sub meshes, collisionmodel, hitboxset, attachments, animations, gibs, etc. all ''reference'' the skeleton. <!--so be careful with [[$lod]] bone modification!-->
<!--The '''Default Pose'''  is used when no animation or vphysics is applied to the skeleton.-->
** <!--smd|triangles-->The '''Reference Mesh''' is the "main body" (as opposed to [[$bodygroup]] sub-meshes) of the Render Model. <!--unless replaced by an [[$lod]] configuration.--> The Reference Mesh's [[UV map|Skinning data]] also defines the filename(s) of the model's '''Default Skin(s)'''.
* Notably, the reference.smd ''does not contain'' the model's
** Physics geometry (collision & hitboxes)
** Skin files
** LOD meshes & skins
** Optional meshes & skins
** Animations
** Game settings (QC /StudioMDL parameters)
{{tip|See [[SMD file format]] for exactly how this data is stored in each "Studio Model Data" file.}}


:;Sub-models: [[$attachment]] points allow world prop models (.mdl), such as the character's "current weapon", to be constrained to a specific bone or bones on the main model. These sub-models will move with the bone they are attached to, but will not deform like the [[$body]] or [[$bodygroup]] meshes. They are essentially prop-constraints for animations rather than part of the main reference model.
==Submesh.smd==
* <code>"submeshname_sub1.smd"</code>, <code>"modelname_ref_sub1.smd"</code> or <code>"modelname_hat_ref.smd"</code>.
* defines a rendered submesh which may be added to the default mesh via $bodygroups. Submeshes cannot be included in the reference.smd.
* includes: ref-skeleton, defines: mesh (ie: skinname, uvmap, envelope & weightmap data)
* submesh.smd must be enveloped to the ref-skeleton ...  


;Default Skin: The '''Reference Skin''' is the name of the image file(s) used when creating the [[UV map]] data in the Mesh (the extension - .tga, .bmp, etc - is recorded but not used in compiling). The actual pixel matrices (colors, normals, etc) are not included in the mesh, and are not compiled by StudioMDL. Instead, they must be compiled into [[VTF]] texture files and included in a [[VMT]] material file. By default, the compiled model expects to find a VMT with the same name as the Reference Skin in the <code>game_dir/materials/models</code> directory. If it's not there, the model will be rendered with the "pink check" error material.
==LOD.smd==
* <code>"lod1_modelname_ref.smd"</code>, <code>"lod1_modelname_sub1.smd"</code>.  
* [[LOD Models]] are simplified versions of renderable meshes. each requires its own smd, and are compiled into VVD/VTX of main model via the $lod configuration.
* the convention is to prefix the modelname "lod#_". The ref and sub.smds are effectively lod0_modelname_ref.smd, lod0_modelname_sub.smd,
* includes: ref-skeleton, defines: mesh geometry (ie: coords, smoothing, skinname, uvmap, envelope & weightmap data)


:;Alternate Skins: The model can have optional alternate skins, which are also VMT files in the <code>game_dir/materials/models</code> directory. The filenames of optional skins must be specified in the QC file's [[$texturegroup]] configuration in order to be available to the model. The skin to be rendered in game is selected by the level designer {{confirm|and cannot change at runtime}}. An alternate skin can differ from the default skin in many ways, but it cannot change the [[UV map]] data in the model's Mesh.
==Physics.smd==
* The Physics.smd is traditionally named <code>"bodymeshname_phy.smd"</code>. _physmodel.smd or _physbox.smd
* defines the hull geometry, envelope and smoothing group data for the collisionmodel. incl ref-skeleton.
* includes the ref-skeleton and defines: hull geometry(s) (ie: vertex coords, normals, & envelope data)
** Because hulls are rigid and not rendered, they don't use any UVmap or weightmap data.
** Each hull must be a convex shape ie somewhere between a sphere and a box. Overlapping/intersecting multiple hulls are used to create ($concave) models.
** Rigid collisionmodels ($collisionmodel) envelope all hulls to the same bone.  
** Jointed collisionmodels ($collisionjoints) envelope some hulls to different bones.


;Level of Detail Optimisation: Source's [[LOD system]] allows a "cheaper" (simplified) version of the model to be rendered at a distance where the loss of detail is not noticeable to the Viewer. Each [[$lod]] configuration specifies the distance threshhold for a block of modifications. It allows the Rendering Engine (at runtime) to effectively replace or remove Meshes, Skins and/or Bones. Replacement [[LOD Models]] and Skins are created as separate SMDs and VMTs, but they are compiled into the main MDL's [[VVD]] and [[VTX]] files.
==Hitbox.smd==
* {{confirm|not compiled by StudioMDL, but opened in text editor for hitbox vertex coordinates?}}
* not rendered, simple collision = simple box geometry


-->
==Animation.smd==
* Each Animation.smd is traditionally named <code>"sequencename.smd"</code>.
* includes the ref-skeleton and defines a keyframed sequence of skeletal poses.
* $sequence "idle" "modelname_idle.smd"
* $sequence "ragdoll" "ragdoll.smd" ACT_DIERAGDOLL 1 fps 30.00
* [[$includemodel]] includes an AnimationLibrary.mdl




[[category:modeling]]
[[category:modeling]]

Latest revision as of 07:58, 20 January 2009


Reference Model

The Reference Model is the basic template or foundation to which a models properties are added. It comprises the Render Geometry and the Rigged Skeleton, and by implication includes the:

  • Default Pose/Animation (Rigid)
  • Default CollisionProperty (NotSolid)
  • Default Appearance (no Skin or Mesh variants)
  • Default LOD threshhold (lod0)

Animation model : "Reference model" is a term used by animators to distinguish the un-animated model's deformable 3D rendering data from the the actual animated sequence (deformation) data that can be applied to it. This includes the model's basic Rig (Skeleton) and Render Surface (Mesh & Skin). It's like a puppet before the puppeteer gets his hands on it. Without animation or propdata for physics, the reference model is unable to move.

Collision model defines the Solidity of the model. Because Source is a little more than a simple animation renderer, most models also require a separate Physics model for collision detection, etc. Although not Rendered on screen, the Physics model is also a kind of Reference model because it too may be deformed by skeletal animation, and contains its own Rigging and (Rigid) Mesh data. The only difference between the "physics" model and the "render" model is that one is used by the Physics Engine, and the other is used by the Rendering Engine... so Physics or Collision models don't have Skins. Collision models are deformed by skeletal animation (ragdolls) but are generally not altered for LOD or visual variations.

LOD models : are "cheaper" versions of the render model - using a simplified Mesh, Skin and/or Skeletal structure for rendering at a distance where the loss of detail is not visible. LOD models are deformed by the same animations as the Reference model.

Variant models visual variations such as optional Skins or optional sub-meshes, are an efficient way to introduce variety or runtime alterations to the render model. Variant models are deformed by the same animations, and are subject to the same LOD version considerations as the Reference model.

So the "Reference model"'s properties add up to an un-animated, not solid, lod_0, single-skinned and single-meshed model.

Compiling a Model

probable destination for this section is an introduction to Compiling models for Source. 3rd party MDL compilers often provide a different GUI to the QC file than StudioMDL, so a checklist of "things you should already have done" would be relevant to all MDL compiler docs. It includes model anatomy/glossary definitions for #REDIRECTs ?

Reference.smd

  • The Reference.smd is traditionally named "modelname_ref.smd".
  • It defines the model's Reference Skeleton and its "default" 3D Rendering Geometry:
    • The Reference Skeleton is the key for all of the model's geometry: vertex data for the render mesh, sub meshes, collisionmodel, hitboxset, attachments, animations, gibs, etc. all reference the skeleton.
    • The Reference Mesh is the "main body" (as opposed to $bodygroup sub-meshes) of the Render Model. The Reference Mesh's Skinning data also defines the filename(s) of the model's Default Skin(s).
  • Notably, the reference.smd does not contain the model's
    • Physics geometry (collision & hitboxes)
    • Skin files
    • LOD meshes & skins
    • Optional meshes & skins
    • Animations
    • Game settings (QC /StudioMDL parameters)
Tip.pngTip:See SMD file format for exactly how this data is stored in each "Studio Model Data" file.

Submesh.smd

  • "submeshname_sub1.smd", "modelname_ref_sub1.smd" or "modelname_hat_ref.smd".
  • defines a rendered submesh which may be added to the default mesh via $bodygroups. Submeshes cannot be included in the reference.smd.
  • includes: ref-skeleton, defines: mesh (ie: skinname, uvmap, envelope & weightmap data)
  • submesh.smd must be enveloped to the ref-skeleton ...

LOD.smd

  • "lod1_modelname_ref.smd", "lod1_modelname_sub1.smd".
  • LOD Models are simplified versions of renderable meshes. each requires its own smd, and are compiled into VVD/VTX of main model via the $lod configuration.
  • the convention is to prefix the modelname "lod#_". The ref and sub.smds are effectively lod0_modelname_ref.smd, lod0_modelname_sub.smd,
  • includes: ref-skeleton, defines: mesh geometry (ie: coords, smoothing, skinname, uvmap, envelope & weightmap data)

Physics.smd

  • The Physics.smd is traditionally named "bodymeshname_phy.smd". _physmodel.smd or _physbox.smd
  • defines the hull geometry, envelope and smoothing group data for the collisionmodel. incl ref-skeleton.
  • includes the ref-skeleton and defines: hull geometry(s) (ie: vertex coords, normals, & envelope data)
    • Because hulls are rigid and not rendered, they don't use any UVmap or weightmap data.
    • Each hull must be a convex shape ie somewhere between a sphere and a box. Overlapping/intersecting multiple hulls are used to create ($concave) models.
    • Rigid collisionmodels ($collisionmodel) envelope all hulls to the same bone.
    • Jointed collisionmodels ($collisionjoints) envelope some hulls to different bones.

Hitbox.smd

  • Confirm:not compiled by StudioMDL, but opened in text editor for hitbox vertex coordinates?
  • not rendered, simple collision = simple box geometry

Animation.smd

  • Each Animation.smd is traditionally named "sequencename.smd".
  • includes the ref-skeleton and defines a keyframed sequence of skeletal poses.
  • $sequence "idle" "modelname_idle.smd"
  • $sequence "ragdoll" "ragdoll.smd" ACT_DIERAGDOLL 1 fps 30.00
  • $includemodel includes an AnimationLibrary.mdl