finished game-engine-terrain-generation #2
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
@ -124,7 +124,7 @@ public class Engine {
|
||||
Light light = new Light(new Vector3f(0,0,-20), new Vector3f(1,1,1));
|
||||
|
||||
//Generate Simple, Flat Terrain
|
||||
Terrain terrain = new Terrain( loader, new ModelTexture(loader.loadTexture("white")));
|
||||
Terrain terrain = new Terrain( loader, new ModelTexture(loader.loadTexture("white")), 16, 32);
|
||||
|
||||
//Create Hexagon
|
||||
HexagonModel hexagonModel = new HexagonModel();
|
||||
|
@ -17,7 +17,7 @@ out vec3 toLightVector;
|
||||
void main(void) {
|
||||
vec4 worldPosition = transformationMatrix * vec4(position, 1.0);
|
||||
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
||||
pass_textureCoords = textureCoords * 40;
|
||||
pass_textureCoords = textureCoords;
|
||||
|
||||
surfaceNormal = (transformationMatrix * vec4(normal, 0.0)).xyz;
|
||||
toLightVector = lightPosition - worldPosition.xyz;
|
||||
|
@ -14,13 +14,19 @@ public class Terrain {
|
||||
|
||||
private List<TerrainTile> terrainTiles = new ArrayList<>();
|
||||
|
||||
public Terrain(Loader loader, ModelTexture modelTexture) {
|
||||
public Terrain(Loader loader, ModelTexture modelTexture, int rows, int columns) {
|
||||
HexagonModel hexagonModel = new HexagonModel();
|
||||
RawModel rawModel = loader.loadHexagon(hexagonModel);
|
||||
TexturedModel texturedModel = new TexturedModel(rawModel, modelTexture);
|
||||
for(int j=22; j>0; j--) {
|
||||
for(int i=-8; i<8; i++) {
|
||||
terrainTiles.add(new TerrainTile(texturedModel, new Vector3f(j - 0.75f *2,0, i* (float)(0.866*2)), 0, 30, 0, 1));
|
||||
for(int row = 0; row < rows; row++) {
|
||||
for(int column = 0; column < columns; column++) {
|
||||
if(row % 2 == 1) {
|
||||
terrainTiles.add(new TerrainTile(texturedModel, new Vector3f(column * 2* 0.866f, 0, row * 1.5f),0,0,0,1));
|
||||
|
||||
} else {
|
||||
terrainTiles.add(new TerrainTile(texturedModel, new Vector3f(column *2 * 0.866f - 0.866f, 0, row * 1.5f),0,0,0,1));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user