diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
index 690b46b..a4e77ce 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
@@ -5,97 +5,15 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
@@ -109,136 +27,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
{}
@@ -253,29 +45,32 @@
"associatedIndex": 6
}
+
+
+
- {
+ "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.keymap",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -406,6 +201,7 @@
+
diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj
index 3fa969b..3fee20b 100644
--- a/enginecustom/enginecustom.vcxproj
+++ b/enginecustom/enginecustom.vcxproj
@@ -36,6 +36,7 @@
+
@@ -95,6 +96,7 @@
+
diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini
index 1dbfb45..ca8f753 100644
--- a/enginecustom/imgui.ini
+++ b/enginecustom/imgui.ini
@@ -17,13 +17,13 @@ DockId=0x00000011,0
[Window][Terrain]
Pos=283,19
-Size=280,615
+Size=280,842
Collapsed=0
DockId=0x00000007,0
[Window][Light]
-Pos=0,328
-Size=281,306
+Pos=0,19
+Size=281,842
Collapsed=0
DockId=0x00000012,0
diff --git a/enginecustom/src/inc/shader/master_shader.h b/enginecustom/src/inc/shader/master_shader.h
new file mode 100644
index 0000000..2d829cc
--- /dev/null
+++ b/enginecustom/src/inc/shader/master_shader.h
@@ -0,0 +1,25 @@
+#pragma once
+#include
+#include
+#include
+
+
+class master_shader
+{
+public :
+
+ master_shader();
+ master_shader(const master_shader& other) = delete;
+ virtual ~master_shader();
+
+ virtual bool initialize(ID3D11Device* device, HWND hwnd) = 0;
+
+
+protected:
+ wchar_t vs_filename_[128], ps_filename_[128];
+
+ wchar_t const* vs_name_ = L"";
+ wchar_t const* ps_name_ = L"";
+
+
+};
diff --git a/enginecustom/src/inc/system/application_class.h b/enginecustom/src/inc/system/application_class.h
index 08af6f5..02ad16b 100644
--- a/enginecustom/src/inc/system/application_class.h
+++ b/enginecustom/src/inc/system/application_class.h
@@ -231,6 +231,8 @@ private :
display_plane_class* display_plane_;
int screen_width_, screen_height_;
camera_class* camera_;
+ camera_class* sun_camera_;
+ camera_class* active_camera_;
position_class* position_;
int drawcalls_;
@@ -320,6 +322,7 @@ private :
// ------------------------------------------------- //
input inputs_;
+ bool tab_was_pressed_;
};
#endif
\ No newline at end of file
diff --git a/enginecustom/src/inc/system/input_class.h b/enginecustom/src/inc/system/input_class.h
index 76a3fd2..d4fd67d 100644
--- a/enginecustom/src/inc/system/input_class.h
+++ b/enginecustom/src/inc/system/input_class.h
@@ -50,10 +50,8 @@ public:
bool IsSPressed() const;
bool IsQPressed() const;
bool IsEPressed()const;
- bool IsTildePressed() const;
- bool IsTildeReleased() const;
-
bool IsKeyDown(unsigned int) const;
+ bool is_key_pressed(const unsigned int);
private:
bool m_keys[256];
diff --git a/enginecustom/src/src/shader/master_shader.cpp b/enginecustom/src/src/shader/master_shader.cpp
new file mode 100644
index 0000000..2d8aec6
--- /dev/null
+++ b/enginecustom/src/src/shader/master_shader.cpp
@@ -0,0 +1,24 @@
+#include "master_shader.h"
+#include "Logger.h"
+
+master_shader::master_shader()
+{
+ // Initialize shader filenames
+ wcscpy_s(vs_filename_, 128, vs_name_);
+ wcscpy_s(ps_filename_, 128, ps_name_);
+
+}
+
+master_shader::~master_shader()
+{
+ // Destructor implementation
+}
+
+bool master_shader::initialize(ID3D11Device* device, HWND hwnd)
+{
+ Logger::Get().Log("Initializing master_shader", __FILE__, __LINE__, Logger::LogLevel::Initialize);
+
+ bool success = false;
+
+ return true;
+}
\ No newline at end of file
diff --git a/enginecustom/src/src/system/application_class.cpp b/enginecustom/src/src/system/application_class.cpp
index b291414..259e5cf 100644
--- a/enginecustom/src/src/system/application_class.cpp
+++ b/enginecustom/src/src/system/application_class.cpp
@@ -49,6 +49,7 @@ application_class::application_class() : should_quit_(false)
light_model_ = nullptr;
render_count_ = 0;
drawcalls_ = 0;
+ tab_was_pressed_ = false;
}
application_class::~application_class()
@@ -121,12 +122,26 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
return false;
}
+ sun_camera_ = new camera_class;
+ if (!sun_camera_)
+ {
+ Logger::Get().Log("Could not create the sun camera object", __FILE__, __LINE__, Logger::LogLevel::Error);
+ return false;
+ }
+
+ sun_camera_->set_position(0.0f,0.0f,0.0f);
+ sun_camera_->set_rotation(0.0f, 0.0f, 0.0f);
+ sun_camera_->render();
+ sun_camera_->get_view_matrix(base_view_matrix_);
+
// Set the initial position of the camera.
camera_->set_position(0.0f, 0.0f, -12.0f);
camera_->set_rotation(0.0f, 0.0f, 0.0f);
camera_->render();
camera_->get_view_matrix(base_view_matrix_);
+ active_camera_ = camera_;
+
// Create and initialize the font shader object.
font_shader_ = new font_shader_class;
@@ -315,6 +330,10 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
sun_light_->SetPosition(0.0f, 100.0f, 0.0f);
sun_light_->SetIntensity(1.0f);
+ sun_camera_->set_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z);
+ sun_camera_->set_rotation(0.0f, 0.0f, 0.0f);
+ sun_camera_->render();
+
// Create and initialize the normal map shader object.
shader_manager_ = new shader_manager_class;
@@ -713,6 +732,14 @@ void application_class::shutdown()
scene_texture_ = nullptr;
}
+ if (sun_camera_)
+ {
+ Logger::Get().Log("Releasing the sun camera object", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
+ delete sun_camera_;
+ sun_camera_ = nullptr;
+ Logger::Get().Log("Sun camera object released", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
+ }
+
Logger::Get().Log("Application class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
@@ -786,11 +813,36 @@ bool application_class::frame(input_class* Input)
buttonE = Input->IsEPressed();
position_->MoveCamera(buttonZ, buttonS, buttonQ, buttonD, buttonE, buttonA, scrollUp, scrollDown, rightMouseDown);
position_->GetPosition(positionX, positionY, positionZ);
+
+ XMFLOAT3 dir = sun_light_->GetDirection();
+ float pitch = asinf(-dir.y) * (180.0f / XM_PI); // en degrés
+ float yaw = atan2f(dir.x, dir.z) * (180.0f / XM_PI); // en degrés
+ float roll = 0.0f;
+
+ if (Input->is_key_pressed(DIK_TAB)) {
+ if (!tab_was_pressed_) {
+ // Alterner la caméra active
+ if (active_camera_ == camera_)
+ active_camera_ = sun_camera_;
+ else
+ active_camera_ = camera_;
+ tab_was_pressed_ = true;
+ }
+ } else {
+ tab_was_pressed_ = false;
+ }
- // Set the postion and rotation of the camera.
- camera_->set_position(positionX, positionY, positionZ);
- camera_->set_rotation(rotationX, rotationY, 0.0f);
- camera_->render();
+ if (active_camera_ == camera_) {
+ // Update the camera position and rotation based on the position class.
+ camera_->set_position(positionX, positionY, positionZ);
+ camera_->set_rotation(rotationX, rotationY, 0.0f);
+ } else {
+ // Update the sun camera position and rotation based on the light position.
+ sun_camera_->set_position(sun_light_->GetPosition().x, sun_light_->GetPosition().y, sun_light_->GetPosition().z);
+ sun_camera_->set_rotation(pitch, yaw, roll);
+ }
+
+ active_camera_->render();
// render the static graphics scene.
result = render(rotation, x, y, z, textureTranslation);
@@ -991,11 +1043,11 @@ bool application_class::render(float rotation, float x, float y, float z, float
blendAmount = 0.1f;
// Generate the view matrix based on the camera's position.
- camera_->render();
+ active_camera_->render();
// Get the world, view, and projection matrices from the camera and d3d objects.
worldMatrix = direct_3d_->get_world_matrix();
- camera_->get_view_matrix(viewMatrix);
+ active_camera_->get_view_matrix(viewMatrix);
projectionMatrix = direct_3d_->get_projection_matrix();
orthoMatrix = direct_3d_->get_ortho_matrix();
@@ -1933,7 +1985,7 @@ void application_class::update_skybox_position()
return;
}
- skybox_[0]->SetTranslateMatrix(XMMatrixTranslation(camera_->get_position().x, camera_->get_position().y, camera_->get_position().z));
+ skybox_[0]->SetTranslateMatrix(XMMatrixTranslation(active_camera_->get_position().x, active_camera_->get_position().y, active_camera_->get_position().z));
}
diff --git a/enginecustom/src/src/system/input_class.cpp b/enginecustom/src/src/system/input_class.cpp
index 1c72dbe..a5da28d 100644
--- a/enginecustom/src/src/system/input_class.cpp
+++ b/enginecustom/src/src/system/input_class.cpp
@@ -432,3 +432,13 @@ bool input_class::IsScrollDown() const
return false;
}
+
+bool input_class::is_key_pressed(const unsigned int key_code)
+{
+ if (m_keyboardState[key_code] & 0x80)
+ {
+ return true;
+ }
+
+ return false;
+}