Jul 14

MapGenerator Menu

Quick update,

Have managed to load a large height-map image and generate a “mini-map” of it and setup the map generation menu:

MapGenerator

 

As the screenshot shows, the original file is 8192×8192 pixels, in 16-bit gray-scale.

Also populated drop-down boxes to select the “world” size in tiles across and the size of each tile, also there is a list to set the maximum height of the generated world. All in “world units”

Next is to link the drop down boxes to change the “pixels to unit” scale value and also to lock the sliders on the left to keep each one less than the one below it (they are there to set the height percentage for painting the one to four textures based on the terrains height during tile generation)

Cheers

Jul 11

TiledTerrain Editor

Hi all.

Some visible progress on the terrain editor program, after bitching with Nifty-Gui I think I’m getting the hang of it. just piecing the menus together and adding code functions to them, once they’re all done the real work can begin.

Here’s some screenshots so far:

File Loading screen for loading tilesets or images/textures:

java 2013-07-11 20-57-06-23

 

The tile-set generator screen (left image pairs for initial height-based textures are diffuse&normal pairs, large right-hand image will show a scaled version of the users heightmap image):
java 2013-07-11 20-57-22-60Until next update!

Cheers.

Mar 16

Further Testing of the TerrainTiler

Another Video. Same camera path as previous posted video but this time a small addition to the code was added to test the Action Hooks for Tile Attached and Tile Detached.

            terrainTiler = new TerrainTiler(cam, 32, uJars, 1, tileDir, this);
            terrainTiler.setGridSize(5);  // grid can be 3,5,7 or 9. Defaults to 3
            terrainTiler.addActionHandler(new TerrainTilerAction() {

                public synchronized void tileAttached(Vector3f center, TerrainQuad tile) {
                    System.out.println("Adding trees to tile: "+tile.getName());
                    float tx = tile.getLocalTranslation().x;
                    float tz = tile.getLocalTranslation().z;
                    int tsize = terrainTiler.getTileSize()*terrainTiler.getTileScale();
                    int num = new Random().nextInt(20)+20;
                    for (int i=0; i<num; i++) {
                        float x = tx - tsize/2 + new Random().nextFloat()*tsize;
                        float z = tz - tsize/2 + new Random().nextFloat()*tsize;
                        float h = terrainTiler.getHeight(new Vector2f(x,z));
                        if (h > 100f & h < 300f) {
                            String id = tile.getName()+i;
                            tree.setLocalTranslation(x, h, z);
                            tree.setName(id);
                            treeList.put(id, tree.clone());
                            rootNode.attachChild(treeList.get(id));
                        }
                    }
                }

                public synchronized void tileDetached(Vector3f center, TerrainQuad tile) {
                    System.out.println("Removing Trees from tile: "+tile.getName());
                    Iterator it = treeList.keySet().iterator();
                    while (it.hasNext()) {
                        String id = (String) it.next();
                        if (id.startsWith(tile.getName())) {
                            rootNode.detachChild(treeList.get(id));
                            treeList.remove(id);
                        }
                    }
                }
            });
            terrainTiler.setEnabled(true);
            rootNode.attachChild(terrainTiler);

Pretty quick and dirty but does the test, “tree” is a Spatial that is a pre-loaded model. The tree model is a very ugly tree imported from a Blender file I found from a quick “free model” search. “treeList” is a ConcurrentHashMap for storing the trees created so it can remove them later. The code throws a random number of trees into the list, provided its location is within a set altitude range. When the tile is detached it finds the trees with the tile ID and removes them.

Next is to test the terrain editing/modifying functions.

Thanks.

Mar 13

TerrainTiler class finalised

Hi again,

My TerrainTiler class is now finalized as far as functions go, I’m now ready to make it a plugin for jME’s SDK for consideration in to the community collection.

Here’s another video showing a nice 4 min fly-over using the latest code. Still a bit plain – needs better textures and objects like trees etc would make it a nice demo.. sooon… 😉

Enjoy!

 

Mar 03

A Video!

Made a quick video to show that this is progressing, almost at clean and optimize stage!

Once the class is stable I’ll be moving on to a World Editor for it. Should be fun 🙂

Thanks!

 

Feb 19

Terrain Generation

Has started,

Had a major headache in the tiler routine that was causing a big memory leak, still needs to be properly sorted but it’s not leaking at the moment. Still not sure if it was my code or the engine library I’m using. Sort it eventually.

Terrain generation has started coming together, still needs more work but here’s an early screenshot for progress. Needs seam welding between the tiles and better smoothing routines but its a start. Gives me something to work on.

Enjoy!

Early Terrain Generator

Early Terrain Generator

Feb 12

TerrainTiler library progress!

Hello again.

The TerrainTiler class library is now progressing very well. Not loading actual tiles yet just random color HillHeightMaps but it’s working and quite flexible: so far I’ve tested a 3×3 grid and a 5×5 grid (shown below)  code also allows 7×7 and 9×9, i’ll test these later, getting late here.

Tomorrow I’ll tackle loading actual terrains with textures and finish off a few functions.

Code is up on GoogleCode so others can look at or test it, currently it’s a project for jMonkeyEngine SDK so you can load the whole project into the SDK and just run it.

Thanks for reading!

TerrainTiler-1 TerrainTiler-2

Nov 15

TerrainTiler

That was quick 😀

Getting progress on the TerrainTiler routine, still need to break it out into its own class and give it threading but it is working and frame rates are still good.

Terraforming tools are also coming together nicely, currently I can smooth the whole visible terrain, paint it with different textures, scale the textures and swap them out for others.

My planning is to have 4 textures per tile but each tile can have 4 of however many textures I decide to have available, this way each tile stays simple but I can have a vast array of different textures to suit the varying type of areas across the map. Also this allows me to put a lot of detail in such as normals/glow/specular maps as I need without breaking the limits of the older graphics cards.

And here are some pics to look at as words are boring 🙂

(The small oval is my “Player” (no pretty models yet, mechanics first). I use the player to test the physics of the terrain for issues as I go. The dome is the tool, adjustable in size.)

Until next time!

Splat Painting

Different Textures per Tile

LoD on terrain

 

 

Oct 01

Objects..

I haz one 🙂

Just a jetty on the shoreline in the terrain editor for point of reference and scale… (and to show I’ve not been asleep… much…)

1st screenshot

Terrain Editor – first object.

Object is from the free community asset pack with the 3D engine. I’ll make my own objects when I’ve got the base code filled.

FYI the engine I’m using is the jMonkeyEngine.

Back to work!