Minor update - viewport window tweak

This commit is contained in:
CatChow0 2025-01-29 19:31:12 +01:00
parent 151ea9b191
commit 452e84aa16
6 changed files with 101 additions and 108 deletions

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="2" />
<option name="singleClickDiffPreview" value="1" />
<option name="vcsConfiguration" value="3" />
</component>
</project>

View File

@ -5,36 +5,28 @@
</component>
<component name="ChangeListManager">
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/discord.xml" afterDir="false" />
<change afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/material_theme_project_new.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/material_theme_project_new.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" 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/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/celshading.ps" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.ps" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.vs" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/hlsl/celshading.vs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/CelShadingShader.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/CelShadingShader.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" 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/src/shader/CelShadingShader.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/shader/shadermanagerclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/shader/shadermanagerclass.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" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DpaMonitoringSettings">
<option name="firstShow" value="false" />
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="ProblemsViewState">
<option name="selectedTabId" value="CurrentFile" />
</component>
<component name="ProjectColorInfo">{
&quot;associatedIndex&quot;: 6
}</component>
@ -43,35 +35,30 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"C++ Project.enginecustom.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
"git-widget-placeholder": "main",
"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"
},
"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 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.fileTypes&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
<component name="RunManager" selected="C++ Project.enginecustom">
}</component>
<component name="RunManager" selected="C/C++ Project.enginecustom">
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
<configuration_1>
<configuration_1 setup="1">
<option name="CONFIGURATION" value="Debug" />
<option name="PLATFORM" value="x64" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
@ -79,18 +66,19 @@
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
</configuration_1>
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
<option name="AUTO_SELECT_PRIORITY" value="0" />
<method v="2">
<option name="Build" />
</method>
</configuration>
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
<configuration_1>
<configuration_1 setup="1">
<option name="CONFIGURATION" value="Debug" />
<option name="PLATFORM" value="x64" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
@ -98,8 +86,10 @@
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
</configuration_1>
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
<option name="AUTO_SELECT_PRIORITY" value="0" />
<method v="2">
<option name="Build" />
@ -118,6 +108,8 @@
<workItem from="1738076088229" duration="80000" />
<workItem from="1738076192788" duration="19000" />
<workItem from="1738076222547" duration="6131000" />
<workItem from="1738171504772" duration="876000" />
<workItem from="1738172392786" duration="67000" />
</task>
<servers />
</component>

View File

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

View File

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

View File

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

View File

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