Texture tiles

Hi all!

I am making a terrain from a .raw-file and texturing it with a Jpeg-file.
The only problem for now is that the texture stretches out.
I want it to be tiled, but how do i do it ???

Thanks in advance,
Emil Alonzo

Emil,

Take a look at this post:

http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=xith3d;action=display;num=1075920495

I re-wrote the terrain demo a while back and tiled a texture on the terrain. The web start, jar, and full source are available if you visit that thread.

Let us know how it goes.

Thank you very much! :smiley:

Now I can navigate through the terrain and everything is fine.

But how do I load the terrain from a file,
e.g: a grey-scale picture (heightmap) ?

Thanks for the help :slight_smile:

Emil Alonzo

Emil,

You would need some way to extract x,y,z values from the picture. Once you’re able to, for example, get the height for a given x,z coordinate, you should be able to modify the inside class “TerrainGenerator” in the demo to use your terrain instead of generating the random terrain that it does currently. Take a look at the method declaration:


public float sample(int x, int z) {
  return (float)(perlin.value((float)x/1400f,(float)z/1400f)+1f)*MAX_HEIGHT;
}

All you would have to do is replace that return statement with a statement that returns a valid height for a given x,z in your heightmap image. The implementation of reading the terrain file is entirely up to you.

Hope this helps.

-M

[quote]Thank you very much! :smiley:

Now I can navigate through the terrain and everything is fine.

But how do I load the terrain from a file,
e.g: a grey-scale picture (heightmap) ?

Thanks for the help :slight_smile:

Emil Alonzo
[/quote]

Hi!

I’m trying to write a program which displays some real world topography in 3d. It reads in a heightmap from a file, creates the shape and textures it with a 2d image of a map.

I’ve been using the terrain demo as a basis to work from.

I’ve managed to load the heightmap into an array of floats 501 x 501 big. I’ve written a class that implements TerrainSampleInferface. The sample(x,y) method returns the float at x, y in my array.

Initially I was getting an array out of bounds exception creating a terrain object 12 by 10. By lowering this to 7 by 7 it seems ok. The trouble is the shape produced is really squashed together, so that whats really a gentle slope looks more like everest.

I’m not really sure what the values mean that you pass into the terrain constructor, or the scale value in the TerrainSampleInterface. If someone could explain that to me it’d be great. Also, how do I stretch out my shape so that it is proportioned a bit better?

Any help would really be appreciated, thanks!!

ps. Is there a terrain tutorial somewhere that I can’t find? That’d be really handy…