Zh/Compiling a model: Difference between revisions
(transtaled litte) |
No edit summary |
||
Line 1: | Line 1: | ||
{{otherlang2 | {{otherlang2|title=编译模型 | ||
|fr=Compiling_a_model:fr | |fr=Compiling_a_model:fr | ||
|ru=Compiling_a_model:ru | |ru=Compiling_a_model:ru |
Revision as of 17:05, 6 October 2015
模型在游戏中使用之前需要被编译。编译他你需要以下三个东西:
- 一套用于描述模型的文件(像SMD, DMX, VTA)。如果你没有,请参见导出一个模型。FBX格式在CSGO的1.34.8.4版本后获得有限的支持。
- 一个QC文件它定义了这里源文件该如何被转换成为一个起源引擎模型,它与材质文件的 VMT文件较为相似。
- 模型工作室程序,这个SDK中的程序利用QC文件来编译输出一个编译过的模型(但愿如此!)
一些设置
假如你已经成功的从你最喜欢的3D建模软件中导出了模型源文件,在编译前,最后一步就是设置VPROJECT环境变量。它定义了模型工作室工具将会在那里输出编译好了的模型。你可以用以下方法改变输出位置:
- 一般地,你可以在SDK启动器(SDK Launcher)中的下拉菜单中选择你当前工作的游戏或者模组来改变它。
- 但你只用模型工作室工具时,在命令行中添加
-game "<指向你gameinfo.txt所在文件夹的完整路径>"
提示:大部分SDK工具都支持
-game
命令行参数
句法高亮
当你使用支持 句法高亮的高级文本编辑器时,编辑QC文件将会变得非常简单。下面是目前支持QC高亮显示规则的两款文本编辑器:
创建一个QC
QC文件仅仅是一个拥有.qc
后缀名的文本文件。你可以在任何地方以任何名字命名它,但是最好将他存储在你SMD文件所在的目录下并且命名它为你目标模型文件的名字。
在文件中应该是一个告诉模型工作室模型的各个SMD文件的位置,编译后文件应该被写入的位置,如何处理动画以及其他特性的一个QC命令列表,你可以在QC命令中找到所有已知命令的列表。
Example
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!
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" $staticprop $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.

$sequence
, even if they aren't actually animated!Tutorials
- For physically-simulated objects, see
prop_data
- For characters or player models, see Compiling a character model
- For weapons, see Creating worldmodels from viewmodels
- For vehicles, see Compiling a vehicle model
- For general help with compiling models, see Category:QC Commands
Compiling
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 pause
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.
Costly collision model
Duplicate weightlist pelvisonly
Short conversion out of range
WARNING: (4768124) : ERROR: 'EXCEPTION ACCESS VIOLATION' (assert: 1)
- 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.

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.
提示: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\
.

<game>\sdk_content\modelsrc\
sdk
- Complete SMD source for both player models in Day of Defeat: Source.
tf
- Complete, but outdated, DMX source for all TF2 classes. Rigged reference meshes are also available as SMD and Maya.
generic
- A tweaked ValveBiped rig (no meshes)
cstrike
- "Urban CT" player model
- Several static props
hl2
- 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
hl2mp
- All with multiplayer animations only:
- Combine soldier
- Metrocop
- Male rebel
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
- Breakable Woodrail prop example different from the one found in Left 4 Dead 1
- Crumbling Ceiling dynamic prop example
See also
- QC
- Category:QC Commands
- Crowbar Tool
- Crowbar, Decompile and Compile Source Engine Models in a user friendly interface
- studiomdl
- Studiocompiler, a graphical interface for studiomdl
- GUIStudioMDL, another graphical interface
- Highlighting and Compiling QCs with ConTEXT
- Notepad++ VDF languages
- Common Compile Errors and Some Solutions