From 98b0936bc51de35219be28647be8d7ac8539183f Mon Sep 17 00:00:00 2001 From: hYdos Date: Fri, 6 Mar 2020 06:09:00 +1000 Subject: [PATCH] seperate model system to deal with buffers --- .../github/hydos/ginger/VulkanLitecraft.java | 5 ++--- .../{ModelLoader.java => VKModelLoader.java} | 19 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) rename src/main/java/com/github/hydos/ginger/engine/vulkan/misc/{ModelLoader.java => VKModelLoader.java} (91%) diff --git a/src/main/java/com/github/hydos/ginger/VulkanLitecraft.java b/src/main/java/com/github/hydos/ginger/VulkanLitecraft.java index 9e0ce5d..77ccd9c 100644 --- a/src/main/java/com/github/hydos/ginger/VulkanLitecraft.java +++ b/src/main/java/com/github/hydos/ginger/VulkanLitecraft.java @@ -28,8 +28,7 @@ import org.lwjgl.vulkan.*; import com.github.hydos.ginger.engine.common.info.RenderAPI; import com.github.hydos.ginger.engine.common.io.Window; import com.github.hydos.ginger.engine.vulkan.misc.*; -import com.github.hydos.ginger.engine.vulkan.misc.ModelLoader.Model; -import com.github.hydos.ginger.engine.vulkan.pipelines.VKPipelineManager; +import com.github.hydos.ginger.engine.vulkan.misc.VKModelLoader.VKMesh; import com.github.hydos.ginger.engine.vulkan.swapchain.VKSwapchainManager; public class VulkanLitecraft { @@ -1209,7 +1208,7 @@ public class VulkanLitecraft { File modelFile = new File(ClassLoader.getSystemClassLoader().getResource("models/chalet.obj").getFile()); - Model model = ModelLoader.loadModel(modelFile, aiProcess_FlipUVs | aiProcess_DropNormals); + VKMesh model = VKModelLoader.loadModel(modelFile, aiProcess_FlipUVs | aiProcess_DropNormals); final int vertexCount = model.positions.size(); diff --git a/src/main/java/com/github/hydos/ginger/engine/vulkan/misc/ModelLoader.java b/src/main/java/com/github/hydos/ginger/engine/vulkan/misc/VKModelLoader.java similarity index 91% rename from src/main/java/com/github/hydos/ginger/engine/vulkan/misc/ModelLoader.java rename to src/main/java/com/github/hydos/ginger/engine/vulkan/misc/VKModelLoader.java index b2b8f45..baa4c1f 100644 --- a/src/main/java/com/github/hydos/ginger/engine/vulkan/misc/ModelLoader.java +++ b/src/main/java/com/github/hydos/ginger/engine/vulkan/misc/VKModelLoader.java @@ -16,14 +16,13 @@ import java.util.logging.Logger; import static java.util.Objects.requireNonNull; import static org.lwjgl.assimp.Assimp.*; -@Deprecated -public class ModelLoader { +public class VKModelLoader { - public static Model loadModel(File file, int flags) { + public static VKMesh loadModel(File file, int flags) { try(AIScene scene = aiImportFile(file.getAbsolutePath(), flags)) { - Logger logger = Logger.getLogger(ModelLoader.class.getSimpleName()); + Logger logger = Logger.getLogger(VKModelLoader.class.getSimpleName()); logger.info("Loading model " + file.getPath() + "..."); @@ -31,7 +30,7 @@ public class ModelLoader { throw new RuntimeException("Could not load model: " + aiGetErrorString()); } - Model model = new Model(); + VKMesh model = new VKMesh(); long startTime = System.nanoTime(); @@ -43,7 +42,7 @@ public class ModelLoader { } } - private static void processNode(AINode node, AIScene scene, Model model) { + private static void processNode(AINode node, AIScene scene, VKMesh model) { if(node.mMeshes() != null) { processNodeMeshes(scene, node, model); @@ -61,7 +60,7 @@ public class ModelLoader { } - private static void processNodeMeshes(AIScene scene, AINode node, Model model) { + private static void processNodeMeshes(AIScene scene, AINode node, VKMesh model) { PointerBuffer pMeshes = scene.mMeshes(); IntBuffer meshIndices = node.mMeshes(); @@ -73,7 +72,7 @@ public class ModelLoader { } - private static void processMesh(AIScene scene, AIMesh mesh, Model model) { + private static void processMesh(AIScene scene, AIMesh mesh, VKMesh model) { processPositions(mesh, model.positions); processTexCoords(mesh, model.texCoords); @@ -117,13 +116,13 @@ public class ModelLoader { } - public static class Model { + public static class VKMesh { public final List positions; public final List texCoords; public final List indices; - public Model() { + public VKMesh() { this.positions = new ArrayList<>(); this.texCoords = new ArrayList<>(); this.indices = new ArrayList<>();