MODEL LOADING BABY WORKS
This commit is contained in:
@@ -7,10 +7,12 @@
|
||||
|
||||
#include "destrum/Components/MeshRendererComponent.h"
|
||||
#include "destrum/Components/Rotator.h"
|
||||
#include "destrum/Components/Spinner.h"
|
||||
#include "destrum/Components/OrbitAndSpin.h"
|
||||
#include "destrum/ObjectModel/GameObject.h"
|
||||
#include "destrum/Util/ModelLoader.h"
|
||||
|
||||
LightKeeper::LightKeeper(): App(), renderer(meshCache, materialCache) {
|
||||
|
||||
}
|
||||
|
||||
LightKeeper::~LightKeeper() {
|
||||
@@ -27,13 +29,15 @@ void LightKeeper::customInit() {
|
||||
std::string fileStr(file.begin(), file.end());
|
||||
spdlog::info("Read from assetfstest.txt: {}", fileStr);
|
||||
testMesh.name = "Test Mesh";
|
||||
testMesh.vertices = vertices;
|
||||
testMesh.indices = indices;
|
||||
// testMesh.vertices = vertices;
|
||||
// testMesh.indices = indices;
|
||||
|
||||
auto list_of_models = ModelLoader::LoadGLTF_CPUMeshes_MergedPerMesh(AssetFS::GetInstance().GetFullPath("game://kitty.glb").generic_string());
|
||||
testMesh = list_of_models[0];
|
||||
testMeshID = meshCache.addMesh(gfxDevice, testMesh);
|
||||
spdlog::info("TestMesh uploaded with id: {}", testMeshID);
|
||||
|
||||
const auto testimgpath = AssetFS::GetInstance().GetFullPath("engine://textures/kobe.png");
|
||||
const auto testimgpath = AssetFS::GetInstance().GetFullPath("game://kitty.png");
|
||||
auto testimgID = gfxDevice.loadImageFromFile(testimgpath);
|
||||
spdlog::info("Test image loaded with id: {}", testimgID);
|
||||
testMaterialID = materialCache.addMaterial(gfxDevice, {
|
||||
@@ -50,6 +54,35 @@ void LightKeeper::customInit() {
|
||||
auto meshComp = testCube->AddComponent<MeshRendererComponent>();
|
||||
meshComp->SetMeshID(testMeshID);
|
||||
meshComp->SetMaterialID(testMaterialID);
|
||||
testCube->AddComponent<Spinner>(glm::vec3(0, 1, 0), glm::radians(10.0f)); // spin around Y, rad/sec
|
||||
//rotate 180 around X axis
|
||||
testCube->GetTransform().SetLocalRotation(glm::quat(glm::vec3(glm::radians(180.0f), 0.0f, 0.0f)));
|
||||
//
|
||||
auto globeRoot = std::make_shared<GameObject>("GlobeRoot");
|
||||
globeRoot->GetTransform().SetWorldPosition(glm::vec3(0.0f));
|
||||
globeRoot->AddComponent<Spinner>(glm::vec3(0, 1, 0), 1.0f); // spin around Y, rad/sec
|
||||
scene.Add(globeRoot);
|
||||
|
||||
const int count = 100;
|
||||
const float radius = 5.0f;
|
||||
|
||||
const float orbitRadius = 5.0f;
|
||||
|
||||
for (int i = 0; i < count; ++i) {
|
||||
auto childCube = std::make_shared<GameObject>(fmt::format("ChildCube{}", i));
|
||||
|
||||
auto childMeshComp = childCube->AddComponent<MeshRendererComponent>();
|
||||
childMeshComp->SetMeshID(testMeshID);
|
||||
childMeshComp->SetMaterialID(testMaterialID);
|
||||
|
||||
childCube->GetTransform().SetWorldScale(glm::vec3(0.1f));
|
||||
|
||||
// Add orbit + self spin
|
||||
auto orbit = childCube->AddComponent<OrbitAndSpin>(orbitRadius, glm::vec3(0.0f));
|
||||
orbit->Randomize(1337u + (uint32_t)i); // stable random per index
|
||||
|
||||
scene.Add(childCube);
|
||||
}
|
||||
|
||||
// testCube->AddComponent<Rotator>(10, 5);
|
||||
|
||||
@@ -63,7 +96,6 @@ void LightKeeper::customUpdate(float dt) {
|
||||
}
|
||||
|
||||
void LightKeeper::customDraw() {
|
||||
|
||||
renderer.beginDrawing(gfxDevice);
|
||||
|
||||
const RenderContext ctx{
|
||||
|
||||
Reference in New Issue
Block a user