Implementing a "GeoMipMap" on a .j3o made in Terrain Editor?

Hi there,

I’ve been trying to learn all the basics before starting into a major project with jme.

I’ve gotten pretty far and my current goal is to be able to make a level of detail for my terrain. I came across this.

“GeoMipMapping: a method of changing the level of detail (LOD) of geometry tiles based on how far away they are from the camera. Between the edges of two tiles, it will seam those edges together so you don’t get gaps or holes.”

I have a simple .j3o scene created in the terrain editor.

How would I apply this “GeoMipMap” to that terrain, and then make it affect my camera.

Clearly you have found this https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:terrain?s[]=lod
Just scroll down to the bottom and theres an example on how to implement LOD control to your terrain…

EDIT: There is also a full explanation of what GeoMipMapping is and how to implement it before the example…

I’m trying to use an already made and textured scene model and apply the GeoMipMap to that.

Or does it have to be a height map or hill map?

This is a completely new concept to me, using this whole level of detail.

it must be height map (such greyscale img)

Are you sure I can’t apply this to a terrain I already have in a .j3o within a class file?

Could I add a custom Control directly to the .j3o file itself that would accomplish this?

@BigBob said: Are you sure I can't apply this to a terrain I already have in a .j3o within a class file?

Could I add a custom Control directly to the .j3o file itself that would accomplish this?

I think @Sploreg may be the right person to ask, I tagged him lets see if he turns up

Your terrain object in the j3o needs to be an actual TerrainQuad class in order for the control to work. You can’t just use any spatial.

Or wait, did you make the terrain in jme’s terrain editor? If so then it is already the correct terrain class and you can apply the lod control to it.

1 Like

@Sploreg Yes! Exactly you got it! I have the actual terrain made in the terrain editor!

I want to apply the lod to this! THANK YOU for understanding!

I want to make it so all of my terrain isn’t constantly visible, I want it to be a bit foggy around the camera. This is a screenshot of what it looks like currently in the game.

Imgur

This thread talks about how to find the terrain and attach the lod control to it. It needs to do this so the camera can be attached.
http://hub.jmonkeyengine.org/forum/topic/terrain-editor-loading-from-scene-lod-control/

There are some fog tutorials on the site. You can also try ‘depth of field’ effects for the camera as well to fade out the far edges.

Thank you. That’s exactly what I needed, thank you. I’m ready to start my project.

One final question.

When it comes to terrain size, how big is too big, from all the tutorials I’ve read it has to be a power of 2 and “not to over do it.”

I’d want a larger map size, but reasonable. Is this a matter of shrinking my models or upping my terrain size?

I’m trying to create a sandbox-style game with different scenes leading off a large main map.

What size would be “too big” in terms of a terrain or “too small” in terms of a model?

Thank you!

Tough question. If you look at FPS games with terrain, it is not that detailed. They use rock models and other props for detail.
You can test a large terrain and see what performance you get, but add in a bunch of test models too. And it’s fine to start with a 512 terrain and then scale it x2. A 1024 terrain scales x2 will be quite large and pretty detailed.

@Sploreg said: This thread talks about how to find the terrain and attach the lod control to it. It needs to do this so the camera can be attached. http://hub.jmonkeyengine.org/forum/topic/terrain-editor-loading-from-scene-lod-control/

[java]TerrainLodControl lodControl = terrain.getChild(“terrain-Scene”).getControl(TerrainLodControl.class);
if(lodControl != null)
lodControl.setCamera(getCamera());[/java]

That was what the other thread in the end recommended yet I am unable to do this. My spatial scene does not have getChild method and even when I look into the JME doc I can’t find it. It is probably something silly I have forgot to do but I can’t figure it out.

You need to cast it to a Node if you want to get children from it.

Use the scene explorer to look at the layout of nodes/geometries/etc within the model and you can see what you need to cast to what.

Gosh, sorry to bring back this old thing, But I still can’t seem to get it.

sceneModel is my loaded scene with a terrain within.

The scenes name is named “testCell” and the terrain “testTerrain”

I just can’t seem to understand what I’m doing wrong,

lodControl = sceneModel.getChild("testTerrain-testCell").getControl(TerrainLodControl.class);

Is the line that crashes it.

[java] public void initCamera(){

System.out.println("This is working");
lodControl = sceneModel.getChild("testTerrain-testCell").getControl(TerrainLodControl.class);
if (lodControl != null){
//lodControl.setCamera(cam);
System.out.println("LOD:" + lodControl);
 
} else {
System.out.println("LOD NULL!");

}[/java]

According to the SceneExplorer your terrain is called “testTerrain” and not “testTerrain-testCell”

No luck with “testTerrain” either.

I was using this post here http://hub.jmonkeyengine.org/forum/topic/terrain-editor-loading-from-scene-lod-control/.

As Sploreg directed me.

It said to use the scene name and the terrain name.

And I believe you may have been the the one who suggested the method in that topic. :wink:

Thank you for the fast response!

If the screenie shows the model you actually load then that should work, you sure you load that model? Its got a suspicious " ’ " in the name…

I’m 100% sure, the model is loading correctly.

sceneModel = (Node) assetManager.loadModel(“Scenes/Bob’sTestCell.j3o”);

If I attach it to the root node it works properly with the physics and such.

But I just can’t to get that LOD control out.

But your code should print “LOD NULL” then… If the model isn’t actually loaded though the spatial would be null you’d get a NPE before, as you try to call getChild() on null.

I’ve even put it on a key trigger, and tried to pull it out within the game.

I thought it may be the GUI that was causing some trouble with the Camera, or something but no luck.

I set up by pressing “f” it would pull the child out and then just print a line.

Standing inside the scene on the terrain.

Crashed.

That is what’s so strange to me, is that it doesn’t even print null.

It just crashes right at that line, in which I try and pull out the lodContorl.