Game Development Community

Trying to generate a terrain chunk

by Alexis Brown · in Torque Game Engine Advanced · 08/21/2006 (1:50 am) · 15 replies

What could I be doing wrong that would cause my terrain to look like this?

imageigloo.com/images/2335myterr.jpg

#1
08/21/2006 (8:14 am)
Uhh..... yeah.

Could you describe to use what you are doing? Maybe from that we can figure out what you're doing wrong.
#2
08/21/2006 (8:14 am)
Are you creating a Jenga game?
#3
08/21/2006 (8:16 am)
If it is atlas then chances are you don't have the atlas shader being loaded.
#4
08/21/2006 (9:26 am)
Yeah, if you are using an AtlasInstance (1) in the MS3.5 code you will need to change some shader path locations.
#5
08/21/2006 (10:08 am)
A Jenga FPS? Beats the hell out of my original idea ;)

I created a terrrain in l3dt and use the following two commands to generate the chu and tqt files
generateChunkFileFromRaw16("terrain_water_demo/data/terrains/test_x0y0.raw", 1024, 2.0, 1.0 / (256.0), "terrain_water_demo/data/terrains/mainterr.chu", 30.0, 4);


generateTQT("terrain_water_demo/data/terrains/testexport_x0y0.jpg", "terrain_water_demo/data/terrains/mainterr.tqt", 2, 512);

I then modified the mission file like thus

new AtlasInstance(BigChunk) {
      position = "0 0 0";
      rotation = "1 0 0 0";
      scale = "1 1 1";
      chunkFile = "~/data/terrains/mainterr.chu"; // Don't forget to tweak these if
      tqtFile = "~/data/terrains/mainterr.tqt";   // you named your files differently.
   };

and I removed the water block.


//I'll look into the shader thing. Not sure why the shader would screw the geometry but then I don't know a lot.

Looked at this www.garagegames.com/docs/tse/general/ch05s02.php and I see the shader being loaded for the terrain_water_demo.
#6
08/21/2006 (10:20 am)
No, this is definitely NOT a shader problem, but a geometry one. And the reason? You're not using the correct syntax. It's now atlasOldGenerateChunkFileFromRaw16 and should look something like this:

atlasOldGenerateChunkFileFromRaw16("terrain_water_demo/yahargiblargin.RAW", 1024, 1.0, 1.0/512.0, "terrain_water_demo/babaganush.chu", 1.0, 5);

Mind you, you will have to add those shaders to your material and shaders.cs files.

-Matt Vitelli
#7
08/21/2006 (10:27 am)
Why did they rename it atlasOldGenerateChunkFileFromRaw16? I just followed this tutorial www.garagegames.com/docs/tse/general/ch05s02.php
#8
08/21/2006 (10:29 am)
Ah yes, that was before Atlas2 was released. Atlas 2 has many rewarding features over Atlas1 so they renamed it "atlasOld"
#9
08/21/2006 (10:34 am)
*sigh*

Thanks. I'll look into atlas2 stuff.
#10
08/21/2006 (10:39 am)
It's the same idea though. Atlas2 imports .chu and saves it as a .atlas file. You can still use all your Atlas1 materials in Atlas2. For more info see Using Atlas2

-Matt Vitelli
#11
08/21/2006 (11:18 am)
Wheee. at least it's not Jenga anymore ;)

www.uploadfile.info/uploads/4f9320a124.jpg
#12
08/21/2006 (11:38 am)
Now its.. uhm... I don't know.

In reference to the generate commands becoming "old"... at the time of the MS3.5 release, the new functionality (that will be in MS4 very soon), wasn't working yet, so they left the old functions in the code so we'd had a way to make the terrains. As soon as GG releases MS4, we should have new methods to follow to generate terrain (and I'm writing a tutorial about using real-world data that should be useful to the general audience).
#13
08/21/2006 (2:40 pm)
It looks to me like it's taking my terrain values and setting them to the max or the min based on some threshold. The texture problem in the above image is because of the old nvidia card I'm using. The texture comes through on my laptop which uses ATI Mobility Radeon X1400

I think I'll go step through the code to try and understand whats going on.


p.s. Thanks for everyones help.
#14
08/21/2006 (3:51 pm)
That min/max thing is geometry-conversion controlled. That's what the "vert scaling" factor is all about. You should be setting it to the inverse of your terrain's total height range. So if you're terrain goes from 0 - 330 m you should set it to 1 / 330.0, or if your terrain goes from -100 - 450 you should set it to 1 / 550.0.

Also, since each geometry "chunk" height only ever ranges from -32,768 to +32,768 in the RAW file (that's why its 16 bit) a slightly more acurate way would be to put your height range over 65,536. So in the above examples you would pass 65536 / 330.0 and 65536 / 550.0, respectively. However, for most height ranges that are not that dramatic (much less than 65,536) it doesn't make much of a difference.
#15
08/22/2006 (1:26 am)
The min/max thing was because I exported the heightfield to a signed 16 bit raw file instead of an unsigned file. I'm a little slow some days ;)