160 likes | 361 Views
Animation, Maya, & Valve Modeling, Exporting, and Compiling. Feb 10 th 2006. Create a Material. In Photoshop, create a 512x512 image File->New Set the image size Change the Width and Height fields to 512 pixels Edit your image! Save the image to ‘img.tga’ File->Save a Copy
E N D
Animation, Maya, & ValveModeling, Exporting, and Compiling Feb 10th 2006
Create a Material • In Photoshop, create a 512x512 image • File->New • Set the image size • Change the Width and Height fields to 512 pixels • Edit your image! • Save the image to ‘img.tga’ • File->Save a Copy • Save to ‘<source dir>/materialsrc/’ • I recommend using GIMP for image editing!
TGA File Format • TGA is short for Targa (aka Truevision), a popular non-proprietary image format favored by Valve • TGA files can be saved with a fourth channel, called Alpha channel, which usually defines transparency • However, VMF shaders use the alpha channel • A shader is a piece of software that instead of executing on the CPU, it executes on the GPU • There are two types of shaders: Pixel shaders and Vertex shaders • Half-Life 2 uses Microsoft's High Level Shading Language (HLSL)
Compile the Material • Compile to a VMT and a VTF • Again, you can download VTFEdit, which is a GUI for authoring textures • http://nemesis.thewavelength.net/index.php?p=38 • We will use the ‘vtex.exe’ utility • This utility can be found under • C:\Program Files\Steam\SteamApps\<username>\sourcesdk\bin • Here is the command we will execute • Go to Start->Run • Type in ‘cmd’ (command prompt) • Move into your ‘<source dir>/materialsrc/’ directory • vtex.exe –mkdir –shader VertexLitGeneric img.tga • Look under ‘<content dir>/materials/’ for the VMT and VTF
Maya and Animation • Yesterday, we created a static object in Maya and learned how to export and compile it for the SMD and MDL file formats needed by Valve • Today, we will create a joint for that static model and produce a single animation • You will first need to construct a ‘base pose’ for an object that you want to animate • We already did this with our static object yesterday • You need to then create a joint/bone hierarchy (called a skeleton)
Base Pose & Skeleton http://www.okino.com/conv/skinning.htm
Animation & Exporting • Follow the general modeling and exporting guidelines from our last lecture, and also from the following URL • http://student.fho-emden.de/~marteppe/monogreen/otherstuff/tut03.htm • We are going to use the model we exported yesterday • We will create a separate file for each animation that we want to use in the game • Valve stores just one file with the base pose and joint hierarchy, and all other animation files only have the skeleton for a particular animation • I will put a tutorial up soon regarding how take already existing HL2 characters and change their ‘skin’ (texture files for the face & body) • ‘Cheapest’ way to get a custom look and feel for your game
Animation http://www.okino.com/conv/skinning.htm
Maya: Add a Joint • Hit Space->Skeleton->Joint Tool • Increase the radius so you can see it, say to a vale of 50 • Click on the joint and hold ‘Ctrl’ and click on pCube1 • Hit Space->Skin->Bind Skin->Rigid Bind • You can also do smooth skinning, but it will not help us out much in this example
Maya: Animate the Object • Select the pCube1 object • Hold Shift and press ‘W’, ‘E’, and ‘R’ • Go to 30 on the time bar, this will be how we are selecting our 30 fps • Change the rotate values to 45, 45, and 45 • Right click in the Transform Attributes box and hit Set Key • You can now run it and watch it animate
Maya: Export the Animation • Go to File->Export SMD Options • Turn on ‘export Animation smds’ under the ‘Export’ tab • Go to ‘Path Settings’ tab and hit ‘default’ • Make sure that ‘smd/qc Path’ is set to • <source dir>/modelsrc/RotCube.smd • Make sure that ‘texture Path’ is set to • <source dir>/materialsrc/
Exporting the Animation • Go to the ‘Animations’ tab • Type in ‘Rotating’ in ‘sequence Name’ • Type in ‘0’ for ‘sequence start’ and ’30’ for ‘sequence end’ • Type in ‘loop fps 30’ in ‘add on end’ • Hit ‘OK Settings’ • Hit ‘Full Compile’
SMD Files • Under ‘<source dir>/modelsrc/’ you should have a few SMD files and a QC • RotCube.qc => File that will be used to specify how we compile into a MDL • RotCube.smd => Reference model • RotCube_idle.smd => Idle animation • RotCube_phy.smd => Physics model • RotCube_Rotating.smd => Animation file
Compile to a MDL • We will use the studiomdl.exe utility • This is in the same bin directory as the vtex.exe material compile utility • To run studiomdl.exe and compile our SMD files into a MDL that we can run in our mod, type • studiomdl.exe RotCube.qc • The result is automatically copied over into • <content dir>/models/
Valve Model Viewer • In the Source SKD menu, launch ‘Model Viewer’ • Go to File->Load Model • Your model should appear as ‘RotCube’
Hammer & your Animation • Add a ‘prop_dynamic_override’ entity • Double left click on it • Go to the ‘world model’ keyvalue • Press on Browse • Find your model • Name the entity ‘myobject’ • Create a ‘logic_timer’ entity • Change the ‘Refire Interval’ to 5 (seconds) • Go to the ‘outputs’ tab • Click ‘add’ • Select ‘onTimer’ (the output) • Find the ‘myobject’ (the entity to effect) • Select ‘SetAnimation’ (the input) • Put ‘Rotating’ in the ‘with a parameter override of’ textbox