Terrian model?

Home Forums AR Sandbox Forum Terrian model?

Tagged: 

This topic contains 22 replies, has 14 voices, and was last updated by  jKrienert 3 days, 2 hours ago.

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #102143

    beldingschools
    Participant

    So on the “Screen Savers show” they are talking about a new feature which is adding a terrain model with blue and red areas. Is this feature released? Would love to play with it.

    #102147

    BrooksideTechTeam
    Participant

    I was also wondering the same thing! Glad to see people are interested in seeing the different modes on it. I’m also wondering if any map changes are possible with the current software. I’m eager to find out!

    #102149

    RafLoncke
    Participant

    Same for me! This sandbox has so many awesome features already and so much that is still possible. I’ll be checking this forums for updates!

    #102166

    redrom
    Participant

    I got chills when I heard that on screen savers. The terrain model feature really hits home for me because I work for a stream restoration design firm. To be able to project an aerial image and have water flow through existing channels and then compare to proposed conditions such as levee setback or reconnecting relic channels…wow!

    #102184

    matthias
    Participant

    Coming from a Landscape Architecture background, and currently using the AR Sandbox as part of my bachelor’s thesis, I’d also love to see that feature implemented. To manipulate a real-world terrain would open up a whole new range of possibilities!

    #102217

    Frank Conforti
    Participant

    Add me to the list of folks interested in adding CAD (Computer Asisted Digging) to the AR Sandbox. Actually, this has been a subject of some casual discussions. A few unsolicited comments (hope Mr. Kreylos is listening!):

    1) Provide a z-axis exaggeration scale especially when modeling real world terrain.
    2) Consider adding contour lines over the “dig here, fill there” color coding. This gives some feel for the how much sand needs to be shifted. An simpler feature might be a fixed grid so the “digger” knows how much to pick up from one square and dump on another.
    3) Provide a “check” feature so that when the “digger” is close to the desired layout highlight the areas that need refining.
    4) Impmenenting multiple passes where the projected colors direct a rough layout first then the more refined layout once the major cut/fills are met.
    5) have the ability to overlay some textual information identifying the elevation values over the projected image at different points (ie, tgt:20cm, curr:5cm.) This would be especially helpful when displaying the projected image on a second monitor (we use such a monitor to display the “plan view” of the terrain)

    As I said, my $0.02, keep or discard.

    #102311

    matthias
    Participant

    Yeah, Frank, these are some good ideas!

    Still hoping this feature gets implemented eventually…

    #102431

    dlay
    Participant

    Is the latest sandbox update (2.2) allowing for this feature with the new support for loading and saving DEM files?

    #102452

    Oliver Kreylos
    Moderator

    Yes, SARndbox 2.2 can load and save DEM files. I need to write detailed instructions, but to load a DEM one needs to create and bind a “Show DEM” tool. This will open a file selection box where one can select a file to load.

    Right now, SARndbox only understands a very simple binary grid format: two 32-bit integers (n and m, number of grid vertices in x and y) followed by four 32-bit floats defining the grid’s left, bottom, right, and top edges in some coordinate system, followed by n*m 32-bit floats defining each grid vertex’s elevation.

    When loading a grid, SARndbox tries to be smart to scale and map the grid to the sandbox rectangle defined in BoxLayout.txt. It’s usually necessary to adjust the grid vertically so that there’s the right amount of sand in the box to build it.

    DEMs can be saved by binding a “Save Bathymetry” tool. When the associated key/button is pressed, the current surface will be written in USGS DEM format.

    #102516

    sharned
    Participant

    I’ve been able to get a “binary grid” file (with totally genned up values) to load into the SARndbox software. The system seems to read the file (and not crash) but when I press the key to “Show DEM”, the topology just turns solid blue. Does this mean I need to “adjust the grid vertically”, or might I have done something else wrong?

    The values in the grid range from a low of 1.03, to a high of 16.85. The grid is only 40 x 30 values, so it’s not like there is a tremendous amount of scaling to do (unless I’ve really misunderstood what’s going on). Any help would be appreciated.

    #102536

    Oliver Kreylos
    Moderator

    If everything is blue, the loaded DEM is below the current sand surface everywhere (blue means too much sand, red means too little sand).

    To adjust the DEM vertically, run the sandbox and load your DEM by assigning a “Show DEM” tool to some button. Once it’s assigned, select “Save Input Graph…” from the “Devices” sub-menu of Vrui’s system menu. Then exit the sandbox and open the file to which you saved.

    It’s the same format as other Vrui configuration files, with one section per assigned tool. Find the section that says “toolClass DEMTool”. Into that section, put a new line
    demVerticalShift 0.0
    then save the file, run the sandbox again, and load the saved input graph from the “Devices” sub-menu.

    You can also put the DEM file name in that section via demFileName so you don’t have to select it every time.

    The trick is to fiddle with the vertical shift value by editing the input graph file until you have just enough sand to recreate the entire DEM. You can edit the file while the sandbox is running, and re-load the changes by selecting “Load Input Graph…” again.

    If you have blue everywhere, use a large negative shift until everything is red. Then bisect until you get it just right.

    #102695

    dlay
    Participant

    I have had trouble finding a source of DEM files that are in the right format (.grid format….I believe?) Does anyone know a source for these files with the right format?

    #102696

    sharned
    Participant

    There really isn’t a standard DEM format that matches what the AR Sandbox can read (at least not right now). The format is simplified as Dr. Kreylos described above.
    I’ve written my own utility to write some data as described, but it is not “real” data… yet. Maybe soon. I’m still struggling to get my “fake” data to work, but I think I’m on the right track.

    I’ll try to share what I’ve done… if it works.
    S. Harned

    #102866

    sharned
    Participant

    Hi, all!

    I’ve been working with the AR Sandbox version 2.3 and having some fun with DEM files.
    It’s time to share what I’ve been doing and let you all have some fun too.

    I’ve been able to use topography files from aerial LiDar surveys and create grid files from them.
    The grid files are in the format that the AR Sandbox will read. It has worked well so far, but I have not tested it exhaustively.
    You are welcome to try this too, with the caveat that it’s not perfect and may not always work.

    First, below is the text of a simple C++ program to create a “grid” file from real DEM data.
    Copy the lines below to a text file and save it with the name “tin2grid.cpp”.

    
    /* Start copying here */
    /* This code is freely released to the public domain. */
    #include <iostream>
    #include <fstream>
    #include <sstream>
    #include <string>
    
    using namespace std;
    
    int main(int argc, char *argv[])
    {
    	if(argc < 3) {
    		cout << "tin2grid <inputfile> <outputfile>" << endl;
    		return 0;
        }
    
    	std::string line;
    	std::string val;
     	float fval;
    
    	std::ifstream infile(argv[1]);
    	std::ofstream outfile(argv[2], ios::binary);
    
    	//first 4 lines need to be handled carefully
    	int h, w;
    	getline(infile, val);
    	w = stoi(val.substr(6,6));
    	getline(infile, val);
    	h = stoi(val.substr(6,6));
    
    	outfile.write(reinterpret_cast<char*>(&w), sizeof(int));
    	outfile.write(reinterpret_cast<char*>(&h), sizeof(int));
    
    	float xmin, ymin, xmax, ymax;
    	getline(infile, val);
    	xmin = stof(val.substr(10, 40));
    	getline(infile, val);
        ymin = stof(val.substr(10, 40));
        xmax = xmin + w;
        ymax = ymin + h;
    
        outfile.write(reinterpret_cast<char*>(&xmin), sizeof(float));
        outfile.write(reinterpret_cast<char*>(&ymin), sizeof(float));
    	outfile.write(reinterpret_cast<char*>(&xmax), sizeof(float));
    	outfile.write(reinterpret_cast<char*>(&ymax), sizeof(float));
    
    	//next two lines are not needed, but we need to read them to skip them
    	getline(infile, val);
        getline(infile, val);
    
    	while(getline(infile,line))
    	{
    		//skip empty lines
    		if(line.empty())
    			continue;
    		stringstream ss(line);
    		while(getline(ss, val, ' '))
    		{
    			fval = stof(val);
    			outfile.write(reinterpret_cast<char*>(&fval), sizeof(float));
    		}
    
    	}
    
    	outfile.close();
    	return 0;
    }
    
    /* Stop copying here */
    

    After you have saved that you will need to compile it into an executable file.
    You can do that at the command line, using the following:

    $ g++ -std=c++11 tin2grid.cpp -o tin2grid

    That will create an executable named “tin2grid”

    Now to explain what it does.

    You need to start with an Arc ASCII TIN file. This utility will convert it to the Sandbox “grid” format.
    Here’s how to get a file to work with:

    To get an Arc ASCII Grid format TIN file:
    1) Open a browser and go to http://OpenTopography.org
    2) Click “Data” in the menus at the top and choose “Lidar Point Cloud”.
    3) Select a dataset from the list. The Airborne Lidar sets work nicely.
    4) Use the map to zoom in on a relatively small area.
    a. The area where the LiDAR data is available will be highlighted in red.
    b. Zoom in on a small set of features.
    5) Click the “Select a Region” button, then drag a rectangle to select an area.
    6) When your rectangle is complete, look in the green highlighted area of the web page below the map. It will show you how many points are in the data for the area you selected. (If you’re using the site as a “guest” you will be limited to 50 million points of data per request. Aim for about 5 million points or less at first.)
    7) In the “Choose Return Classification” section, turn off “Unclassified”. This will reduce the points somewhat.
    8) In the “Point Cloud Data Download” section, select “Point cloud data in ASCII format”. (This selection is not really important, but one of the selections must be chosen. Only the TIN data will be used.)
    9) In the “DEM Generation (Streaming TIN) section, leave “Calculate TIN” on, and select “Arc ASCII Grid” format in the “Grid Format” menu.
    10) Enter a name for the “Job Title” (it only has to be meaningful to you), a description, and your email address.
    a. These things are required so that you can get an email with links to download the data if it takes a long time to process. Turning off the “Calculate TIN” feature makes it pretty quick though, like a couple minutes in my tests.
    11) Click the Submit button and wait for the process to finish.
    12) You need to download the “DEM Results” that will a file named “output.tin.tar.gz”.
    a. If you download on a Windows machine, you will need 7-Zip or something equivalent to open GZIP archive, and the TAR file within.
    b. Copy the file to your Linux machine where you run the AR Sandbox.
    c. Extract the file named “output.tin.asc” and rename it to something meaningful to you.
    d. Run the tin2Grid utility to convert this to a “grid” file that the AR Sandbox software can read.
    e. Invocation is: tin2grid <inputfile> <outputfile>

    Hope this is helpful to you.
    S. Harned

    • This reply was modified 7 months, 3 weeks ago by  sharned.
    #102894

    siki
    Participant

    I’ve also created a similar tool in Python. My tool converts the dem output of SARndbox direcly to grid format. It can be found on github

    https://github.com/zsiki/SARndbox_util

Viewing 15 posts - 1 through 15 (of 23 total)

You must be logged in to reply to this topic.

Comments are closed.