|
@@ -6,48 +6,28 @@ import static eu.tankernn.game.Settings.NORMAL_MAP;
|
|
|
import static eu.tankernn.game.Settings.TEXTURE_FILES;
|
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
|
|
|
import org.lwjgl.util.vector.Vector3f;
|
|
|
-import org.lwjgl.util.vector.Vector4f;
|
|
|
|
|
|
-import eu.tankernn.gameEngine.TankernnGame;
|
|
|
-import eu.tankernn.gameEngine.entities.Entity;
|
|
|
+import eu.tankernn.gameEngine.GameLauncher;
|
|
|
+import eu.tankernn.gameEngine.TankernnGame3D;
|
|
|
+import eu.tankernn.gameEngine.entities.Entity3D;
|
|
|
import eu.tankernn.gameEngine.entities.Light;
|
|
|
import eu.tankernn.gameEngine.entities.Player;
|
|
|
import eu.tankernn.gameEngine.entities.PlayerCamera;
|
|
|
import eu.tankernn.gameEngine.loader.textures.TerrainTexturePack;
|
|
|
import eu.tankernn.gameEngine.loader.textures.Texture;
|
|
|
-import eu.tankernn.gameEngine.renderEngine.DisplayManager;
|
|
|
-import eu.tankernn.gameEngine.renderEngine.Scene;
|
|
|
-import eu.tankernn.gameEngine.renderEngine.gui.GuiTexture;
|
|
|
import eu.tankernn.gameEngine.renderEngine.skybox.Skybox;
|
|
|
import eu.tankernn.gameEngine.renderEngine.water.WaterTile;
|
|
|
import eu.tankernn.gameEngine.terrains.TerrainPack;
|
|
|
-import eu.tankernn.gameEngine.util.DistanceSorter;
|
|
|
import eu.tankernn.gameEngine.util.InternalFile;
|
|
|
-import eu.tankernn.gameEngine.util.MousePicker;
|
|
|
-
|
|
|
-public class Game extends TankernnGame {
|
|
|
- MousePicker picker;
|
|
|
-
|
|
|
- List<Entity> entities;
|
|
|
- List<Light> lights;
|
|
|
- List<GuiTexture> guis;
|
|
|
- Light sun;
|
|
|
-
|
|
|
- TerrainPack terrainPack;
|
|
|
-
|
|
|
- Player player;
|
|
|
|
|
|
+public class Game extends TankernnGame3D {
|
|
|
public Game() {
|
|
|
- super(new Skybox(Texture.newCubeMap(InternalFile.fromFilenames("skybox", TEXTURE_FILES, "png"), 200), Texture.newCubeMap(InternalFile.fromFilenames("skybox", NIGHT_TEXTURE_FILES, "png"), 200), 200), DUDV_MAP, NORMAL_MAP);
|
|
|
- entities = new ArrayList<Entity>();
|
|
|
-
|
|
|
- lights = new ArrayList<Light>();
|
|
|
- sun = new Light(new Vector3f(1000, 1000, 0), new Vector3f(1f, 1f, 1f));
|
|
|
- lights.add(sun);
|
|
|
+ super(Settings.GAME_NAME,
|
|
|
+ new Skybox(Texture.newCubeMap(InternalFile.fromFilenames("skybox", TEXTURE_FILES, "png"), 200),
|
|
|
+ Texture.newCubeMap(InternalFile.fromFilenames("skybox", NIGHT_TEXTURE_FILES, "png"), 200), 400),
|
|
|
+ DUDV_MAP, NORMAL_MAP, new Light(new Vector3f(1000, 1000, 0), new Vector3f(1f, 1f, 1f)));
|
|
|
|
|
|
try {
|
|
|
setupTerrain();
|
|
@@ -55,16 +35,14 @@ public class Game extends TankernnGame {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
setupWater();
|
|
|
- setupGuis();
|
|
|
|
|
|
player = new Player(0, new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), 1,
|
|
|
loader.getModel(0).getRawModel().getBoundingBox(), terrainPack);
|
|
|
camera = new PlayerCamera(player, terrainPack);
|
|
|
- entities.add(player);
|
|
|
- entities.add(new Entity(2, new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), 1,
|
|
|
+
|
|
|
+ entities.add(new Entity3D(2, new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), 1,
|
|
|
loader.getModel(2).getRawModel().getBoundingBox()));
|
|
|
lights.add(new Light(new Vector3f(0, 1000, 0), new Vector3f(1f, 1f, 1f)));
|
|
|
- picker = new MousePicker(camera, camera.getProjectionMatrix(), terrainPack, entities, guis);
|
|
|
}
|
|
|
|
|
|
private void setupTerrain() throws FileNotFoundException {
|
|
@@ -80,34 +58,19 @@ public class Game extends TankernnGame {
|
|
|
}
|
|
|
|
|
|
private void setupWater() {
|
|
|
- WaterTile water = new WaterTile(50, 50, 0);
|
|
|
+ WaterTile water = new WaterTile(50, 50, 0, 60);
|
|
|
waterMaster.addWaterTile(water);
|
|
|
}
|
|
|
|
|
|
- private void setupGuis() {
|
|
|
- guis = new ArrayList<GuiTexture>();
|
|
|
- }
|
|
|
-
|
|
|
public void update() {
|
|
|
- player.move();
|
|
|
- camera.update();
|
|
|
- picker.update();
|
|
|
+ super.update();
|
|
|
if (picker.getCurrentTerrainPoint() != null) {
|
|
|
entities.get(1).setPosition(picker.getCurrentTerrainPoint());
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- public void render() {
|
|
|
- // Sort list of lights
|
|
|
- DistanceSorter.sort(lights, camera);
|
|
|
-
|
|
|
- renderer.renderShadowMap(entities, sun);
|
|
|
-
|
|
|
- Scene scene = new Scene(entities, terrainPack, lights, camera, sky);
|
|
|
- waterMaster.renderBuffers(renderer, scene);
|
|
|
- renderer.renderScene(scene, new Vector4f(0, 1, 0, Float.MAX_VALUE));
|
|
|
- waterMaster.renderWater(camera, lights);
|
|
|
- DisplayManager.updateDisplay();
|
|
|
+ public static void main(String[] args) {
|
|
|
+ GameLauncher.init(Settings.GAME_NAME);
|
|
|
+ GameLauncher.launch(new Game());
|
|
|
}
|
|
|
}
|