seperate model system to deal with buffers

liteCraft
hYdos 2020-03-06 06:09:00 +10:00
parent 1a02cef964
commit 98b0936bc5
2 changed files with 11 additions and 13 deletions

View File

@ -28,8 +28,7 @@ import org.lwjgl.vulkan.*;
import com.github.hydos.ginger.engine.common.info.RenderAPI; import com.github.hydos.ginger.engine.common.info.RenderAPI;
import com.github.hydos.ginger.engine.common.io.Window; 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.*;
import com.github.hydos.ginger.engine.vulkan.misc.ModelLoader.Model; import com.github.hydos.ginger.engine.vulkan.misc.VKModelLoader.VKMesh;
import com.github.hydos.ginger.engine.vulkan.pipelines.VKPipelineManager;
import com.github.hydos.ginger.engine.vulkan.swapchain.VKSwapchainManager; import com.github.hydos.ginger.engine.vulkan.swapchain.VKSwapchainManager;
public class VulkanLitecraft { public class VulkanLitecraft {
@ -1209,7 +1208,7 @@ public class VulkanLitecraft {
File modelFile = new File(ClassLoader.getSystemClassLoader().getResource("models/chalet.obj").getFile()); 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(); final int vertexCount = model.positions.size();

View File

@ -16,14 +16,13 @@ import java.util.logging.Logger;
import static java.util.Objects.requireNonNull; import static java.util.Objects.requireNonNull;
import static org.lwjgl.assimp.Assimp.*; import static org.lwjgl.assimp.Assimp.*;
@Deprecated public class VKModelLoader {
public class ModelLoader {
public static Model loadModel(File file, int flags) { public static VKMesh loadModel(File file, int flags) {
try(AIScene scene = aiImportFile(file.getAbsolutePath(), 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() + "..."); logger.info("Loading model " + file.getPath() + "...");
@ -31,7 +30,7 @@ public class ModelLoader {
throw new RuntimeException("Could not load model: " + aiGetErrorString()); throw new RuntimeException("Could not load model: " + aiGetErrorString());
} }
Model model = new Model(); VKMesh model = new VKMesh();
long startTime = System.nanoTime(); 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) { if(node.mMeshes() != null) {
processNodeMeshes(scene, node, model); 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(); PointerBuffer pMeshes = scene.mMeshes();
IntBuffer meshIndices = node.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); processPositions(mesh, model.positions);
processTexCoords(mesh, model.texCoords); processTexCoords(mesh, model.texCoords);
@ -117,13 +116,13 @@ public class ModelLoader {
} }
public static class Model { public static class VKMesh {
public final List<Vector3fc> positions; public final List<Vector3fc> positions;
public final List<Vector2fc> texCoords; public final List<Vector2fc> texCoords;
public final List<Integer> indices; public final List<Integer> indices;
public Model() { public VKMesh() {
this.positions = new ArrayList<>(); this.positions = new ArrayList<>();
this.texCoords = new ArrayList<>(); this.texCoords = new ArrayList<>();
this.indices = new ArrayList<>(); this.indices = new ArrayList<>();