Game Development Community

dev|Pro Game Development Curriculum

TSE: Atlas terrain import GUI

by Neo Binedell · 07/12/2005 (11:35 pm) · 52 comments

Download Code File

Playing around with generating atlas terrain from L3DT heightfields and textures I got fed up with having
to type in everything everytime so I created a quick little GUI for it. I also added a new file
load dialog gui as the stock dialog does not allow for directory selection, etc.

Unzip the file into your "tse/examples" directory.
The files sit in a seperate dir in "examples/common/ui/nx" so it wont overwrite anything.

All you need to do then is to add the following lines to "examples/common/client/canvas.cs"
right after the "Common Gui's" execs and it will be part of your default setup and can be used just
like any other default guis:

...

   //
   //   NX extensions
   //
   exec("~/ui/nx/NXInit.cs");

  ...

Then to access it just press CTRL + F12 and it will pop up the gui to ease the pain of
terrain generation ;p

I'll add progress display etc, in the future

Hopefully this will help the multitude I've seen in the forums who have trouble with this...

[update - 2006-03-07]

Added button to calculate leaf size for textures automatically.

[/update]

~ neo
#21
05/25/2006 (8:46 am)
Zip mailed to your public e-mail address...

~neo
#22
05/25/2006 (9:24 am)
Nope I'm on Window XP and using Visual Studio for my editor and Izarc for the zip manager. None have ever let me down before. So it's wierd. No the attachment to my email was the same. But thanks for the response. Would you send the NXAtlasCreateDlg.gui file to my email by itself. Would be greatly appreciated.
Shon
theatomizer.com
#23
05/25/2006 (9:35 am)
Ok, I've mailed everything to you unzipped just to be sure.

~neo
#24
05/26/2006 (7:41 am)
Neo,

Yes I got it and thank you very very much, it worked great. we are not sure why we were getting a corrupt file, but that fixed it and is working good. Your the Man Neo. DT/Maylock thanks you as well and says your awesome.
Shon
#25
05/26/2006 (7:48 am)
Well a tool is only valuable if it works AND you can get it ;p

Good luck and be sure to keep us all updated with progress, etc...

~neo
#26
05/26/2006 (8:35 am)
Hay Neo,

Maylock aka DT DeathTwister here, I have a quick question if I may? I noticed the posts above about:

Quote:So if, in range, it goes from -200m to +400m, the range is 600? I tried something close and it seems to work OK. It is more intuitive!

This really helps the process tremendously!

Neo Binedell (Mar 18, 2006 at 07:09)
Yup you are correct, the range is 600. You can see it on the height map menu in L3DT.

So if that is true I am a bit confused here. I looked in my height field and it went from -186 to +2425/ So should I put in that field 2611?

I looked in my height field map and it said in text:
virt-scale 0.040174
virt-offset -195.141479

I am not sure which one I should be using? sorry for a dumb artist question here. My associate is in town ATM.

DT
#27
05/26/2006 (9:13 am)
There are no dumb artists, just dumb or non-intuitive tools ;p

The range is the vertical range used in the terrain: basically the distance from the lowest
point in the terrain to the highest point. This range then gets mapped to the 16 bit range of the
raw file. It is much easier and more intuitive to work with than all the floating point nonsens ;p

To find the range in L3DT, go to operations/heightfield/change vertical scale

www.neoji.co.za/neo/gg/L3DTRange1.png
And use the Range value.

www.neoji.co.za/neo/gg/L3DTRange.png

~neo
#28
05/26/2006 (9:24 am)
PS:

Quote:
So if that is true I am a bit confused here. I looked in my height field and it went from -186 to +2425/ So should I put in that field 2611?

Indeed, it works as simply as this:

range = maxHeight - minHeight
so
range = 2425 - (-186) = 2425 + 186 = 2611

~neo
#29
05/26/2006 (9:29 am)
Woot thanks,

DT
#30
05/26/2006 (9:43 am)
WOW, just saw this. Don't know how I missed it but.

There are no dumb artists, just dumb or non-intuitive tools ;p

Quote:The range is the vertical range used in the terrain: basically the distance from the lowest
point in the terrain to the highest point. This range then gets mapped to the 16 bit range of the
raw file. It is much easier and more intuitive to work with than all the floating point nonsens ;p

To find the range in L3DT, go to operations/heightfield/change vertical scale

Oh ya, this helps allot thanks for showing me exactly where that was puppy was. My calcs were slightly off BTW, now have the right info, KK ready to go now so restarting comp and going for it /smiles.

Thanks bro you have been most helpful to not just me I am sure. Think one of us should make a good tut for Aaron on this I think. I will when I get it down if no one else has the time, but I have to get it down first, ROTFL. Ah, but feel free Neo to do it. /winks...There is allot of steps though to get it into TSE all in all.

DT
#31
05/26/2006 (11:28 am)
Hay Neo,

dang, When I tried to import my terrain into I had the GUI up and have filled in.....

Mesh
size at 1024
square size at 2
error metric at 2
and tree depth at 6 (should be 5?)
and my height range was 2634

texture
Size 1024
Tree depth 6
leaf size 32 "when calculated".

Here is my problem atm.

When I tried to generate a chunk file, it didn't that I could see anywhere (what dir will it go to?) and when I hit the texture generate button, it flat out crashed TSE. Going to take another look and shot at it while I get help. you guys are great, once I get this down I'll be a monster hahahaha.

I am not at all sure about that size thing? even though that is what I thought I was supposed to do. I had the texture at 4096+ the one pixel (4096 to 4097), and I did that to the .raw file as well. But I have tried both ways with the extra pixel and without the extra pixel, seems to crash the same here. Not sure if that is the problem, or just dumb me?

Monks has a post he just posted about this and I am going to look at it as there was something about minus 1 on the tree depth, so maybe recalc it again?

My porgrammer had to go to the emergency as since his hand operation his hand has been getting worse not better so I can't get his help for a bit till he gets back. he is in much pain and chances of him helping today are about nill now I think.

Here is what I am trying to import to TSE.

www.theatomizer.com/postedImages/VG1f12.jpg

Not sure what me doing wrong atm.

DT
#32
05/27/2006 (10:31 am)
A quick update for the weekend.

We have found the TSE milestone 3 we have, does not seem to work with your gui for us anmyway. It all compiled great when we did it, but it wouldn't make a chunk and the texture crashed so fast to the desktop when hitting the process button that it made your head spin, then we figured it maybe was the build as we know the GUI works great.

So we put it in TSE milestone 2 and I have been able to generate a chunk file now WOOT.

But now the texture button when I hit Process it don't do a thing:cry: and I am so close to. Here is a screen shot of the texture editor, and I will take a closer look at what you are saying. hehe I am so close now, once I get this figured out I will be one happy artist Laughing Laughing Laughing Cool Cool Cool . I do have both with the extra pixel as well btw. /smiles...

www.theatomizer.com/postedImages/ImportTextureL3DT2TSEv2.jpg
Here is also a screen of the chunk I did get and I have no idea ATM why the texture didn't do anything.

www.theatomizer.com/postedImages/ImportMeshL3DT2TSEv2.jpg
So I am at kinda loggerhead now. Will re-read this post and others on L3DT site and see what I am missing still. But for sure, part of it was the version of TSE we have on version 3. the rest will work itself out I am sure. Thanks for the help and yes, I just about have it I think, or at least getting there.

Hope this all helps me to get this figured out.

DT Twisted Evil Maylock
_________________
Quantum Psychics is the future of man, as he stands up and takes stock of his mind. he can for the first time build a new reality.

ATOMIX Productions
www.theatomizer.com
#33
05/27/2006 (4:01 pm)
@Maylock:

Sorry only got back to my PC now. I'm using the latest head from CVS and the GUI works fine here.
To make double sure I just generated a terrain from scratch, loaded it up and ran around on it.
No problemo. Did you get any error messages in the console?

Just to recap:

Your RAW/CHUNK file should be 1 pixel bigger on both X and Y than the size you put in the GUI.
So the actual size is e.g. 1025x1025 and you enter 1024 in the size field.
The texture does not need the extra pixel stuff.

Forgot to add, your square size should be the same as what you set on the map (horz. scale) and
the GUI will save out the terrain to the path and filename set in the output file text box. From your
screen shot that looks like "common/ui". I usually place all terrains in a seperate terrain dir so I know
where to find em if I forget where I put em (yes it happens ;)

Other things to try is to lower your tree depth and up your error metric until it produces something.
Then reverse the operation until it breaks again.

~neo
#34
05/28/2006 (6:57 am)
Good morning Neo,

Hay maybe bring this over to L3DT on a post I have going so I am not double doing this, or here? The link is:

www.bundysoft.com/phpBB2/viewtopic.php?p=1006#1006

I have gotten a chunk to generate now in M2, not sure what build on M3 I have atm, /chuckles....but no texture can I generate and here is an excert from my console log to show you . Then i'll come back and post an answer in this? in case I am not the only one to find this both now and later../smiles. I know I am doing something wrong, just not sure exactly what yet. But I am close.

The error log goes though like this:

Quote:*** Load Main Menu
path: ~/data/terrains/
calb: nxATCDDoSetInputFile
spec: *.raw
path: *
path: ~/data/terrains/
calb: nxATCDDoSetInputFile
spec: *.jpg
path: *
leafsize: 128
NX::AtlasCreateDlg: running texture import...
NX::AtlasCreateDlg: common/ui/VG1f_TX.jpg
AtlasTQTFile::createTQT - Invalid treeDepth/tileSize (2 ^ (6 - 1) * 128 != 4097)
Done!
NX::AtlasCreateDlg: running texture import...
NX::AtlasCreateDlg: common/ui/VG1f_TX.jpg
AtlasTQTFile::createTQT - Invalid treeDepth/tileSize (2 ^ (6 - 1) * 128 != 4097)
Done!
NX::AtlasCreateDlg: running texture import...
NX::AtlasCreateDlg: common/ui/VG1f_TX.jpg
AtlasTQTFile::createTQT - Invalid treeDepth/tileSize (2 ^ (6 - 1) * 128 != 4097)
Done!
leafsize: 256
NX::AtlasCreateDlg: running texture import...
NX::AtlasCreateDlg: common/ui/VG1f_TX.jpg
AtlasTQTFile::createTQT - Invalid treeDepth/tileSize (2 ^ (5 - 1) * 256 != 4097)
Done!
leafsize: 128

my mesh is 1025 like ya said and have changed texture back to 4096, but am still getting this error message.

DT
#35
05/28/2006 (12:14 pm)
My guess is that you put 4096 in the GUI but have not changed the size of the texture back to
4096. When the TSE code reads the jpg file it finds that its header says 4097x4097 and has a fit.

Let's run through it from the top:

1) You create the terrain in L3DT e.g. 1024x1024, horz.scale of 1.
2) Horz. scale means each vertex/height sample is 1 meter apart. If for example you entered
1 in L3DT and then entered 4 in TSE everything would look a lot flatter as the points are scaled out
4 times along the x/y axis.
3) You generat all the maps needed (height map,attribute map,normal map,texture map)
4) You want a more detailed texture so you make it say, 4096.
5) You either resample the height map or resize the RAW file to get the mesh to be 1024+1 = 1025.
6) You run TSE, select the mesh import and enter 1024 for size and fitting values for the rest.
7) You should now have a mesh. You select the texture import and enter 4096 as the size and fitting values for the rest.
8) The texture must be a power of 2 (when you generate it AND in the GUI). The extra 1 pixel stuff is JUST FOR THE MESH.
9) You set up your mission to load that CHU and TQT file and run around it and say YAY!

~neo
#36
05/29/2006 (6:24 am)
Dang,

OK I want that /wry smile....... Yup, I almost have it and yes I agree I did have my map at texture map 4097, but then I re-did the size issue, I still get the 4097 error message now. It will not go away at all, still says it is 4097 and I know it isn't........

This is so frustrating for me atm. I'm buggered and am about ready to walk away and go for a long walk, haha :lol:.

At this point I am thinking my comp is buggered somehow. My texture is 4096 and can't figure out why it says it is 4097 in the error log??? Have checked it like 5 times now in and out of photoshop and that error keeps coming up. It seems to have a mind of it's own now about the texture sizes. I even tried restarting my comp in case it got caught up in the ram cash somehow :cry: I could swear I have it now, but I don't, I hate comps sometimes ROTFL:roll: haha.

Thanks so much for your help bro, I will endeavor to figure this out. I can see I have the info now and I do think I know how to do all this now, but it sure is being a pesky problem fer me ATM.

Aaron at L3DT is going to set up a Tut for this and Trollfiddler is on it as well so I am sure I and others will get it together here soon.

I sure wish I could figure out why it keeps seeing a 4097 instead of the 4096 graphic that is there now though.
Back into the breach I travel one more time to find the errant graphic I guess, see ya'll soon dudes.

Thanks for trying to help bro, looks like it is all on me now. I will post a screen shot when I get it worked out, thanks bro your the best. I am sure I will get it together one day here soon, got nothing better to do today besides that walk.........Hahahahahahahaha ROTFL, one has to have humor about now so comps don't get thrown across the room ROTFL.

Maylock
#37
05/29/2006 (8:04 am)
Hay brother Neo,

OK WEEEEEEEE------ YAYAYAYAYAYAYAYAYya WOOO HOO I got it........

OK I had figured out it had to be me somehow as I had to be missing something. I was right, somehow I had (misplaced/copied to a wrong dir.) to the wrong place, and while I changed the one I thought was the one I saw in the drop down menu, it wasn't it was in another dir at the root, one up from where I thought it was somehow. I am sure it was my bad ROTFL. So after I changed that 4097 to 4096 all went well. From here on in it will be tweaking all the way I am sure. I gots it I think by golly. Your the wizard Neo, ju da man............as an old Ogre once said.

Need a day or 2 and will post some screens I am thinking both here and on: www.bundysoft.com/L3DT/

Grahpic compitition going on now there as well..../winks

Quantum Psychics is the future of man, as he stands up and takes stock of his mind. he can for the first time build a new reality.
Maylock Aromy Stansbury aka: DT or DeathTwister :twisted:
ATOMIX Productions
www.theatomizer.com
Klamath, CA.
#38
05/29/2006 (8:55 am)
Looks like the walk helped then ;p

Happy to hear you solved the problem. I can't even count the number of times I've burned
myself with wrong dirs.

And I must say that a quick walk or even a cig outside (for those that do) usually opens the
door to DOH!

~neo
#39
05/29/2006 (12:59 pm)
Hay all,

ROTFL ROTFL ROTFL,

Well I have a terrain in now and here is a quick screen shot to show that I actually did it, I can hardly believe it myself, yuk yuk.

www.theatomizer.com/postedImages/TSEm3LG2.jpgAs you can see I have issues with my texture at the moment, but at least I have it in now and the rest is tweaking, and judging but what I see, tweaking one hell of allot.

www.theatomizer.com/postedImages/TSEm3LG1.jpgHEHE I'll get it, IT WILL take a bit but I'll get this puppy to look like what I have in Terragen or the L3DT viewer.

I have questains but I want to think about them before I post next.
One thing I think I did wrong was I flipped the texture file 180 degrees so I didn't have to mess with flipping the .raw file, but I can see that was a mistake. So I will go back and hunt the Tut I saw on that part and see if I can get a fix to start out with on that fopaw. my bad there for sure.

Question:
does the texture file get better Rez on the landscape if it is a bigger size, or a smaller size? I thought it would be better rez if I took it up to 4096, instead of the smaller size that was default in L3dt FOR EXPORT??

Our console log is all messed up also (WHew it got issues), the water block is all messed up (water not showing in block), Texture all messed up (adjustments), but all in all I am a happy camper today, a small step forward.

At least I have forward motion now /winks.

Maylock
www.theatomizer.com
#40
07/13/2006 (6:45 am)
Hey Neo! Any chance you updated this for Atlas 2 yet. Just started reading the docs and lots of new changes. trying to wrap around the .atlas file stuff. Here we go again. Early adopter is such fun!!!!
Thanks Neo;
Shon