Maya to HL2 integration

http://img210.imageshack.us/img210/4906/mayatohl2em4.jpg

Setting up Maya

The first thing you will need to do is download the following export for the appropriate version of Maya.

http://mitglied.lycos.de/prallvamp/

I am using Pralls export because I am familiar with it. Open it up and place the folders Prefs and Scripts into your Maya version folder in my documents.

Vista: C:\Users\xxxxxxx\Documents\Maya\8.5-x64
xp: C :\Documents and Settings\xxxxxxx\My Documents\Maya\8.5-x64

Now we need to set the project location in Maya.

  1. Start Maya and go to File/Project/New and click Browse.
  2. Navigate to your C:\Program
    Files\Steam\steamapps\sphitser\sourcesdk_content\hl2\modelsrc folder and click Ok.

Also, Maya has a different unit of measure than Source. You can make the units be the same by going to Window / Settings/Prefrences / Prefrences / Settings and changing the Linear to Inches.

Making Your Model

I hope you have some basic knowledge of Maya. If not than you might not understand this tutorial. I will be making a box in this tutorial.

After you make your model and have it ready for export, you should all ways check to make sure your Normals are facing the right direction. To do this select your model and go to Display / Polygons / Face Normals and make sure all the lines are facing outward. If they are not, than your faces will not show up in game.

Setting up the UVs

We need to UV map the model before we do anything else. There are many different ways to make your UV map. You could use a specific program or just Maya itself, I’m going to be using Maya.
A UV map is basially every single face laid out flat. for example here is my UV map of my box.

http://img145.imageshack.us/img145/2685/wasdwasdjb9.jpg

As you can see 6 squares which are my faces on my box. Here is what it looks like once I edit it in paint and apply it in Maya.

http://img530.imageshack.us/img530/4980/boxuvga8.jpg

Here are some links on creating your UV map because this tutorial is not about making your UV map, it’s about exporting and integration.

http://www.eliteops.com/sama/uv_tutorial/index.htm
http://www.etc.cmu.edu/bvw/fall04/uv%20tutorial/UV_Mapping_Tutorial.htm
http://www.eliteops.com/sama/AdvancedUV/index.htm

After you have your map done, then texture it up and save it as a Tga 32 bit. Place your texture in your C:\Program Files\Steam\steamapps\sphitser\sourcesdk_content\hl2\materialsrc folder, because vtex.exe won’t know where to place your Vtf file in. You can use many programs to texture your UV map. Here is Sh4d0ws tutorial on how to do it.

http://forums.facepunchstudios.com/showthread.php?t=153186

That should tell you everything you need to know.
You also need to make a Vmt file to go along with your Vtf. To do this open notepad and copy and paste the following.



"VertexLitGeneric"
{
	"$basetexture" "YOUR MODEL NAME"
	"$model" 1
	"$envmapmode" 1
		
}


This is just a simple Vmt, you can make better ones with different shaders. You can use VTFedit to customize your vmt. Here is the link to Nems tool.

http://nemesis.thewavelength.net/index.php?c=149

Save it as “yourmodelname.vmt” and make sure that it saved as an actual Vmt and not .vmt.txt. You need to place it in a folder that you named the exact same thing as your model in C:\Program Files\Steam\steamapps\sphitser\half-life 2\hl2\materials\models folder, for me its C:\Program Files\Steam\steamapps\sphitser\half-life 2\hl2\materials\models\box.

Applying your texture

We need to make sure our Tga texture is applied to our model before we export, this is super important.

To do this follow these steps.

  1. Select your model and go to Window / Rendering Editors / Hypershade

  2. Select the shader Phong

http://img145.imageshack.us/img145/3466/phongcw1.jpg

, it should apply to your model by default. To make sure, middle click your phong shader in the materials tab

http://img530.imageshack.us/img530/9762/phong2wj6.jpg

and drag it onto your model.

  1. You should now see your Phong shader pop up in the Attribute Editor, if not click this button

http://img145.imageshack.us/img145/6290/attribsm0.jpg

in the top left.

  1. In the color box, click the little checkered
    button

http://img145.imageshack.us/img145/6827/colorboxip0.jpg

, another window should pop up.

  1. Select the option named File

http://img145.imageshack.us/img145/6228/filepn8.jpg

and click on the Browse button

http://img530.imageshack.us/img530/3252/filebuttonqk1.jpg

in the Attribute editor.

  1. Browse for your texture and apply it. If it does not show up on your model press 6 to view in texture mode.

Final setup steps

Now we need to setup some final things in Maya before we offically export. First we need to make a layer for our Reference and Physics layer and apply the model to it. We also need to edit its membership attributes.

To do so follow these steps

  1. Make sure you have your Channel Box / Layer Editor open. If not click this button

http://img207.imageshack.us/img207/6039/layertabbh2.jpg

in the top right.

  1. Now click the layer button

http://img247.imageshack.us/img247/8040/layerdc0.jpg

and change the name of the layer

http://img530.imageshack.us/img530/7352/layer1el5.jpg

to reference (Do this by double clicking it).

  1. Now select your model and right click on your reference layer (you will now see a drop down list) and select (Add Selected Objects). To check if it worked click the view check box

http://img207.imageshack.us/img207/8087/vboxtd7.jpg

on your layer, your model should disappear.

Do not do steps 4-5 if you have a older version of Maya than 8.0-8.5.

  1. Now right click your layer and go down to Membership.

  2. Select the reference layer on the right and click the + button on the left to see what’s in it. Now select your mesh from the list on the right and add the shape node to the layer. I know this sounds confusing and you might want to skip but you cannot, I repeat CANNOT skip this or your model will NOT compile. Here is what mine looks like before and after I add the shape node.

BEFORE

http://img521.imageshack.us/img521/2302/referfij3.jpg

AFTER

http://img521.imageshack.us/img521/9858/fawef2ux4.jpg

Save your work and reopen, because you cannot have any undo in Mayas history when you compile your Smds.

Compiling Your SMDs

Note, everyone should be aware of the latest state of the SDK. I say this because currently you can not compile models under Episode 2, you have to do it under Episode 1.

Before we compile lets make a couple shortcuts on our desktop. Go to your Source Sdk Bin folder, for me its C:\Program Files\Steam\steamapps\sphitser\sourcesdk\bin\ep1\bin and make shortcuts of Vtex.exe, Studiomdl.exe, and Hlmv.exe on your desktop.

Now open up Maya and go to File / Export SMD and click the little button on the right. It should open up a window and use these settings.

http://img247.imageshack.us/img247/2351/smdpf7.jpg

I only have Reference checked for a reason. Now click the path settings tab and click default. It will default if you have saved your file already. You will want to make sure it is saved in your Sourcesdk_Content folder under Hl2/Models because the exporter will not know where to export it to.

Go back into Maya and click Full Compile in the compiling options. It should have a popup window with a little progress bar go through everything, if this happens than you have done everything right.

Now if you open up your project folder you should see 3 files in it now.
Here is what mine says.



box.mb
box.smd
box_idle.smd


Open Maya back up and double click on the Reference layer and rename it to Physics. Go back into your compiling options and uncheck “Export to Reference” and check the Physics one, also uncheck export one frame idle Smd. Once you do all of that then click “Full Compile”. After you compile you are now at the point where you can close Maya.

The Qc File

Now we have to create a Qc file. A Qc file is what tells Studiomdl how to compile your model. Here is a really basic one that will work just fine for you. This one is mine so you will have to change “box” to your model name.



$modelname box\box.mdl
$cdmaterials models\box
$surfaceprop "metal"
$staticprop
$scale 1
$body studio "box.smd"
$sequence idle "box_idle" fps 1
$collisionmodel "box_phy.smd"
{
$Mass 1
$concave
}
$upaxis Y




$modelname tells the folder to colpile to 

$cdmaterials tells the location of the texture

$surfaceprop is what will happen if you shoot it or hit it
($body studio "box.smd"

$sequence idle "box_idle" fps 1

$collisionmodel "box_phy.smd")
Thease are the names of your Reference, Physics, and Idle smds.

$Mass is how much it weighs while ingame


I chose UpaxisY because that’s what it is in Maya. Maya and HL2 have two different Upaxiss.

Please read the Wiki on Qc files for more infomation.

The Bat File

We will now create a Bat file to compile with. If we don’t the command prompt will just close and not let us see if we had any errors.

To do this follow these steps.

  1. Create a new Notepad Doc and right click on our shortcut of Studiomdl.exe, click properties, highlight, copy and paste your location of Studiomdl in Notepad, for me its C:\Program Files\Steam\steamapps\sphitser\sourcesdk\bin\ep1\bin\studiomdl.exe make sure you have quotes surrounng it “C:\Program Files\Steam\steamapps\sphitser\sourcesdk\bin\ep1\bin\studiomdl.exe”.

  2. Now after the last quotes on the Studiomdl directory put a space and paste the directory where your Qc file is, for me its C:\Program Files\Steam\steamapps\sphitser\sourcesdk_content\hl2\modelsrc\box you will also need to add the name of the Qc file to the link and also add the quotes so it looks like this “C:\Program Files\Steam\steamapps\sphitser\sourcesdk_content\hl2\modelsrc\box\box.qc”.

  3. Now press enter and type pause after all of that. Save your file as a Bat and your done!

Now your ready to compile your model, so run the Bat file and you should see a Command Prompt pop up and start processing. If it is successfull than you should read “Completedg workin on xxxxx.qc”.

NOTE: You need to have Source SDK running and have the drop down list set to where you want your model to compile to. If you want it in GMOD you will have to do some file moving. Also if your having trouble with the SDK than try right clicking on it in your steam tools list, go down to properties, and click on Set Launch Options and type in “-engine ep1” and open the SDK back up.

Compiling the texture

To compile your texture you must first open up your C:\Program Files\Steam\steamapps\sphitser\sourcesdk_content\hl2\materialsrc folder and find your Tga file. Then drag it on your Vtex.exe shortcut, this will convert your Tga to a Vmt. You should see a CMD pop open and do a couple things, it will ask you to press any key to close.

To test out your prop open up your model folder in your HL2 directory and drag the MDL file on your Hlmv shortcut. If it works than congratulations, if not then keep trying.

At this time you should have everything necessary to have a prop working in game. If you have any trouble please contact me and let me know what’s wrong. Please leave me a comment and tell me if this was useful.

Wow ! Very nice tutorial ! Gold Star for you :smiley:

Thanks man, it took me around 6 hours to make.

Thanks for the tutorial, I’ve been looking for one for some time now.

Nice work, looks good. If you’re up for it though, perhaps you could go into a bit more depth as to what some things do? I remember when I was starting out it got confusing because tutorials told me to do certain things, but not why I needed to.

Either way, it’s a nice guide. I’ll bookmark it so I can refer other people to it.

Thanks, this comes right at the time I need it, just one more question: does maya uses the same unit size as gmod?

Actualy no, I’ll include this in the tutorial. Maya has a different unit of measure than Source also a different up axis. You can make the units be the same by going to Window / Settings/Prefrences / Prefrences / Settings and changing the Linear to Inches.

Ok, I added the information on units of measure.

I’m getting:
“WARNING: AppFramework : Unable to load module p4lib.dll!
ERROR: ‘EXECEPTION_ACCES_VIOLATION’ (assert:1)”
when I run the batch file.
The file isn’t found anywhere on my computer, where should it have come from?

Ok, open up Hlmv before you compile you Qv file. Tell me if that works.

This needs to be pinned.

Opening hlmv doesn’t help, and also, I needed to add -game “C:\Program Files\Steam\steamapps\accountname\half-life 2\hl2” to the end of every shortcut-target from the tools (hlmv,vtex & studiomdl).

**edit:**found it, I used the orange box tools instead op the ep1 tools

Edit:

I’m getting further now but I’m still not completely out:
The resulting mdl file is just an empty file. I’m getting erros on collision models and some other stuff, here are the results of the batch file:



C:\Users\------\Desktop>"C:\Program Files\Steam\steamapps\vice_freak\sourcesdk\b
in\ep1\bin\studiomdl.exe" -game "C:\Program Files\Steam\steamapps\vice_freak\hal
f-life 2\hl2" "C:\Program Files\Steam\steamapps\vice_freak\sourcesdk_content\hl2
\modelsrc\hats\salesmanhat.qc"
qdir:    "c:\program files\steam\steamapps\vice_freak\sourcesdk_content\hl2\mode
lsrc\hats\"
gamedir: "C:\Program Files\Steam\steamapps\vice_freak\half-life 2\hl2\"
g_path:  "salesmanhat"
Working on "salesmanhat.qc"
SMD MODEL salesmanhat.smd
SMD MODEL salesmanhat_idle.smd
SMD MODEL salesmanhat_phy.smd
WARNING: Bad collision model, check your smoothing groups!!!
WARNING: Truncating model!!!!
WARNING: salesmanhat_phy.smd has bad smoothing groups
Model has 1 convex sub-parts
Collision model completed.
---------------------
writing C:\Program Files\Steam\steamapps\vice_freak\half-life 2\hl2\models/hats\
salesmanhat.mdl:
bones          708 bytes (1)
animations     104 bytes (1 anims) (1 frames) [0:01]
sequences      220 bytes (1 seq)
ik/pose        164 bytes
eyeballs         0 bytes (0 eyeballs)
flexes           0 bytes (0 flexes)
textures        72 bytes
keyvalues        0 bytes
Collision model volume 114.70 in^3
collision        0 bytes
total         1468
ERROR: 'EXCEPTION_ACCESS_VIOLATION' (assert: 1)
ERROR: Aborted Processing on 'hats\salesmanhat.mdl'

C:\Users\------\Desktop>pause
Druk op een toets om door te gaan. . .

Wow, so you like it Heilos. I feel honored, and yes, that would be cool if it was pinned.

Edit:

And as for you, I am not sure what is going on. I would say make a new post asking for help because I don’t have a clue.

Ok so I followed your tutorial closely, everything is in place. When I go to compile an error window pops up that says,

The procedure entry point
?LockForRead@CThreadSpinRWLock@@QAEXXZ could not be located in the dynamic link libary tier0.dll.

It sounded somewhat similar to yarrofdoom’s error so I tried what you asked him to do, run Hlmv before compiling the QC file…

BUT when I run Hlmv I get the SAME exact error that I get when trying to run studiomdl

Halp!

Have you accidentially used the orange box tools instead of the episode 1 tools, beccause that was the problem with me.

edit:hey spiffy, you forgot to put ‘$’ in front of ‘model" 1’ in the vmt file

Edit:

I don’t know what I did, but it finally worked for me. Here’s the result:

http://garrysmod.org/img/dl/30589_2.jpg

Thank you very much spiffy!

And for the ones that want the cube:
http://garrysmod.org/downloads/?a=view&id=30589

Hey, no problem dude, that’s what I’m here for. I will also fix what you pointed out.

I’m not sure, I used the .exe located in (for me)

C:\Program Files\Valve\Steam\SteamApps\blackcow237\sourcesdk\bin\ep1\bin\

Good work dude, not a lot of attention to Maya with Half life modders. Gold star!

Hey thanks man I appriciate it.

Edit:

You’ll need to do that until Valve fixes the SDK.

I think you misunderstood, I am using the .exe in that directory, that’s whats giving me the error.

Doing some googleing I am finding some other threads about the problem, no real solution.

Why are some people able to compile (like sphitser) and others not. We all have the same version of steam and the SDK right? What is he doing that I am not?