Bladeren bron

Merge branch 'master' of git@tankernn.eu:game3d.git

Conflicts:
	res/models.json
	src/main/java/eu/tankernn/game/Game.java
	src/main/java/eu/tankernn/game/Launcher.java
frans 8 jaren geleden
bovenliggende
commit
6507006f0b

+ 3 - 3
pom.xml

@@ -3,7 +3,7 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>eu.tankernn.game</groupId>
 	<artifactId>tankernn-3d-game</artifactId>
-	<version>0.0.1-SNAPSHOT</version>
+	<version>0.0.2</version>
 	<name>Tankernn 3D Game</name>
 
 	<repositories>
@@ -18,7 +18,7 @@
 		<dependency>
 			<groupId>eu.tankernn.gameEngine</groupId>
 			<artifactId>tankernn-game-engine</artifactId>
-			<version>1.1</version>
+			<version>1.2</version>
 		</dependency>
 		<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
 		<dependency>
@@ -44,7 +44,7 @@
 							<archive>
 								<manifest>
 									<addClasspath>true</addClasspath>
-									<mainClass>eu.tankernn.game.Launcher</mainClass>
+									<mainClass>eu.tankernn.game.Game</mainClass>
 								</manifest>
 								<manifestEntries>
 									<Specification-Title>${project.name}</Specification-Title>

+ 9 - 0
res/models.json

@@ -8,11 +8,20 @@
 	{
 		name: "barrel",
 		id: 1,
+<<<<<<< HEAD
 		reflectivity: 0.5d
 	},
 	{
 		name: "lantern",
 		id: 2,
 		reflectivity: 0.5d
+=======
+		reflectivity: 0.5
+	},
+	{
+		name: "lantern",
+		id: 2,
+		reflectivity: 0.5
+>>>>>>> branch 'master' of git@tankernn.eu:game3d.git
 	}
 ]

+ 15 - 52
src/main/java/eu/tankernn/game/Game.java

@@ -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());
 	}
 }

+ 2 - 2
src/main/java/eu/tankernn/game/Settings.java

@@ -9,6 +9,6 @@ public class Settings {
 	public static final String[] NIGHT_TEXTURE_FILES = {"midnight_rt", "midnight_lf", "midnight_up", "midnight_dn", "midnight_bk", "midnight_ft"};
 	
 	// Water settings
-	public static final String DUDV_MAP = "waterDUDV";
-	public static final String NORMAL_MAP = "waterNormalMap";
+	public static final String DUDV_MAP = "waterDUDV.png";
+	public static final String NORMAL_MAP = "waterNormalMap.png";
 }

+ 20 - 0
src/main/java/eu/tankernn/game/networking/GameClientHandler.java

@@ -0,0 +1,20 @@
+package eu.tankernn.game.networking;
+
+import eu.tankernn.gameEngine.Chunk;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.channel.ChannelInboundHandlerAdapter;
+
+public class GameClientHandler extends ChannelInboundHandlerAdapter {
+	@Override
+	public void channelRead(ChannelHandlerContext ctx, Object msg) {
+		Chunk w = (Chunk) msg;
+		
+		
+	}
+
+	@Override
+	public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
+		cause.printStackTrace();
+		ctx.close();
+	}
+}