Model Config
Description
The model configuration file (model cfg for short) is the interface between a (P3D) model and the program.
It is a look-up table which is processed during the binarization process, to tell the program what the various sections of the model are, which skeleton it uses and how it is animated.
This system is more flexible than the one previously used, because all the information is stored for the model and not for the object class in the main configuration file. This means that several object classes can use the same model and don't have to define the animations for this model seperately.
A goal of the system is to seperate the configuration of models into a designer and an artist part.
This is done by the introduction of a class AnimationSources in the main configuration file (the designer part) and the continuing use of the class Animations in the model cfg (the artist part).
Most models will be able to inherit definitions from basic definitions on higher levels in the data hierarchy. An example hierarchy is described and illustrated below.
p:\ofp2\vehicles\model.cfg - Defines a class Default.
p:\ofp2\vehicles\land\wheeled\model.cfg - Defines a class Car.
p:\ofp2\vehicles\land\wheeled\landrover\model.cfg - Defines a class LandRover.
p:\ofp2\vehicles\land\wheeled\landrover\lr6x6_3 - In the model is a property config=LandRover (this feature is not implemented and may never be).
p:\ofp2\vehicles\land\wheeled\landrover\lr6x6_mg240 - Has a LR6x6_MG240.cfg, which inherits from class LandRover and adds definitions for a turret.
Notes
At this stage the file is parsed during the binarization of a model and animations can be played in the program with user actions. Eventually they can be previewed using the Buldozer viewer.
The model cfg follows a set of naming conventions. There can be several model cfg files, named by default model.cfg, named after the folder name or named after a specific model. In the case that both a model.cfg and <foldername>.cfg are present, only the latter is parsed. The <modelname>.cfg is parsed alongside of the other model cfg files and therefore the model can be seen as an additional level in the hierarchy.
When we have an example folder called humr with a model called hmmwv.p3d, we can use the following names: model.cfg or humr.cfg and next to that a hmmwv.cfg.
In the future a model may support a named property called config, which tells the model which class in the model cfg to use. There is some doubt whether this feature will be implemented though.
There are model cfg files that do not relate directly to a specific model, but are used for the generic base class definitions, such as class Default.
The functionality of the animations has been extended, allowing to do in scripting what was done before using RTM animations. In addition, animation controllers were introduced, which allow for the control of different animations at the same time. This opens up possibilities like having several turrets on a tank.
The model cfg and main configuration file (where classes cfgModels, cfgSkeletons and Animations were previously defined) operate together to smooth the change from the old to the new system. When a model cfg and the main configuration file both define the same model, the model cfg takes precedence.
Segments
cfgModels
This segment defines all properties of each model. The class names correspond to the model name.
Here you define which sections the model has, which skeleton it uses and its animations.
//Declare base classes class CarAnimations { class IndicatorSpeed; }; class CfgModels { class Car; //Declare base class. class Vodnik: Car { sectionsInherit = "Car"; //Inherit all sections from class Car. //Add new section. sections[] = { "section1" }; skeletonName = "Vodnik"; //Use the Vodnik skeleton. class Animations: CarAnimations //Inherit from generic animations. { class IndicatorSpeed: IndicatorSpeed //Redefine the maximum value { //for the speed indicator. maxValue = 40; }; }; }; };
cfgSkeletons
This segment defines the skeleton for the model and the bones that it uses.
class CfgSkeletons { class Car; //Define base class. class Vodnik: Car { skeletonInherit = "Car"; //Inherit all bones from class Car. skeletonBones[] = //Add two new bones. The movement { //of bone2 is linked to bone1. "bone1", "" "bone2", "bone1" }; }; };
Animations
This segment is part of class cfgModels and defines all animations used by the model.
class Animations { class FrontWheelR { type = "rotationX"; //The type of animation. source = "wheel"; //The controller that provides input. selection = "pravy predni"; //The name of the skeleton bone used. axis = ""; //The name of the axis in the model. memory = true; //Is the axis defined in the memory level of the //model or not? sourceAddress = "loop"; //Does the animation loop or not? minValue = 0; //The minimum value of the motion range. //i.e. The controller input when animation phase is 0. maxValue = 1; //The maximum value of the motion range. //i.e. The controller input when animation phase is 1. angle0 = 0; //The starting angle of this animation, where the //animation phase is 0. angle1 = "rad -360"; //The ending angle of this animation, }; //where the animation phase is 1. };
Animation sources
These are the controllers that provide the input for the animation phase of the animations. These controllers are defined in the animation class using the source parameter. It's also possible to define custom controllers in the main configuration file, using class AnimationSources.
Name | Description | Simulation Classes |
---|---|---|
altBaro | The baro altitude. | Aircraft |
altRadar | The radar altitude. | Aircraft |
gear | The vehicle's gear. | Aircraft |
horizonBank | The banking angle of the vehicle. | Aircraft |
horizonDive | The diving angle of the vehicle. | Aircraft |
vertSpeed | The vertical speed. | Aircraft |
aileron | The main aileron control surfaces. | Airplane |
aileronB | The bottom speed brake as opening ailerons. | Airplane |
aileronT | The top speed brake as opening ailerons. | Airplane |
aoa | The Angle Of Attack. | Airplane |
elevator | The elevators. | Airplane |
flap | The flaps. | Airplane |
rotor | The rotors. | Airplane |
rudder | The rudder. | Airplane |
speedBrake | The speed brake. | Airplane |
direction | The orientation of the vehicle. | Any |
fuel | The fuel level. | Any |
gmeter | The G-forces. | Any |
rpm | The rpm of the vehicle. Used in rpm indicators. | Any |
speed | The speed of the vehicle. Used in speed indicators. | Any |
time | Timer-based input. | Any |
clockHour
|
The current time in hours. | Any (including e.g. Weapon) |
clockMinute | The current time in minutes. Derived from clockHour. | Any (including e.g. Weapon) |
clockSecond | The current time in seconds. Moves discreetly every second and independently from clockHour. | Any (including e.g. Weapon) |
damage | Current damage level (0=healthy, 1=destroyed) | Any |
pedals | The pedals. | Bicycle |
damper | The suspension of the vehicle. Currently only works with type translationY. | Car, Tank, Aircraft, Motorcycle |
drivingWheel | The orientation of the steering wheel. Used for the steering wheel and steered wheels. | Car, Ship, Motorcycle |
mainGun | The main gun. | Car, Tank, Helicopter, Ship |
mainTurret | The main turret. | Car, Tank, Helicopter, Ship |
wheel | Normal wheels that turn based on moving forward. | Car, Airplane, Motorcycle |
compassArrow | The arrow. | Compass |
compassCover | The cover. | Compass |
compassPointer | The pointer. | Compass |
rotorH | The 'horizontal' rotor. | Helicopter |
rotorV | The 'vertical' rotor. | Helicopter |
rotorHDive | Tilt of the 'horizontal' rotor. | Helicopter |
rotorVDive | Tilt of the 'vertical' rotor. | Helicopter |
support | The support stand. | Motorcycle |
hatchCommander | The commander hatch. | Tank |
hatchDriver | The driver hatch. | Tank |
hatchGunner | The gunner hatch. | Tank |
obsGun | The observer or commander gun. | Tank |
obsTurret | The observer or commander turret. | Tank |
reload | The movement when reloading. | Weapon |
revolving | The movement when firing. | Weapon |
turretDir | The orientation of the turret. | Tank |
wheelL | The left track wheels. | Tank |
wheelR | The right track wheels. | Tank |
Animation types
This table outlines the Animation Types you can use for an animation class.
Type | Description |
---|---|
rotation | Circular motion. |
rotationX | Idem, but locked to the X axis. |
rotationY | Idem, but locked to the Y axis. |
rotationZ | Idem, but locked to the Z axis. |
translation | Motion along one axis. |
translationX | Idem, but locked to the X axis. |
translationY
|
Idem, but locked to the Y axis. |
translationZ | Idem, but locked to the Z axis. |
Animation Properties
This table outlines the properties (or entries) that each defined animation class expects to be present based on the animation type that is specified.
Eg. If you specify a an animation type of 'rotationX' you must specify the animation properties 'angle0' and 'angle1'.
Property | Description | Animation Type |
---|---|---|
source | Controller used for input. | Any |
selection | Skeleton bone. | Any |
axis
|
Model axis. | Any |
begin
|
Starting point of an oriented model axis. This can be used in combination with end instead of axis. |
Any |
end
|
Ending point of an oriented model axis. This can be used in combination with begin instead of axis. |
Any |
memory | Optional (default is true). Axis in memory level or not? | Any |
animPeriod | Time in seconds for one animation cycle. Only used by custom controllers. |
Any |
minValue | Minimum value of the motion range. i.e. Controller input when the animation phase is 0. | Any |
maxValue | Maxmimum value of the motion range. i.e. Controller input when the animation phase is 1. | Any |
minPhase | Minimum phase of the animation.i.e. Animation phase when the controller value is 0. |
Any |
maxPhase | Maxmimum value of the motion range.i.e. Animation phase when the controller value is 1. |
Any |
sourceAddress | Does the animation loop or not? This can be any of three different values: clamp (default), loop or mirror. | Any |
angle0 | Starting angle of this animation, where the animation phase is 0. | Rotations |
angle1 | Ending angle of this animation, where the animation phase is 1. | Rotations |
offset0 | Starting offset of this animation, where the animation phase is 1. | Translations |
offset1 | Ending offset of this animation, where the animation phase is 1. | Translations |
AnimationSources
This is not part of the model cfg, but part of the main configuration file. This class allows you to define new user controllers or modify selected properties of existing controllers.
Defining custom controllers makes it possible to use one custom controller for several different animations. If an animation does not define the source parameter, the program looks for a custom controller defined in this class with the same name.
It is also possible to override an existing controller using this class, but be extremely careful in this case. The custom controller will hide the original one, leaving the latter inaccessible. Overriding is done using the :: notation in the source parameter as can be seen in the third example.
class AnimationSources { class MachineGun { source = "reload"; //The controller used for the definition of //this controller. weapon = MachineGun25W; //In the specific case of using the reload }; //controller, the weapon class name. };
class AnimationSources { //Used by animations called Door1, which don't define the source //parameter or by animations that define source = Door1;. class Door1 { source = "user"; //The controller is defined as a user animation. animPeriod = 1; //The animation period used for this controller. initPhase=1; //Initial phase when object is created. }; };
class AnimationSources
{
class wheel
{
source = "::wheel"; //Overriding the existing wheel controller.
};
};
Example
You can find a howto for the CfgModels (a working attack helicopter) here as well as a howto on cfgModels & cfgSkeletons with additional description and examples here.