A couple more questions about TerrainGrid

  1. The first one is about the forester. I have set up the grass system just asif I am using a normal TerrainQuad, with unexpected results, as you can see in the image below

    http://i.imgur.com/pVBbm.png



    I think it is only loading the grass onto one patch, although it does seem to be loading the grass everywhere in the output window.


  2. When I use heightmaps, there is a strange gap at the edge the edge of each heightmap

    http://i.imgur.com/O5f9G.jpg



    Each of my heightmaps are 128x128, & each the size of each terrainquad is 257. all of the heightmaps should fit together seamlessly, I made a 1536x1536 heightmap in photoshop then used my own program to split it up into 144 different 128x128 heightmap images.



    Also, my terrain comes out like a mayan temple :confused: why is this?



    Thanks people.

Impossible to say w/o any hint on how you do it.

Oh, sorry Normen… Were you talking about how I split up the images?

Code:
import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.util.Scanner;

import javax.imageio.ImageIO;

public class Splitter {
public static void main(String[] args) throws IOException {

//Load up heightmap
Scanner inputs = new Scanner(System.in);
System.out.println("Enter image path");
String path1 = inputs.nextLine();
File file = new File(path1);
FileInputStream fis = new FileInputStream(file);

System.out.println("Enter output path");

String path2 = inputs.nextLine();

BufferedImage image = ImageIO.read(fis);

System.out.println("Enter the first part of the final string e.g A in A-5,4");

String fp = inputs.nextLine();

System.out.println("Enter the Output file format (png or jpg)");

String ff = inputs.nextLine();

//The number of separate heightmap ‘chunks’
int rows = 12;
int cols = 12;
int chunks = rows * cols;

int Width = image.getWidth() / cols;
int Height = image.getHeight() / rows;

int count = 0;
BufferedImage imgs[] = new BufferedImage[chunks];

//Fill the array with the chunks
for (int x = 0; x < rows; x++) {
for (int y = 0; y < cols; y++) {
//Initialize the image array with image chunks
imgs[count] = new BufferedImage(Width, Height, image.getType());

//Draw the chunks
Graphics2D gr = imgs[count++].createGraphics();
gr.drawImage(image, 0, 0, Width, Height, Width * y, Height * x, Width * y + Width, Height * x + Height, null);
gr.dispose();
}
}

int counting = 0;
//Save each chunk into seperate files, named specifically for TerrainGrid
for(int w = -5; w <= 6; w++){

for (int i = -5; i <= 6; i++) {

ImageIO.write(imgs[counting], ff, new File( path2 + fp + i + ","+ w + "." + ff));
counting++;
}
}

}

}

No, the terraingrid code where you try to put it together.

you have your grid tiles loading into the wrong spots, so the heightmaps don’t match up.

Well, all I can say to that s, why are they loaded into the wrong spots? :confused:

Terrain grid doesn’t magically load them. You have to use the AssetTileLoader with the correct file suffixes (the tile coordinates) on all of the tiles that get loaded.

Look at TerrainGridTileLoaderTest and the zip data that is loads, match it up with yours.

you mean this?

Code:
this.terrain = new TerrainGrid("terrain", 65, 257, new ImageTileLoader(assetManager, new Namer() {
        public String getName(int x, int y) {
            return &quot;Scenes/HeightMaps/MAP&quot; + x + &quot;,&quot; + y + &quot;.jpg&quot;;
            //return &quot;Scenes/terrain_0_0.png&quot;;
        }
    }));

I'm pretty sure that they're all named correctly too.

Yes that piece of code.

They are obviously not named correctly (x/y flipped). That or you have changed something somewhere else.

But that can’t be right as I use the exact same program for my splat maps. It seems more like the bottom & right corners of each terrainquad just drop down instead of using the heightmap data. Iv’e flipped just about everycombination of axes that there is, It just doesnt fix anything.

you might have your two for loops backwards:

for (int x = 0; x < rows; x++) {

for (int y = 0; y < cols; y++) {



try



for (int y = 0; y < cols; y++) {

for (int x = 0; x < rows; x++) {



(just a shot in the dark)

No, tried that :confused: but in the mean time, is there any way to smooth out my terrain, like I said before it looks like a mayan temple :stuck_out_tongue:



http://i.imgur.com/tFdAt.png

use a 16bit grayscale heightmap and run a blur on your heightmap image, or use heightmap.smooth()

How can you use HeightMap.smooth() with terraingrid since no heightmap objext is called?

well you don’t really want to use that one for terrain grid, since it might not seam at the edges. Use the smoothed 16-bit grayscale images

1 Like