Jump to content
Sign in to follow this  
rocket

Some Exciting Developments...

Recommended Posts

Well, I have come up with some new processes to greatly speed up the creations of large maps, using the "import objects" function.

Here's a brief description of them:

Importing Buildings

- I take a point data file in Globe Mapper, export it as a CSV, run it through a Excel VBA macro, and then import instantly into Visitor.

Imported Vegetation

- I took vegetation data in Globe Mapper, exported as a BMP, imported into the BMP to Text program. This gave me a vegetation mask. I then wrote a VBA macro in Excel to read through the file, and randomly place a number of objects based on the brightness of the mask. This macro then exports a list of items to a text file. Then import the text file into Visitor and the objects are all placed!

- I have just tested this process out, and it works.

Just to reitterate, I've now made a way that you can import hundreds of thousands if vegetation items within minutes :) All you do is paint a mask of the area that you want to deploy vegetation, go through some (reasonably complex) export steps, and they're in visitor. No mucking around individually placing them.

I will post some screenshots later today, I'm working with Soul_Assassin for him to develop the tools. In the meantime, I have it all working using Excel 2007 macros if anyone is interested :D

Share this post


Link to post
Share on other sites

I would be interested.

Could you tutorialize the gathering of this data, what site, what to download and so on?

Share this post


Link to post
Share on other sites

So, this is how visitor looks before:

visitor_before.jpg

Then what we do, is create a mask (I used LINZ real world data for vegetation) as below:

mask_bmp.jpg

This is a greyscale map, the value of the brightness decides how many objects get placed inside it. In this case, white means 2 (2 objects per 7.5 meters).

I convert this to a text image (as per below);

mask_text.jpg

And then convert this in Excel using a macro I will post shortly. This generated over 200,000 objects. I imported these into visitor below:

visitor_after.jpg

Edited by Rocket

Share this post


Link to post
Share on other sites

Closeup of the results:

visitor_close.jpg

And in buldozer:

bulldozer.jpg

The whole process took 12 minutes. Not bad, for 204300 objects :)

---------- Post added at 07:08 PM ---------- Previous post was at 07:04 PM ----------

This is the macro I used to populate the data, and I used ImageJ to convert the greyscale map to a text file. I placed // at the bottom of the text file to ensure all data was made.

I'll post up a tutorial and download links soon. Hopefully Soul_Assassin will be able to create a command line tool that does it all automagically.

Edited by Rocket

Share this post


Link to post
Share on other sites

Nice work, looks interesting, are you guys planning to create the tools as an addition to the 3dsmax Arma2 toolset?

Share this post


Link to post
Share on other sites

this is Deeply Impressive!!!

DTED lvl 0 data is available for most countries and usually includes a "nature" or vegetation shapefile... this could be totally invaluable for anyone using real world data! - especially if the vegetation placed could be a random selection similar to the random object placer script!

I'll be watching this with interest!

B

Edited by Bushlurker

Share this post


Link to post
Share on other sites

You can use roller to create a dummy mask based on the terrain height.

Might be useful in some cases here too.

Share this post


Link to post
Share on other sites
Nice work, looks interesting, are you guys planning to create the tools as an addition to the 3dsmax Arma2 toolset?

nope just a seperate comandline tool with a few inputs to turn the text image into a object placement file that can be directly imported into Visitor. written in C++.

Share this post


Link to post
Share on other sites

I am very interested in this process. Please let me know of any developments.

Share this post


Link to post
Share on other sites
comandline tool with a few inputs to turn the text image into a object placement file that can be directly imported into Visitor. written in C++.

Please make it open source so we all can learn :)

Share this post


Link to post
Share on other sites

Im still very new to c++ and this would be the first prog that saw the light of day so I'm positive there are even better ways to do this, so don't laugh :)

#include <fstream>
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main()
{
char fileName[64];
char fileNameOut[64];
char objectType[64];
float squareSize;
float density;
int maskSize;
int ender;
int num = 0;

char * cstr, *p;

cout << "            "<< endl;                                                           
cout << "            "<< endl;                                                             
cout << "                           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@    "<< endl;           
cout << "                             @@111111111111@111111111111@@     "<< endl;            
cout << "                               @@1111111111@@111111111@@          "<< endl;         
cout << "                                @111111111@ @111111111@           "<< endl;         
cout << "                 *********      @111111111@ @111111111@     **********   "<< endl;  
cout << "                 *0000000*      @@@@@@@@@@@ @@@@@@@@@@@     *000000000*  "<< endl;  
cout << "                 *0000000**************  *******      @******000000000*   "<< endl; 
cout << "                 *000000000000000000000***000000*     *000000000000000*   "<< endl; 
cout << "                *00000000000000***000000**0000000*   *0000000000000000*    "<< endl;
cout << "                *00000000000000* *000000**0000000*   *0000000000000000*    "<< endl;
cout << "                *00000000000000***000000**00000000* *000000000000000000*  "<< endl; 
cout << "               *00000*00000000000000000***000000000*00000000000000*0000*   "<< endl;
cout << "               *00000**00000000000000**  *000000000000000000000000**000*   "<< endl;
cout << "               *00000**000000000000**    *000000000000000000000000**000*   "<< endl;
cout << "               *00000* *0000000000000**  *000000000000000000000000* *000*  "<< endl;
cout << "              *00000****00000000*000000* *00000**000000**00000000****000*  "<< endl;
cout << "              *0000000000000000**000000* *00000* **00** *000000000000000*  "<< endl;
cout << "              *0000000000000000* *00000* *00000*   **   *00000000****000*  "<< endl;
cout << "            ***00000****0000000* *00000***00000*        *00000000*  *000***"<< endl;
cout << "            ***00000*  *0000000* *0000000000000*        *00000000*  *00000*"<< endl;
cout << "            *********  ********* *********@*@***        **********  *******"<< endl;
cout << "            *                   @@@@@@@@@@@ @@@@@@@@@@@                  "<< endl;  
cout << "                                @555555555@@5555555555@                   "<< endl; 
cout << "                               @@5555555555@5555555555@@                   "<< endl;
cout << "                             @@555555555555@555555555555@@                 "<< endl;
cout << "                           @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@               "<< endl;
cout << "                                                                           "<< endl;

cout << "maskMapper v1. Object pacement for ArmA2.\nCoded by Soul_Assassin; concept by Rocket.\n2009 (c) Soul_Assassin\n-------------------------------------------------\n";
cout << "Source File Name (e.g. input.txt):\n";
cin >> fileName ;
cout << "Output File Name (e.g. output.txt):\n";
cin >> fileNameOut ;
cout << "Mask Size (pixels):\n";
cin >> maskSize ;
cout << "Object Type:\n";
cin >> objectType ;
cout << "Square Size:\n";
cin >> squareSize ;
cout << "Density:\n";
cin >> density ;
cout << "------------------------------------------------\n";

int x = 0;
int y = maskSize-1; 
float yPos;
float xPos;
float xPosObj;
float yPosObj;
float angObj;
float numObjectsFloat;
float randX;
int numObjectsInt;

ifstream fin(fileName);
ofstream fout(fileNameOut,ios::app);

if (!fin)
	cout << "File Does Not Exist!\n";

while (y>=0)
{
	yPos = y * squareSize;
	string tmp;
	getline(fin,tmp);
	if (tmp != "")
	{
		cstr = new char [tmp.size()+1];
		strcpy (cstr, tmp.c_str());
		p = strtok (cstr," \n\t");
		while (p != NULL)
		{
			xPos = x * squareSize;
			int data;
			data = atoi(p);
			numObjectsFloat = (float)data/255 * density;
			numObjectsInt = (int)numObjectsFloat;
			for (int j = 1 ; j <= numObjectsInt; j++)
			{
				randX = (float)rand()/(float)RAND_MAX;
				xPosObj = xPos + ( rand() % (int)squareSize) + randX;
				yPosObj = yPos + ( rand() % (int)squareSize) + randX;
				angObj = randX*360 - 180;
				fout << "\"" << objectType << "\";" << xPosObj << ";" << yPosObj << ";0;" << angObj << ";" << endl;
				num++;
			}
			p= strtok(NULL," \n\t");
			x++;
		}
		delete[] cstr;
	}
	y--;
	x = 0;
}


fin.close();
fout.close();
cout << "Finished! Created "<< num << " objects successfully.\n";
cin >> ender;
return 0;
}

Share this post


Link to post
Share on other sites

I'll have the tutorial up in a few hours.

I've also written a VB program to create "lines" of objects. For example, for powerlines. You just write the co-ords in a text file, run the script, and it writes the stuff for input.

I'll see if I can get soul_assassin to turn this into a C++ program also.

Share this post


Link to post
Share on other sites

Can we use the lines for roads too... hmm not really asking, just thinking out loud. I mean it does straight objects? Can it do curves like in roads?

Share this post


Link to post
Share on other sites

RE: MaskMapper

I have written up the tool download page on the wiki at:

http://community.bistudio.com/wiki/MaskMapper

Download link is there.

I have also put up a detailed tutorial at:

http://community.bistudio.com/wiki/MaskMapper_Tutorial_for_Visitor_3

RE: LineMapper

This is still being tweaked, it MIGHT be possible to use it for roads, not sure how to create them yet. I only have it written in VB so its a bit of a pain, but should be easy enough to convert. I use trigonometry to work out direction and angles, will post some more info when I have refined it somewhat. I just placed 10km of powerlines with ease... :)

Share this post


Link to post
Share on other sites

This is truly fantastic! It should increase the rate at which maps are created.

Thanks gents!

Share this post


Link to post
Share on other sites

Well done.

Roller from Spooner has a command line tool called Split.exe.

It splits a text file to 200 KB files each. That was our max for importing objects.

Share this post


Link to post
Share on other sites
It splits a text file to 200 KB files each. That was our max for importing objects.

Really? I've been able to import 1.2 million objects as my maximum in a single import before visitor crashed - with the file size about 32mb. Mind you, Visitor ballooned to nearly 4GB in ram used... I'm running Vista 64bit here, with 6GB of ram. I'm able to import more than that, if I import five hundred thousand at a time. Perhaps the limit is RAM related.

Share this post


Link to post
Share on other sites
Sorry I meant 200k objects. Not sure how big of a file that is.

Actually Spooner made it possibly to specify the amount of lines/objects you want

per file:

http://dev-heaven.net/wiki/23/Split

I think 200k is a good limit of objects to import per time. On that note, does the overall amount of objects affect map performance, or is it the amount streamed in at that time that does (ie, the density)?

On my 30km x 30km map, I'm trying to decide on a sensible tree budget. Any thoughts or experiences?

Edited by Rocket

Share this post


Link to post
Share on other sites

Just gave this a try... works perfectly!

shapefile > mask in Global Mapper, followed by the tutorial procedure and into visitor...

VegPlacer.jpg

And in bulldozer...

twees.jpg

No problems whatsoever!

Thanks a million guys!! This is really going to help a lot of people!

Well done!!

B

Share this post


Link to post
Share on other sites

You can get a shapefile, then open it in Global Mapper. A shapefile will have an extension *.shp typically. Then you go 'Export Raster > BMP" and you have your image :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×