Using TerraMonkey/TerrainGrids with custom heightmaps

I’ve written my own function to generate heightmaps (all of 2^n sizes) and i can’t seem to find a way to plug them into the code of



http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/terrain/TerrainGridTest.java



Should i write my own MyTerrainGrid’s and MyTerrainGridListener’s ? (where ‘My’ is the name for my custom type of heighmap)



basically for now i just wanna use the same heightmap and run around in it forever to confirm that i got my custom heightmaps,

later on i’ll get the real heighmaps from file or database.





So: is there a way that can do this that i missed in the tutorials, or should i go roll my own ?











unrelated bonus-sidequestion



i’m currently using PhysicsNodes to attach my terrain to my landscape as follows, but it is deprecated



[java]

landscape = new PhysicsNode(terrain, sceneShape, 0);

rootNode.attachChild(landscape);

getPhysicsSpace().add(landscape);

[/java]

How should i do this better? (Documentation uses this method, don’t blame me)

Afaik the terrainGrid automatically attaches RigidBodyControls to the terrain if there is already one on the first quad. The example uses physics. The manual of jMP should be updated as well if you updated to nightly version, so I doubt the deprecated PhysicsNode is really mentioned there still.

Not sure if i’m understanding correctly, partly because i cant get my first terrainGrid, it requires [format]BasedHeightMapGrid (Image, Raw, MipMap, etc) for which there is no equivalent to my own CustomHeightMap.











as for the bonus question:

I meant the tuts on the site, example: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:intermediate:terrain_collision (still uses Physics Node)



also: godly gods there is a mansual INSIDE jMP ? (figured i would be stock NetBeans crud)



Hows does one update this internal documentation ? because you are right: the Terrain Collision in there is still from PhysicsNode and i did just pull and link the nightlies today (because i needed those for the TerrainGrid libs)

If you look into the code of [format]BasedHeightMapGrid classes - and basically the HeightMapGrid interface itself - all it does is provide a HeightMap object to a given Vector3f parameter, where the parameter identifies a cell in space. If you want to repeat your CustomHeightMap forever, all you need to do is implement this interface, and return your CustomHeightMap object no matter what cell id you get. The TerrainGrid class will take care for the rest. All you need to be aware of is that the opposite sides of your heightmap should have the same heights, or it will look pretty bad. :wink: The TerrainGridListener interface is used for situations where you want to have more control over the terrain loaded by the grid, like change some alphamaps in the material, load objects on the given cell, etc.



@Normen is a few versions behind though… He’s right that the grid used to learn about physics by simply checking if one was attached to the grid. Now you have to take care of adding a rigidBodyControl to each tile loaded in the aforementioned TerrainGridListener. A full example on how to do this is in the TerrainGridTest class.