MobileDragon INI Compiler

 

Overview:

The INI Compiler is the console application for converting files with text format to the files with binary format. It is useful to save settings for the application in binary format. Currently MobileDragon supports two types of such settings files: LOD settings file and Texture Animation settings file. Creating of these files is described bellow. You may to create your own settings files with unique formats.

 

Source file format:

Source files can have any extension, but they have to have content only in text format.
Structure of source file should be equal INI file structure:

[group_name]
param1_name=value1
param2_name=value2
param3_name=value3
param4_name=value4
param5_name=value5
param6_name=value6

INI Compiler supports converting of few data formats: String, Integer and Float. Value with Float format will be converted to the value with Fixed point (16.16) format. Name of parameter defines its data format.
There is format of parameter’s name:

[s|i|f]_param_name

The first symbol of parameter’s name defines value format of this parameter.
s – parameter’s value is String value,
i – parameter’s value is Integer value,
f – parameter’s value is Float value.
These symbols must be in lower register.
The second symbol of parameter’s name must be ‘_’.

There is complete example of content of source file:

[house1]
i_doors_count=3
f_width=20.34
f_height=5.7
s_street_name=Big_Avenue

[other_house]
i_doors_count=1
f_width=10.5
f_height=5.2
s_street_name=Small_Avenu
e

 

Output file format:

INI Compiler DO NOT saves names of parameters in the output file, but it saves group’s name. Also every group in the output binary file is separated by Header. Header defined as 4 bites hexadecimal value 0xAAAAAAAA. After header that precedes every group in the file placed file position of the data block of next group. This position is represented as 4 byte integer value.
Thus for example above in output file will be saved following information in binary format:

File pos Data Comments
addr0 0xAAAAAAAA // group header
addr1 addr8 // file position of next group block
addr2 house1 // 1st group’s name
addr3 3 // i_doors_count
addr4 20.34 // f_width
addr5 5.7 // f_height
addr6 Big_Avenue // s_street_name
addr7 0xAAAAAAAA // group header
addr8 addr14 // file position of next group block
addr9 other_house // 2nd group’s name
addr10 1 // i_doors_count
addr11 10.5 // f_width
addr12 5.2 // f_height
addr13 Small_Avenue // s_street_name
addr14 EOF // end of file

Every string value is saved as null terminated string.
Therefore you have to take into account order of parameters in your source file to load it in your application.

 

Running:

INI Compiler takes one startup parameter from the command line. This parameter is the name of source ini-file (with any extension) for converting.
For example command
C:\inicomp.exe settings.txt
will run INI Compiler to converting source file “settings.txt” to the binary format.

INI Compiler will create *.dat file with the same name and in the same directory as source file. For example after converting source file with name “settings.txt”, new file with name “settings.dat” will be created in the same directory. This file is the output binary file.

 

Creating of LOD settings file:

Mobile Dragon 3D API provides support of Levels Of Details (LOD) technology. To use LOD in the 3D application, it’s necessary to create set of scenes with different LOD first (see 3D MAX Exporter documentation for more details). After this it’s necessary to create LOD settings file. This file describes how objects with different LODs will be linked.
Let’s see an example of scene with 3 LOD levels.
This scene has a few objects with following names:
– house01
– house02
– house03
– tree01
– tree02
– well
– ground

It’s important to name objects by unique names, even if some objects belong to equal conception (for example all houses can’t have equal names “house”, we have to name them “house01”, “house02” etc.). But it’s possible to set common settings for these objects by replacing unequal symbols of name with “?” symbol. For example if we need to set common LOD settings for all objects with names “house01”, “house02” and “house03”, we have to name the group for these objects like “house??”. Here symbol “?” is a substitute of last two symbols of every name.
For every object we have to set switch radius for every LOD level. When distance from the game camera to the object reaches this switch radius value then LOD level of this object will be switched to the next (lower) level. It’s important that count of LOD levels for the scene have to be equal to the count of switch radiuses in the LOD settings file.
For example, object “house01” has 4 LOD levels. This means that we need to set 4 switch radiuses for this object in the LOD settings file. We have to create settings group for this object in accordance with common rules of settings file format. For example:

[house01] // name of settings group equals to object’s name
f_radius_1=10 // switch radius from 1 to 2 LOD level
f_radius_2=15 // switch radius from 2 to 3 LOD level
f_radius_3=20 // switch radius from 3 to 4 LOD level
f_radius_4=30 // switch radius from 4 to dummy LOD level

Why we have set switch radius for the last (4-th) LOD level if we have only 4 LOD levels? In fact it means that switch to the next 5-th level will occur, but this 5-th level is dummy LOD level and when distance from camera to the “house01” will reach 30, this object will not be drawn (it’ll disappear). If we need this object to stay visible after it will reach 4-th LOD level, we have to set switch radius for the last (4-th) level to zero. In fact, zero-radius is the infinite switch radius.
Here is another example. Let us suppose that our 3D scene has 4 LOD levels: high, middle, normal and low. Level designer have to create 4 scenes with different LOD levels. But object with name “house01” actually has 3 LOD levels (high, middle, low). Thus, in scene with normal LOD level designer can skip object “house01”. This will reduce result file size (see 3D MAX Exporter documentation for more details). We have to denote this fact in our settings file. To show that an object in current LOD level have to be drawn as in previous LOD level we need to set the switch radius for current LOD level equal to the switch radius of previous LOD level. For our example:

[house01] // name of settings group is equal to object’s name
f_radius_h=10 // switch radius from High to Middle LOD level
f_radius_m=20 // switch radius from Middle to Low LOD level
f_radius_n=20 // switch radius for Normal LOD level equal to previous
f_radius_l=30 // switch radius for Low LOD level

So, let’s create complete LOD settings file for the whole scene. We have a few objects in the scene and few requirements described in the table below:

Names of objects
LOD levels availability/Switch radiuses
Endless visibility
High
Middle
Normal
Low
house01
Yes
Yes
No
Yes
Yes
house02
Yes
Yes
No
Yes
Yes
house03
Yes
Yes
No
Yes
Yes
tree01
Yes
Yes
Yes
Yes
No
tree02
Yes
Yes
Yes
Yes
No
well
Yes
No
No
Yes
No
ground
Yes
No
No
No
Yes

Let us suppose that switch radiuses for corresponding LOD levels (if they are available) for all objects are equal:
from High to Middle LOD level – 10 units,
from Middle to Normal LOD level – 20 units,
from Normal to Low LOD level – 30 units,
from Low to Dummy LOD level – 40 units.

Here is complete content of LOD settings file for this scene:

[house??]
f_sr_high_middle=10
f_sr_middle_normal=30
f_sr_normal_low=30 // uses previous LOD level
f_sr_low_dummy=0 // endless visibility

[tree??]
f_sr_high_middle=10
f_sr_middle_normal=20
f_sr_normal_low=30
f_sr_low_dummy=40 // object will disappear

[well]
f_sr_high_middle=30
f_sr_middle_normal=30 // uses previous LOD level
f_sr_normal_low=30 // uses previous LOD level
f_sr_low_dummy=40 // object will disappear

[well]
f_sr_high_middle=0 // always visible in High LOD level
f_sr_middle_normal=0
f_sr_normal_low=0
f_sr_low_dummy=0

And the last feature. When MobileDragon loads LOD settings from *.dat file, it creates a list of switch radiuses for each object and then sorts this list by increment. It takes into account that zero-radius is the largest possible radius. Thus if you’ll make an error and set radiuses not by increment, MobileDragon will fix it. For example you’ll write the following:

[tree??]
f_sr_high_middle=20
f_sr_middle_normal=10
f_sr_normal_low=0
f_sr_low_dummy=30

MobileDragon will interpret it as:

[tree??]
f_sr_high_middle=10
f_sr_middle_normal=20
f_sr_normal_low=30
f_sr_low_dummy=0

 

Creating of Texture Animation settings file:

MobileDragon includes special features, which allow to play and control texture animation. It is a simple realization of texture animation that based on textures switching. To play texture animation MobileDragon needs to know the list of textures and delays for each of them. To create settings file for texture animation we have to use the INI Compiler application. In this file we have to define file names of textures and its delays. One settings file can define several texture animations. The name of settings group will be interpreted as the name of texture animation. Settings block for one texture animation have to correspond with following format:

[animation_name]
s_texture1_name=texture1 // name of 1st texture file without extension
i_texture1_delay=1000 // delay for 1st texture in user’s units
s_texture2_name=texture2 // name of 2nd texture file without extension
s_texture2_delay=1000 // delay for 2nd texture in user’s units
... // etc.

For example, we need to create two texture animation. Each of them has 4 frames – 4 textures in series. Now we have to create the following settings file for these animations.

[face_animation] // first texture animation (face animation)
s_t1_name=face1
i_t1_delay=1200
s_t2_name=face2
s_t2_delay=1000
s_t3_name=face3
s_t3_delay=1100
s_t4_name=face4
s_t5_delay=1300

[water_animation] // second texture animation (water animation)
s_t1_name=water_center
i_t1_delay=1000
s_t2_name=water_left
s_t2_delay=1000
s_t3_name=water_center
s_t3_delay=1000
s_t4_name=water_rigth
s_t5_delay=1000

 

 

Copyright 2005-2006 Herocraft Hitech Co. Ltd.