Simulation based engine

Hi, I’m currently looking for a simulation based engine, with the ability for terrain grid like you see in games like, SimCity and almost any Sid Meyer games. And was wondering if jMonkeyEngine was able to handle this in a positive performance wise way.

While looking at the many tests thats included in the engine, I’m very pleased with the overall performance and features in JME3, but I’ve not been able to find a clear answer to my question through the tests neither random google/forum searches…

Also, if JME3 are able to handle it well, could someone point me in the right direction? Class, guides, wiki anything would be much appreciated!

PS: I do not have the time nor the patience to test every single engine out there for my simple question, so I was hoping someone could provide a quick and easy answer…

Are you looking for a 3d world, or a tile-based 2d world? Sim city has gone through both types.

I assume 3d. And yes jme can do this. You can use the terrain system it has and just snap buildings/objects to set integer values when you place or move them.

Yes 3d, kinda like what you saw in SimCity 4 and CitiesXL, but still grid based…

Are there a certain part of the terrain class that would allow me to make such a viewable and “clickable/editable” grid ? Or must I make that myself ?

The grid based part is just where the buildings/roads snap to. That is separate from the terrain. So you can use the terrain as it is, and still use the height modification tools like in the SDK.

The snapping/grid you have to make, but really it is just a little bit of code where you drag or place buildings. Once they are placed, they will will just fit on that grid.

As for placing buildings on sloped terrain, you can use Terrain.getNormal(x,z) to see if it is too steep; then you can show the player that they cannot build there.

Thanks for the quick and precise answers :slight_smile:

Now that my interest in JME have been increased, I was wondering, if and when I should come to a coding problem concerning jme, can such a question be asked here in this forum(under some subforum ofc), or is this forum only for problems with jme itself, like bugs and such?

Glad I could help.

Feel free to post questions any time. No doubt someone else will have the same question as you and will want to know the answer.

The forums are for anything jme related, not just bugs specifically in jme. Questions such as “I’m trying to do this with jme but I don’t know how yet…” are perfectly acceptable and welcomed. If it is not specifically jme related, but still game related, then you can still post it. You just might get better or different answers on sites like more suited to the broader topic of game development.

I saw in some other post under the terramonkey forum that the terrain is build on a grid, would it be possible and logical to use that grid for my placement of buildingds/plots, or did I misunderstand some term in the jme?

hi, I guess you are referring to TerrainGrid class. It’s just an implementation of a paging terrain system, that loads/unloads part of the terrain as needed. In my understanding @Sploreg was talking about a second kind of a grid you can create by simply casting your coordinates to int and taking only integer points on the terrain as snapping positions.

Fair enough, it was nothing but a misunderstanding…

anthyon said:
taking only integer points on the terrain as snapping positions.

Im still not complete sure of what is meant by this. But either someone could explain it, or I'll properly figure it out along the way...

When you have selected to build a building or road, you will want a (probably transparent) model that follows around with the mouse and snaps to the terrain, so you can see where it is going to be built. In your model’s/actor’s class you can override the setLocalTranslation() method to look at the incoming position, and round it off to the nearest integer value. Then it will drag around as normal but you will see it jump from, what would seem like, grid coordinates. So there wouldn’t be a physical grid that you would store, it would just be simulated and would work like one by simply rounding off the coordinates. Of course you would want to keep the Y-value the same, but the X and Z values you would round off.

Hope that helps.

1 Like

Now I get it, thank you very much for clearing that out for me :slight_smile:

This is the first time im using a predefined/opensource engine, I’ve always been acustomed with making all of it myself, but this time I want quality instead of wasting my time inventing the deep plate all over :slight_smile:

I’ve always been doing things in C#, but now its time for a new project with new tools and experiences…

Glad we could help.

Let us know how your progress goes, we are always interested to see everyone’s projects. :slight_smile:


Im just gonna keep to this topic, no need to flood the forum with too many noob questions, and this post is all about being a noob…

So first round of noob questions:

  • 1. I've been doing the tutorials, and stumbled across the Textures. The tuts mention Tex1, Tex2 and Tex3, does this mean that there are only 3 texture layers or is it unlimited?

  • 2. How would one be able to create deserts/grassy/forest areas from a height map, as height in the real world have nothing to do with the ability for a tree to grow(except for mountains and such, but you get the point), or if the sun is direct. So are there a known library for moisture for the terrain generator, or would I need to create one?

  • 3. I would need to fixate the camera, so it is always from a static angle, only movable from touching window edges with the mouse and keyboard, and zoom with scrollwheel. But so far I've only seen projects involving third or first person cameras. So my question is, does jme have the capability of a static camera?

  • 4. Does anyone know of some articles for mouse interaction in jme(Like in a builder game) instead of the normal first/third person shooter style interaction.

And finally, off topic, I think there is a bug with the forums pager, if im located at page 3 and click page 4 and use the browsers back button, I automaticly return to page 1 instead of page 3.
  1. you can use up to 12 diffuse textures for terrain, 13 textures total including normal maps.
  2. you would have to write this. Take the elevation and the slope of the terrain to do a rough estimate

    3+4) yes. I’m sure someone has posted some sample code on the forums. You will need an InputListener that you pass onto the InputManager of your scene. There you intercept the mouse movement and clicks.

yilmas said:
And finally, off topic, I think there is a bug with the forums pager, if im located at page 3 and click page 4 and use the browsers back button, I automaticly return to page 1 instead of page 3.

I'm not sure if it is a bug with the forums, it can be irritating though. @erlend_sh might know
yilmas said:(...)
And finally, off topic, I think there is a bug with the forums pager, if im located at page 3 and click page 4 and use the browsers back button, I automaticly return to page 1 instead of page 3.

It's not a bug, it's just unintuitive design. That's unfortunately how our CMS (WordPress+BuddyPress) works right now. There's a major upgrade due for release any day now. Hopefully it will address this shortcoming and several others.

Terrain used, is the same from the HelloTerrain.

I’ve created a ChaseCam that is locked on an object located on the ground of the terrain, with no height/width/depth(This will at some point be given its own CollisionGroup to avoid bumping into other plots/objects)…

The object will be what moves the camera, and not the other way around.

As any heightmap the maximum height is 255, and for some reason my cam treats that as its own maximum height. How do I fix this ?

Also, no matter what I write in the ChaseCam.setDefaultDistance() the starting distance of the camera dosn’t change. What might be wrong?


ChaseCamera chasecam = new ChaseCamera(cam, boxCam, inputManager);





Off off-topic: Whats up with the little smiley in the very lower left corner of site? :stuck_out_tongue:

The chase cam only cares about the object you are locked onto, not the terrain. There must be some coincidence to the height limitation.

You’re going to have to debug the ChaseCam.setDefaultDistance() issue, and track down with a breakpoint what is setting the value. I can’t tell from what you have.

The smiley face watches us… always…

Sploreg said:
The smiley face watches us... always...

SPY sappin' mah website!

Try setting the minDist and maxDist then the defaultDist. Also, make sure minDist isn't higher than defaultDist. If it's the case, that might give the result you're seeing.