User:Gammerman12/Sandbox/Authoring HWM

From Valve Developer Community
< User:Gammerman12
Revision as of 23:13, 17 August 2013 by Gammerman12 (talk | contribs) (Created page with "==Exporting the Model== If you're using Maya, you've gotta follow a couple steps to export the model correctly. With your model selected, go into the MEL script editor and enter ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Exporting the Model

If you're using Maya, you've gotta follow a couple steps to export the model correctly. With your model selected, go into the MEL script editor and enter this command

vsDmxIO -export -ufc -ac -exportType model -exportType skeletalAnimation -selection -filename "C:/Foo/Bar/parts/dmx/head_morphs.dmx"

Why do we use this command? Because of -ufc. Maya normally uses hyphens (-) in place of underscores (_), and underscores are required for DMXedit to recognize the blend shape as a corrector. -ufc means "Underscores For Correctives," which preserves underscores in the export.

Blender will preserve underscores for you, so you can skip this, open source users!

Coding for DMXedit

DMXedit requires some sort of script (.lua and apparently .py) that tells the program to run the files inside game/sdktools/lua. Bay Raitt privately released the script used for the Medic in tf_movies, so this is a good jumping off point. For this tutorial, we will be using a modified game/sdktools/lua/reference_heads/tf_movies.dmx which has had it's correctives properly named with underscores instead of hyphens (someone at Valve, please export the scout's head with ufc!!) You can download it here [[1]]. As for the script, this is what it looks like.

-- Set the game mod to be tf_movies - all actors live in the tf_movies mod 
vs.SetGame( "Elements" );
-- load in the actor source file 
Load( "parts/dmx/head_morphs.dmx", "relative" );
base = "base";
-- define what the separator is for selection, as currently some of the select shapes are "SELECT-eyes" and some are "SELECT_eyes 
-- selectSeparator = "_";
-- flag what parts of the face are going to be compiled 
upperFaceSwitch = true ;
lowerFaceSwitch = true ;
-- lock teeth and throat socket.
if lowerFaceSwitch then dofile( vs.GameDir() .. "../sdktools/lua/face_lockJaw.lua" );
end 
-- generate corrective combinations. 
dofile( vs.GameDir() .. "../sdktools/lua/face_correctors.lua" );
ResetState();
SaveDelta( "TongueBack" );
SaveDelta( "TongueCurlDown" );
SaveDelta( "TongueCurlUp" );
SaveDelta( "TongueFunnel" );
SaveDelta( "TongueLeft" );
SaveDelta( "TongueNarrow" );
SaveDelta( "TongueOut" );
SaveDelta( "TongueRight" );
SaveDelta( "TongueV" );
SaveDelta( "TongueWide" );
SaveDelta( "SELECT-tongue" );
-- group eye controls
GroupControls( "CloseLid", "CloseLidLo", "CloseLidUp" );
GroupControls( "BrowInV", "WrinkleNose", "RaiseBrowIn" );
GroupControls( "NoseV", "PressNose", "SneerNose" );
GroupControls( "NostrilFlare", "SuckNostril", "BlowNostril" );
GroupControls( "CheekH", "DeflateCheek", "InflateCheek" );
GroupControls( "JawD", "SuckJaw", "JutJaw" );
GroupControls( "JawH", "SlideJawR", "SlideJawL" );
GroupControls( "JawV", "ClenchJaw", "OpenJaw" );
GroupControls( "LipsV", "CompressLips", "OpenLips" );
GroupControls( "LipUpV", "JutUpperLip", "OpenUpperLip" );
GroupControls( "LipLoV", "RaiseChin", "OpenLowerLip" );
GroupControls( "Smile", "SmileFlat", "SmileFull", "SmileSharp" );
GroupControls( "FoldLipUp", "SuckLipUp", "FunnelLipUp" );
GroupControls( "FoldLipLo", "SuckLipLo", "FunnelLipLo" );
GroupControls( "ScalpD", "ScalpBack", "ScalpForward" );
GroupControls( "TongueH", "TongueLeft", "TongueRight" );
GroupControls( "TongueCurl", "TongueCurlUp", "TongueCurlDown" );
GroupControls( "TongueD", "TongueBack", "TongueOut" );
GroupControls( "TongueWidth", "TongueNarrow", "TongueWide" );
-- reorder controls
ReorderControls( "CloseLid", "InnerSquint", "OuterSquint", "BrowInV", "BrowOutV", "Frown", "NoseV", "NostrilFlare", "CheekV", "CheekH", "JawD", "JawH", "JawV", "LipsV", "LipUpV", "LipLoV", "Smile", "Platysmus", "FoldLipUp", "FoldLipLo", "PuckerLipUp", "PuckerLipLo", "LipCnrTwst", "Dimple", "PuffLipUp", "PuffLipLo", "ScalpD", "TongueD", "TongueH", "TongueV", "TongueCurl", "TongueFunnel", "TongueWidth" );
SetEyelidControl("CloseLid", true );
-- setup stereo controls
SetStereoControl("CloseLid", true );
SetStereoControl("InnerSquint", true );
SetStereoControl("OuterSquint", true );
SetStereoControl("BrowInV", true );
SetStereoControl("BrowOutV", true );
SetStereoControl("Frown", true );
SetStereoControl("NoseV", true );
SetStereoControl("NostrilFlare", true );
SetStereoControl("CheekV", true );
SetStereoControl("CheekH", true );
SetStereoControl("JawD", false );
SetStereoControl("JawH", false );
SetStereoControl("JawV", false );
SetStereoControl("LipsV", true );
SetStereoControl("LipUpV", true );
SetStereoControl("LipLoV", true );
SetStereoControl("Smile", true );
SetStereoControl("Platysmus", true );
SetStereoControl("FoldLipUp", true );
SetStereoControl("FoldLipLo", true );
SetStereoControl("PuckerLipUp", true );
SetStereoControl("PuckerLipLo", true );
SetStereoControl("LipCnrTwst", true );
SetStereoControl("Dimple", true );
SetStereoControl("PuffLipUp", true );
SetStereoControl("PuffLipLo", true );
SetStereoControl("ScalpD", true );
SetStereoControl("TongueV", false );
SetStereoControl("TongueH", false );
SetStereoControl("TongueCurl", false );
SetStereoControl("TongueD", false );
-- add control dominators 
AddDominationRule( { "FunnelLipLo" },  { "Dimple"} );
AddDominationRule( { "FunnelLipUp" },  { "Dimple"} );
AddDominationRule( { "BrowOutV" },     { "WrinkleNose"} );
AddDominationRule( { "FunnelLipLo" },  { "PuffLipLo"} );
AddDominationRule( { "FunnelLipLo" },  { "PuffLipUp"} );
AddDominationRule( { "FunnelLipUp" },  { "PuffLipLo"} );
AddDominationRule( { "FunnelLipUp" },  { "PuffLipUp"} );
AddDominationRule( { "LipCnrTwst" },   { "Dimple"} );
AddDominationRule( { "OpenJaw" },      { "InflateCheek"} );
AddDominationRule( { "OpenLips" },     { "PuffLipLo"} );
AddDominationRule( { "OpenLips" },     { "PuffLipUp"} );
AddDominationRule( { "OpenLowerLip" }, { "CompressLips"} );
AddDominationRule( { "OpenLowerLip" }, { "FunnelLipLo"} );
AddDominationRule( { "OpenLowerLip" }, { "PuffLipLo"} );
AddDominationRule( { "OpenLowerLip" }, { "PuffLipUp"} );
AddDominationRule( { "OpenLowerLip", "OpenUpperLip" }, { "OpenLips"} );
AddDominationRule( { "OpenUpperLip" }, { "CompressLips"} );
AddDominationRule( { "OpenUpperLip" }, { "FunnelLipUp"} );
AddDominationRule( { "OpenUpperLip" }, { "PuffLipLo"} );
AddDominationRule( { "OpenUpperLip" }, { "PuffLipUp"} );
AddDominationRule( { "Platysmus" },    { "FunnelLipLo"} );
AddDominationRule( { "Platysmus" },    { "FunnelLipUp"} );
AddDominationRule( { "Platysmus" },    { "LipCnrTwst"} );
AddDominationRule( { "Platysmus" },    { "PuckerLipLo"} );
AddDominationRule( { "Platysmus" },    { "PuckerLipUp"} );
AddDominationRule( { "PuckerLipLo" },  { "SmileFlat"} );
AddDominationRule( { "PuckerLipLo" },  { "SmileFull"} );
AddDominationRule( { "PuckerLipLo" },  { "SmileSharp"} );
AddDominationRule( { "PuckerLipLo" },  { "SuckLipLo"} );
AddDominationRule( { "PuckerLipLo",	"OpenJaw" }, { "FunnelLipLo"} );
AddDominationRule( { "PuckerLipUp" },  { "SmileFlat"} );
AddDominationRule( { "PuckerLipUp" },  { "SmileFull"} );
AddDominationRule( { "PuckerLipUp" },  { "SmileSharp"} );
AddDominationRule( { "PuckerLipUp" },  { "SuckLipUp"} );
AddDominationRule( { "PuckerLipUp", "OpenJaw" }, { "FunnelLipUp"} );
AddDominationRule( { "SmileFull" },    { "InflateCheek"} );
AddDominationRule( { "SmileFull" },    { "SuckLipUp"} );
dofile( vs.GameDir() .. "../sdktools/lua/face_lipZipper.lua" );
-- Import( vs.ContentDir() .. "models/player/medic/parts/dmx/medic_tongue.dmx" );
dofile( vs.GameDir() .. "../sdktools/lua/face_wrinkleScales.lua" );
ComputeNormals();
ComputeWrinkles();
-- generate wrinkle weights maps for the teeth to stop them from glowing. 
dofile( vs.GameDir() .. "../sdktools/lua/face_wrinkleTeeth.lua" );
-- create wrinkle deltas for glowing tongue 
ResetState();
SetState( "SELECT-tongue" ) ;
ComputeWrinkle( "OpenJaw", 1 );
DeleteDelta( "SELECT-tongue" );
-- cleanup
dofile( vs.GameDir() .. "../sdktools/lua/face_cleanup.lua" );
-- Save a version of the head for the sfm.
Save( "parts/dmx/head_morphs_sfm.dmx", "relative" );