PDA

View Full Version : (automatic) terrains from (x,y,z) values?


debeoulve
7th Apr 2004, 03:12 PM
Hi,
First of all, I'm not trying to make a game, but I'm curious if I can use the runtime to visualise scientific (geological) data. So before I dive into the depths of the code/engine, I hope you're willing to answer some newbie's questions (TIA :)

So I have text files with (x,y,z) values, a height table.
1. Is there any way to quickly generate a terrain from those values?

2. Is there any way to write those values directly into an unreal level file and view the results? (this would be really nice to automate the level generation, allowing for real-time interaction between visualisation and modelling)

Thanks in advance!

Jos

ttl
7th Apr 2004, 11:53 PM
1. You could code a program to create a 16bit greyscale bitmap (G16) from your text file, which could in turn be used as a heightmap in a terraininfo actor.

2. Well you cant get much quicker then just selecting a new heightmap in your existing level. But if you wanted to, you could code your own program, but this time have it so it creates an unreal map in .t3d format which is rather basic. My advice though would be just to keep a template map and import your new height maps into the template, and then if you like it and wont to do more with it save it under a different name.

NB: If you are not worried about performance you could make your on brush builder and build your terrain out of it instead, then you could just format text file so it can be loaded as a config file for the builder. However I still think a separate height map generator is the way to go.

Part 2 continued. If I was doing this, I would code my terrain generator in a direct x app and have a preview window where the low vertices were blue and the high white (in between green ie. Sea, grass, snow). So I could preview it without having to import the heightmap into the unreal editor.

Vito
8th Apr 2004, 01:20 AM
Yeah, your best bet is to convert your text data (DEMs?) into a 16-bit greyscale BMP or TGA heightmap, and import that.

You should be able to write a commandlet to generate the map if all you have is terrain and BSP in that regard.

debeoulve
9th Apr 2004, 01:51 PM
Hi,

1. You could code a program to create a 16bit greyscale bitmap (G16) from your text file, which could in turn be used as a heightmap in a terraininfo actor.

OK, that could be done easily. I'm using Matlab (a scientific scripting language) and it supports this 'natively'.

2. Well you cant get much quicker then just selecting a new heightmap in your existing level. But if you wanted to, you could code your own program, but this time have it so it creates an unreal map in .t3d format which is rather basic.

A, directly creating those .t3d files sounds what I would like to do, since i'd like to make something that people who barely know how Windows works can still use. So what would be a good source for looking into this? Any doc about the technical basics of the unreal engine and the file formats?

NB: If you are not worried about performance you could make your on brush builder and build your terrain out of it instead, then you could just format text file so it can be loaded as a config file for the builder. However I still think a separate height map generator is the way to go.

I'm not really worried about performance at all, so this seems interesting as well. Do you have any idea where I should start? I guess I'd like to know:
- what does the .t3d file specification look like?
- how do 'brushes' work and how can they be built?
- what's a good tutorial to learn making easy levels, without any combat/game related stuff?
- why is there no help document for the runutime yet? :-)

Any help with any of these would be highly appreciated

Jos

Vito
10th Apr 2004, 04:33 AM
Make a normal map in UnrealEd that's set up the way you want it. Make a fake terrain using the built-in terrain tools that's the size you want, but instead of storing the terrain in MyLevel, store it in its own package. Save the map. Then export that map to T3D.

When you want to create a new map, make a copy of your T3D file, and in a regular text editor, change the reference to the terrain texture and package name. Make a new package and texture with that new name, using the new terrain you've made. Load up that package in the editor, and then import the T3D, and do a full rebuild. Presto change-o, you have a new map with nearly no work.

And there is a help file for the Runtime. It's called UDN. Start at http://udn.epicgames.com/Content/WebHome and work your way from the top of the table of contents on the left to the bottom.

ttl
10th Apr 2004, 11:31 AM
I'm using Matlab

Which just happens is the best mathematical program around =]



A, directly creating those .t3d files sounds what I would like to do, since i'd like to make something that people who barely know how Windows works can still use.

As Vito said, just extract an existing map. Then you can either write your own exporter from scratch or go the way Vito suggested, which is just to edit the heightmap part of it (so you could say, save all info up until where the heightmap name is meant to go in one text file and the rest in another then simply put them together with the name of the heightmap inbetween).


- what does the .t3d file specification look like?


I dont think there is one, but it is so simple that anyone with basic knowledge of the unreal engine should easily be able to work it out.


- how do 'brushes' work and how can they be built?

Check out BrushBuilder.uc, CubeBuilder.uc and TerrainBuilder.uc in Editor\Classes
NB: This is the "difficult" way of doing things, so dont say I didnt warn you :P


- what's a good tutorial to learn making easy levels, without any combat/game related stuff?

You can google for this one :)


- why is there no help document for the runutime yet? :-)

See Vito's post. Also note that http://wiki.beyondunreal.com CAN be useful, though it tends to be less "exact" and more ut2k3 specific.


Note: you can also do some fancy stuff using #execs if you dont want to go the .t3d way

ttl
14th Apr 2004, 10:01 AM
I just thought I'd mention you can do some pretty cool stuff just using the editor console. I made a few .txt file you can "exec" in the console. I have attached them along with some example heightmaps and a t3d file that the .txt files use. If you wanted to you could code you're external program to to find the console command window in unrealed and send an exec command that loads a .txt file to import your newly created heightmap.

Anyway the example files and a readme is included in the attached zip file.

To give you a general idea of what this does before you download it, here's a cut out from the readme:


batchimport.txt:
opens EM_Runtime.urt imports ..\batchterrain\heightmaps\1.bmp, rebuilds the map with the new terrain and saves the map as TerrainInMap.urt
It then imports ..\batchterrain\heightmaps\2.bmp as the heightmap but this time to the MyPackage_T.utx, it then rebuilds the map and saves the MyPackage_T.utx package in your texture directory and saves the map as TerrainInSeperatePacakge.urt.

How to use: type "exec ..\batchterrain\batchimport.txt" in the editor console.


t3dimport.txt:
imports ..\batchterrain\t3d\example.t3d and ..\batchterrain\heightmaps\3.bmp as the heightmap, then rebuils and saves the map as TerrainFromT3d.urt

How to use: type "Exec ..\batchterrain\t3dimport.txt" in the editor console.

quickimport.txt:
imports ..\batchterrain\hieghtmaps\3.bmp into the current map and sets it as the current heightmap.

How to use: First load the map of your choice (it must have terrain) and type "exec ..\batchterrain\quickimport.txt"



Edit:
The original file was removed, if you want the updated version check my next post.

debeoulve
14th Apr 2004, 10:06 AM
[...] I have attached them along with some example heightmaps and a t3d file that the .txt files use. [...]

Wow, thanks ttl!
I'm at work at the moment (5pm local time), but i'll definitely look into it later.

Jos

ttl
14th Apr 2004, 10:12 AM
np :)

debeoulve
14th Apr 2004, 02:52 PM
These scripts are really useful, and knowing that thay can be made maybe even more so. Playing around with them I find that you have to be patient with the editor though - it tends to crash often and hard... ;)

New questions have risen from your excellent help - importing new terrains (the three bmp files) into the runtime map seems to give some unwanting effects:
- the terrain is not visible generally, just the other stuff (the bridge, waterfall, river, wheatfields etc)
- the playerstart is usually not in a valid place and has to be placed manually, but that could be related to the first issue
- although the terrain isn't visible, trees etc are floating in mid-air, so it seems like the terrain is there but is not rendered. However, walking into the void causes sinking down

any general idea what could be the problem? Or is it just too much to ask of the editor to add a terrain that doesn't match the rest of the level and compute what's supposed to change?

Jos

ttl
14th Apr 2004, 11:19 PM
As for the terrain not showing up, if you were using quickimport.txt for some reason I had height spelt wrong so it was not finding the texture to import it (I dont know how that happened seeing I tested it... I guess I must have "intelligently" decided to change it at some point)

BTW. Press the button directly to the right of the command edit box to bring up the console that way you can see the errors.

I have attached a fixed batchterrain.zip even though I only replaced the first line in quickimport.txt to "TEXTURE IMPORT Name=Heightmap Group=Terrain Package=myLevel File="..\batchterrain\heightmaps\3.bmp""

When and where is it crashing? (ie. how can you reproduce it?)

Also with the playerstart you'll either have to aling it manually or generate a .t3d that defines its location with each of your heightmaps. (or if you only have one you could set playerstart location ... etc)

NB: The zip file must extracted to your runtime directory, so it is for example C:\unrealengine2runtime\batchterrain (it could be c:\anything\batchterrain as long as the runtime is installed there)

debeoulve
15th Apr 2004, 12:59 PM
Sorry for not being more specific. I already changed the slight typo. Actually the terrains import OK in the editor (ie I see the wireframe mesh). But when playing the level after doing a full rebuild, the terrain doesn't show, just the other objects. This also happens after exec-ing batchimport.txt. But I assume it's because the heightmap has too many large peaks and I somehow end up beneath them in stead of on top...

As for the crashes, they all look something like this, after apparently clicking the wrong button at the wrong time (here: staircase editor when terrain editor is active)

"No Label

OS: Windows 2000 5.0 (Build: 2195)
CPU: AuthenticAMD PentiumPro-class processor @ 1104 MHz with 511MB RAM
Video: RADEON 9500 PRO / 9700 (6378)

General protection fault!

History: WButtonGroup::ButtonClicked <- WButtonGroup::OnCommand <- WWindow::WndProc <- WWindow::StaticProc <- WWindow::WndProc <- WWindow::StaticProc <- MessagePump <- MainLoop"

ttl
15th Apr 2004, 10:56 PM
Ahh while you had the terrain editting window open, there is your problem... I thought you meant it had somethign to do with the execs. See: http://wiki.beyondunreal.com/wiki/UnrealEd_Goblin


Btw it must just be the player start...because i can even set a new heightmap whilst in game andit works (does crash sometimes due to collison). Just open up the map... move the player start somewhere that is valid and save it (no need to rebuild) or you can type "fly" in the console (which is what i do before i change a terrainmap in game). However unfortunately the standard "fly" command does not stop collision, so if you want to do that you'll most likely have to script your own function.