Hello,
I am trying to make a hexagon-based terrain (one hexagon, where currently player is located, is shown at the time), but I faced a few difficulties. Basically, I want to use normal TerrainGrid system and render on the screen only part of a given shape (hexagon) of the terrain. And then, when player moves to the next hexagon, previous one will be discarded and new one displayed.
I started with the following idea:
I took a texture with painted hexagon and by changing texture coordinates and drawing vertices only inside the hexagon (and discarding others) I could partially achieve my goal. But then I faced a problem when hexagon overlaps a few nearly located TerrainQuads, I could not force to draw the texture for different quads with different texture coordinates. Because for the shader doing this there is no indications or identifiers of different TerrainQuads, that I could use for changing texture coordinates.
Then I decided that I don’t need such a texture with the hexagon at all. I simply wrote an algorithm in the vertex shader calculating whether current vertex belongs to the hexagon of a given size or not and I passed hexagon index (in the virtual hexagon grid over the terrain) parameter to the shader from the update loop. And everything was fine until I reached the point where I needed to change hexagon index parameter when player moves to the next one (to see the next hexagon on the screen). Shortly, it simply did not work any more.
As I understand, when I pass the index for the first time, the system calculates 16 TerrainQuads how it should be (4 attached and 12 detached) and it draws my hexagon shape somewhere according to the passed parameter and all other vertices of these 16 quads are discarded. And then, while my hexagon moves within these original 16 quads it will not redraw them.
Maybe I am missing something or doing it completely wrong? (I am not yet advanced with the jMonkey) I will really appreciate any advice which direction I should investigate to overcome my problem and reach my goal.
Thank you in advance.