From 662fd9a8ef47ad528dae50cfbaaa7018e677d232 Mon Sep 17 00:00:00 2001 From: halotroop2288 Date: Tue, 25 Feb 2020 22:34:11 -0800 Subject: [PATCH] Other stuff --- .../github/halotroop/litecraft/Litecraft.java | 2 +- .../litecraft/types/block/Block.java | 27 ++++++++++--------- .../engine/cameras/FirstPersonCamera.java | 2 +- .../hydos/ginger/engine/obj/ModelLoader.java | 5 ++-- .../ginger/engine/obj/OBJFileLoader.java | 4 +-- .../engine/render/texture/ModelTexture.java | 1 + 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/github/halotroop/litecraft/Litecraft.java b/src/main/java/com/github/halotroop/litecraft/Litecraft.java index 88c6ffa..2aaf144 100644 --- a/src/main/java/com/github/halotroop/litecraft/Litecraft.java +++ b/src/main/java/com/github/halotroop/litecraft/Litecraft.java @@ -36,7 +36,7 @@ public class Litecraft extends Game Window.create(1200, 800, "LiteCraft", 60); GingerUtils.init(); Window.setBackgroundColour(0.2f, 0.2f, 0.6f); - TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/soil/gravel.png"); + TexturedModel dirtModel = ModelLoader.loadGenericCube("block/cubes/stone/brick/brick.png"); StaticCube.scaleCube(1); Player player = new Player(dirtModel, new Vector3f(0, 0, -3), 0, 180f, 0, new Vector3f(0.2f, 0.2f, 0.2f)); Camera camera = new Camera(new Vector3f(0, 0.1f, 0), player); diff --git a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java index ba38319..e12003c 100644 --- a/src/main/java/com/github/halotroop/litecraft/types/block/Block.java +++ b/src/main/java/com/github/halotroop/litecraft/types/block/Block.java @@ -5,17 +5,15 @@ import com.github.hydos.ginger.engine.render.models.TexturedModel; public class Block { + public static final Block AIR = new Block(new Properties().visible(false)); + public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties()); + public static final Block STONE = new Block("block/cubes/stone/basic/gneiss.png", new Properties()); + public static class Properties { // add properties to this builder! private boolean visible = true; private boolean fullCube = true; - public Properties visible(boolean visible) - { - this.visible = visible; - return this; - } - public Properties fullCube(boolean fullCube) { this.fullCube = fullCube; @@ -27,14 +25,20 @@ public class Block public boolean isVisible() { return visible; } - } - public static final Block AIR = new Block(new Properties().visible(false)); - public static final Block DIRT = new Block("block/cubes/soil/dirt.png", new Properties()); - public static final Block STONE = new Block("block/cubes/stone/cobblestone.png", new Properties()); + public Properties visible(boolean visible) + { + this.visible = visible; + return this; + } + } + public final TexturedModel model; public final boolean visible; + protected Block(Properties properties) + { this((TexturedModel) null, properties); } + protected Block(String texture, Properties properties) { this(ModelLoader.loadGenericCube(texture), properties); } @@ -43,7 +47,4 @@ public class Block this.model = model; this.visible = properties.visible; } - - protected Block(Properties properties) - { this((TexturedModel) null, properties); } } diff --git a/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java b/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java index 88573cd..5d61e3a 100644 --- a/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java +++ b/src/main/java/com/github/hydos/ginger/engine/cameras/FirstPersonCamera.java @@ -12,6 +12,7 @@ public class FirstPersonCamera extends Camera public FirstPersonCamera(Player player) { super(player); + player.isVisible = false; } public float getPitch() @@ -35,6 +36,5 @@ public class FirstPersonCamera extends Camera roll = player.getRotX(); yaw = -player.getRotY() + 180; pitch = player.getRotZ(); - } } diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java b/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java index 783d9d3..ffb6752 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java +++ b/src/main/java/com/github/hydos/ginger/engine/obj/ModelLoader.java @@ -16,8 +16,7 @@ public class ModelLoader public static TexturedModel loadModel(String objPath, String texturePath) { - Mesh data = OBJFileLoader.loadModel(objPath, texturePath); - TexturedModel tm = new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(), data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath)); - return tm; + Mesh data = OBJFileLoader.loadModel(objPath); + return new TexturedModel(Loader.loadToVAO(data.getVertices(), data.getIndices(),data.getNormals(), data.getTextureCoords()), new ModelTexture(texturePath)); } } diff --git a/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java b/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java index b0cb742..304a296 100644 --- a/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java +++ b/src/main/java/com/github/hydos/ginger/engine/obj/OBJFileLoader.java @@ -7,9 +7,9 @@ import com.github.hydos.ginger.engine.math.vectors.*; public class OBJFileLoader { - public static String resourceLocation = "C:/Users/Hayden/Desktop/Ginger3D/src/main/resources/models/"; + public static String resourceLocation = "~/Desktop/Ginger3D/src/main/resources/models/"; - public static Mesh loadModel(String filePath, String texturePath) + public static Mesh loadModel(String filePath) { AIScene scene = null; try diff --git a/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java b/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java index df97d58..935c102 100644 --- a/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java +++ b/src/main/java/com/github/hydos/ginger/engine/render/texture/ModelTexture.java @@ -24,6 +24,7 @@ public class ModelTexture public ModelTexture(String file) { + // TODO: Add a missing texture placholder in case of null file. texture = Image.createImage("/textures/" + file); GL11.glBindTexture(GL11.GL_TEXTURE_2D, this.textureID); GL11.glTexParameterf(GL11.GL_TEXTURE_2D, 10241, 9729.0f);