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:
CatChow0 2025-03-17 12:59:04 +01:00
parent 8b9e860c00
commit 7eb6ed72e6
16 changed files with 3304 additions and 108 deletions

View File

@ -5,10 +5,17 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/enginecustom/TODO.txt" afterDir="false" />
<change afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/sceneManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/shader-error.txt" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/shader-error.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/hlsl/font.ps" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/font.ps" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/systemclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/systemclass.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Systemclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Systemclass.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
@ -74,32 +81,32 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;C++ Project.enginecustom.executor&quot;: &quot;Run&quot;,
&quot;C/C++ Project.enginecustom.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.keymap&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"C++ Project.enginecustom.executor": "Run",
"C/C++ Project.enginecustom.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
},
&quot;keyToStringList&quot;: {
&quot;rider.external.source.directories&quot;: [
&quot;C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache&quot;,
&quot;C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache&quot;,
&quot;C:\\Users\\arivas\\AppData\\Local\\Symbols\\src&quot;
"keyToStringList": {
"rider.external.source.directories": [
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
"C:\\Users\\arivas\\AppData\\Local\\Symbols\\src"
]
}
}</component>
}]]></component>
<component name="RunManager" selected="C++ Project.enginecustom">
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
<configuration_1>
@ -165,6 +172,11 @@
<workItem from="1738515031789" duration="14018000" />
<workItem from="1741705445392" duration="138000" />
<workItem from="1741706018301" duration="5499000" />
<workItem from="1742198713923" duration="31000" />
<workItem from="1742198792655" duration="4618000" />
<workItem from="1742203643675" duration="600000" />
<workItem from="1742206836574" duration="258000" />
<workItem from="1742207107802" duration="5340000" />
</task>
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
<option name="closed" value="true" />
@ -207,4 +219,8 @@
<MESSAGE value="Patch update - add menu button" />
<option name="LAST_COMMIT_MESSAGE" value="Patch update - add menu button" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

2970
Doxyfile Normal file

File diff suppressed because it is too large Load Diff

8
enginecustom/TODO.txt Normal file
View File

@ -0,0 +1,8 @@
- Scene Manager :
TODO : Save and Load Scene
- ImguiManager :
TODO : Add Save and Load Scene Button in the bar menu
TODO : Add a preview of the game in a new window

View File

@ -4,28 +4,28 @@ Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1180,27
Size=396,826
Pos=1233,27
Size=343,826
Collapsed=0
DockId=0x00000005,0
[Window][Objects]
Pos=8,27
Size=290,826
Collapsed=0
DockId=0x0000000A,0
[Window][Terrain]
Pos=8,27
Size=290,487
Size=522,826
Collapsed=0
DockId=0x00000009,0
[Window][Terrain]
Pos=8,27
Size=250,974
Collapsed=0
DockId=0x00000007,0
[Window][Light]
Pos=8,27
Size=290,487
Size=290,866
Collapsed=0
DockId=0x00000009,1
DockId=0x00000007,1
[Window][Shader Manager]
Pos=8,27
@ -34,20 +34,20 @@ Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=1516,27
Size=396,974
Pos=8,27
Size=289,974
Collapsed=0
DockId=0x00000005,1
DockId=0x00000009,0
[Window][DockSpace Demo]
Size=1584,861
Collapsed=0
[Window][Render Window]
Pos=300,27
Size=878,826
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000002,0
DockId=0x00000009,0
[Window][DockSpace]
Pos=0,0
@ -66,24 +66,24 @@ Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=8,775
Size=1904,226
Pos=8,627
Size=1568,226
Collapsed=0
DockId=0x0000000E,0
DockId=0x00000006,0
[Docking][Data]
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1568,598 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=290,826 Split=Y Selected=0x393905AB
DockNode ID=0x00000009 Parent=0x00000007 SizeRef=395,413 Selected=0x393905AB
DockNode ID=0x0000000A Parent=0x00000007 SizeRef=395,411 Selected=0x031DC75C
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1276,826 Split=X
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=878,826 CentralNode=1 Selected=0x9204953B
DockNode ID=0x00000005 Parent=0x00000008 SizeRef=396,826 Selected=0x9F035453
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=X
DockNode ID=0x00000009 Parent=0xCCBD8CF7 SizeRef=522,974 Selected=0x031DC75C
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1044,974 Split=X
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=699,826 Split=Y
DockNode ID=0x00000004 Parent=0x00000002 SizeRef=2032,866 Split=Y
DockNode ID=0x0000000B Parent=0x00000004 SizeRef=1568,637 Split=X
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
DockNode ID=0x0000000C Parent=0x00000004 SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=2032,226 Selected=0xAB74BEE9
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453

View File

@ -123,6 +123,7 @@
<ClInclude Include="src\inc\system\physics.h" />
<ClInclude Include="src\inc\system\Positionclass.h" />
<ClInclude Include="src\inc\system\rendertextureclass.h" />
<ClInclude Include="src\inc\system\sceneManager.h" />
<ClInclude Include="src\inc\system\Spriteclass.h" />
<ClInclude Include="src\inc\system\systemclass.h" />
<ClInclude Include="src\inc\system\textclass.h" />
@ -455,6 +456,9 @@
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Model\OBJ\</DestinationFolders>
</CopyFileToFolders>
</ItemGroup>
<ItemGroup>
<Content Include="TODO.txt" />
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>

View File

@ -11,13 +11,13 @@ DockId=0x00000005,0
[Window][Objects]
Pos=8,27
Size=289,974
Size=289,826
Collapsed=0
DockId=0x00000009,0
[Window][Terrain]
Pos=8,27
Size=250,826
Size=250,974
Collapsed=0
DockId=0x00000007,0
@ -35,9 +35,9 @@ DockId=0x00000001,2
[Window][Engine Settings]
Pos=8,27
Size=1223,826
Size=289,974
Collapsed=0
DockId=0x00000009,1
DockId=0x00000009,0
[Window][DockSpace Demo]
Size=1584,861

Binary file not shown.

View File

@ -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.

View File

@ -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;

View File

@ -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);

View File

@ -77,7 +77,8 @@ public:
REFRACTION,
TEXTURE,
SKYBOX,
SUNLIGHT
SUNLIGHT,
ALPHA_MAPPING
};
ShaderType GetActiveShader() const { return m_activeShader; };

View 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;
};

View File

@ -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);
/////////////

View File

@ -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);
}
}
}

View File

@ -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
}

View File

@ -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ée
static int currentShader = 0; // Index de l'option actuellement sélectionnée
@ -374,7 +406,7 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
NewFrame();
// Setup the dockspace
SetupDockspace();
SetupDockspace(app);
//ImGui Widget
ImGui::Begin("Khaotic Engine", NULL);