Jump to content

PAC - Blender to Gmod. How?


Recommended Posts

PAC has been in the talks for a while now. I, like many, agree that PACs should be more efficient. One of the steps taken was to move from .obj import to .mdl import (aka experimental model import) because .obj imports have an exponentially higher rendertime impact, and thus reduces the FPS for everyone more and slows the server down more. Even if you turn off PAC, the server still has to render everyone's PACs itself which contributes to it slowing down.

 

So, to help make the server more enjoyable for everyone, I'm going to try to make an indepth guide on how to import from Blender (where you open all manner of models, such as .objs) into Gmod (and by extension, PAC).

 

 

 

First, a tool list.

Blender. You'll obviously need Blender for this. You can click the link or alternatively ,Blender is also available for download on Steam.

Blender Source Tools. These tools allow you to import source material (such as .smd and .qc, as well as export as .smd, and allows you to compile .qc files which ultimately is what creates a model for gmod)

Blender XNALARA Tools. This one is more optional, but you'll find a lot of good models for XNALara, so being able to import .xps files directly into Blender helps streamline things.

VTFEdit. VTFEdit is a program that allows you to open .vtf and .vmt files, as well as import common images like .png and .jpg and export them as .vtf. This is needed to be able to texturize your model.

 

This guide will only explain how to import generic non-rigged models into GMod. Not how to import full playermodels. It's mostly meant for importing misc items like gear or hair, or for importing headhacks.

 

 

 

Test Run
 

Spoiler

 

First, we will do a test run to ensure you've got the hang of importing a model. First things first.

We open Blender.

b3cb1a754980026d3381e6b42d64e24f.png

You will be met with this screen. First we make sure our Blender tools were installed properly. (They should have instructions with them, otherwise simply google 'How to install Blender Tools' and follow the instructions.)

 

We navigate to the tab on the right and click the 'Scene' button, that's the little square button with the sun, sphere and cylinder. Third from the left.

If we scroll down on this tab, we should see the "Source Engine Export" menu as featured below. If you see this, Blender Source  Tools have been installed and enabled correctly.

4d8cae787f919131d79b5ee8518430c9.png

 

 

Next we check if XNALara tools were installed. This is easy, on the very far left you'll find a list of vertical tabs. If one of them is named 'XPS', it's installed and enabled correctly.

3cb4f06b0559cb74af04aaaf98dfea8a.png

 

 

Now that we have our tools ready and set, we will start by importing the default cube that Blender starts with. If we can import this into Garry's Mod, we can import anything into Garry's Mod.

First thing we do is we navigate to the 'Material' tab on the right. That's the ball with the checkers on it.

3a4c718407898d82d13b43ca3e1d7537.png

Here, we doubleclick the 'Material' you see highlighted in blue. This allows us to rename the material. Rename it to Cube

We do this because when we export this model later, it will look for a file named after whichever materials we have applied to it. In this case we have the material named 'Cube' applied on our cube, so later when it's exported, Gmod will look for a 'Cube.vmt' to texturize it ingame.

For models that already have materials applied to them, you will instead find a bunch of materials here with probably long names, depending on which model you have selected.

You should rename them to something short and concise, for example the material for the head being "head_d_summer_001" or something long like that, rename it to just "head"

Otherwise you will need to name your .vmts "head_d_summer_001.vmt" later and that's just unnecessary and tedious.

 

 

Now with our material named Cube, we move our cursor into the object window. That's the same window the actual cube itself is in. With the cube selected (it will be highlighted in orange) we press CTRL + C then CTRL + V. We have now created a duplicate of the cube as you will see on the right, named 'Cube.001'.

a9eeab2f0b1283374e18adbb54f2f34b.png

Doubleclick on the 'Cube.001' name you see on the right and rename it to 'Cube_phys'

We do this because Gmod needs a 'collision mesh', that's a model made specifically to handle the collision of the model. Complex models such as faces and hairs have a lot of detail to them, and complex collision meshes causes issues, so instead a simplified model is created that acts as the physical model that collides with the world in Garry's Mod. In this case it's just another identical cube.

 

 

Now we move our cursor back into the object window and CTRL + C then CTRL + V again, this will create 'Cube_phys.001'

1dd6a247bd78c734680527f3fe6f8862.png

We rename this one to 'Cube_idle'

We do this because it needs an animation model to take from. We wont have any animations for any of our imports, however it's necessary to create regardless.

 

 

Now, at the bottom you will see the animation frame controls; the long horizontal window that counts from -50 to 280, and the controls below that say "Start: 1" "End: 250" and to the immediate right of those two, the frame selector that currently says "1" with arrows going either direction. Make sure you have 'Cube_idle' selected.

9e09a88ed74ca9774138ad8bc127f97a.png

First we click on the "End:" and set it to "2" instead of "250" so now our animation frame is only 2 frames.

 

 

bd127983b0e0377ea5116ca25d789064.png

Now we move our cursor into the object window and press i on your keyboard. The 'Insert Keyframe' Menu will pop up, click on "LocRotScale".

Then at the bottom, change the frame selector to 2 and repeat, clicking on "LocRotScale" again.

 

You'll know you've done it right if you see two very thin, yellow lines in the frame window. Again make sure you have 'Cube_idle' selected.

fed96e3fb3624a228b4ab544331883df.png

We've now set the idle animation that Garry's Mod requires.

 

 

Now we move on to the Scene tab like we were at before with the source tools and scroll down to them.

I will look like this.

8997929cbbdb14f598001476053a93fd.png

First we click on the 'SMD' button, we need this export type for models.

Then, we choose an Export Path. Create a folder anywhere and set your export path to that folder.

 

The 'Export Path' window will no longer be highlighted in red.

b0eb763b5584d9efd37cafbdc41ec67e.png

Now, we need to set the engine path.

This will be in your Steam/SteamApps/Common/Garry's Mod/Bin folder

It is NOT in Common/Garry's Mod/Garry's Mod/Bin!

 

We do this because Blender needs to access our studiomdl.exe executable that's included in our Garry's Mod install by default. It uses this .exe to convert our blender models into .mdl models.

When we have set the Engine Path properly, it will open up more options if we scroll down.

   4df4a966b83a794b4e9afa1a7ac524a7.png

You will now see 'Game Path' open up under the Source Engine QC Complies menu.

Set this to your 'Common/Garry's Mod/Garry's Mod' folder.

We do this because Blender needs to know where our 'models' and 'materials' folders are so it can put our future exported model into said 'models' folder.

 

When the path is set right, Blender will open up the 'QC Path' option directly below the Game Path.

ca87f06897e6113cc2d5fcea0dc93740.png

For this, you need to Download This QC file.

Put the 'Cube.qc' file wherever you set your export path to previously.

Now open the QC Path and navigate to where you put your QC file, then doubleclick on the Cube.qc file.

 

If Blender accepts the QC file, it should now look like this, with the 'cube.qc' button.

de4b14e1257275139d65e71f569129c0.png

 

 

The QC file is the file that determines many aspects of our model

c9204e7d14552f293ba03e1ad33ae5b5.png

You can open .qc files with any common text viewer, including Notepad which comes with all Windows installs.

 

$modelname

This determines what our exported model will be named.

 

$scale

This sets the scale of the model. 1 is 1:1 with Blender scale, 2 makes it twice as big etc.

 

$body

This determines which .smd is used to create the visible body (or prop/head)

 

$cdmaterials

This line is important for us. It determines where in "garry's mod/materials" it will look for our textures.

With this qc file by default it will look in "garry's mod/materials/cube/cubething/" to prevent clutter in the future you should change this on a per model basis. For example, if you're importing Shepard from Mass Effect, maybe change it to "YourNameHere/Shepard/"

 

$surfaceprop

This determines what kind of surface properties our model will have. For the cube, we have metal. We're making a metal cube.

If you're doing a headhack, change this value to 'flesh'

You can google source surfaceprop list for more options. It's not important for PAC since they wont be physical models.

 

$contents

This always remains as 'solid' because our objects should always be solid.

 

$sequence

This sets our idle sequence to the 'Cube_idle' that we created earlier.

 

$collisionmodel

This sets the collision model for our model. In this case, setting it to the 'Cube_phys' that we created earlier.

The values below this determine the various weights and properties of our physical model. Also not important for PAC imports.

 

You change the above values to the corresponding values depending on your model import, for example if you're importing Shepard and in Blender his head was named 'ShepardHead', Blender will export it as ShepardHead.smd and you will need to write "ShepardHead.smd" for $body

Et Cetera Et Cetera.

 

Now, we export our models from Blender to .smd format.

1b3b1ad6ca2ba37ac770e87f8924ba18.png

With the export path set to the same place as the .qc file, click on the 'Export' button. It will prompt you with two options, click on "Scene export(3 files)" and pay attention up top of Blender. A small window will confirm that 3 files were exported.

You should now see "Cube.smd", "Cube_phys.smd" and "Cube_idle.smd" where you set your export path to.

 

 

 Now create a folder named "anims"

d19d4d889cff8f6778f3de4de3cfe4ca.png

Take your Cube_idle.smd file and put it into your "anims" folder you just created.

bf1074f8758fe2760b335cf3d22d0f21.png

 

Now, with our .qc file having the correct names of our .smd files, we come to the big test.

In Blender we navigate to the Source Engine QC Complies menu and click on the 'cube.qc' button.

b0ddeb1e792ded4c2f485f1658b7e04f.png

If we have done everything correctly (which we seem to have, since mine just compiled), it will say up top in Blender

3c360eca17556747e45099bd4486570f.png

If it says this, your model has now compiled successfully. You can confirm this by going into your 'Garry's Mod/Garry's Mod/models/cube/" path where you should now find your cube.mdl present.

If you find this, congratulations. You have now imported a cube into Gmod.

 

However, we're not quite done yet. Almost. We need a texture of course!

Remember in the QC file, it said "$cdmaterials "cube\cube_thing\""?

We now go into our 'Garry's Mod/Garry's Mod/materials/' folder and create a folder named 'Cube', then inside that folder we create one named 'Cube_thing', and inside this folder we put these two files.

These are our .vmt and .vtf files.

 

92a2a3d43a316f21d6ba1cf15f42863f.png

.vmt

The .vmt file is a text file that determines which .vtf file is used to apply on our cube model, as well as other more advanced options that we wont worry about for this test.

If you put some other path in your .qc file for the textures, you need to open this file and adjust the .vtf path in this to fit.

 

.vtf

This is the actual texture itself. In this case I've put a simple eye texture, so if we did it right it should look like a cube with eyeball textures on it ingame.

 

And now, if you search 'cube' in Garry's Mod, you should now find your cube. Click it to spawn it and bam!
B3F27B18148E099CAAD871DFC4071FBB54EC7C5F

We now have a cube in Garry's Mod.

 

Now if we want to import this cube into PAC, we take all the .mdl files (mdl, vvd, vtx etc.) and put them in a folder, then take all the textures and put them with the .mdl files in the folder. Then, using 7zip we rightclick on the folder with our model and materials in them (THERE SHOULD ONLY BE ONE MODEL) and click "add to archive"

2b8be14183d5411e104af9b91ed2db0a.png

It'll open a window. Set archive format (mine is in danish, cos) to zip

Set compression level (the one that says Komprimeringsniveau on my screenshot) to "save" or something like that. It should be the top option. This makes it so the .zip will NOT be compressed, as PAC cannot read compressed .zip files.

Now, with your uncompressed ZIP with both model and materials in it created, you upload this .zip to your place of choice (like dropbox or using ShareX)

Now with the link you're given to your zip, open up PAC in garry'smod and create Experimental>Model, then set the model path to your .zip link.

It should now download the model and you should see it in PAC. PAC will scream and yell at you if you didn't do it right, saying it either can't find something it needs or that the zip is compressed.

 

 

 

Example of a quick import of an xnalara model, to export as .smd and then compile into a proper .mdl with the .qc file

 

 

We import the .xps model.

We delete any piece we don't need (such as the body).

We change the model names so we know what our .smd file will be named.

We change the material names to more easily keep track of them, THEN we select all the objects and ctrl+J to join them into a single object. Keep your mouse in the object window when doing this.

We hit CTRL+Shift+Alt+C and hit "Geometry to Origin" to center the model. This is important.

We hit "S" on our keyboard and scale the XPS model up to ~30 times size. Most XPS models are much smaller in scale that GMOD models, hence we scale them up. If you forget to do this, PAC also has a scale feature.

We get our .QC file (in my case I copied an existing one) and place it where we need it.

We create our _phys cube, then scale it up to roughly fit the head.

We create our _idle cube (I copy-pasted the _phys cube) and set the animation frame to 2 frames, then set LocRotScale for both frames.

We export the .smd, it will pop up with a warning that your two cubes dont' have textures applied. That's fine, they don't need any.

We create the anims folder and move the _idle.smd in there, then open the .qc file and adjust it as necessary.

With our .qc file set and our .smd files ready, we click on the .qc file in Blender and it compiles successfully, as seen at the top of Blender.

 

 

 

Setting the textures

 

 

Don't forget to resize your textures. Usually 512x512 is enough, 1024x1024 should be the max and only for primary textures like the face and hair if you use this size at all.

 

https://puu.sh/DiKk8/82bb13f115.zip

Included is a set of basic .vmt textures. You can use the head.vmt as a base to create your own head.vmt file, as well as any similar .vmt's

You can use the hair.vmt to create your own hair.vmts, as well as things like eyelashes and other hair-like transparent textures.

You can use the eye.vmt to create your own eye.vmts, as well as other shiny objects.

 

If you import an object like a scarf or glasses, remove references to "detail" vtf files and use the head.vmt as your base for non-transparent pieces and hair.vmt for transparent pieces (like the glasses lens)

 

 

 

I may have missed some things or forgot to explain something, if there's any problems feel free to comment below and I'll try to address them and update the guides as needed.

  • Like 1
Link to comment
  • Dark locked and pinned this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...