Prechádzať zdrojové kódy

Model specification for animated models

Tankernn 8 rokov pred
rodič
commit
7eeff86728

+ 3 - 19
src/main/java/eu/tankernn/game/Game.java

@@ -11,14 +11,10 @@ import org.lwjgl.util.vector.Vector3f;
 
 import eu.tankernn.gameEngine.GameLauncher;
 import eu.tankernn.gameEngine.TankernnGame3D;
-import eu.tankernn.gameEngine.animation.animatedModel.AnimatedModel;
-import eu.tankernn.gameEngine.animation.animation.Animation;
-import eu.tankernn.gameEngine.animation.loaders.AnimationLoader;
 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.ModelTexture;
 import eu.tankernn.gameEngine.loader.textures.TerrainTexturePack;
 import eu.tankernn.gameEngine.loader.textures.Texture;
 import eu.tankernn.gameEngine.particles.ParticleMaster;
@@ -27,7 +23,6 @@ import eu.tankernn.gameEngine.renderEngine.MasterRenderer;
 import eu.tankernn.gameEngine.renderEngine.water.WaterMaster;
 import eu.tankernn.gameEngine.renderEngine.water.WaterTile;
 import eu.tankernn.gameEngine.terrains.TerrainPack;
-import eu.tankernn.gameEngine.util.InternalFile;
 import eu.tankernn.gameEngine.util.MousePicker;
 
 public class Game extends TankernnGame3D {
@@ -40,20 +35,7 @@ public class Game extends TankernnGame3D {
 			e.printStackTrace();
 		}
 		
-		InternalFile charFile;
-		ModelTexture texture;
-		try {
-			charFile = new InternalFile("model.dae");
-			texture = new ModelTexture(Texture.newTexture(new InternalFile("diffuse.png")).anisotropic().create());
-		} catch (FileNotFoundException e) {
-			e.printStackTrace();
-			return;
-		}
-		
-		Animation anim = AnimationLoader.loadAnimation(charFile);
-		AnimatedModel playerModel = loader.loadDAE(charFile, texture);
-		playerModel.registerAnimation(anim);
-		player = new Player(playerModel, new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), 1, loader.getBoundingBox(0), terrainPack);
+		player = new Player(loader.getModel(3), new Vector3f(0, 0, 0), new Vector3f(0, 0, 0), 1, loader.getBoundingBox(0), terrainPack);
 		
 		entities.add(player);
 		camera = new PlayerCamera(player, terrainPack);
@@ -69,6 +51,8 @@ public class Game extends TankernnGame3D {
 		
 		entities.add(new Entity3D(loader.getModel(2), new Vector3f(10, 10, 10), new Vector3f(0, 0, 0), 1, loader.getBoundingBox(2)));
 		
+		entities.add(new Entity3D(loader.getModel(3), new Vector3f(10, 10, 10), new Vector3f(0, 0, 0), 1, loader.getBoundingBox(2)));
+		
 		postProcessor = new PostProcessor(loader);
 		picker = new MousePicker(camera, camera.getProjectionMatrix(), entities, guiMaster.getGuis());
 	}

+ 9 - 0
src/main/resources/models.json

@@ -14,5 +14,14 @@
 		name: "lantern",
 		id: 2,
 		reflectivity: 0.5d
+	},
+	{
+		name: "cowboy",
+		id: 3,
+		model: "model.dae",
+		texture: "diffuse.png",
+		animations: {
+			"run": "model.dae"
+		}
 	}
 ]