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.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();

View File

@ -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<Vector3fc> positions;
public final List<Vector2fc> texCoords;
public final List<Integer> indices;
public Model() {
public VKMesh() {
this.positions = new ArrayList<>();
this.texCoords = new ArrayList<>();
this.indices = new ArrayList<>();