Set size of terrain and initialize camera ad midpoint of terrain
This commit is contained in:
		
							parent
							
								
									98b6208c74
								
							
						
					
					
						commit
						ba47896d88
					
				| @ -128,19 +128,16 @@ public class Engine { | ||||
| 
 | ||||
|         //Generate Simple, Flat Terrain | ||||
|         Terrain terrain = new Terrain(0,0, loader, new ModelTexture(loader.loadTexture("grass"))); | ||||
|         Terrain terrain1 = new Terrain(1,0, loader, new ModelTexture(loader.loadTexture("grass"))); | ||||
| 
 | ||||
|         // Run the rendering loop until the user has attempted to close | ||||
|         // the window or has pressed the ESCAPE key. | ||||
|         MasterRenderer renderer = new MasterRenderer(); | ||||
|         while ( !glfwWindowShouldClose(window) ) { | ||||
|             //entity.increaseRotation(0,1,0); | ||||
|             renderer.processTerrain(terrain1); | ||||
|             renderer.processTerrain(terrain); | ||||
|             //renderer.processEntity(entity); | ||||
|             renderer.render(light, camera); | ||||
|             glfwSwapBuffers(window); // swap the color buffers | ||||
| 
 | ||||
|             // Poll for window events. The key callback above will only be | ||||
|             // invoked during this call. | ||||
|             glfwPollEvents(); | ||||
|  | ||||
| @ -4,8 +4,8 @@ import utils.vectors.Vector3f; | ||||
| 
 | ||||
| public class Camera { | ||||
| 
 | ||||
|     private Vector3f position = new Vector3f(0,10,0); | ||||
|     private float pitch; | ||||
|     private Vector3f position = new Vector3f(50,100,50); | ||||
|     private float pitch = 90; | ||||
|     private float yaw = 180; | ||||
|     private float roll; | ||||
| 
 | ||||
|  | ||||
| @ -6,7 +6,8 @@ import core.engine.textures.ModelTexture; | ||||
| 
 | ||||
| public class Terrain { | ||||
| 
 | ||||
|     private static final float SIZE = 800; | ||||
|     private static final float WIDTH = 100; | ||||
|     private static final float DEPTH = 100; | ||||
|     private static final int VERTEX_COUNT = 128; | ||||
| 
 | ||||
|     private float x; | ||||
| @ -16,8 +17,8 @@ public class Terrain { | ||||
| 
 | ||||
|     public Terrain(int gridX, int gridZ, Loader loader, ModelTexture modelTexture) { | ||||
|         this.texture = modelTexture; | ||||
|         this.x = gridX * SIZE; | ||||
|         this.z = gridZ * SIZE; | ||||
|         this.x = gridX * WIDTH; | ||||
|         this.z = gridZ * DEPTH; | ||||
|         this.model = generateTerrain(loader); | ||||
|     } | ||||
| 
 | ||||
| @ -30,9 +31,9 @@ public class Terrain { | ||||
|         int vertexPointer = 0; | ||||
|         for(int i=0;i<VERTEX_COUNT;i++){ | ||||
|             for(int j=0;j<VERTEX_COUNT;j++){ | ||||
|                 vertices[vertexPointer*3] = (float)j/((float)VERTEX_COUNT - 1) * SIZE; | ||||
|                 vertices[vertexPointer*3] = (float)j/((float)VERTEX_COUNT - 1) * WIDTH; | ||||
|                 vertices[vertexPointer*3+1] = 0; | ||||
|                 vertices[vertexPointer*3+2] = (float)i/((float)VERTEX_COUNT - 1) * SIZE; | ||||
|                 vertices[vertexPointer*3+2] = (float)i/((float)VERTEX_COUNT - 1) * DEPTH; | ||||
|                 normals[vertexPointer*3] = 0; | ||||
|                 normals[vertexPointer*3+1] = 1; | ||||
|                 normals[vertexPointer*3+2] = 0; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user