In my game I’m using TerrainGrid + FractalTileLoader to create a large game world… Do I need to update something special to trigger the TerrainGrid after it is constructed? Maybe something to trigger one of the TerrainGridListener functions tokeep it from messing up? See end of post for code and more info.
When I start the game it just spams this in the debug console repeatedly and nothing is visible:
gridMoved → newCenter = (0.0, 0.0, 0.0)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
fixed normals (0.0, 0.0, 0.0)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
gridMoved → newCenter = (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
— OVERWORLD CHUNK LOADED: 0,0
— OVERWORLD CHUNK UNLOADED: 0,0
fixed normals (NaN, 0.0, NaN)
/*
* Add a listener that loads and unloads chunks.
*/
overworld.addListener(new TerrainGridListener() {
/*
* notifies the system about a tile being loaded
* @param newCenter
*/
@Override
public void gridMoved(Vector3f newCenter) {
System.out.println("gridMoved -> newCenter = " + newCenter.toString());
}
@Override
public void tileAttached(Vector3f cell, TerrainQuad quad) {
final int oldChunkX = currentChunkX;
final int oldChunkZ = currentChunkZ;
int newChunkX = (int) cell.x;
int newChunkZ = (int) cell.z;
/*if (newChunkX == oldChunkX && newChunkZ == oldChunkZ) {
return; // commented to see if it fixes the problem. it doesnt
}*/
currentChunkX = newChunkX;
currentChunkZ = newChunkZ;
System.out.println("--- OVERWORLD CHUNK LOADED: " + newChunkX + "," + newChunkZ);
try {
Texture texture = client.assets().loadTexture("terrain/overworld/alpha_" + (int) cell.x + "_" + (int) cell.z + ".png");
quad.getMaterial().setTexture("AlphaMap", texture);
} catch (Exception e) {
quad.getMaterial().setTexture("AlphaMap", client.assets().loadTexture("terrain/overworld/alpha_default.png"));
}
overworld.attachChild(quad);
//quad.setCullHint(CullHint.Inherit); // messed with this a lot to see if it fixes the problem. it doesnt
}
@Override
public void tileDetached(Vector3f cell, TerrainQuad quad) {
System.out.println("--- OVERWORLD CHUNK UNLOADED: " + (int) cell.x + "," + (int) cell.y);
//overworld.detachChild(quad); // commented to see if it fixes the problem. it doesnt
}
});
When I use the spellbook to teleport to a village, sometimes it will stop spamming and the terrain will be visible. The spell does nothing special, except for set the character’s local translation to x/z (The character’s gets teleported to a village at startup also, as a test to see if it fixes the problem, and it doesn’t)