Editing and Customization > Tutorials

[TUT] Exporting and Compiling a Prop from Maya

(1/2) > >>

Konrad Beerbaum:
This is a tutorial on how to take a static prop from Maya 7.0 into the game using the ep2 sdk. In order to use Valve's SMD exporter, you must use Maya 7.0.  Later versions will not work.  This tutorial assumes you already have the SDK installed, have GES Beta3 set up correctly in your gameconfig.txt file, and have it selected as the current game in the SDK launcher.  For info on how to set up the gameconfig.txt, check the PropTestMap tutorial http://forums.goldeneyesource.com/index.php/topic,1612.0.html. 

Required Materials:
Display Model
Physics Model
LOD Models (if applicable)
Diffuse Map named propname.tga.
Normal Map named propname_normal.tga.
Specular Map named propname_specular.tga.

Step 1: Installing the Valve SMD Exporter

Locate the runmaya.bat file located in Valve\Steam\SteamApps\username\sourcesdk\maya\7.0

Right click on runmaya.bat and click edit. 

Change the first line to point to your Maya installation.  Mine looks like this: set PATH=%SOURCESDK%\bin;"C:\Program Files\Alias\Maya7.0\bin";%PATH%

Save and close the window.  Doubleclick on the runmaya.bat file.  It will open the command line, run a few lines of code, and then launch Maya automatically. 

In Maya, go to Window>Settings/Preferences>Plug-in Manager. Click the loaded and auto - load checkboxes next to the vstSmdl0.mll plugin.  On my computer, this plugin seems to disappear every time you exit maya, so I need to run the .bat file every time I start maya. 

Step 2: Setting up Studiomdl.exe.

Locate the Studiomdl.exe file located in Valve\Steam\SteamApps\username\sourcesdk\bin\orangebox\bin

Create a shortcut on your desktop to studiomdl.exe.  Right click on the shortcut, and in the target field add C:\WINDOWS\system32\cmd.exe /K in front of the target location.  There is a space after /K and before the start of the target location. If windows is located on a different drive letter, change as necessary.  I don't know if this works in vista.  After the address, add -nop4 . Mine looks like the following: C:\WINDOWS\system32\cmd.exe /K E:\Valve\Steam\SteamApps\username\sourcesdk\bin\orangebox\bin\studiomdl.exe -nop4 

Step 3: Setting up the Half-Life Model Viewer

Locate hlmv.exe located in Valve\Steam\SteamApps\username\sourcesdk\bin\orangebox\bin and create a shortcut to it on your desktop. 

Step 4: Setting up directories. 

Open up the Valve\Steam\SteamApps\username\sourcesdk_content\ directory.  Create a folder called gesbeta3. Inside this folder, create 2 folders, modelsrc and materialsrc.
Copy your diffuse texture into the materialsrc directory.  The diffuse texture must be a targa file named propname.tga.  In this example, mine is named FuelTank.tga.   

Step 5: Exporting your models out of Maya. 

In your scene you should have the display model, lod models, and a physics model. Each model should be 1 combined piece with all history deleted and transforms frozen.  They should all be centered on the grid and overlap exactly with each other.  I would recommend putting them on separate display layers for easy management.  The physics model needs to have all smooth normals. 

Create a phong shader.  Put your diffuse texture that is located in Valve\Steam\SteamApps\username\sourcesdk_content\materialsrc\propname.tga into the color channel.  Assign this phong shader to all 3 models. 

Now it is time to export. 

Select your display model and go to File>Export Selection Option Box . Change the file type to Valve SMD Model.  Leave everything unchecked, and change the Up Axis to one that matches your scene.  In my case it was $upaxis Y.  Click Export Selection and save the file into Valve\Steam\SteamApps\username\sourcesdk_content\modelsrc\ . Name the file propname.smd.  In this case mine was FuelTank.smd. 

Select your LOD1 model and go to File>Export Selection Option Box . Change the file type to Valve SMD Model.  Leave everything unchecked, and change the Up Axis to one that matches your scene.  In my case it was $upaxis Y.  Click Export Selection and save the file into Valve\Steam\SteamApps\username\sourcesdk_content\modelsrc\ . Name the file propname_lod1.smd.  In this case mine was FuelTank_lod1.smd. 

Select your physics model and go to File>Export Selection Option Box . Change the file type to Valve SMD Physics Model.  Leave everything unchecked, and change the Up Axis to one that matches your scene.  In my case it was $upaxis Y.  Click Export Selection and save the file into Valve\Steam\SteamApps\username\sourcesdk_content\modelsrc\ . Name the file propname_phy.smd.  In this case mine was FuelTank_phy.smd. 

Step 6: Compiling

Before we compile, we want to make sure the smd files have valid texture paths.  Right click on each of the 3 smd files and open them with wordpad.  In the section starting with the word triangles, you should see the name of your prop followed by sets of numbers.  The name should be the same as your diffuse texture.  The smd is recording every triangle in your model, and what texture is assigned to it.  If instead of your model name, it says debug/empty, you fucked up.  Make sure your diffuse texture is in the materialsrc directory, the phong shader is using that texture, and it is applied to every model you are exporting.  If you really wanted to, you could do a find/replace in wordpad and replace all the debug/empty words with the name of your model.  I recommend getting it right in maya though, so you don't have to fix it every time you export a new version. 

Now we need to create a qc file to compile the model with.  I won't go over all the possible qc configurations in this tutorial, the info is on the Valve wiki here http://developer.valvesoftware.com/wiki/Qc.  Open up wordpad and create a new text file. 

Add the info from the example qc shown here.  Change the $modelname and $cdmaterials to the location that matches your situation.  Since beta3 is set as our game in the sdk, it will automatically put them there.  In this case, it will put the model files into the Valve\Steam\SteamApps\SourceMods\gesbeta3\models\props\runway\ directory. It knows most of the path, so we only need to put the part after models. Materials will be put into the Valve\Steam\SteamApps\SourceMods\gesbeta3\materials\models\props\runway directory.  It knows most of the path, so we only need to put the part after materials.

Change the $surfaceprop value to one that matches your prop.  This value determines what sound plays when the object is hit, and what type of gibs comes out when the object breaks.  A list of all possible values is here: http://developer.valvesoftware.com/wiki/Surfaceprop. Make sure the $upaxis  value matches your scene.  Change FuelTank to your prop name in all the entries.  Since this is a static prop, you can ignore the mass value.  The $lod 80 value is the distance that the object will swap to the next stage.  The second lod stage isn't used for this example, so don't include it, I just included it to show how to handle multiple lod stages.

Save the text file as propname.qc and put it in the modelsrc directory. Mine was FuelTank.qc. 

Now it is time to compile.  Drag and drop your qc file on top of the shortcut to studiomdl.exe on your desktop.  If all goes well, it will run through some stuff in the command line, and stay open so you can view the results. 

First you want to check to make sure it completed successfully.  The other thing to check is that the collision model is correct.  If you use more than 20 pieces, you will get a message saying the collision model was too costly and it will create a single hull as the collision model instead.  You need to reduce the collision model to less than 20 pieces, or use the override code if absolutely necessary.  To use more than 20 pieces, see http://developer.valvesoftware.com/wiki/Compiling_Models .  I would really recommend just reducing the physics model instead. 

Now that it has compiled, we need to take care of the textures. 

Step 7:  Converting textures in photoshop.

Download and install the photoshop vtf plugin if you haven't already: http://developer.valvesoftware.com/wiki/Photoshop_VTF_Plugin

Open up your Diffuse Map targa and save it out as a vtf file.  Choose the Compressed Texture preset.  Save the file to the correct place in the materials folder in the gesbeta3 directory, Valve\Steam\SteamApps\SourceMods\gesbeta3\materials\. In my case, it was Valve\Steam\SteamApps\SourceMods\gesbeta3\materials\models\props\runway\.

Open up your normal map targa and specular map targa in photoshop.  Create an alpha channel in your normal map channel list.  Paste your specular map into the alpha channel of the normal map.  Save out the normal map using the Compressed Texture w/ Alpha preset. Save it into the same materials directory as the diffuse map. 

Now we need to create a VMT file.  This is the shader that tells the engine how to render the texture files.  Open wordpad and create a new file.  Copy the example and change it to fit your file names.  There are a lot of advanced settings, but I won't cover those here.  A list of VMT commands can be found here: http://developer.valvesoftware.com/wiki/Shader_Types_and_Parameters.  Save it as propname.vmt in the same directory as your textures.  Mine was FuelTank.vmt. 

Step 8:
If you made it this far, congrats, you're almost done.  Just drag your mdl file onto the shortcut to hlmv.exe on your desktop and it will open up and show you your model.  If your model shows up correctly, congrats! 

To check your lod, click on the Model tab in hlmv.  Check the box next to Auto LOD.  Since my lod switch is set to 80, when I zoom about past 80 units, the lod model will swap in.  The LOD Metric shows your distance.  You will also see the polycount indicator change when it swaps. 

If your model doesn't view correctly, or you want to use some of the more advanced options, hit up me or one of the devs who knows how to compile, we should be able to solve your problem very quickly.  There are so many variations and ways to fuck up that I'm not going to go into them here.

Now that your model is viewable in hlmv, you should import it into a test map and test it in the game.  See http://forums.goldeneyesource.com/index.php/topic,1612.0.html for instructions on how to do so. 

If any section is unclear or incorrect, post the info and I'll edit the tutorial to improve it.  I will also be adding links to other tutorials and reference in time. 

Loafie, Hero of Dreams:
This is a godsend, now if only the pictures worked, haha. Also, does the maya 7-only still apply? That's kind of lame of valve

Konrad Beerbaum:
The pictures were located in the gallery on the old forums.  I checked the wayback machine and they have only cached to feb 2008, which is before those images were added.  Does that mean they are gone?

Valve still uses Maya 7.0, so they only made their plugin work with that version.  I don't know if there has been a new release. 

Sean [Baron]:
They are likely gone.

Loafie, Hero of Dreams:
i wonder if i can get pralls exporter to work


[0] Message Index

[#] Next page

Go to full version