Render Quad of HexagonTerrainTiles

This commit is contained in:
Sebastian Böckelmann 2024-03-21 17:18:01 +01:00
parent 7bed6d5d01
commit 11f5fa99fe
2 changed files with 21 additions and 12 deletions

View File

@ -128,15 +128,15 @@ public class Engine {
ModelTexture hexagonTexture = new ModelTexture(loader.loadTexture("white")); ModelTexture hexagonTexture = new ModelTexture(loader.loadTexture("white"));
TexturedModel hexagontexturedModel = new TexturedModel(hexagonRawModel, hexagonTexture); TexturedModel hexagontexturedModel = new TexturedModel(hexagonRawModel, hexagonTexture);
//Entity entity = new Entity(hexagontexturedModel, new Vector3f(1.7319988f,0,0), 0,0,0,1f); Entity entity =new Entity(hexagontexturedModel, new Vector3f(0.866f , 0, -1.4999994f), 0, 0, 0,1);
// Run the rendering loop until the user has attempted to close // Run the rendering loop until the user has attempted to close
// the window or has pressed the ESCAPE key. // the window or has pressed the ESCAPE key.
MasterRenderer renderer = new MasterRenderer(); MasterRenderer renderer = new MasterRenderer();
input(camera, renderer); input(camera, renderer, entity);
while ( !glfwWindowShouldClose(window) ) { while ( !glfwWindowShouldClose(window) ) {
renderer.processTerrain(terrain); renderer.processTerrain(terrain);
//renderer.processEntity(entity);
renderer.render(light, camera); renderer.render(light, camera);
glfwSwapBuffers(window); // swap the color buffers glfwSwapBuffers(window); // swap the color buffers
// Poll for window events. The key callback above will only be // Poll for window events. The key callback above will only be
@ -147,7 +147,7 @@ public class Engine {
loader.cleanUp(); loader.cleanUp();
} }
private void input(Camera camera, MasterRenderer masterRenderer) { private void input(Camera camera, MasterRenderer masterRenderer, Entity entity) {
GLFWScrollCallback glfwScrollCallback = new GLFWScrollCallback() { GLFWScrollCallback glfwScrollCallback = new GLFWScrollCallback() {
@Override @Override
@ -212,21 +212,23 @@ public class Engine {
public void invoke(long window, int key, int scancode, int action, int mods) { public void invoke(long window, int key, int scancode, int action, int mods) {
if(key == GLFW_KEY_A) { if(key == GLFW_KEY_A) {
//move camera to left //move camera to left
/*entity.increasePosition(0.001f, 0, 0); entity.increasePosition(0.001f, 0, 0);
System.out.println(entity.getPosition());*/ System.out.println(entity.getPosition());
} }
if(key == GLFW_KEY_D) { if(key == GLFW_KEY_D) {
/*entity.increasePosition(-0.001f, 0, 0); entity.increasePosition(-0.001f, 0, 0);
System.out.println(entity.getPosition());*/ System.out.println(entity.getPosition());
} }
if(key == GLFW_KEY_W) { if(key == GLFW_KEY_W) {
camera.moveForward(); entity.increasePosition(0, 0, 0.001f);
System.out.println(entity.getPosition());
} }
if(key == GLFW_KEY_S) { if(key == GLFW_KEY_S) {
camera.moveBackward(); entity.increasePosition(0, 0, -0.001f);
System.out.println(entity.getPosition());
} }
if(key == GLFW_KEY_Y && action == GLFW_PRESS) { if(key == GLFW_KEY_Y && action == GLFW_PRESS) {

View File

@ -27,9 +27,16 @@ public class Terrain {
TexturedModel hexagontexturedModel = new TexturedModel(hexagonRawModel, hexagonTexture); TexturedModel hexagontexturedModel = new TexturedModel(hexagonRawModel, hexagonTexture);
List<TerrainTile> generatedTerrainTiles = new ArrayList<>(); List<TerrainTile> generatedTerrainTiles = new ArrayList<>();
for(int x=-16; x<16; x++) { for(int y = -9; y<9; y++) {
generatedTerrainTiles.add(new TerrainTile(hexagontexturedModel, new Vector3f(x * 1.7319988f , 0, 0), 0, 0, 0,1)); for(int x=-16; x<16; x++) {
float xPos = x * 1.7319988f;
if(y % 2 == 0) {
xPos -= 0.866f;
}
generatedTerrainTiles.add(new TerrainTile(hexagontexturedModel, new Vector3f(xPos , 0, y * -1.4999994f), 0, 0, 0,1));
}
} }
generatedTerrainTiles.add(new TerrainTile(hexagontexturedModel, new Vector3f(0 , 0, 0), 0, 0, 0,1));
System.out.println(31 * 1.7319988f); System.out.println(31 * 1.7319988f);