L3DT users' community
Large 3D terrain generator

Campaign Cartographer 2 - File Format (FCW)

Correspondence concerning plugins and scripts; development, use, bugs and ideas.

Campaign Cartographer 2 - File Format (FCW)

Postby Shealladh » Sun Jul 01, 2007 12:19 pm

As promised awhile ago I found the CC2's file format data HERE.

There are four sections to the DevZone about this native format (FCW).

1] XP's: Here we tackle the tough chore of adding directly to the CAD core of CC2 using C.

2] Intercom: Intercom lets your C or Visual Basic program communicate with CC2.

3] File Format: The binary nature of the file format may at first seem mysterious but here we will unlock its secrets.

Another page exists, possibly an older file format: File Format 1

4] Scripting: In writing CC2 scripts, you will be choreographing all of CC2's actions allowing you to take full control.

With the majority of my files in FCW format I would like to see a way to convert them over to L3DT, especially if we can get the "vector" format agreed upon.

Code: Select all
To properly navigate within an open map file, it is essential to know where you are. With this in mind, I will show you how to properly walk through an entire FCW file and identify all the entities with it.

To start, you have already seen the file information and the header. The file information does not follow the rules that every other entity within the file follows, but it suffices to know that it is 128 bytes long.

Starting with the 129th byte and the next three bytes, we have a ‘WORD’. If you remember, the file format is described in assembly language and uses such strange terms as ‘SBYTE’, ‘DWORD’ and ‘REAL4’. These are the variable types in assembly just like ‘String’, ‘Long’, and ‘Single’ are used in Visual Basic.

Here is a list of assembly variable types and there length:

    * ‘BYTE’ = A single byte
    * ‘SBYTE’ = A variable length string. Usually followed by a length.
    * ‘WORD’ = Two bytes starting with the least significant.
    * ‘DWORD’ = Four bytes starting with the least significant.
    * ‘REAL4’ = Four bytes that holds a floating point number.

Starting with the Header, all entities start with the same six bytes in this order:

ERLen   dword   sizeof(HDR)   ;actual length (bytes in use)

EType   byte   ET_IB      ;entity type code

IType   byte   IB_HDR      ;info block type

If the entity type (Etype) is zero, then the info block type (Itype) value defines what type of non-drawn entity it is. Here is a list of the non-drawn entity types:

    * 0 = "Header"
    * 1 = Old and unused
    * 2 = "Views"
    * 3 = "Layers"
    * 4 = "Grids"
    * 5 = "Printer Settings"
    * 6 = "Line Styles"
    * 7 = "Fill Styles"
    * 8 = "Named Views"
    * 9 = "Color Map Data"
    * 16 = "Dimension Styles"
    * 17 = "Fonts"

So, to walk through a map file, you start at byte 129 and read in the first four bytes to find the length of the next entity. Add that length to the pointer that points to the first byte in the entity and you are now at the first byte of the next entity.

If that was all there was to it, then walking through the file format would be a breeze. Unfortunately this is not the case. We also have to deal with something called sublists. Sublists are lists of entities like lines and points etc. that are not part of the main map but instead belong to either a group, a multipoly or a symbol. So if you find an entity that has a sublist, the entity is immediately followed by its sublist.

Once you have found the first byte of what could be the next entity, you need to check the next five bytes for the tale-tell signal that starts a sublist: 5 0 0 0 0. If you find a sublist then you need to walk through it as well by adding five to your pointer and going from there.

Likewise, at the end of a sublist, you encounter the tale-tell signal: 5 0 0 0 1. Add five again to your pointer and continue.

In the example program, you will see how I manage the navigation of a map file. I also read in and display the entity type lines. You should be able to take this framework and add to it so that you have a fully functioning map viewer.


All I need to do is track down the native Fractal Terrains format (FTW) to enable better functions for what I'm designing. It would be really nice to load the whole FTW file and convert into vectors or import data directly into L3DT for such things as rainfall, vegetation, etc.

Any thoughts?
I take solice from the fact that I know nothing...compared to the rest of the world.
Shealladh
Contributing member
 
Posts: 49
Joined: Fri Sep 29, 2006 1:52 pm
Location: Melbourne, Australia

Postby Aaron » Mon Jul 02, 2007 2:09 pm

Hi Shealladh,

Is there any info on the actual contents of the file sections? For instance, what exactly is contained in the "Colour map data" section? Also, my reading of the CC site would suggest that the maps contain no actual topographic data. Is this so, and if so, how would you propose we invent the height data to match?

Cheerio,
Aaron.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia


Return to Plugins and scripts

Who is online

Users browsing this forum: No registered users and 4 guests