diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml b/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml
index 4bb9f4d..64af657 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml
@@ -1,6 +1,7 @@
-
+
+
\ No newline at end of file
diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
index d1b362c..d1c6e5a 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
@@ -5,36 +5,28 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
{
"associatedIndex": 6
}
@@ -43,35 +35,30 @@
- {
+ "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.fileTypes",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
-
+}
+
-
+
-
@@ -79,18 +66,19 @@
+
+
-
+
-
@@ -98,8 +86,10 @@
+
+
@@ -118,6 +108,8 @@
+
+
diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini
index cfd977a..bdbaca0 100644
--- a/enginecustom/imgui.ini
+++ b/enginecustom/imgui.ini
@@ -44,8 +44,8 @@ Size=1584,861
Collapsed=0
[Window][Render Window]
-Pos=300,27
-Size=878,826
+Pos=8,27
+Size=1170,826
Collapsed=0
DockId=0x00000002,0
@@ -66,8 +66,8 @@ 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
diff --git a/enginecustom/src/inc/system/applicationclass.h b/enginecustom/src/inc/system/applicationclass.h
index 76946fa..cf3afbe 100644
--- a/enginecustom/src/inc/system/applicationclass.h
+++ b/enginecustom/src/inc/system/applicationclass.h
@@ -120,6 +120,7 @@ public:
void SetWindowSize(ImVec2 size) { windowSize = size; };
ImVec2 GetWindowSize() const { return windowSize; };
+ float GetAspectRatio() const { return (float)m_screenWidth / (float)m_screenHeight; };
Physics* GetPhysics() const { return m_Physics; };
diff --git a/enginecustom/src/src/system/applicationclass.cpp b/enginecustom/src/src/system/applicationclass.cpp
index 443fa52..4bdf65b 100644
--- a/enginecustom/src/src/system/applicationclass.cpp
+++ b/enginecustom/src/src/system/applicationclass.cpp
@@ -2,36 +2,50 @@
ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
{
- m_Direct3D = 0;
- m_Camera = 0;
- m_Model = 0;
- m_Bitmap = 0;
- m_Sprite = 0;
- m_Timer = 0;
- m_MouseStrings = 0;
- m_FontShader = 0;
- m_Font = 0;
- m_Fps = 0;
- m_FpsString = 0;
- m_ShaderManager = 0;
- m_RenderCountString = 0;
- m_ModelList = 0;
- m_Position = 0;
- m_DisplayPlane = 0;
- m_BathModel = 0;
- m_WaterModel = 0;
- m_Light = 0;
- m_RefractionTexture = 0;
- m_ReflectionTexture = 0;
+ m_Direct3D = nullptr;
+ m_Camera = nullptr;
+ m_Model = nullptr;
+ m_Bitmap = nullptr;
+ m_Sprite = nullptr;
+ m_Timer = nullptr;
+ m_MouseStrings = nullptr;
+ m_FontShader = nullptr;
+ m_Font = nullptr;
+ m_Fps = nullptr;
+ m_FpsString = nullptr;
+ m_ShaderManager = nullptr;
+ m_RenderCountString = nullptr;
+ m_ModelList = nullptr;
+ m_Position = nullptr;
+ m_DisplayPlane = nullptr;
+ m_BathModel = nullptr;
+ m_WaterModel = nullptr;
+ m_Light = nullptr;
+ m_RefractionTexture = nullptr;
+ m_ReflectionTexture = nullptr;
m_SceneTexture = nullptr;
- m_Physics = 0;
+ m_Physics = nullptr;
m_cubes.clear();
m_terrainChunk.clear();
m_object.clear();
m_RenderQueues.clear();
m_Skybox.clear();
m_Lights.clear();
- m_SunLight = 0;
+ m_SunLight = nullptr;
+ m_swapChain = nullptr;
+ m_GroundModel = nullptr;
+ m_WallModel = nullptr;
+ m_hwnd = nullptr;
+ m_baseViewMatrix = XMMatrixIdentity();
+ m_RenderTexture = nullptr;
+ m_screenWidth = 0;
+ m_screenHeight = 0;
+ m_numLights = 0;
+ m_waterHeight = 0.0f;
+ m_waterTranslation = 0.0f;
+ TrueLightPosition = XMFLOAT3(0.0f, 0.0f, 0.0f);
+ m_LightModel = nullptr;
+ m_renderCount = 0;
}
ApplicationClass::~ApplicationClass()
@@ -82,7 +96,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd)
return false;
}
- result = m_Direct3D->Initialize(screenWidth, screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
+ result = m_Direct3D->Initialize(m_screenWidth, m_screenHeight, VSYNC_ENABLED, hwnd, FULL_SCREEN, SCREEN_DEPTH, SCREEN_NEAR);
if (!result)
{
Logger::Get().Log("Could not initialize Direct3D", __FILE__, __LINE__, Logger::LogLevel::Error);
@@ -728,14 +742,7 @@ bool ApplicationClass::Frame(InputClass* Input)
// Set the frame time for calculating the updated position.
m_Position->SetFrameTime(m_Timer->GetTime());
- // Check if the left or right arrow key has been pressed, if so rotate the camera accordingly.
- //keyDown = Input->IsLeftArrowPressed();
- //m_Position->TurnLeft(keyDown);
-
- //keyDown = Input->IsRightArrowPressed();
- //m_Position->TurnRight(keyDown);
-
- m_Position->TurnMouse(deltaX, deltaY, 0.1f, rightMouseDown);
+ m_Position->TurnMouse((float)deltaX, (float)deltaY, 0.1f, rightMouseDown);
// Get the current view point rotation.
m_Position->GetRotation(rotationY, rotationX);
@@ -853,9 +860,6 @@ bool ApplicationClass::RenderRefractionToTexture()
// Generate the view matrix based on the camera's position.
m_Camera->Render();
-
- // Get the world, view, and projection matrices from the camera and d3d objects.
- worldMatrix = m_Direct3D->GetWorldMatrix();
m_Camera->GetViewMatrix(viewMatrix);
projectionMatrix = m_Direct3D->GetProjectionMatrix();
@@ -894,11 +898,8 @@ bool ApplicationClass::RenderRefractionToTexture()
bool ApplicationClass::RenderReflectionToTexture()
{
- XMMATRIX worldMatrix, reflectionViewMatrix, projectionMatrix;
- XMFLOAT4 diffuseColor[4], getDirection[4], ambientColor[4];
- bool result;
-
-
+ XMMATRIX reflectionViewMatrix;
+
// Set the render target to be the reflection render to texture and clear it.
m_ReflectionTexture->SetRenderTarget(m_Direct3D->GetDeviceContext());
m_ReflectionTexture->ClearRenderTarget(m_Direct3D->GetDeviceContext(), 0.0f, 0.0f, 0.0f, 1.0f);
@@ -908,12 +909,7 @@ bool ApplicationClass::RenderReflectionToTexture()
// Get the camera reflection view matrix instead of the normal view matrix.
m_Camera->GetReflectionViewMatrix(reflectionViewMatrix);
-
- // Get the world and projection matrices from the d3d object.
- worldMatrix = m_Direct3D->GetWorldMatrix();
- projectionMatrix = m_Direct3D->GetProjectionMatrix();
-
-
+
// Reset the render target back to the original back buffer and not the render to texture anymore. And reset the viewport back to the original.
m_Direct3D->SetBackBufferRenderTarget();
m_Direct3D->ResetViewport();
@@ -932,9 +928,7 @@ bool ApplicationClass::RenderSceneToTexture(float rotation)
// Set the position of the camera for viewing the cube.
m_Camera->Render();
-
- // Get the matrices.
- worldMatrix = m_Direct3D->GetWorldMatrix();
+
m_Camera->GetViewMatrix(viewMatrix);
m_RenderTexture->GetProjectionMatrix(projectionMatrix);
@@ -961,10 +955,9 @@ bool ApplicationClass::RenderSceneToTexture(float rotation)
bool ApplicationClass::Render(float rotation, float x, float y, float z, float textureTranslation)
{
XMMATRIX worldMatrix, viewMatrix, orthoMatrix, projectionMatrix, rotateMatrix, translateMatrix, scaleMatrix, srMatrix, reflectionMatrix;
- float positionX, positionY, positionZ, radius;
- XMFLOAT4 diffuseColor[4], lightPosition[4], getDirection[4], ambientColor[4];
- int modelCount, renderCount, i;
- bool result, renderModel;
+ XMFLOAT4 diffuseColor[4], lightPosition[4], ambientColor[4];
+ int i;
+ bool result;
float blendAmount;
// Set the blending amount to 10%.
@@ -996,21 +989,15 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
}
// Redimensionner la texture de rendu si nécessaire
- if (m_SceneTexture->GetTextureWidth() != windowSize.x || m_SceneTexture->GetTextureHeight() != windowSize.y)
+ if ((float)m_SceneTexture->GetTextureWidth() != windowSize.x || (float)m_SceneTexture->GetTextureHeight() != windowSize.y)
{
m_SceneTexture->Shutdown();
- m_SceneTexture->Initialize(m_Direct3D->GetDevice(), windowSize.x, windowSize.y, SCREEN_DEPTH, SCREEN_NEAR, 1);
+ m_SceneTexture->Initialize(m_Direct3D->GetDevice(), (int)windowSize.x, (int)windowSize.y, SCREEN_DEPTH, SCREEN_NEAR, 1);
}
m_SceneTexture->SetRenderTarget(m_Direct3D->GetDeviceContext());
m_SceneTexture->ClearRenderTarget(m_Direct3D->GetDeviceContext(), 0.0f, 0.0f, 0.0f, 1.0f);
- //Add the 3 first value of the first light position to the TrueLightPosition XMFLOAT3
- positionX = lightPosition[0].x;
- positionY = lightPosition[0].y;
- positionZ = lightPosition[0].z;
- XMFLOAT3 TrueLightPosition = XMFLOAT3(positionX, positionY, positionZ);
-
scaleMatrix = XMMatrixScaling(0.5f, 0.5f, 0.5f); // Build the scaling matrix.
rotateMatrix = XMMatrixRotationY(rotation); // Build the rotation matrix.
translateMatrix = XMMatrixTranslation(x, y, z); // Build the translation matrix.
@@ -1394,7 +1381,6 @@ void ApplicationClass::GenerateTerrain()
Logger::Get().Log("Generating terrain", __FILE__, __LINE__);
char modelFilename[128];
- bool result;
XMMATRIX scaleMatrix;
float scaleX, scaleY, scaleZ;
diff --git a/enginecustom/src/src/system/imguiManager.cpp b/enginecustom/src/src/system/imguiManager.cpp
index 833c238..21532cd 100644
--- a/enginecustom/src/src/system/imguiManager.cpp
+++ b/enginecustom/src/src/system/imguiManager.cpp
@@ -626,6 +626,19 @@ void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSiz
ImGui::Begin("Render Window");
windowSize = ImGui::GetContentRegionAvail();
+
+ // Get the aspect ratio of the scene in app
+ float aspectRatio = app->GetAspectRatio();
+ // calculate the size of the window
+ if (windowSize.x / windowSize.y > aspectRatio)
+ {
+ windowSize.x = windowSize.y * aspectRatio;
+ }
+ else
+ {
+ windowSize.y = windowSize.x / aspectRatio;
+ }
+
app->SetWindowSize(windowSize);
// Assurez-vous que la texture est valide