L3DT users' community
Large 3D terrain generator

Perform Function without Display

It doesn't hurt to ask...

Perform Function without Display

Postby Rummy » Wed Mar 28, 2007 3:06 pm

It would be nice if we could perform a function, resize heightfield for example, and not have it attempt to render or display after....almost command line if you will. For very large maps it can take as long to display as it did to resize and since I can't perform another function until it finishes it slows work flow. It kind of defeats the purpose for some where you need to see the output but as with most GIS programs displaying really large files is not always a good thing (most allow you to work and display certain areas) and with something like a resized HF it can be a lengthy process given that your tile size is now much smaller....am I making sense?
Rummy
Contributing member
 
Posts: 49
Joined: Wed Jan 31, 2007 2:28 pm

Postby Aaron » Thu Mar 29, 2007 1:00 am

Hi Rummy,

Thanks for the request. I'll put a simple command-line-esque plugin on the to-do list.

Cheers,
Aaron.

PS: You can cancel the map redraw using the 'cancel' button if it's taking too long.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby Rummy » Thu Mar 29, 2007 1:26 am

Hi Aaron, thanks! I canceled but could not perform anything else as it said the heightfield map was busy. It's not a terribly big problem but if I want to try different climate settings for my attribute map it needs the HF displayed...is that correct?
Rummy
Contributing member
 
Posts: 49
Joined: Wed Jan 31, 2007 2:28 pm

Postby Aaron » Thu Mar 29, 2007 2:05 am

Hi Rummy,

No, that just sounds like a bug. Cancelling the rendering should not leave the heightfield in a busy state. I'll look into it.

In theory, the operations should work regardless of which map is displayed (exceptions: export active map, split to mosaic, combine mosaic, and duplicate tile borders, which depend on the map that's displayed).

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

Postby Aaron » Fri Mar 30, 2007 12:26 am

Hi Rummy,

Following-up on the command-line stuff, I've started to implement the plugin (ZeoScript). At the moment, the scripting plugin can only handle function calls with arguments that are basic data types (int, float, string, etc.) This means you can run basic scripts like:

Code: Select all
project.SaveProjectFile "C:\my data\this is a test.proj"


... to save the map project. I still have to implement handling of more complex data types like maps and file formats, but that should be fairly quick work. Anyway, once that's settled you'll be able to do stuff like:

Code: Select all
// resize the heightfield to 512x512.

calc.map.Resize <m:HF> 513 513

// PS: line comments are supported using //


or:

Code: Select all
// export the heightfield as a PNG
file.SaveMapFile <m:HF> "C:\tempdir\tempmap.png" 0 false true


or maybe even:

Code: Select all
file.SaveMapFile <m:HF> <z:file.SaveAsDlg "png" "PNG images (*.png)|*.png|"> 0 false true

// this example calls the function 'file.SaveAsDlg' to open a file-save
// dialog, to get the filename to save the png.
// It doesn't work yet, but when it does...!


The list of available functions to be called (e.g. 'file.SaveMapFile') is already viewable in the 'atFuncBrowser' plugin (installed by default), which you can open using the 'Extensions->atFuncBrowser->Browse functions' menu option. Of particular interest may be the functions under 'calc->HF', which includes the lion's share of L3DT's heightfield effects. Once I've got those '<m:...>' and '<z:...>' things working, you'll be able to run them all. I was going to add menu options for all of those functions, but now I think I'll scupper that idea since they'll be accessible via ZeoScript.

Anyway, as I said above, it's not quite ready yet. If I have the time, I'll get this going tonight, but otherwise it will have to wait until next week.

Cheers,
Aaron.
Last edited by Aaron on Fri Mar 30, 2007 3:11 am, edited 1 time in total.
User avatar
Aaron
Site Admin
 
Posts: 3696
Joined: Sun Nov 20, 2005 2:41 pm
Location: Melbourne, Australia

Postby Rummy » Fri Mar 30, 2007 1:03 am

:D This sounds great.
Rummy
Contributing member
 
Posts: 49
Joined: Wed Jan 31, 2007 2:28 pm

Postby carldt » Sat Mar 31, 2007 11:53 am

With cdPython (0.9), this task should be as easy as

Code: Select all
import zeolite

zeolite.calc_HF_ScaleMap (zeolite.cvar.theAPI.project_GetMap('HF'), 0.5, True)


However, on L3DT Version: Std 2.5 build 16
Build date: 04-Mar-07

I get a bunch of errors in the log:

VARFAC_CopyValues error
- type 'map' cannot be copied

CVar::SetValue error:
- cannot copy data

calc_HF_ScaleMap error:
- heightfield not initialised

zeofunc_calc_HF_ScaleMap error:
- call to calc_HF_ScaleMap failed

CZeoFunc::CallFunction error:
- The function 'ScaleMap' in the plugin 'L3DT-CORE' returned an error.


The generated wrapper code for ScaleMap is:

Code: Select all
void calc_HF_ScaleMap (ZMAP hMap, float val, bool ShowProgress)
{
    static ZFUNC hFuncScaleMap = NULL;
   
    if (hFuncScaleMap == NULL)
        hFuncScaleMap = theAPI.zeofunc_GetFunc("calc.HF.ScaleMap");

    ZLIST hArgs = theAPI.var_CreateTemp(VarID_varlist);
    /* create all the args here */

    ZVAR hVarhMap = theAPI.list_CreateItem(hArgs, VarID_map, "hMap");
    theAPI.var_SetValue(hVarhMap, &hMap);

    ZVAR hVarval = theAPI.list_CreateItem(hArgs, VarID_float, "val");
    theAPI.var_SetValue(hVarval, &val);

    ZVAR hVarShowProgress = theAPI.list_CreateItem(hArgs, VarID_bool, "ShowProgress");
    theAPI.var_SetValue(hVarShowProgress, &ShowProgress);

    ZVAR hRetVar = theAPI.zeofunc_Execute(hFuncScaleMap, hArgs);
    return;
}


Aaron, can you spot a bug in the generated code?
carldt
Contributing member
 
Posts: 39
Joined: Mon Mar 05, 2007 7:38 am

Postby Aaron » Sun Apr 01, 2007 6:03 am

Hi Carl,

Where you do:

Code: Select all
theAPI.var_SetValue(hVarhMap, &hMap);


You should do:

Code: Select all
theAPI.var_SetVarRef(hVarhMap, hMap);


SetVarRef makes hVarhMap an alias of hMap (it accesses the same data). This way, a copy of the map is not created, which is important given the size of those things. Generally, when passing large objects around, I'll use SetVarRef to avoid copying the data.

The purpose of var_SetValue (and var_GetValue too) is for is accessing simple data types like integers, where you can do stuff like this:

int i = 50;
theAPI.var_SetValue(hVar, &i);

That is, the second argument is a handle to the actual data type wrapped by the variable. In the case of a map variable, the data type is a class, the source code for which is not provided with Zeolite, so you can't call var_SetValue with a map (same goes for the other classes like formats, lists, etc).

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

Postby carldt » Sun Apr 01, 2007 8:55 am

Aaron,

Thanks, I have modified my Python C API generator script to take into account types that are set by reference (temp.GetTypeID() >= zeolite.VarID_colour and temp.GetTypeID() <= zeolite.VarID_ProgBox).

I'll upload cdPython-0.10 shortly.

The above example doesn't give me errors now, however I don't really notice any difference in the HF.
carldt
Contributing member
 
Posts: 39
Joined: Mon Mar 05, 2007 7:38 am


Return to Feature requests

Who is online

Users browsing this forum: No registered users and 6 guests

cron