Author Topic: MakeAHMap and AH3  (Read 2806 times)

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
MakeAHMap and AH3
« on: January 05, 2016, 12:47:59 PM »
Hello,

Also I've taken a break for a while from AH, I still would like to make sure that MakeAHMap utility for building terrains from geographical data continues to work with AH3.

Recall: http://www.hitechcreations.com/wiki/index.php/Terrain_Generation_From_Geographical_Data

It creates following files:

1. terrain elevations (.elv file)
2. high resolution shorelines and rivers (waterd.bmp/waterc.bmp)
3. ground cover (tiles) according to the geographical data set, i.e. farm, forest, dessert areas, etc. (gndtype.bmp)
4. Nice looking clipboard map.

Now I'd like to know what changes should I do to make the stuff work:

1. Are waterd.bmp/waterc.bmp relevant for representation for shore lines?
2. Ground cover gndtype - AFAIR it had changed am I right.
3. And of course AFAIR the resolution of elevations had changed how the alignment between all these types changed

And the last but not least - water elevations, AH2 has slope restriction that I fixed by modifying elevations (because real world slopes are higher quite frequently) have slope restrictions changed in new version and how.

What I would really appreciate is documentation of terrain file formats.

Thank You.

(Also I don't have to fly, I'm much more flexible with coding  :) )
Artik, 101 "Red" Squadron, Israel

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12315
      • http://www.hitechcreations.com
Re: MakeAHMap and AH3
« Reply #1 on: January 05, 2016, 01:05:29 PM »
The concept of water map is gone. All elevations below 0 are considered water.

Elevation is now signed 16 bit at 660 ft vertex spacing.

gndtype.bmp is similar but now the channel control is different . See the document for specifics on file types.

http://bbs.hitechcreations.com/smf/index.php/topic,376440.0.html

HiTech

Offline Easyscor

  • Plutonium Member
  • *******
  • Posts: 10882
Re: MakeAHMap and AH3
« Reply #2 on: January 05, 2016, 01:24:24 PM »
Hi Artik, I see Hitech has responded while I was writing this but here it is anyway.


There are import options unless you obtain the file formats for the htx (I believe it is) format.

1. terrain elevations (.elv file)
This is now a .raw file. It can be either 16 bit signed (zero is zero elev.) or unsigned. I doubt you'll want the unsigned version but it's documented in this forum. This is a 4096x4096 raster as they all are. Search on .raw files in this forum.

2. high resolution shorelines and rivers (waterd.bmp/waterc.bmp)
You're going to need to do some of that coad stuff here. No water above zero elevation except the new river paths.
You can build custom objects containing lakes if you like but that's not in your program description.
Water is automatic if the elevation drops below zero. I'd suggest contacting htc to see if you can obtain the format for the shoreline htx files but the raw elevation files may be all you need. If you do retrieve the htx file format, please document it in here.


3. ground cover (tiles) according to the geographical data set, i.e. farm, forest, dessert areas, etc. (gndtype.bmp)
This is another 4096x4096 file but it's an RGB bitmap. Search on 'Splat' files in this forum.

4. Nice looking clipboard map.

Now I'd like to know what changes should I do to make the stuff work:

3. And of course AFAIR the resolution of elevations had changed how the alignment between all these types changed
Everything is shifted. iirc, 1/2 mile north and 1/2 mile east. waterd won't quite line up but you should play with the TE to see the changes.

Easy in-game again.
Since Tour 19 - 2001

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
Re: MakeAHMap and AH3
« Reply #3 on: January 05, 2016, 03:47:43 PM »
Thanks few quick questions:

@hitech - river objects (I assume like roads as well) how can I create ones? I need file format specifications. The geographical data contains rivers in already in piecewise linear format so all I need is to convert relevant part to internal TE river object. Am I right? If so can you please provide a format there?

Regarding the water below 0. It is problematic. It basically means that all lakes should be at 0 level.

I can think of following ways to resolve it:

1. I can either modify elevations and move lakes to 0.
1.a if I add rivers they would... Flow backward at some parts (assuming I'll know how to do it)
1.b Or I can "create canyons" where rivers/lakes exists this would cover in such a case both rivers and lakes - I can specify some slope threshold regarding canyon depths.
2. Remove lakes entirely, keep rivers as objects
3. Make lakes special kind of ground type with special tiles so they'll look like a water but behave like... grass. keep rivers as objects
4. Remove both rivers and lakes (but it can really badly hurt the impression of the map).

To be honest I think of either (1b) or 4. Maybe 1a.

What do you think?
Artik, 101 "Red" Squadron, Israel

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12315
      • http://www.hitechcreations.com
Re: MakeAHMap and AH3
« Reply #4 on: January 05, 2016, 04:13:50 PM »
Thanks few quick questions:

@hitech - river objects (I assume like roads as well) how can I create ones? I need file format specifications. The geographical data contains rivers in already in piecewise linear format so all I need is to convert relevant part to internal TE river object. Am I right? If so can you please provide a format there?

Regarding the water below 0. It is problematic. It basically means that all lakes should be at 0 level.

I can think of following ways to resolve it:

1. I can either modify elevations and move lakes to 0.
1.a if I add rivers they would... Flow backward at some parts (assuming I'll know how to do it)
1.b Or I can "create canyons" where rivers/lakes exists this would cover in such a case both rivers and lakes - I can specify some slope threshold regarding canyon depths.
2. Remove lakes entirely, keep rivers as objects
3. Make lakes special kind of ground type with special tiles so they'll look like a water but behave like... grass. keep rivers as objects
4. Remove both rivers and lakes (but it can really badly hurt the impression of the map).

To be honest I think of either (1b) or 4. Maybe 1a.

What do you think?

You can make decent lakes with rivers, file format is not finalized, but it consist of spline points along with widths.

HiTch

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
Re: MakeAHMap and AH3
« Reply #5 on: January 05, 2016, 04:18:00 PM »
You can make decent lakes with rivers, file format is not finalized, but it consist of spline points along with widths.

HiTch


Great, even if it is only preview format it would be great to know one to at least see how stuff works. Later the relevant module can be updated.

Looking forward.
Artik, 101 "Red" Squadron, Israel

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12315
      • http://www.hitechcreations.com
Re: MakeAHMap and AH3
« Reply #6 on: January 05, 2016, 04:36:15 PM »
The current format

The y value is height off ground for roads, and width for rivers.


   fprintf(Fp,"%d\n",TrackList->TrackCnt);
   for(TrackIndex= 0 ;TrackIndex < TrackList->TrackCnt;++TrackIndex)
   {
      Track = TrackList->Tracks[TrackIndex];
      if(Track == NULL)
      {
         fclose(Fp);
         return -1;
      }

      fprintf(Fp,"%d,Type\n",Track->Type);
      fprintf(Fp,"%d,Flags\n",Track->Flags);
      fprintf(Fp,"%d,ResourceType\n",Track->ResourceType);

      fprintf(Fp,"%d,DestFieldIndex\n",Track->DestFieldIndex);
      fprintf(Fp,"%d,SourceFieldOrObjectIndex\n",Track->SourceFieldOrObjectIndex);
      fprintf(Fp,"%f,SrcRadius\n",Track->SrcRadius);
      fprintf(Fp,"%f,DestRadius\n",Track->DestRadius);

      fprintf(Fp,"%s\n",Track->TrackName);
      fprintf(Fp,"%d,PntCnt\n",Track->SplinePath.NodeCnt);

      PntCnt = Track->SplinePath.NodeCnt;
      for(PntIndex= 0 ;PntIndex < PntCnt;++PntIndex)
      {
         fprintf(Fp,"%lf,%lf,%lf\n",Track->SplinePath.Pnts[PntIndex].x,
                                    Track->SplinePath.Pnts[PntIndex].y,
                                    Track->SplinePath.Pnts[PntIndex].z);
      }
   }



Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: MakeAHMap and AH3
« Reply #7 on: January 05, 2016, 07:51:13 PM »
Hitech: in the .tra file are the text descriptors after the comma actually necessary, or can I leave them out (to save space, a 512x512 terrain I'm working on has about 25K points in several hundred river segments).

Edit: actually never mind.  Because the number of elements is way less than the number of points total, it wouldn't make much difference at all.
« Last Edit: January 05, 2016, 08:12:34 PM by 715 »

Offline hitech

  • Administrator
  • Administrator
  • *****
  • Posts: 12315
      • http://www.hitechcreations.com
Re: MakeAHMap and AH3
« Reply #8 on: January 06, 2016, 11:44:21 AM »
715:

They are not necessary, I simply put them there to make the file easier to read.


Also what is the spacing you are using between points? That's sounds like a very large number since we already smooth with splines?

If so I may wish to write an optimizer to remove points X distance from the spline curve.

BTW the hold up on the rivers & roads is how do do an efficient collision and culling system. Nothing has jumped into my head yet.

HiTech

« Last Edit: January 06, 2016, 11:52:34 AM by hitech »

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
Re: MakeAHMap and AH3
« Reply #9 on: January 06, 2016, 12:23:38 PM »
BTW the hold up on the rivers & roads is how do do an efficient collision and culling system. Nothing has jumped into my head yet.

HiTech

Just a thought...

Basically if you ignore a rare case of "road higher the terrain" you can just rasterize the roads/rivers and just check upon collision with the ground what kind of surface it is. Having a simple grid/sub-grid spatial index would make it easily O(1) operation.
Artik, 101 "Red" Squadron, Israel

Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: MakeAHMap and AH3
« Reply #10 on: January 06, 2016, 03:24:56 PM »
Also what is the spacing you are using between points? That's sounds like a very large number since we already smooth with splines?

If so I may wish to write an optimizer to remove points X distance from the spline curve.

HiTech

I have no control over the spacing.  The numbers I quoted are for the WBDII portion of the fine resolution GSHHG GIS dataset.  That is actually a pretty coarse dataset (much coarser than the SRTM WBD set that I wanted to use).  However, it's the only one I can use as most rivers are defined by a line which allows importing into your river path file. SRTM WBD is way more detailed, but it defines rivers the same way as lakes, as closed polygons, thereby defining the path of both left and right bank shorelines.  So far I cannot conceive of an automatic way to convert a closed polygon into a spline path.  I've not even had much success doing it manually either in the TE and I can't seem to create anything but the simplest blob like lake.  Maybe I'm missing something.

If that's too many points then it's probably up to me to write an optimizer routine for my program to remove points so I'm not importing too many points. (Edit: or just use the lower resolution versions of that database instead of the fine one.)  It won't be easy to do that intelligently (but the lower res databases have probably already solved that).  (I can't see anyone using the TE to generate too many path points manually that you'd have to have a routine to reduce them in your code.)  First I'll try importing at full resolution and see if it chokes the TE.  Each path is limited to 256 points right?  (I'll have to break some river segments into sub segments as some have more than 400 points.)
« Last Edit: January 06, 2016, 03:31:35 PM by 715 »

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
Re: MakeAHMap and AH3
« Reply #11 on: January 06, 2016, 03:30:26 PM »
...The numbers I quoted are for the WBDII portion of the fine resolution GSHHG GIS dataset...

Are we working on same stuff?

makeahmap uses GSHHG data to create rivers on the map for AH2 terrains. But in AH2 it uses waterd to mark them. So in AH3 it probably should be path - something I want to do.
Artik, 101 "Red" Squadron, Israel

Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: MakeAHMap and AH3
« Reply #12 on: January 06, 2016, 03:43:06 PM »
Are we working on same stuff?

makeahmap uses GSHHG data to create rivers on the map for AH2 terrains. But in AH2 it uses waterd to mark them. So in AH3 it probably should be path - something I want to do.

Yeah.  (But I'm just coding to keep my brain from atrophying.)  I actually wanted to use the SRTM WBD dataset as it is way more detailed than GSHHG.  GSHHG is kind of coarse; most rivers (virtually all in Europe) are defined only by path with only very crude information about width (4 values of river "importance").  Some sections of rivers, like those behind dams, are defined as lakes, i.e. closed polygons, and I'm at a loss on how to convert them to AH3 spline path + width.  I'd be interested in any ideas you have on that.

Offline artik

  • Silver Member
  • ****
  • Posts: 1907
      • Blog
Re: MakeAHMap and AH3
« Reply #13 on: January 07, 2016, 09:07:34 AM »
Some sections of rivers, like those behind dams, are defined as lakes, i.e. closed polygons, and I'm at a loss on how to convert them to AH3 spline path + width.  I'd be interested in any ideas you have on that.

GSHHG has two sets: sea/land/lake/land sets of polygons and rivers as "lines" it actually makes it simpler to integrate it into TE. Of course the biggest problem is Lake as you need water above the sea level.

If HTC would be so kind to allow water at non-0 altitude it would make stuff much simpler :-)

What I can think of is something like that:



It looks like the track has source radius and destination radius or in general I can create a circle with it. So I can start filling the lake with circles using Monte-Carlo method allowing some overlapping from big to small.

Or start from borders:



And increase "river" width each time going inside.

Also I think it would be good idea if some lakes are huge or not to high above sea level just put them on altitude 0 regarding their geographical altitude.




This way or another currently TE brings my Laptop to BSOD once I try to add a river in it...   :mad:  So I'll start from basic terrain and than go to lakes and rivers.
Artik, 101 "Red" Squadron, Israel

Offline 715

  • Silver Member
  • ****
  • Posts: 1835
Re: MakeAHMap and AH3
« Reply #14 on: January 07, 2016, 10:23:22 AM »
I am almost certain that source and destination radius parameters are not what you think.  I've played with that in the terrain editor and it had no effect on the river appearance.  I suspect they have something to do with supply.  Also, using multiple overlapping river paths to construct a water feature creates artifacts as currently implemented because the river banks overlap.  However, I think the river rendering is maybe only preliminary.  Edit: I like your second idea, although it will probably also have problems with overlapping visible banks.  I'll try that manually and if it works then there is the hard topological problem of coding it automatically.  ;)

So, Hitech, how big a bribe would a closed polygon lake object cost us?  :)
« Last Edit: January 07, 2016, 11:04:07 AM by 715 »