Ru/Compiling a model: Difference between revisions
(→Compile environment: - translated) |
|||
Line 38: | Line 38: | ||
Киньте на него ваш файл с описанием, как кидали бы на сам исполняемый файл (studiomdl.exe) - по своей сути этот .cmd нечто вроде ярлыка. | Киньте на него ваш файл с описанием, как кидали бы на сам исполняемый файл (studiomdl.exe) - по своей сути этот .cmd нечто вроде ярлыка. | ||
== QC | == QC-команды == | ||
:''''' | :'''''Чтобы увидеть полный список документированных QC-команд''', посмотрите [[:Category:QC Commands]].'' | ||
Вот QC-файлы для неанимированного статичного prop'а: | |||
[[$modelname]] "props_sdk/myfirstmodel.mdl" | [[$modelname]] "props_sdk/myfirstmodel.mdl" | ||
Line 54: | Line 54: | ||
[[$collisionmodel]] "myfirstmodel-phys.smd" { [[$concave]] } | [[$collisionmodel]] "myfirstmodel-phys.smd" { [[$concave]] } | ||
{{tip| | {{tip|Путь для файлов SMD по умолчанию совпадает с расположением QC. Если что-то находится в другой папке, то в любой команде вы можете указать относительные или явно прописанные пути.}} | ||
Here is a brief summary of what each of those commands does. For more detail, click on the names. | Ниже приведен краткий обзор того, что каждая из команд делает. Чтобы просмотреть страницы с более подробной информацией, щелкните по именам команд. Here is a brief summary of what each of those commands does. For more detail, click on the names. | ||
;<code>[[$modelname]]</code> | ;<code>[[$modelname:ru]]</code> | ||
: | :Определеяет имя и местоположение основного файла будущей скомпилированной модели относительно папки <code><имя мода>/models/</code>. При компиляции будет создано еще несколько файлов, и их имя будет образовано от указанного здесь значения. | ||
;<code>[[$body]]</code> | ;<code>[[$body:ru|$body]]</code> | ||
:Defines the SMD that contains the [[vertex]], [[UV map]], [[skeleton]] and [[envelope]] data for the model. Without this, your model will have no physical appearance. | :Defines the SMD that contains the [[vertex]], [[UV map]], [[skeleton]] and [[envelope]] data for the model. Without this, your model will have no physical appearance. | ||
:A name ('mybody') is given because it is possible for a model to have several bodies - like the [[npc_metropolice|metrocop]], who has one with a [[npc_manhack|manhack]] attached and one without. | :A name ('mybody') is given because it is possible for a model to have several bodies - like the [[npc_metropolice|metrocop]], who has one with a [[npc_manhack|manhack]] attached and one without. | ||
:{{tip| | :{{tip|Более сложные модели используют вместо [[$body:ru|$body]] код <code>[[$model (QC):ru|$model]]</code>}} | ||
;<code>[[$staticprop]]</code> | ;<code>[[$staticprop:ru|$staticprop]]</code> | ||
:Tells studiomdl that the model has no moving parts, allowing it to perform several important optimisations. It is required if the model is to be used with [[prop_static]], but does not prevent it from being used elsewhere! (Indeed, most models that are to be physically-simulated use the command as well.) | :Tells studiomdl that the model has no moving parts, allowing it to perform several important optimisations. It is required if the model is to be used with [[prop_static]], but does not prevent it from being used elsewhere! (Indeed, most models that are to be physically-simulated use the command as well.) | ||
;<code>[[$surfaceprop]]</code> | ;<code>[[$surfaceprop:ru|$surfaceprop]]</code> | ||
:How the object's surface reacts to other entities in the world. Also helps define the weight of the object, if the QC command to calculate it is used. | :How the object's surface reacts to other entities in the world. Also helps define the weight of the object, if the QC command to calculate it is used. | ||
:{{note|An identical command is used in [[material]]s. Should they clash on a model, the QC version is chosen. It isn't clear why this functionality is duplicated.}} | :{{note|An identical command is used in [[material]]s. Should they clash on a model, the QC version is chosen. It isn't clear why this functionality is duplicated.}} | ||
;<code>[[$cdmaterials]]</code> | ;<code>[[$cdmaterials:ru|$cdmaterials]]</code> | ||
:The folder to load the model's material(s) from. Remember that the materials must be the same name as the ones you applied in your modelling package. The value is relative to <code><mod folder>/materials/</code>. | :The folder to load the model's material(s) from. Remember that the materials must be the same name as the ones you applied in your modelling package. The value is relative to <code><mod folder>/materials/</code>. | ||
;<code>[[$sequence]]</code> | ;<code>[[$sequence:ru|$sequence]]</code> | ||
:Even though this model is <code>$staticprop</code> and therefore not animated, Source needs an empty 'idle' animation to correctly handle it. If the animation is truly idle it will only have one frame, rendering the <code>fps</code> property meaningless (but it's included anyway in demonstration). | :Even though this model is <code>$staticprop</code> and therefore not animated, Source needs an empty 'idle' animation to correctly handle it. If the animation is truly idle it will only have one frame, rendering the <code>fps</code> property meaningless (but it's included anyway in demonstration). | ||
;<code>[[$collisionmodel]]</code> | ;<code>[[$collisionmodel:ru|$collisionmodel]]</code> | ||
:Defines the SMD that will be used to calculate [[physics]] collisions by the engine. Without a collision model, physical objects will simply fly through the model (which in some cases may be what you want). | :Defines the SMD that will be used to calculate [[physics]] collisions by the engine. Without a collision model, physical objects will simply fly through the model (which in some cases may be what you want). | ||
:{{tip|If your collision model needs to be animated, use <code>[[$collisionjoints]]</code> instead.}} | :{{tip|If your collision model needs to be animated, use <code>[[$collisionjoints:ru|$collisionjoints]]</code> instead.}} | ||
;<code>[[$concave]]</code> | ;<code>[[$concave:ru|$concave]]</code> | ||
:A collision model must be [[Wikipedia:convex|convex]], but you can create [[Wikipedia:concave|concave]] shapes by combining more than one of them into the same model. This command tells studiomdl that this is what you intend - without it, all of your collision SMD's meshes will instead be merged into one shape that wraps them all around. | :A collision model must be [[Wikipedia:convex|convex]], but you can create [[Wikipedia:concave|concave]] shapes by combining more than one of them into the same model. This command tells studiomdl that this is what you intend - without it, all of your collision SMD's meshes will instead be merged into one shape that wraps them all around. | ||
Revision as of 05:28, 21 September 2008
В статье описано, как компилировать модели с помощью studiomdl для внутриигрового использования. Прежде чем начать, вам понадобятся какие-нибудь файлы SMD, которые вы и будете компилировать. Если у вас их еще нет, прочтите статью об Экспорте моделей.

Формат QC
Помимо файла в формате SMD с данными о модели, вам понадобится файл формата QC, который - в чем-то похоже на файл материала VMT - описывает как нужно интерпретировать данные из SMD-файла. При подготовке к компиляции вы потратите большую часть времени именно на него.
QC - это просто текстовый файл с расширением .qc
. Его можно создать где угодно и назвать как вам нравится. Лучше, однако, хранить свои данные организованно, и держать SMD и QC в одной папке, которую разумно будет назвать так же, как будущий файл модели.
Порядок компиляции
При настройке компиляции важнейшим шагом является выбор правильной переменной VPROJECT. Вот как это можно сделать:
- Глобально, указав свою игру/мод в выпадающем списке SDK launcher'а
- Только для программы studiomdl, запустив ее с параметром
-game "<полный путь к директории с вашим gameinfo.txt>"
Что касается работы с QC-файлами для моделей, то вам очень, правда - очень пригодится продвинутый текстовый редактор, который поддерживает выделение синтаксиса цветом и который сможет запускать studiomdl - без ручной работы с командной строкой или bat-файлами. На текущий момент существует два таких редактора:
Скачайте редактор и правила подсветки синтаксиса, настройте исполнение studiomdl - и все, можно приступать к работе!
Сложный способ
Если вы не хотите или не можете использовать ни один из редаторов (перечислены выше), то компилировать QC-файлы придется, перетаскивая и кидая их на studiomdl.exe. Программу можно найти в папке sourcesdk/bin/orangebox/bin/
(если нужно, замените orangebox/ на ep1/).
Легче это будет делать, если для автоматизации создать в каком-нибудь легко доступном месте на компьютере .cmd-файл. Это просто переименнованный txt с каким-нибудь таким текстом:
"%sourcesdk%/bin/orangebox/bin/studiomdl" %1 pause
Киньте на него ваш файл с описанием, как кидали бы на сам исполняемый файл (studiomdl.exe) - по своей сути этот .cmd нечто вроде ярлыка.
QC-команды
- Чтобы увидеть полный список документированных QC-команд, посмотрите Category:QC Commands.
Вот QC-файлы для неанимированного статичного prop'а:
$modelname "props_sdk/myfirstmodel.mdl" $body mybody "myfirstmodel-ref.smd" $staticprop $surfaceprop combine_metal $cdmaterials "models/props_sdk" $sequence idle "myfirstmodel-idle.smd" loop fps 15 $collisionmodel "myfirstmodel-phys.smd" { $concave }

Ниже приведен краткий обзор того, что каждая из команд делает. Чтобы просмотреть страницы с более подробной информацией, щелкните по именам команд. Here is a brief summary of what each of those commands does. For more detail, click on the names.
$modelname:ru
- Определеяет имя и местоположение основного файла будущей скомпилированной модели относительно папки
<имя мода>/models/
. При компиляции будет создано еще несколько файлов, и их имя будет образовано от указанного здесь значения. $body
- Defines the SMD that contains the vertex, UV map, skeleton and envelope data for the model. Without this, your model will have no physical appearance.
- A name ('mybody') is given because it is possible for a model to have several bodies - like the metrocop, who has one with a manhack attached and one without.
$staticprop
- Tells studiomdl that the model has no moving parts, allowing it to perform several important optimisations. It is required if the model is to be used with prop_static, but does not prevent it from being used elsewhere! (Indeed, most models that are to be physically-simulated use the command as well.)
$surfaceprop
- How the object's surface reacts to other entities in the world. Also helps define the weight of the object, if the QC command to calculate it is used.
Примечание:An identical command is used in materials. Should they clash on a model, the QC version is chosen. It isn't clear why this functionality is duplicated.
$cdmaterials
- The folder to load the model's material(s) from. Remember that the materials must be the same name as the ones you applied in your modelling package. The value is relative to
<mod folder>/materials/
. $sequence
- Even though this model is
$staticprop
and therefore not animated, Source needs an empty 'idle' animation to correctly handle it. If the animation is truly idle it will only have one frame, rendering thefps
property meaningless (but it's included anyway in demonstration). $collisionmodel
- Defines the SMD that will be used to calculate physics collisions by the engine. Without a collision model, physical objects will simply fly through the model (which in some cases may be what you want).
Совет:If your collision model needs to be animated, use
$collisionjoints
instead.$concave
- A collision model must be convex, but you can create concave shapes by combining more than one of them into the same model. This command tells studiomdl that this is what you intend - without it, all of your collision SMD's meshes will instead be merged into one shape that wraps them all around.
You will be able to use this sample to compile your own model (minus any animations), so swap in your own SMDs and see what happens.
Compiling more advanced models
- For physically-simulated objects, see
prop_data
- For characters or player models, see Compiling a character model
- For viewmodels, see Compiling a viewmodel
- For vehicles, see Compiling a vehicle model
- For general help with compiling models, see Category:QC Commands
Samples
Valve provide numerous sample models in the SDK for you to learn from, including several fully-articulated characters and players. They can be found at:
sourcesdk_content\cstrike\modelsrc
sourcesdk_content\hl2\modelsrc
sourcesdk_content\hl2mp\modelsrc
sourcesdk_content\generic\modelsrc
(a walking animation for Valve's default skeleton)
Common errors
- 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.
See also
- QC
- Category:QC Commands
- studiomdl
- Studiocompiler, a graphical interface for studiomdl
- GUIStudioMDL, another graphical interface
- Highlighting and Compiling QCs with ConTEXT
- Notepad++ VDF languages