From 39f01e54a2406db6c81c841c41756ac6f8bf8032 Mon Sep 17 00:00:00 2001
From: Vanessa Karolek <vaka1997@uni-koblenz.de>
Date: Thu, 26 Aug 2021 15:57:28 +0200
Subject: [PATCH] [#92] add simple mesh to main.cpp for first AS testing

---
 .../rtx/resources/cube/boards2_vcyc_jpg.jpg   |  3 ++
 projects/rtx/resources/cube/cube.bin          |  3 ++
 projects/rtx/resources/cube/cube.blend        |  3 ++
 projects/rtx/resources/cube/cube.blend1       |  3 ++
 projects/rtx/resources/cube/cube.glb          |  3 ++
 projects/rtx/resources/cube/cube.gltf         |  3 ++
 projects/rtx/src/main.cpp                     | 42 ++++++++++++++++---
 7 files changed, 55 insertions(+), 5 deletions(-)
 create mode 100644 projects/rtx/resources/cube/boards2_vcyc_jpg.jpg
 create mode 100644 projects/rtx/resources/cube/cube.bin
 create mode 100644 projects/rtx/resources/cube/cube.blend
 create mode 100644 projects/rtx/resources/cube/cube.blend1
 create mode 100644 projects/rtx/resources/cube/cube.glb
 create mode 100644 projects/rtx/resources/cube/cube.gltf

diff --git a/projects/rtx/resources/cube/boards2_vcyc_jpg.jpg b/projects/rtx/resources/cube/boards2_vcyc_jpg.jpg
new file mode 100644
index 00000000..2636039e
--- /dev/null
+++ b/projects/rtx/resources/cube/boards2_vcyc_jpg.jpg
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:cca33a6e58ddd1b37a6e6853a9aa0e7b15ca678937119194752393dd2a0a0564
+size 1192476
diff --git a/projects/rtx/resources/cube/cube.bin b/projects/rtx/resources/cube/cube.bin
new file mode 100644
index 00000000..3303cd86
--- /dev/null
+++ b/projects/rtx/resources/cube/cube.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:9bb9b6b8bbe50a0aaa517057f245ee844f80afa7426dacb2aed4128f71629ce4
+size 840
diff --git a/projects/rtx/resources/cube/cube.blend b/projects/rtx/resources/cube/cube.blend
new file mode 100644
index 00000000..62ccb2c7
--- /dev/null
+++ b/projects/rtx/resources/cube/cube.blend
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:a6c1e245f259c610528c9485db6688928faac0ab2addee9e3c2dde7740e4dd09
+size 774920
diff --git a/projects/rtx/resources/cube/cube.blend1 b/projects/rtx/resources/cube/cube.blend1
new file mode 100644
index 00000000..13f21dcc
--- /dev/null
+++ b/projects/rtx/resources/cube/cube.blend1
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f4496f423569b8ca81f3b3a55fad00f925557e0193fb9dbe6cdce7e71fb48f7b
+size 774920
diff --git a/projects/rtx/resources/cube/cube.glb b/projects/rtx/resources/cube/cube.glb
new file mode 100644
index 00000000..66a42c65
--- /dev/null
+++ b/projects/rtx/resources/cube/cube.glb
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:198568b715f397d78f7c358c0f709a419e7fd677e54cdec7c19f71b5ed264897
+size 1194508
diff --git a/projects/rtx/resources/cube/cube.gltf b/projects/rtx/resources/cube/cube.gltf
new file mode 100644
index 00000000..42817614
--- /dev/null
+++ b/projects/rtx/resources/cube/cube.gltf
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:f82f455647a84ca6242882ae26a79a499d3ce594f8de317ab89488c5b79721ac
+size 2823
diff --git a/projects/rtx/src/main.cpp b/projects/rtx/src/main.cpp
index 92e1c0e8..6a001509 100644
--- a/projects/rtx/src/main.cpp
+++ b/projects/rtx/src/main.cpp
@@ -54,12 +54,44 @@ int main(int argc, const char** argv) {
 	);
 
 	// init RTXModule
-	vk::PhysicalDevice physicalDevice = core.getContext().getPhysicalDevice();
-	rtxModule.init(physicalDevice);
+//	rtxModule.init(&core);
 
-	vkcv::scene::Scene scene = vkcv::scene::Scene::load(core, std::filesystem::path(
-			argc > 1 ? argv[1] : "resources/Sponza/Sponza.gltf"
-	));
+//	vkcv::scene::Scene scene = vkcv::scene::Scene::load(core, std::filesystem::path(
+//			argc > 1 ? argv[1] : "resources/Sponza/Sponza.gltf"
+//	));
+
+    // TODO: replace by bigger scene
+	vkcv::asset::Scene mesh;
+
+	const char* path = argc > 1 ? argv[1] : "resources/cube/cube.gltf";
+	int result = vkcv::asset::loadScene(path, mesh);
+
+	if (result == 1) {
+	    std::cout << "Mesh loading successful!" << std::endl;
+	} else {
+	    std::cerr << "Mesh loading failed: " << result << std::endl;
+	    return 1;
+	}
+
+	assert(!mesh.vertexGroups.empty());
+	auto vertexBuffer = core.createBuffer<uint8_t>(
+	        vkcv::BufferType::VERTEX,
+	        mesh.vertexGroups[0].vertexBuffer.data.size(),
+	        vkcv::BufferMemoryType::DEVICE_LOCAL
+	        );
+
+	vk::Buffer vertexBufferHandle = vertexBuffer.getVulkanHandle();
+
+
+	vertexBuffer.fill(mesh.vertexGroups[0].vertexBuffer.data);
+
+	auto indexBuffer = core.createBuffer<uint8_t>(
+	        vkcv::BufferType::INDEX,
+	        mesh.vertexGroups[0].indexBuffer.data.size(),
+	        vkcv::BufferMemoryType::DEVICE_LOCAL
+	        );
+
+	indexBuffer.fill(mesh.vertexGroups[0].indexBuffer.data);
 
 	const vkcv::AttachmentDescription present_color_attachment(
 		vkcv::AttachmentOperation::STORE,
-- 
GitLab