Compiling a model:ko

From Valve Developer Community
Revision as of 12:53, 10 April 2016 by Mochan77 (talk | contribs)
Jump to: navigation, search
English Français Русский 简体中文

모델은 StudioMDL 등을 통해 컴파일 작업을 거쳐야 겡미에서 사용이 가능합니다. 이 컴파일 작업에는 3가지 요소들이 쓰이게 됩니다.

  • 모델 소스 파일들 (SMD, DMX, VTA) 모델의 정점값등을 담고 있으며 애니메이션에서도 쓰이는 파일들입니다. FBX 또한 쓰이지만 CS:GO 이후 소스엔진들만 지워하고 있고 SMD로 작업을 하여도 무리가 없기에 대부분 SMD Reference 형태의 모델과 시퀀스 모델로 작업이 이루어지고 있습니다.
  • QC 파일은 벨브 모델 생성을 위한 컴파일러 프로그램인 StudioMDL로 해독 가능한 명령어들을 텍스트 파일 형태로 담고 있는 파일입니다.
  1. 작성된 모델 파일 SMD 아니면 DMX 아니면 FBX 파일을 만들고 추가 동작이 필요하면 시퀀스 SMD 파일등을 만들어 주고 얼굴 표정 변화가 필요하다면 VTA 버텍스 애니메이션 정보를 담고 있는 파일을 작성합니다.
  2. 이 위키를 참고하여 상황에 맞는 QC 명령어들을 텍스트 파일로 정렬합니다. (완전히 프로그래밍 스크립팅입니다.)
  3. VMT 파일 작성을 하고 텍스쳐를 벨브 텍스쳐 파일 VTF로 변화을 해줍니다. - $cdmaterial 명령어로 위치 지정이 가능합니다.
  4. 용도에 맞게 가공된 파일들 (SMD, VTA, DMX 및 블블라라라) 같은 디렉토리에 두고 QC 파일을 컴파일러인 Studiomdl에 던져주면 컴파일 된 모델 MDL을 벹어냅니다.
  • 에러가 나면 컴파일이 중단되면서 에러원인을 출력하게 됩니다.

Setting up

Assuming that your source files have exported OK from your favorite 3D modeling software, the only step you need to take before compiling is choosing the current VPROJECT. This defines where studiomdl will write out the compiled model. You can configure the value:

  1. Globally, by selecting your game/mod in the SDK launcher's drop-down list.
  2. For studiomdl only, by running it with -game "<full path to your gameinfo.txt folder>"
    Tip.png Tip: Most SDK tools accept -game.

Syntax highlighting

Editing a QC file becomes much easier when you use an advanced text editor with support for syntax highlighting. There are two editors with QC highlighting rules at the moment:

Creating a QC

A QC file is simply a text file with the extension .qc. You can create it anywhere and name it anything, but it's best to be organised and store it with your SMDs in a folder with the same name as the destination model file.

Inside it should be a list of commands that tell studiomdl about the location of the model's various SMDs, where the compiled files should be written to (relative to VPROJECT), how to process animations, and potentially much, much more. You will find all known commands listed at Category:QC Commands.


File locations

When a source file is referenced in your QC, the compiler will look for it in the same folder. You should therefore place all your source files for a given model in the same folder. There are, however, commands to tell the compiler that you want to give it a file that is not in the same folder as the QC!

  • With an absolute path (e.g. C:\modelsrc\my_model\)
  • With a relative path (e.g. .\subfolder or ..\)
    Tip.png Tip: A single period is the current folder. Two periods is the one above it. ..\..\ goes two directories up.
  • With $pushd and $popd.

Here is a very simple QC file for a solid model without any animation or special properties (click on each command for details):

$modelname	"props\myfirstmodel.mdl"
$body mybody	"myfirstmodel-ref.smd"
$surfaceprop	combine_metal
$cdmaterials	"models\props"

$sequence idle	"myfirstmodel-ref.smd"

$collisionmodel	"myfirstmodel-phys.smd" { $concave }

You should be able to use this as a template to compile your own model, so swap in your own SMDs (of DMXes, or FBXes) and see what happens.

Note.png Note: All models must have at least one $sequence, even if they aren't actually animated!



With your text editor

The easiest way to compile a model is with the built-in launch features of advanced text editors.

With a batch file

If you can't (or don't want to) use an advanced text editor, you will be compiling QCs by dragging them onto studiomdl in Windows. You can find the executable file in sourcesdk/bin/[orangebox|ep1]/bin/.

The process will be easier if you create a .cmd file somewhere more accessible to automate it. This is simply a renamed .txt file containing something like this:

"%sourcesdk%/bin/orangebox/bin/studiomdl" -nop4 %1

Drop your QC file onto the CMD as you would studiomdl itself; it's essentially a shortcut to the executable.

With Compiling Tools

You can also use tools like Crowbar to compile your model. You can simply load your QC file, select your Source Game and then click Compile

Common errors

  • Error opening <model>! (Check for write enable)
Studiomdl won't create folders that don't exist; you must manually create a path to your .mdl before compiling.
If you receive EXCEPTION_ACCESS_VIOLATION without an error code, try compiling with HLMV running.
  • WARNING: Bad collision model, check your smoothing groups!!!
If you created the collision model with XSI then you need to turn off Geometry Approximation's Automatic Discontinuity (Explorer -> Your Mesh -> Geometry Approximation -> Polygon Mesh -> Discontinuity -> Untick Automatic) for the smoothing groups to be exported properly.
Note.png Note: If disabling automatic discontinuity doesn't work, try making your collision model simpler.
  • WARNING: Model has 2-dimensional geometry (less than 0.500 inches thick on any axis)!!!
This will happen if one, or more, face isn't in the same smoothing group as the rest of the collision model. To fix this simply assign all faces of your mesh to the smoothing goup 1 (since you can only use 1 smoothing group). Many thanks to Vaenyc for this thread
This also happens if there literally is too thin geometry in a collision model. This might be related to scaling down a model with $scale, especially if the intent was to recompile a full-sized model for skybox usage. (In that case, replacing the collision model by an empty one might be adequate as skybox content usually won't need collisions.)
  • Bounding box out of range
The compile error "bounding box out of range" followed by a string of coordinates means that the collision model for your mesh is larger than the maximum allowed size which seems to be hard coded at 16384 units in any direction. This often happens when you either scale up a model too much forcing the collision outside the range, or if your animation causes your collisionjoints to move outside this range.
Tip.png Tip: A solution might be to divide the model into several smaller pieces if possible.
In the case where your model isn't going to be colliding with other objects in the world, it seems that you can also ignore this error if need be as it doesn't seem to impact performance.

SDK samples

The SDK has numerous sample models, including several fully-articulated characters and players. They can be found at sourcesdk_content\<game>\modelsrc\.

Note.png Note: Left 4 Dead and Left 4 Dead 2 sample models can be found at <game>\sdk_content\modelsrc\
Complete SMD source for both player models in Day of Defeat: Source.
Complete, but outdated, DMX source for all TF2 classes. Rigged reference meshes are also available as SMD and Maya.
A tweaked ValveBiped rig (no meshes)
"Urban CT" player model
Several static props
Airboat and Buggy
Antlion Guard
Male citizen (old version with only a few animations)
Some CS stuff that is probably a duplicate of \cstrike's content
Viewmodels for all HL2 weapons
All with multiplayer animations only:
Combine soldier
Male rebel
Left 4 Dead <Left 4 Dead>
Common infected Models, Bodygroups, and commands necessary for Dynamic Skins
Breakable Woodrail prop example
Explosive Weapon examples for red gas cans and propane tanks
Left 4 Dead 2 <Left 4 Dead 2>
Breakable Woodrail prop example different from the one found in Left 4 Dead 1
Crumbling Ceiling dynamic prop example

See also