Author: UNKNOWN ()

Convert interior geometry .map files into Torque .dif and performs several major functions: perform CSG operations on the map brushes to produce polygons, build a portal tree used for visibiliy testing, produce a BSP tree used for collision, produce lightmaps based on lighting information in the map, aggregate multiple static LODs.


Synopsis

map2dif [-v] [-p] [-s] [-l] [-h] [-g] [-e] [-n] [-o outputDirectory] [-t textureDirectory] file.map

  -v Print program version information
-p Include a preview bitmap in the interior file
-d Process only the detail specified on the command line
-l Process as a low detail shape (implies -d)
-h Process for final build (exhaustive BSP search)
-g Generate navigation graph info
-e Do extrusion test
-n Noisy error/statistic reporting
-s Don't search for textures in parent dir.
-q <1,2> Parse Quake map file, version 1 or 2
-o dir Directory in which to place the .dif file
-t dir Location of textures
file.map The map file being converted

Description

Essentially map2dif takes a map file as an argument, processes it, and produces a Torque .dif file. By default the .dif is located in the same directory as the .map file. In order to process the map, the textures used in the map need to be loaded. Map2Dif searches for those textures starting in the texture dir, which is by default the directory of the .map file, then in it's parent directory recursively until it reaches the root. Map2dif will load either .jpg, or .png version of the textures specified in the map.

Map2Dif loads the textures to determin the width and height of each texture. This information is used to calculate polygon texture mapping information stored in the .dif file. If a texture's size should later be changed, all interiors using that texture would have to be re-processed.

For backwards compatability with Tribes 2, map2dif appends the name of the wad file to the dir path before commencing it's search. So if the wad file is called "wadName" and the texture directory is:

	/tribes2/base/interiors
Map2Dif will search the following directories for the textures:
	/tribes2/base/interiors/wadName
	/tribes2/base/interiors
	/tribes2/base
The root, or first directory, is never searched.


Torque Directories

The Torque engine expects textures to be in the same directory as the source art, or in a parent directory. Parent directories are searched all the way to the root of the run time exe path (the root itself is not searched). With the example directory and test app, all interior art is stored in the data mod and organized organized into texture set directories located in the root of the data mod:

	data/interiors/evil1
	data/interiors/test
	data/interiors/...

Each texture set includes all of it's textures in it's root directory. Map and .dif files are organized by type into sub directories which may be more than one level deep. As an example, one may create a collection of medieval buildings using the evil1 texture set and organize the .map and .dif files as follows:

	.../evil1
	.../evil1/medieval
	.../evil1/medieval/walls
	.../evil1/medieval/towers
	.../evil1/medieval/towers/small
	.../evil1/medieval/towers/large
	etc.

In this example, all the textures associated with the evil1 set are still located in the evil1 directory and the .map and .dif files are located in the leaf directories. The medieval module may introduce new textures for use by it's own sub modules by placing them in the ../evil1/medieval directory. The mediaval module would, or course, have to include it's on wad file for use with WorldCraft.

Since map2Dif will scan the parent directories looking for textures, map files are simply processed in place. Using the medieval example ubove, a wall map would be converted as follows:

	map2dif data/interiors/evil1/medieval/walls/crenelated.map

This example command would be run from the test application's root directory, but could be run from any location as long as the map file's path is specified correctly.


Tribes 2

Map2dif is the Torque equivilent of Tribes 2 tool Morian. Currently map2dif is backwards compatible with Tribes 2 which expects all .dif files to be located in the modName/interiors directory and all textures to be located in modName/textures/wadName. Assuming your mod name is base and your textures are located in the correct directory, issue the following command from the Tribes 2 root dir:

	map2dif -o base/interiors -t base/textures mapFile.map

The map file may be located in any directory as long as it's fully specified, but the command must be executed from the Tribes 2 root dir.


Special Textures

Map2Dif uses the following texture names to help identify special brushes. Though these textures are never loaded, they should be in the wad file so that they may be used in WorldCraft.

These textures can optionaly be .jpg files.


Lighting

This needs to be filled in...


Detail Levels

This needs to be filled in...


Map Entities

This is a list of the entities supported by map2dif and the entity attribute options. To initialize WorldCraft, use the Torque game config file torque.fgd.

Core Entities
    worldspawn
        detail_number           int (default is 0)
        min_pixels              int (default is 250)
        geometry_scale          int Must be a power of 2 (default is 32)
        light_geometry_scale    int Must be a power of 2 (default is 32)
        ambient_color           color (default is 0,0,0)
        emergency_ambient_color color (default is 0,0,0)

    detail
    collision
    vehicle_collision

    portal
        ambient_light           bool: Pass ambient light (default is 0)

    target
        name                    string (default "")
        origin                  pos (default 0,0,0)

Light Emitters
    light_emitter_point
        origin                  pos (default 0,0,0)
        target
        state_index
        falloff_type            bool: 0 = distance, 1 = linear (default false)
        falloff1                float (default is 10)
        falloff2                float (default is 100)
        falloff3                float (default is 0)

    light_emitter_spot
        origin                  pos (default is 0,0,0)
        target
        state_index
        falloff_type            bool: 0 = distance, 1 = linear (default false)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        falloff3                int (default is 0)
        direction               vector (default is 0,0,-1)
        theta                   radian: inner angle (default is 0.2)
        phi                     radian: outer angle (default is 0.4)

Lights
    light
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        spawnflags              int: animation flags...
        alarm_type              bool (default is 0)
        state                   int: State number
            duration            float: State duration
            color               color: State color

Scripted Lights
    light_omni
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        color                   color (default is 1,1,1)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)


    light_spot
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        target
        color                   color (default is 1,1,1)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        distance1               int: Inner distance (default is 10)
        distance2               int: Outer distance (default is 100)

Animated Lights
    light_strobe
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        target
        spawnflags              int: animation flags...
        color1                  color (default is 0,0,0)
        color2                  color (default is 1,1,1)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        speed                   int (default is ?)

    light_pulse
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        spawnflags              int: animation flags...
        color1                  color (default is 0,0,0)
        color2                  color (default is 1,1,1)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        speed                   int (default is ?)


    light_pulse2
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        spawnflags              int: animation flags...
        color1                  color (default is 0,0,0)
        color2                  color (default is 1,1,1)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        attack                  float (default is 1)
        sustain1                float (default is 1)
        sustain2                float (default is 1)
        decay                   float (default is 1)

    light_flicker
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        spawnflags              int: animation flags...
        color1                  color (default is 1,1,1)
        color2                  color (default is 0,0,0)
        color3                  color (default is 0,0,0)
        color4                  color (default is 0,0,0)
        color5                  color (default is 0,0,0)
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        speed                   int (default is ?)

    light_runway
        name                    string (default "")
        origin                  pos (default is 0,0,0)
        spawnflags              int: animation flags...
        color                   color (default is 1,1,1)
        target
        alarm_type              bool (default is 0)
        falloff1                int (default is 10)
        falloff2                int (default is 100)
        speed                   int (default is ?)
        steps                   int (default is 0)
        pingpong                bool (default is 0)

Special Entities
    mirror_surface
        origin                  pos (default is 0,0,0)
        alpha_level             int (default is ?)

    door_elevator
        name                    string (default is "")
        path_name               string (default ?)
        trigger[0-7]_name       string (defaul ?)

    force_field
        name                    string (default "")
        color                   color (default is 0.5,.8,1)
        trigger[0-7]_name       string (defaul ?)

    ai_special_node
        name                    string (default "")
        origin                  pos (default is 0,0,0)

Path Entities
    path_node
        name                    string (default "")
        next_node               string (default ?)
        next_time               int (default ?)

    path_start
        name                    string (default "")
        next_node               string (default ?)
        next_time               int (default ?)

Trigger Entities
    trigger
        name                    string (default "")