L3DT users' community
Large 3D terrain generator

Export to xyz format ?

Any and all chit-chat regarding L3DT.

Export to xyz format ?

Postby seafire6 » Mon Mar 30, 2009 1:36 am

Is there any method to export the heightfield map to xyz ASCII format?
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby Aaron » Mon Mar 30, 2009 8:33 pm

Hi Seafire,

The bad news is that L3DT doesn't yet have an XYZ exporter, but I can add it to the to-do list.

In the mean-time, you might like to try the DirectX '.x' exporter, as this writes an ASCII file that contains the X/Y/Z vertex points, which you could probably manually edit into the desired format for XYZ.

Alternatively, you can try a little script I've written that will export the heightfield in an ASCII xyz point list [script follows at end of post]. I'm not sure if it's exactly the format you want, but if not, please reply here with the first few lines of an example file so that I can get the gist. The output of the script as it stands looks like:

file wrote:0, 0, -305.971,
10, 0, -304.724,
20, 0, -302.632,
30, 0, -301.02,
40, 0, -297.852,
50, 0, -295.217,
etc...


To run the below script, select the 'Extensions->ZeoScript->Run script' menu option, and paste the code into the window.

Please note that the script requires L3DT release 2.7 or later. If you do not have this version, I suggest you update now.

Please also note that since this is a script, and not a compiled plugin, the exporter will be extraordinarily slow. It might take an hour or more to do a 1024x1024 pixel heightmap. It may also appear to hang or stop updating the progress bar, but don't worry, it's just not responding to Windows messages whist it exports the file.

Anyway, I suggest you try this with a tiny map first (e.g. 128x128 heightfield pixels or less) before you use it in anger on a larger map. If the output turns out to be not what you wanted, please let me know, and I'll adjust it accordingly. If it is what you want, then I'll bash together a compiled plugin to write the XYZ format properly and much, much more quickly.

Please let me know how it goes.

Best regards,
Aaron.

PS: The script is:

Code: Select all
//
// get map handle, and check size
//

new hvar "hMap"
set hMap <zs:project.GetMapH "HF">

new int "nx"
new int "ny"
set nx <zs:map.GetWidth hMap>
set ny <zs:map.GetHeight hMap>

new float "HorizScale"
set HorizScale <zs:map.GetHorizScale hMap>

assert <zs:isgt nx 0> "Heightfield is not initialised!"

//
// ask user for filename
//

new string "FileName"
set FileName <zs:file.SaveDlg "xyz" NULL "XYZ ascii file (*.xyz)|*.xyz|All files (*.*)|*.*|">
if <zs:iseq 0 <zs:strlen FileName>>
  return 0
endif

//
// prepare progress box
//

new progbox "ProgBox"
new int64 "p"
new int64 "pmax"

set p 0
set pmax ny

progbox.ShowWnd ProgBox
progbox.SetTitle ProgBox "Exporting XYZ"


//
// Open file
//

new voidptr "fp"
set fp <zs:fopen FileName "w">
assert fp "Cannot open file!"

//
// Declare loop variables
//

new int "i"
new int "j"
new float "x"
new float "y"
new float "z"
new string "s"

//
// Here we go!
//

set j 0
do

  // set progress every line
  progbox.SetProgress ProgBox p pmax
  incr p

  set i 0
  do
    set x <zs:mul HorizScale i>
    set y <zs:mul HorizScale j>
    map.GetPixel hMap i j z

    set s <zs:strcat x ", ">
    set s <zs:strcat s y>
    set s <zs:strcat s ", ">
    set s <zs:strcat s z>
    set s <zs:strcat s ",\n">
   
    fwrite fp s
       
  while <zs: islt <zs:incr i> nx>
while <zs: islt <zs:incr j> ny>


//
// Close file
//

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

Postby seafire6 » Tue Mar 31, 2009 12:55 am

Thank you for the reply. I think I'll waite until the official xyz export with L3DT.
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby Aaron » Tue Mar 31, 2009 9:28 am

Hi Seafire,

I can't start work on the 'official' plugin until I know the structure of the file format. Do you have an example XYZ file, by any chance? Alternatively, do you know of a published specification for this format? According to a quick Google, the 'XYZ' file extension is used for a couple of different (obviously incompatible) file formats, and without knowing which one you want, there's not much point in starting on a plugin.

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

Postby seafire6 » Thu Apr 02, 2009 2:08 am

Aaron thank you for your interest. I'm developing new terrain for the simulator VBS2. It requires elevation data in XYZ ASCII triplet format. It also requires a 'satellite ' image (or other texture data) as PNG 24-bit RGB format which I don't think will be a problem for L3DT as it stands. I really hope a plug in can be created. VBS2 is a product of Bohemia Interactive Australia.
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby Aaron » Thu Apr 02, 2009 10:56 am

Hi Seafire,

I have a plugin for you to test. Firstly, you'll need to update to the latest developmental build of L3DT, which is v2.7 build 3, now on the downloads page under the 'developmental builds' heading. You can install this side-by-side with the stable release without one affecting the other.

Secondly, download the XYZ plugin from here:

http://www.bundysoft.com/wiki/doku.php?id=plugins:fileio:l3dtio_xyz

If you've not installed plugins before, instructions are here:

http://www.bundysoft.com/docs/doku.php?id=l3dt:userguide:extensions:install

In the absence of any example files or detailed knowledge of the format requirements, I've made a few guesses about the XYZ format, including:
  • There is no header.
  • The XYZ triplets are floating point, separated by spaces.
  • The coordinate system is defined with X and Y (the first two numbers) in the plane, and Z (the last one) upwards.
  • The X coodinate increases from west to east, the Y coordinate increases from south to north, and the Z coordinate increases from below to above.
If any of these guesses turn out to be wrong, please let me know and I'll update the plugin accordingly.

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

Postby Aaron » Wed Apr 08, 2009 9:54 am

Hi Seafire,

Did you have a chance to test the plugin? Does it produce the format you expected?

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

Postby seafire6 » Thu Apr 16, 2009 1:38 am

Thank you again for the program. It succeeded nicely in exporting an '.xyz' file that I was able to import into the program that I would then utilize to finalize (ie place objects, roads etc ) onto to the terrain created in L3DT. I'm having some trouble though once in the program. It converts the xyz file to a .pew file. Instead of displaying a nice heightfield map I see a featureless light blue screen, and what makes it worse is the hideous shade of blue it is. Any ideas are welcome and I'll continue to work in the program which is called Visitor3. Again I really have to commend your support. It amazes me that you are more help from across the opposite side of the world than I could probably get in person from any shop down the street. Agin, thank you for your trouble,
Mike
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby seafire6 » Sun Apr 19, 2009 3:31 pm

Please disregard the above post. After some additional work I was able to get the L3DT xyz file into Visitor 3 without any problems at all; it worked beatifully. Your xyz conversion plug in was perfect. I'm loudly singing the praises of your product to others in the VBS 2 world. The next task is now to begin work on importing a texture image to serve as a 'satellite image' which the engine uses to set terrain surface textures. The resolution of the image should be either 1,2,4,8,16, or 32 meters/pixel. Is there a way in L3DT to set this parameter on the texture image ? The other question I have is , how can we combine the water image map with the texture map so that we have all of the water properly textured wuth the land in the same image ? Again you help is greatly appreciatted.
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby Aaron » Mon Apr 20, 2009 11:19 am

Hi Seafire,

The resolution of the image should be either 1,2,4,8,16, or 32 meters/pixel. Is there a way in L3DT to set this parameter on the texture image ?


In L3DT, the spatial resolution of the texture map depends on the resolution of the heightfield, and the texture/heightfield size ratio. For example, if you use a horizontal scale of 16m/pixel for the heightfield (as set in the heightfield size wizard), and a texture/heightfield ratio of 8 (as set in the texture wizard), you will get a texture resolution of 2m/pixel.

The other question I have is , how can we combine the water image map with the texture map so that we have all of the water properly textured wuth the land in the same image ?


L3DT doesn't bake the water texture onto the heightfield, as these are two separate surfaces. I suspect you could do this in Photoshop, or else a plugin could be written.

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

Postby seafire6 » Wed Apr 22, 2009 1:37 am

Thanks for your reply, so if I understand this correctly there is no way to have water textures on the texture map ? Where there is water there is only the 'sand' type texture ? I apologize if this is a a noobish question, just trying to understand.
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am

Postby Aaron » Wed Apr 22, 2009 12:03 pm

Hi Seafire,

In short, no, there is no current way to bake the water surface texture onto the terrain texture. The reason is because it would look wierd and wrong from any angle other than directly above.

Consider the image below:

Image

In this cutaway you can see the water texture on the water surface, and the terrain texture on the terrain surface beneath the water. If you were to bake the water surface texture onto the terrain texture, you would end up with a very strange looking seafloor that looked a little like the surface but was non-flat and in the wrong place.

If you really do want the water surface texture baked onto the terrain texture, I could do this on the condition that I also bake the water height onto the heightfield, thereby eliminating the mismatch between a flat water texture on a non-flat seafloor surface. It still wouldn't look as good as a separate semi-transparent water surface with a water texture (see above image), but at least it wouldn't be as obviously wrong as mapping one surface's texture onto another. Would this do?

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

Postby seafire6 » Sat Apr 25, 2009 12:08 am

Aaron thanks for your help. For VBS 2 what I need is just a flat '2d' image with both dry land and water textures on the same image to serve as a 'satellite image' for the Visitor 3 software to then create its own suface textures. Your surface textures, both land and sea/water look great and would suffice for the satellite image without any problems and they would only really to be in the 2d perspective as far as my needs. Again thank you so much for your time and effort, how you find time for it all amazes me.
seafire6
Member
 
Posts: 18
Joined: Mon Mar 30, 2009 1:32 am


Return to General discussion

Who is online

Users browsing this forum: No registered users and 38 guests