Some beginner's questions

Hello guys,
I’m new to jMonkeyEngine and have some questions.
I hope I’m in the right forum.

I already searched with google for some answers, but got no satisfying ones.
I created my first map with custom textures, hills, post-processed water, skybox, player and so on.
Now I want to put some objects at the map like grass and a Forest. And some caves / dungeons would be nice. :wink:

I found a plugin named Forester, but it seems outdated (2011?). Is there a more up-to-date version?
Can you advise some good tutorials or working sourcecode demos?

Thanks for you’re help
greetings Nero

Hey,

as far as I know, the forester plugin is pretty outdated, yeah. Doing it yourself is not so hard however:

First, you need to think of method to distribute the trees on the map. If you’re doing it by hand, thats fine, too. Otherwise you can either google something or just think something up yourself.
What’s very important when you have a lot of trees and grass: Optimization.
If you just add them all to the rootNode, you’ll drown in draw calls.

Therefore you need to pratition the world in chunks and batch each chunk using GeometryBatchFactory or BatchNode, which will increase your performance greatly.

I don’t know how big your map is. It may be possible that - once you’re not longer held back by having too many draw calls - you’re held back by too many triangles. In this case you need to introduce Level of Detail. You could for example have different LOD levels for each chunk; i’ve personally found this to be the best approach.

This may sound like a lot of work, but knowing how optimization work will get important for you soon enough anyway.

2 Likes

As for tutorials: I don’t know if you mean forester specific tutorials, but if you want general tutorials: here is everything you need.
(mostly at least :slight_smile: )

Thank you for the quick reply. I wanted a general tutorial like this.
Ok, at first I have to partition the world into chunks. Then I need to let the trees and grass to be placed
on fix positions. Placing everything manualy would be really annoying. Any suggestions, code snippets or demo projects?^^

You need to use your mind… :-o

I can give give you my own approach in pseudo code:

for (every chunk):
    for (n-times) {
        x = randomNumber
        z = randomNumber
        if (XandZareTooCloseToAnotherTreeInThisChunk) {
            continue
        } else {
            placeTheTree
        }
    }
}

Depending on the chunk size, the n you use and the minimum distance between trees, you can get a pretty nice distribution of trees.

If you want more advanced placement, like distinction in forests and non-forests, I can recommend implementing Perlin Noise and checking if perlin(x,z) is smaller than some number. If it is, you don’t place the tree because you’re not in a forest.

Edit: I forgot: Use not only your mind but also use :google:

Ok, thanks. I’ll give it a try. :smiley: