Do alot of stuff

This commit is contained in:
2024-12-26 21:09:52 +01:00
parent 9f90739b90
commit 033909656a
151 changed files with 599059 additions and 157 deletions

View File

@@ -0,0 +1,80 @@
//
// Created by Bram on 25/12/2024.
//
#include "DioramaScene.h"
#include "../Utils.h"
#include "../Effects/Effect.h"
#include "../Effects/FireEffect.h"
#include <iostream>
void DioramaScene::Initialize(ID3D11Device *DevicePtr) {
std::vector<std::unique_ptr<Utils::MaterialMesh>> materialMeshes;
Utils::LoadObjWithMaterials("resources/scene.obj", materialMeshes, true, DevicePtr);
for (const auto &mesh: materialMeshes) {
if(mesh->vertices.size() > 0) {
std::shared_ptr<Material> material = std::make_shared<Material>();
BaseEffect *effect{ nullptr };
if(mesh->opacity_map != ""){
// std::cout << "Opacity map found" << mesh->opacity_map << std::endl;
effect = new FireEffect(DevicePtr, L"resources/Fire.fx");
material->diffuseTexturePtr = Texture::LoadFromFile("./resources/diorama/" + mesh->diffuse_texture, DevicePtr);
// material-> = Texture::LoadFromFile("./resources/" + mesh->opacity_map, DevicePtr);
} else {
material->diffuseTexturePtr = Texture::LoadFromFile("./resources/diorama/" + mesh->diffuse_texture, DevicePtr);
effect = new Effect(DevicePtr, L"resources/SimpleDiffuse.fx");
}
m_meshes.push_back(new Mesh(DevicePtr, mesh->vertices, mesh->indices, material, effect));
Matrix worldMatrix = m_meshes.back()->GetWorldMatrix();
worldMatrix *= Matrix::CreateScale(2.f, 2.f, 2.f);
worldMatrix *= Matrix::CreateScale(-1.f, 1.f, 1.f);
m_meshes.back()->SetWorldMatrix(worldMatrix);
}
}
materialMeshes.clear();
Utils::LoadObjWithMaterials("resources/brok/brok.obj", materialMeshes, true, DevicePtr);
for (const auto &mesh: materialMeshes) {
if(mesh->vertices.size() > 0) {
std::shared_ptr<Material> material = std::make_shared<Material>();
BaseEffect *effect{ nullptr };
effect = new Effect(DevicePtr, L"resources/SimpleDiffuse.fx");
material->diffuseTexturePtr = Texture::LoadFromFile("./resources/brok/" + mesh->diffuse_texture, DevicePtr);
m_meshes.push_back(new Mesh(DevicePtr, mesh->vertices, mesh->indices, material, effect));
Matrix worldMatrix = m_meshes.back()->GetWorldMatrix();
worldMatrix *= Matrix::CreateRotationY(3.14f / 2.f);
worldMatrix *= Matrix::CreateScale(0.021f, 0.021f, 0.021f);
worldMatrix *= Matrix::CreateScale(-1.f, 1.f, 1.f);
worldMatrix *= Matrix::CreateTranslation(-8.55f, 12.33f, 0.69f);
m_meshes.back()->SetWorldMatrix(worldMatrix);
}
}
}
std::vector<Mesh *> &DioramaScene::GetMeshes() {
return m_meshes;
}
std::vector<std::shared_ptr<Material>> &DioramaScene::GetMaterials() {
return m_materials;
}
void DioramaScene::Cleanup() {
for (Mesh *mesh : m_meshes) {
delete mesh;
}
m_meshes.clear();
m_materials.clear();
}