Minor Update - V8.1.0
[FIX] : - Alpha Shader [FEAT] : - Add Scene action in bar menu - Start to implemented Save And Load Logique
This commit is contained in:
@@ -28,10 +28,10 @@ float4 FontPixelShader(PixelInputType input) : SV_TARGET
|
||||
// Sample the texture pixel at this location.
|
||||
color = shaderTexture.Sample(SampleType, input.tex);
|
||||
|
||||
// If the color is black on the texture then treat this pixel as transparent.
|
||||
// If the color is black on the texture then discard this pixel.
|
||||
if (color.r == 0.0f && color.g == 0.0f && color.b == 0.0f)
|
||||
{
|
||||
return color / color;
|
||||
discard;
|
||||
}
|
||||
|
||||
// If the color is other than black on the texture then this is a pixel in the font so draw it using the font pixel color.
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#include "reflectionshaderclass.h"
|
||||
#include "physics.h"
|
||||
#include "frustum.h"
|
||||
#include <fstream>
|
||||
|
||||
#include <WICTextureLoader.h>
|
||||
#include <comdef.h> // Pour _com_error
|
||||
@@ -145,6 +146,12 @@ public:
|
||||
void SetCanFixedUpdate(bool canFixedUpdate) { CanFixedUpdate = canFixedUpdate; };
|
||||
|
||||
ID3D11ShaderResourceView* GetBackBufferSRV() const {return m_BackBufferSRV;};
|
||||
|
||||
// Save and load scene
|
||||
void SaveScene();
|
||||
void LoadScene();
|
||||
|
||||
void SetScenePath(std::string path) { m_scenePath = path; };
|
||||
|
||||
private:
|
||||
bool Render(float, float, float, float, float);
|
||||
@@ -160,7 +167,7 @@ private:
|
||||
void ConstructSkybox(); // Construct the skybox
|
||||
void UpdateSkyboxPosition(); // Update the skybox position
|
||||
bool RenderSkybox(XMMATRIX view, XMMATRIX projection); // Render the skybox
|
||||
|
||||
|
||||
public :
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
std::vector<ID3D11ShaderResourceView*> m_SkyboxTextures;
|
||||
@@ -180,6 +187,8 @@ private :
|
||||
HWND m_hwnd;
|
||||
bool m_windowed;
|
||||
|
||||
std::string m_scenePath;
|
||||
|
||||
// ------------------------------------- //
|
||||
// ------------- RENDERING ------------- //
|
||||
// ------------------------------------- //
|
||||
@@ -202,6 +211,7 @@ private :
|
||||
std::vector<Object*> m_terrainChunk;
|
||||
float m_speed = 0.1f; // speed for the demo spinning object
|
||||
std::vector<Object*> m_object;
|
||||
std::vector<Object*> m_ImportedObject;
|
||||
int m_ObjectId = 0;
|
||||
std::vector<std::reference_wrapper<std::vector<Object*>>> m_RenderQueues;
|
||||
std::vector<Object*> m_Skybox;
|
||||
|
@@ -2,7 +2,8 @@
|
||||
#ifndef _IMGUI_MANAGER_H_
|
||||
#define _IMGUI_MANAGER_H_
|
||||
|
||||
#include "Logger.h"
|
||||
#include "Logger.h"
|
||||
#include "sceneManager.h"
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_impl_dx11.h>
|
||||
@@ -23,7 +24,7 @@ public:
|
||||
void Shutdown();
|
||||
void Render(ApplicationClass* app);
|
||||
void NewFrame();
|
||||
void SetupDockspace();
|
||||
void SetupDockspace(ApplicationClass* app);
|
||||
|
||||
// Widgets
|
||||
void WidgetSpeedSlider(float* speed);
|
||||
|
@@ -77,7 +77,8 @@ public:
|
||||
REFRACTION,
|
||||
TEXTURE,
|
||||
SKYBOX,
|
||||
SUNLIGHT
|
||||
SUNLIGHT,
|
||||
ALPHA_MAPPING
|
||||
};
|
||||
|
||||
ShaderType GetActiveShader() const { return m_activeShader; };
|
||||
|
40
enginecustom/src/inc/system/sceneManager.h
Normal file
40
enginecustom/src/inc/system/sceneManager.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class sceneManager
|
||||
{
|
||||
public:
|
||||
static sceneManager& Get()
|
||||
{
|
||||
static sceneManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
sceneManager(sceneManager const&) = delete;
|
||||
void operator=(sceneManager const&) = delete;
|
||||
|
||||
void SetSceneFilePath(const std::string& path) { m_sceneFilePath = path; }
|
||||
void SetSceneFileName(const std::string& name) { m_sceneFileName = name; }
|
||||
|
||||
bool SaveScene()
|
||||
{
|
||||
// Implement the save scene logic here
|
||||
return true;
|
||||
}
|
||||
|
||||
bool LoadScene()
|
||||
{
|
||||
|
||||
|
||||
// Implement the load scene logic here
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
sceneManager() = default;
|
||||
~sceneManager() = default;
|
||||
|
||||
// Scene file path
|
||||
std::string m_sceneFilePath;
|
||||
std::string m_sceneFileName;
|
||||
};
|
@@ -3,12 +3,17 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
static bool DEBUG_MODE = true;
|
||||
|
||||
#include "Logger.h"
|
||||
|
||||
#include "inputclass.h"
|
||||
#include "applicationclass.h"
|
||||
#include "imguiManager.h"
|
||||
#include <mutex>
|
||||
#include <filesystem>
|
||||
#include <commdlg.h>
|
||||
|
||||
#include "../resources.h"
|
||||
#include <chrono>
|
||||
|
||||
@@ -27,6 +32,8 @@ public:
|
||||
|
||||
void SendPath(wchar_t* path, std::filesystem::path WFolder);
|
||||
|
||||
void GetScenePath();
|
||||
|
||||
protected:
|
||||
bool Frame();
|
||||
void InitializeWindows(int&, int&);
|
||||
@@ -54,7 +61,6 @@ private:
|
||||
// FUNCTION PROTOTYPES //
|
||||
/////////////////////////
|
||||
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
static LRESULT CALLBACK SecondaryWndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
|
||||
/////////////
|
||||
|
@@ -62,12 +62,16 @@ bool SystemClass::Initialize()
|
||||
}
|
||||
|
||||
// Initialize imgui
|
||||
m_imguiManager = new imguiManager;
|
||||
result = m_imguiManager->Initialize(m_hwnd, m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
|
||||
if (!result)
|
||||
if(DEBUG_MODE)
|
||||
{
|
||||
return false;
|
||||
m_imguiManager = new imguiManager;
|
||||
result = m_imguiManager->Initialize(m_hwnd, m_Application->GetDirect3D()->GetDevice(), m_Application->GetDirect3D()->GetDeviceContext());
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -144,6 +148,12 @@ void SystemClass::Run()
|
||||
// Loop until there is a quit message from the window or the user.
|
||||
done = false;
|
||||
|
||||
|
||||
// Ask For the scene file
|
||||
SetScenePath();
|
||||
|
||||
m_Application->LoadScene();
|
||||
|
||||
while (!done)
|
||||
{
|
||||
// Handle the windows messages.
|
||||
@@ -206,13 +216,17 @@ bool SystemClass::Frame()
|
||||
return false;
|
||||
}
|
||||
|
||||
// Render ImGui
|
||||
result = m_imguiManager->ImGuiWidgetRenderer(m_Application);
|
||||
if (!result)
|
||||
if (DEBUG_MODE)
|
||||
{
|
||||
Logger::Get().Log("Failed to render ImGui widgets", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
// Render ImGui
|
||||
result = m_imguiManager->ImGuiWidgetRenderer(m_Application);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to render ImGui widgets", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
m_Application->GetDirect3D()->EndScene();
|
||||
|
||||
@@ -468,15 +482,29 @@ void SystemClass::SendPath(wchar_t* path, std::filesystem::path WFolder)
|
||||
m_Application->SetWFolder(WFolder);
|
||||
}
|
||||
|
||||
LRESULT CALLBACK SecondaryWndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
|
||||
void SystemClass::GetScenePath()
|
||||
{
|
||||
switch (umessage)
|
||||
OPENFILENAME ofn;
|
||||
wchar_t szFile[260];
|
||||
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = m_hwnd;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Ker Scene\0*.ker\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (GetOpenFileName(&ofn) == TRUE)
|
||||
{
|
||||
case WM_DESTROY:
|
||||
case WM_CLOSE:
|
||||
PostQuitMessage(0);
|
||||
return 0;
|
||||
default:
|
||||
return DefWindowProc(hwnd, umessage, wparam, lparam);
|
||||
std::filesystem::path filepath = ofn.lpstrFile;
|
||||
// convert to string
|
||||
std::string path = filepath.string();
|
||||
m_Application->SetScenePath(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
#include "applicationclass.h"
|
||||
|
||||
#include "systemclass.h"
|
||||
|
||||
ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
|
||||
{
|
||||
m_Direct3D = nullptr;
|
||||
@@ -989,15 +991,17 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
}
|
||||
|
||||
// Redimensionner la texture de rendu si n<>cessaire
|
||||
if ((float)m_SceneTexture->GetTextureWidth() != windowSize.x || (float)m_SceneTexture->GetTextureHeight() != windowSize.y)
|
||||
if (DEBUG_MODE)
|
||||
{
|
||||
m_SceneTexture->Shutdown();
|
||||
m_SceneTexture->Initialize(m_Direct3D->GetDevice(), (int)windowSize.x, (int)windowSize.y, SCREEN_DEPTH, SCREEN_NEAR, 1);
|
||||
}
|
||||
if ((float)m_SceneTexture->GetTextureWidth() != windowSize.x || (float)m_SceneTexture->GetTextureHeight() != windowSize.y)
|
||||
{
|
||||
m_SceneTexture->Shutdown();
|
||||
m_SceneTexture->Initialize(m_Direct3D->GetDevice(), (int)windowSize.x, (int)windowSize.y, SCREEN_DEPTH, SCREEN_NEAR, 1);
|
||||
}
|
||||
|
||||
m_Direct3D->SetBackBufferRenderTarget();
|
||||
m_Direct3D->ResetViewport();
|
||||
|
||||
m_Direct3D->SetBackBufferRenderTarget();
|
||||
m_Direct3D->ResetViewport();
|
||||
}
|
||||
|
||||
/// CPT ALED C'EST ICI QUE CA SE PASSE ///
|
||||
|
||||
@@ -1855,6 +1859,31 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
// Utiliser l'enum ShaderType pour d<>terminer quel shader utiliser
|
||||
switch (object->GetActiveShader())
|
||||
{
|
||||
|
||||
case Object::ALPHA_MAPPING:
|
||||
|
||||
// Enable alpha blending for transparency.
|
||||
m_Direct3D->EnableAlphaBlending();
|
||||
|
||||
result = m_ShaderManager->RenderAlphaMapShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
object->GetIndexCount(),
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(5),
|
||||
object->GetTexture(3)
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the alpha map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
m_Direct3D->DisableAlphaBlending();
|
||||
return false;
|
||||
}
|
||||
m_Direct3D->DisableAlphaBlending();
|
||||
break;
|
||||
|
||||
case Object::CEL_SHADING:
|
||||
result = m_ShaderManager->RenderCelShadingShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
@@ -1895,7 +1924,21 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
break;
|
||||
|
||||
case Object::SPECULAR_MAPPING:
|
||||
result = m_ShaderManager->RenderSpecMapShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0), object->GetTexture(1), object->GetTexture(2), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), m_Camera->GetPosition(), m_Lights[0]->GetSpecularColor(), m_Lights[0]->GetSpecularPower());
|
||||
result = m_ShaderManager->RenderSpecMapShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
object->GetIndexCount(),
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(1),
|
||||
object->GetTexture(2),
|
||||
m_Lights[0]->GetDirection(),
|
||||
m_Lights[0]->GetDiffuseColor(),
|
||||
m_Camera->GetPosition(),
|
||||
m_Lights[0]->GetSpecularColor(),
|
||||
m_Lights[0]->GetSpecularPower()
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the specular map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -1903,7 +1946,14 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
}
|
||||
break;
|
||||
case Object::TEXTURE:
|
||||
result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection, object->GetTexture(0));
|
||||
result = m_ShaderManager->RenderTextureShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
object->GetIndexCount(),
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0)
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -1912,8 +1962,17 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
break;
|
||||
|
||||
case Object::LIGHTING:
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection,
|
||||
object->GetTexture(0), diffuse, position, ambient);
|
||||
result = m_ShaderManager->RenderlightShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
object->GetIndexCount(),
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
diffuse,
|
||||
position,
|
||||
ambient
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the object model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -1932,7 +1991,8 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
m_SunLight->GetDiffuseColor(),
|
||||
m_SunLight->GetAmbientColor(),
|
||||
m_SunLight->GetDirection(),
|
||||
m_SunLight->GetIntensity());
|
||||
m_SunLight->GetIntensity()
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the object model using the sunlight shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -1940,8 +2000,17 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
}
|
||||
break;
|
||||
default:
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, view, projection,
|
||||
object->GetTexture(0), diffuse, position, ambient);
|
||||
result = m_ShaderManager->RenderlightShader(
|
||||
m_Direct3D->GetDeviceContext(),
|
||||
object->GetIndexCount(),
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
diffuse,
|
||||
position,
|
||||
ambient
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the object model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -2174,4 +2243,15 @@ bool ApplicationClass::RenderSkybox(XMMATRIX view, XMMATRIX projection) {
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApplicationClass::SaveScene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ApplicationClass::LoadScene()
|
||||
{
|
||||
// Read the file and load the scene
|
||||
|
||||
}
|
@@ -69,7 +69,7 @@ void imguiManager::NewFrame()
|
||||
ImGui::NewFrame();
|
||||
}
|
||||
|
||||
void imguiManager::SetupDockspace() {
|
||||
void imguiManager::SetupDockspace(ApplicationClass* app) {
|
||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||
ImGui::SetNextWindowPos(viewport->Pos);
|
||||
@@ -97,6 +97,22 @@ void imguiManager::SetupDockspace() {
|
||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
// Scene file menu
|
||||
if (ImGui::BeginMenu("Scene")) {
|
||||
if (ImGui::MenuItem("Save Scene")) {
|
||||
// Save the scene
|
||||
app->SaveScene();
|
||||
}
|
||||
if (ImGui::MenuItem("Load Scene")) {
|
||||
// Load the scene
|
||||
app->LoadScene();
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
@@ -198,7 +214,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
{
|
||||
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||
}
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Texture
|
||||
@@ -212,6 +228,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
};
|
||||
|
||||
// Display all images
|
||||
ImGui::BeginChild("TextureChild", ImVec2(0, 100), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
for (int count = 0; count < textureCategories.size(); count++)
|
||||
{
|
||||
std::string textureLabel = "Texture##" + std::to_string(index) + "##" + std::to_string(count);
|
||||
@@ -231,7 +248,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
ofn.lpstrFile[0] = '\0';
|
||||
szFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
@@ -260,7 +277,7 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndChild();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -274,8 +291,23 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
ImGui::Separator();
|
||||
|
||||
// Liste des options
|
||||
const char* shaderOptions[] = { "Enable Global Lighting", "Enable Lighting", "Enable Cel Shading", "Enable Normal Mapping", "Enable Specular Mapping" };
|
||||
Object::ShaderType shaderTypes[] = { Object::SUNLIGHT,Object::LIGHTING, Object::CEL_SHADING, Object::NORMAL_MAPPING, Object::SPECULAR_MAPPING };
|
||||
const char* shaderOptions[] = {
|
||||
"Enable Global Lighting",
|
||||
"Enable Lighting",
|
||||
"Enable Cel Shading",
|
||||
"Enable Normal Mapping",
|
||||
"Enable Specular Mapping",
|
||||
"Enable Alpha Mapping"
|
||||
};
|
||||
|
||||
Object::ShaderType shaderTypes[] = {
|
||||
Object::SUNLIGHT,
|
||||
Object::LIGHTING,
|
||||
Object::CEL_SHADING,
|
||||
Object::NORMAL_MAPPING,
|
||||
Object::SPECULAR_MAPPING,
|
||||
Object::ALPHA_MAPPING
|
||||
};
|
||||
|
||||
// Variable pour stocker l'option s<>lectionn<6E>e
|
||||
static int currentShader = 0; // Index de l'option actuellement s<>lectionn<6E>e
|
||||
@@ -374,7 +406,7 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
||||
NewFrame();
|
||||
|
||||
// Setup the dockspace
|
||||
SetupDockspace();
|
||||
SetupDockspace(app);
|
||||
|
||||
//ImGui Widget
|
||||
ImGui::Begin("Khaotic Engine", NULL);
|
||||
|
Reference in New Issue
Block a user