2 Commits

17 changed files with 316 additions and 514 deletions

View File

@@ -6,8 +6,15 @@
<component name="ChangeListManager">
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
<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/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/src/inc/system/Skybox.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/Skybox.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/application_class.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/stats.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/stats.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/application_class.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/stats.cpp" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -27,9 +34,83 @@
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="cidr-memory-view://4" root0="FORCE_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/enginecustom/include/Inc/VertexTypes.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
@@ -58,7 +139,7 @@
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
"C++ Project.enginecustom.executor": "Run",
"C/C++ Project.KhaoticDemo.executor": "Run",
"C/C++ Project.enginecustom.executor": "Run",
"C/C++ Project.enginecustom.executor": "Debug",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
@@ -213,6 +294,12 @@
<workItem from="1748869642637" duration="3049000" />
<workItem from="1748954607174" duration="14202000" />
<workItem from="1748969487337" duration="402000" />
<workItem from="1750187491423" duration="4397000" />
<workItem from="1750191969842" duration="162000" />
<workItem from="1750248915365" duration="442000" />
<workItem from="1750335650897" duration="2051000" />
<workItem from="1750344288223" duration="1751000" />
<workItem from="1750351735497" duration="9648000" />
</task>
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
<option name="closed" value="true" />

View File

@@ -1,106 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1281,19
Size=303,842
Collapsed=0
DockId=0x0000000F,0
[Window][Objects]
Pos=0,19
Size=281,842
Collapsed=0
DockId=0x00000011,0
[Window][Terrain]
Pos=0,19
Size=280,842
Collapsed=0
DockId=0x00000007,0
[Window][Light]
Pos=0,19
Size=281,842
Collapsed=0
DockId=0x00000012,0
[Window][Shader Manager]
Pos=8,27
Size=330,487
Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=1281,527
Size=303,334
Collapsed=0
DockId=0x00000010,0
[Window][DockSpace Demo]
Size=1584,861
Collapsed=0
[Window][Render Window]
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000011,0
[Window][DockSpace]
Pos=0,0
Size=1584,861
Collapsed=0
[Window][Add Object]
Pos=1188,0
Size=396,430
Collapsed=0
[Window][Log]
Pos=8,518
Size=1568,335
Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=0,636
Size=1279,225
Collapsed=0
DockId=0x00000006,0
[Window][Render Stats]
Pos=0,636
Size=1279,225
Collapsed=0
DockId=0x00000004,0
[Window][render Window]
Pos=16,718
Size=997,758
Collapsed=1
[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=0,19 Size=1584,842 Split=X
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1 Selected=0x4FC83240
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Split=Y Selected=0x9F035453
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B

View File

@@ -1,89 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][Khaotic Engine]
Pos=1233,27
Size=343,826
Collapsed=0
DockId=0x00000005,0
[Window][Objects]
Pos=8,27
Size=289,413
Collapsed=0
DockId=0x00000007,0
[Window][Terrain]
Pos=8,442
Size=289,411
Collapsed=0
DockId=0x00000008,0
[Window][Light]
Pos=8,27
Size=290,866
Collapsed=0
DockId=0x00000004,1
[Window][Shader Manager]
Pos=8,27
Size=330,487
Collapsed=0
DockId=0x00000001,2
[Window][Engine Settings]
Pos=1233,27
Size=343,826
Collapsed=0
DockId=0x00000005,1
[Window][DockSpace Demo]
Size=1584,861
Collapsed=0
[Window][Render Window]
Pos=8,27
Size=1559,974
Collapsed=0
DockId=0x00000007,0
[Window][DockSpace]
Pos=0,0
Size=1584,861
Collapsed=0
[Window][Add Object]
Pos=1188,0
Size=396,430
Collapsed=0
[Window][Log]
Pos=8,518
Size=1568,335
Collapsed=0
DockId=0x0000000C,0
[Window][Log Window]
Pos=299,627
Size=932,226
Collapsed=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=X
DockNode ID=0x00000009 Parent=0xCCBD8CF7 SizeRef=289,974 Split=Y Selected=0x031DC75C
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,299 Selected=0x031DC75C
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,297 Selected=0x393905AB
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1613,974 Split=X
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=Y
DockNode ID=0x00000004 Parent=0x0000000B SizeRef=932,598 CentralNode=1
DockNode ID=0x00000006 Parent=0x0000000B SizeRef=932,226 Selected=0xAB74BEE9
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x0B098C4B

View File

@@ -10,28 +10,50 @@ Collapsed=0
[Window][Khaotic Engine]
Pos=1267,19
Size=317,842
Size=317,609
Collapsed=0
DockId=0x00000002,0
[Window][render Stats]
Pos=275,630
Size=1309,231
Pos=0,630
Size=1584,231
Collapsed=0
DockId=0x00000004,0
DockId=0x00000009,0
[Window][Objects]
Pos=0,19
Size=273,842
Size=238,609
Collapsed=0
DockId=0x00000005,0
DockId=0x0000000B,0
[Window][Terrain]
Pos=0,19
Size=266,609
Collapsed=0
DockId=0x00000007,0
[Window][Log Window]
Pos=794,630
Size=790,231
Collapsed=0
DockId=0x0000000A,0
[Window][Light]
Pos=0,19
Size=238,609
Collapsed=0
DockId=0x0000000B,1
[Docking][Data]
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=273,842 Selected=0x031DC75C
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1309,842 Split=Y
DockNode ID=0x00000003 Parent=0x00000006 SizeRef=1584,609 Split=X
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=990,842 CentralNode=1
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=317,842 Selected=0x9F035453
DockNode ID=0x00000004 Parent=0x00000006 SizeRef=1584,231 Selected=0xF5D1BB37
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=238,842 Selected=0x031DC75C
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1344,842 Split=X
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1025,842 CentralNode=1
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Selected=0x9F035453
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9

View File

@@ -13,7 +13,7 @@ public:
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
object* ConstructSkybox();
object* ConstructSkybox(application_class* app);
// Variables

View File

@@ -42,6 +42,7 @@
#include <algorithm>
#include <DirectXMath.h>
#include <mutex>
#include <memory>
#include "shadow_map.h"
#include "stats.h"
@@ -54,6 +55,8 @@ constexpr bool full_screen = false;
constexpr float screen_depth = 1000.0f;
constexpr float screen_near = 0.3f;
static std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
struct input
{
bool key_left = false;
@@ -78,8 +81,7 @@ public:
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
void create_big_cube(int side_count);
void process_terrain_generation();
bool create_big_cube(int side_count);
virtual bool initialize(int, int, HWND, bool is_vulkan);
void shutdown();
virtual bool frame(input_class*);

View File

@@ -57,7 +57,7 @@ public:
ImVec2 GetWindowSize() const { return windowSize; }
// Getters
void SetApp(application_class* app) { app_ = app; }
void SetApp(std::shared_ptr<application_class> app) { app_ = app; }
// Shader toggles
@@ -75,7 +75,7 @@ private:
std::vector<widget_entry> widgets_;
application_class* app_;
std::shared_ptr<application_class> app_;
scene_manager* scene_manager_;
stats* stats_;

View File

@@ -26,15 +26,23 @@ enum class ShaderType
ALPHA_MAPPING
};
class object : public model_class
class object
{
public:
object(application_class& app);
object();
~object();
object(const object&) = delete;
object& operator=(const object&) = delete;
bool Initialize(
ID3D11Device* device,
ID3D11DeviceContext* deviceContext,
char* modelFilename,
TextureContainer& texturesContainer
);
void SetScaleMatrix(XMMATRIX scaleMatrix);
void SetRotateMatrix(XMMATRIX rotateMatrix);
void SetTranslateMatrix(XMMATRIX translateMatrix);
@@ -119,6 +127,9 @@ public:
bool IsGravityEnabled() const { return m_gravityEnabled; }
void SetGravityEnabled(bool state) { m_gravityEnabled = state; }
std::shared_ptr<model_class> get_model() const { return m_model_; }
void SetModel(std::shared_ptr<model_class> model) { m_model_ = model; }
public :
bool m_demoSpinning = false;
XMVECTOR m_previousPosition;
@@ -127,6 +138,9 @@ public :
bool m_gravityEnabled = true;
private:
application_class& m_Application;
XMMATRIX m_scaleMatrix;
XMMATRIX m_rotateMatrix;
XMMATRIX m_translateMatrix;
@@ -149,5 +163,7 @@ private:
float m_alpha = 0.0f;
float m_initialStretch = 0.0f;
float m_springConstant = 10.0f;
std::shared_ptr<model_class> m_model_;
};

View File

@@ -6,6 +6,7 @@
#include "object.h"
#include <intrin.h> // Pour __cpuid
#include <dxgi.h> // Pour DXGI
#include <mutex>
#pragma comment(lib, "dxgi.lib")
class stats
@@ -36,7 +37,6 @@ public:
std::string get_gpu_driver_version(ID3D11Device* device);
private:
std::thread update_geometric_thread_;
std::thread update_display_thread_;
fps_class* fps_;

View File

@@ -32,20 +32,12 @@ public:
void send_path(wchar_t* path, std::filesystem::path w_folder);
application_class* get_application_class() const { return application_; }
void set_application_class(application_class* application) {
if (application_) {
delete application_;
}
application_ = application;
}
input_class* get_input_class() const { return input_; }
void set_input(input_class* input) {
if (input_) {
delete input_;
}
input_ = input;
}
std::shared_ptr<application_class> get_application_class() const { return application_; }
void set_application_class(std::shared_ptr<application_class> application) { application_ = std::move(application); }
std::shared_ptr<input_class> get_input_class() const { return input_; }
void set_input(std::shared_ptr<input_class> input) { input_ = std::move(input); }
HWND get_hwnd() const { return hwnd_; }
void set_d_3D_mock(d_3d_class* mock) {application_->set_direct_3d(mock);}
@@ -61,9 +53,9 @@ private:
HINSTANCE hinstance_;
HWND hwnd_;
input_class* input_;
application_class* application_;
imguiManager* imgui_manager_;
std::shared_ptr<input_class> input_;
std::shared_ptr<application_class> application_;
std::shared_ptr<imguiManager> imgui_manager_;
int initial_window_width_;
int initial_window_height_;

View File

@@ -23,7 +23,7 @@ void Skybox::Initialize(d_3d_class* d3dClassRef)
m_d3dClassRef = d3dClassRef;
}
object* Skybox::ConstructSkybox()
object* Skybox::ConstructSkybox(application_class* app)
{
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -51,7 +51,7 @@ object* Skybox::ConstructSkybox()
}
// Create the model object
m_Skybox = new object();
m_Skybox = new object(*app);
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
if (!result)
{

View File

@@ -505,7 +505,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
//ConstructSkyboxWithPlanes();
Skybox* skybox = new Skybox;
skybox->Initialize(direct_3d_);
skybox_.push_back(skybox->ConstructSkybox());
skybox_.push_back(skybox->ConstructSkybox(this));
culling_active_ = true;
culling_thread_ = std::thread(&application_class::culling_thread_function, this);
@@ -765,8 +765,6 @@ void application_class::shutdown()
bool application_class::frame(input_class* Input)
{
process_terrain_generation();
stats_->reset_draw_call_count();
int mouseX, mouseY, currentMouseX, currentMouseY;
@@ -1157,6 +1155,7 @@ bool application_class::render(float rotation, float x, float y, float z, float
// return false;
// }
stats_->update_geometric_stats();
// Update the render count text.
result = update_render_count_string(get_render_count());
@@ -1300,16 +1299,7 @@ int application_class::get_screen_height() const
void application_class::generate_terrain()
{
Logger::Get().Log("G<EFBFBD>n<EFBFBD>ration du terrain avec instanciation", __FILE__, __LINE__, Logger::LogLevel::Info);
// Nettoyer les objets terrain existants pour <20>viter les fuites
for (auto* chunk : terrain_chunk_)
{
if (chunk)
{
chunk->Shutdown();
delete chunk;
}
}
terrain_chunk_.clear();
// Dimensions du terrain
@@ -1338,7 +1328,7 @@ void application_class::generate_terrain()
for (int j = 0; j < gridSizeZ; j++)
{
// Cr<43>er un nouvel objet de terrain
object* terrain = new object();
object* terrain = new object(*this);
// Initialiser avec le mod<6F>le et les textures_ pr<70>charg<72>es
if (!terrain->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, textureContainer))
@@ -1371,6 +1361,7 @@ void application_class::generate_terrain()
void application_class::add_kobject(std::wstring& filepath)
{
std::lock_guard<std::mutex> lock(objects_mutex_);
Logger::Get().Log("Adding object", __FILE__, __LINE__);
char modelFilename[128];
@@ -1391,7 +1382,7 @@ void application_class::add_kobject(std::wstring& filepath)
L"assets/Texture/BricksGLOSS2K.png"
};
object* newObject = new object();
object* newObject = new object(*this);
newObject->LoadTexturesFromPath(kobjTexture,KobjectsTextures, direct_3d_); // Load textures_ from the path
newObject->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, KobjectsTextures);
newObject->SetMass(1.0f);
@@ -1405,7 +1396,7 @@ void application_class::add_kobject(std::wstring& filepath)
object_.push_back(newObject);
// V<>rifiez que l'objet a bien re<72>u les textures_
if (newObject->GetTexture(TextureType::Diffuse,0) == nullptr)
if (newObject->get_model()->GetTexture(TextureType::Diffuse,0) == nullptr)
{
Logger::Get().Log("object texture is null after initialization", __FILE__, __LINE__, Logger::LogLevel::Error);
}
@@ -1413,6 +1404,7 @@ void application_class::add_kobject(std::wstring& filepath)
void application_class::add_cube()
{
std::lock_guard<std::mutex> lock(objects_mutex_);
Logger::Get().Log("Adding cube", __FILE__, __LINE__);
char modelFilename[128];
@@ -1427,7 +1419,7 @@ void application_class::add_cube()
static int cubeCount = 0;
float position = cubeCount * 2.0f;
object* newCube = new object();
object* newCube = new object(*this);
newCube->LoadTexturesFromPath(cubeTexture, CubeTexture, direct_3d_); // Load textures_ from the path
newCube->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, CubeTexture);
newCube->SetTranslateMatrix(XMMatrixTranslation(position, 0.0f, 0.0f));
@@ -1438,25 +1430,19 @@ void application_class::add_cube()
void application_class::delete_kobject(int index)
{
std::lock_guard<std::mutex> lock(objects_mutex_);
Logger::Get().Log("Deleting object", __FILE__, __LINE__);
if (index < object_.size())
{
object_[index]->Shutdown();
delete object_[index];
object_.erase(object_.begin() + index);
}
}
void application_class::delete_terrain()
{
std::lock_guard<std::mutex> lock(objects_mutex_);
Logger::Get().Log("Deleting terrain", __FILE__, __LINE__);
for (auto cube : terrain_chunk_)
{
cube->Shutdown();
delete cube;
}
terrain_chunk_.clear();
}
@@ -1819,17 +1805,17 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
translateMatrix
);
object->Render(direct_3d_->get_device_context());
object->get_model()->Render(direct_3d_->get_device_context());
if (active_camera_ == sun_camera_)
{
result = shader_manager_->render_depth_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0)
object->get_model()->GetTexture(TextureType::Diffuse,0)
);
}
@@ -1844,13 +1830,13 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
result = shader_manager_->render_alpha_map_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->GetTexture(TextureType::Diffuse,1),
object->GetTexture(TextureType::Alpha,0)
object->get_model()->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,1),
object->get_model()->GetTexture(TextureType::Alpha,0)
);
if (!result)
{
@@ -1864,11 +1850,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::CEL_SHADING:
result = shader_manager_->render_cel_shading_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
sun_light_->GetDiffuseColor(),
sun_light_->GetAmbientColor(),
sun_light_->GetDirection(),
@@ -1884,12 +1870,12 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::NORMAL_MAPPING:
result = shader_manager_->render_normal_map_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->GetTexture(TextureType::Normal,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Normal,0),
lights_[0]->GetDirection(),
lights_[0]->GetDiffuseColor()
);
@@ -1903,13 +1889,13 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::SPECULAR_MAPPING:
result = shader_manager_->render_spec_map_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->GetTexture(TextureType::Normal,0),
object->GetTexture(TextureType::Specular,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Normal,0),
object->get_model()->GetTexture(TextureType::Specular,0),
lights_[0]->GetDirection(),
lights_[0]->GetDiffuseColor(),
camera_->get_position(),
@@ -1926,11 +1912,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::TEXTURE:
result = shader_manager_->render_texture_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0)
object->get_model()->GetTexture(TextureType::Diffuse,0)
);
if (!result)
{
@@ -1942,11 +1928,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::LIGHTING:
result = shader_manager_->renderlight_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
diffuse,
position,
ambient
@@ -1961,11 +1947,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::SKYBOX:
result = shader_manager_->render_skybox_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
sun_light_->GetDiffuseColor(),
sun_light_->GetAmbientColor(),
sun_light_->GetDirection(),
@@ -1981,11 +1967,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
case ShaderType::SUNLIGHT:
result = shader_manager_->render_sunlight_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
sun_light_->GetDiffuseColor(),
sun_light_->GetAmbientColor(),
sun_light_->GetDirection(),
@@ -2001,11 +1987,11 @@ bool application_class::render_pass(const std::vector<std::reference_wrapper<std
default:
result = shader_manager_->renderlight_shader(
direct_3d_->get_device_context(),
object->GetIndexCount(),
object->get_model()->GetIndexCount(),
worldMatrix,
view,
projection,
object->GetTexture(TextureType::Diffuse,0),
object->get_model()->GetTexture(TextureType::Diffuse,0),
diffuse,
position,
ambient
@@ -2168,134 +2154,56 @@ void application_class::physics_thread_function()
}
}
void application_class::create_big_cube(int side_count)
bool application_class::create_big_cube(int side_count)
{
Logger::Get().Log("Lancement de la g<>n<EFBFBD>ration du terrain dans un thread s<>par<61>", __FILE__, __LINE__, Logger::LogLevel::Info);
// Cr<43>er un thread qui ex<65>cutera la g<>n<EFBFBD>ration du terrain
std::thread generationThread([this, side_count]() {
Logger::Get().Log("Thread de g<>n<EFBFBD>ration de terrain d<>marr<72>", __FILE__, __LINE__, Logger::LogLevel::Info);
std::string modelName = "assets/Model/TXT/cube.txt";
std::shared_ptr<model_class> sharedModel;
// V<>rifier si le mod<6F>le existe d<>j<EFBFBD>
auto it = g_model_cache.find(modelName);
if (it != g_model_cache.end()) {
sharedModel = it->second;
} else {
// copy le string en char*
char model_file[128];
size_t convertedChars = 0;
(void)wcstombs_s(&convertedChars, model_file, sizeof(model_file), std::wstring(modelName.begin(), modelName.end()).c_str(), _TRUNCATE);
// Stockage temporaire pour les nouveaux objets
std::vector<object*> newTerrainChunks;
// Cr<EFBFBD>er et initialiser le mod<6F>le si non trouv<75>
auto newModel = std::make_shared<model_class>();
TextureContainer textures;
textures.diffusePaths.push_back(L"assets/Texture/Bricks2K.png");
textures.normalPaths.push_back(L"assets/Texture/BricksNRM2K.png");
textures.specularPaths.push_back(L"assets/Texture/BricksGLOSS2K.png");
newModel->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), textures);
if (!newModel->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(),model_file, textures)) {
Logger::Get().Log("Impossible d'initialiser le mod<6F>le du gros cube", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
g_model_cache[modelName] = newModel;
sharedModel = newModel;
}
// Dimensions du terrain
float scaleX = 1.0f;
float scaleY = 1.0f;
float scaleZ = 1.0f;
// Cr<EFBFBD>er temporairement les cubes dans un vecteur local
std::vector<object*> tempCubes;
tempCubes.reserve(side_count * side_count * side_count);
// Pr<EFBFBD>parer les donn<6E>es pour la cr<63>ation des cubes
std::vector<std::tuple<float, float, float, std::string, int>> cubeData;
int objectId = object_id_;
// G<>n<EFBFBD>rer les donn<6E>es des cubes
for (int i = 0; i < side_count; i++) {
for (int j = 0; j < side_count; j++) {
for (int k = 0; k < side_count; k++) {
// V<>rifier si nous devons arr<72>ter le thread
if (should_quit_) {
Logger::Get().Log("G<EFBFBD>n<EFBFBD>ration de terrain annul<75>e", __FILE__, __LINE__, Logger::LogLevel::Info);
return;
}
// Position et nom du cube
float posX = i * scaleX;
float posY = k * scaleY;
float posZ = j * scaleZ;
std::string name = "TerrainTile_" + std::to_string(i) + "_" + std::to_string(j) + "_" + std::to_string(k);
// Stocker les donn<6E>es du cube
cubeData.push_back(std::make_tuple(posX, posY, posZ, name, objectId++));
}
// G<EFBFBD>n<EFBFBD>rer side_count<6E> cubes
for (int x = 0; x < side_count; x++)
{
for (int y = 0; y < side_count; y++)
{
for (int z = 0; z < side_count; z++)
{
object* cubePart = new object(*this);
cubePart->SetModel(sharedModel);
cubePart->SetTranslateMatrix(XMMatrixTranslation(static_cast<float>(x),static_cast<float>(y),static_cast<float>(z)));
tempCubes.push_back(cubePart);
}
}
// Synchroniser avec le thread principal pour cr<63>er les objets
// Cette partie doit <20>tre ex<65>cut<75>e dans le thread principal (via une file d'attente ou autre m<>canisme)
std::lock_guard<std::mutex> lock(terrain_mutex_);
terrain_generation_data_ = std::move(cubeData);
terrain_generation_ready_ = true;
next_terrain_object_id_ = objectId;
Logger::Get().Log("Donn<EFBFBD>es de g<>n<EFBFBD>ration de terrain pr<70>par<61>es (" + std::to_string(terrain_generation_data_.size()) + " cubes)", __FILE__, __LINE__, Logger::LogLevel::Info);
});
// D<>tacher le thread pour qu'il s'ex<65>cute en arri<72>re-plan
generationThread.detach();
}
void application_class::process_terrain_generation()
{
// V<>rifier si des donn<6E>es de terrain sont pr<70>tes <20> <20>tre trait<69>es
if (!terrain_generation_ready_) {
return;
}
// Acqu<71>rir les donn<6E>es g<>n<EFBFBD>r<EFBFBD>es
std::vector<std::tuple<float, float, float, std::string, int>> cubeData;
{
std::lock_guard<std::mutex> lock(terrain_mutex_);
cubeData = std::move(terrain_generation_data_);
terrain_generation_data_.clear();
terrain_generation_ready_ = false;
object_id_ = next_terrain_object_id_;
}
Logger::Get().Log("Cr<EFBFBD>ation des objets terrain <20> partir des donn<6E>es pr<70>par<61>es", __FILE__, __LINE__, Logger::LogLevel::Info);
// Nettoyer les objets terrain existants
for (auto* chunk : terrain_chunk_)
{
if (chunk) {
chunk->Shutdown();
delete chunk;
}
}
terrain_chunk_.clear();
// Cr<43>er un conteneur de textures_ partag<61>
TextureContainer textureContainer;
textureContainer.diffusePaths.push_back(L"assets/Texture/Bricks2K.png");
textureContainer.normalPaths.push_back(L"assets/Texture/BricksNRM2K.png");
textureContainer.specularPaths.push_back(L"assets/Texture/BricksGLOSS2K.png");
// Pr<50>charger les textures_ une seule fois
model_class* sharedModel = new model_class();
sharedModel->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), textureContainer);
char modelFilename[128];
strcpy_s(modelFilename, "assets/Model/TXT/cube.txt");
// Cr<43>er les objets <20> partir des donn<6E>es
for (const auto& [posX, posY, posZ, name, id] : cubeData)
{
// Cr<43>er un nouvel objet de terrain
object* terrain = new object();
// Initialiser avec le mod<6F>le et les textures_
if (!terrain->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, textureContainer))
{
Logger::Get().Log("<EFBFBD>chec de l'initialisation d'une tuile de terrain", __FILE__, __LINE__, Logger::LogLevel::Error);
delete terrain;
continue;
}
// Configurer l'objet
XMFLOAT3 position(posX, posY, posZ);
XMFLOAT3 scale(1.0f, 1.0f, 1.0f);
terrain->SetPosition(XMLoadFloat3(&position));
terrain->SetScale(XMLoadFloat3(&scale));
terrain->SetName(name);
terrain->SetType(ObjectType::Cube);
terrain->SetActiveShader(ShaderType::TEXTURE);
terrain->SetId(id);
// Ajouter <20> la liste des chunks de terrain
terrain_chunk_.push_back(terrain);
}
delete sharedModel;
Logger::Get().Log("G<EFBFBD>n<EFBFBD>ration du terrain termin<69>e avec " + std::to_string(terrain_chunk_.size()) + " cubes", __FILE__, __LINE__, Logger::LogLevel::Info);
// Transf<73>rer les cubes du vecteur temporaire au vecteur membre
cubes_ = std::move(tempCubes);
return true;
}

View File

@@ -165,7 +165,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
// initialize the scene manager
scene_manager_ = new scene_manager;
if (!scene_manager_->initialize(app_)) {
if (!scene_manager_->initialize(app_.get())) {
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -441,7 +441,7 @@ void imguiManager::WidgetObjectWindow()
// Compter combien de textures_ de ce type existent
int textureCount = 0;
while (object->GetTexture(type, textureCount) != nullptr)
while (object->get_model()->GetTexture(type, textureCount) != nullptr)
{
textureCount++;
}
@@ -450,7 +450,7 @@ void imguiManager::WidgetObjectWindow()
ImGui::BeginGroup();
for (int texIndex = 0; texIndex < textureCount; texIndex++)
{
ID3D11ShaderResourceView* texture = object->GetTexture(type, texIndex);
ID3D11ShaderResourceView* texture = object->get_model()->GetTexture(type, texIndex);
if (texture)
{
// ID unique pour chaque bouton de texture
@@ -477,7 +477,7 @@ void imguiManager::WidgetObjectWindow()
if (GetOpenFileName(&ofn))
{
// Changer la texture existante
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
object->get_model()->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
}
}
@@ -515,7 +515,7 @@ void imguiManager::WidgetObjectWindow()
if (GetOpenFileName(&ofn))
{
// Ajouter une nouvelle texture
object->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
object->get_model()->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
}
}

View File

@@ -2,9 +2,27 @@
#include <comdef.h>
#include "application_class.h"
#include "d_3d_class.h"
object::object()// initialize the reference here
object::object(application_class& app) : m_Application(app)// initialize the reference here
{
m_scaleMatrix = XMMatrixIdentity();
m_rotateMatrix = XMMatrixIdentity();
m_translateMatrix = XMMatrixIdentity();
m_srMatrix = XMMatrixIdentity();
m_worldMatrix = XMMatrixIdentity();
m_previousPosition = XMVectorZero();
m_velocity = XMVectorZero();
m_acceleration = XMVectorZero();
m_mass = NULL;
m_isGrounded = false;
m_id = NULL;
m_boundingRadius = 1.0f;
}
object::object()
: m_Application(*static_cast<application_class*>(nullptr)) // Remplacer suivant votre logique
{
m_scaleMatrix = XMMatrixIdentity();
m_rotateMatrix = XMMatrixIdentity();
@@ -24,6 +42,34 @@ object::~object()
{
}
bool object::Initialize(
ID3D11Device* device,
ID3D11DeviceContext* deviceContext,
char* modelFilename,
TextureContainer& texturesContainer
)
{
std::string filename(modelFilename);
auto it = g_model_cache.find(filename);
if (it != g_model_cache.end())
{
m_model_ = it->second;
}
else
{
auto new_model = std::make_shared<model_class>();
if (!new_model->Initialize(device, deviceContext, modelFilename, texturesContainer))
{
return false;
}
g_model_cache[filename] = new_model;
m_model_ = new_model;
}
return true;
}
void object::SetScaleMatrix(XMMATRIX scaleMatrix)
{
m_scaleMatrix = scaleMatrix;

View File

@@ -84,14 +84,7 @@ bool scene_manager::load_scene() {
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// Nettoyer les objets existants
for (auto& obj : object_vec_) {
if (obj) {
obj->Shutdown();
delete obj;
}
}
object_vec_.clear();
object_id_ = 0;
@@ -192,7 +185,7 @@ bool scene_manager::load_scene() {
}
// preload texture
if (!newObject->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), objectTextures))
if (!newObject->get_model()->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), objectTextures))
{
// G<>rer l'erreur
return false;
@@ -281,28 +274,28 @@ bool scene_manager::save_scene() {
// M<>me chose pour les autres types de textures_
// Textures diffuses
const auto& diffusePaths = object->GetTextureContainer().GetPaths(TextureType::Diffuse);
const auto& diffusePaths = object->get_model()->GetTextureContainer().GetPaths(TextureType::Diffuse);
outFile << " " << diffusePaths.size();
for (const auto& path : diffusePaths) {
outFile << " " << convert_w_string_to_string(path);
}
// Textures normales
const auto& normalPaths = object->GetTextureContainer().GetPaths(TextureType::Normal);
const auto& normalPaths = object->get_model()->GetTextureContainer().GetPaths(TextureType::Normal);
outFile << " " << normalPaths.size();
for (const auto& path : normalPaths) {
outFile << " " << convert_w_string_to_string(path);
}
// Textures sp<73>culaires
const auto& specularPaths = object->GetTextureContainer().GetPaths(TextureType::Specular);
const auto& specularPaths = object->get_model()->GetTextureContainer().GetPaths(TextureType::Specular);
outFile << " " << specularPaths.size();
for (const auto& path : specularPaths) {
outFile << " " << convert_w_string_to_string(path);
}
// Textures alpha
const auto& alphaPaths = object->GetTextureContainer().GetPaths(TextureType::Alpha);
const auto& alphaPaths = object->get_model()->GetTextureContainer().GetPaths(TextureType::Alpha);
outFile << " " << alphaPaths.size();
for (const auto& path : alphaPaths) {
outFile << " " << convert_w_string_to_string(path);

View File

@@ -26,11 +26,6 @@ bool stats::initialize(application_class* app)
Logger::Get().Log("FPS object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
// call update() in a separate thread
std::thread update_geometric_thread(&stats::update_geometric_stats, this);
update_geometric_thread_ = std::move(update_geometric_thread); // Move the thread to the member variable
update_geometric_thread_.detach(); // Detach the thread to run independently
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
@@ -39,8 +34,7 @@ bool stats::initialize(application_class* app)
void stats::update_geometric_stats()
{
while (true)
{
object_vec_ = app_->get_kobjects();
cubes_vec_ = app_->get_cubes();
terrain_chunk_vec_ = app_->get_terrain_cubes();
@@ -48,10 +42,6 @@ void stats::update_geometric_stats()
total_vertex_count_ = get_total_vertex_count();
total_triangle_count_ = get_total_triangle_count();
visible_triangle_count_ = get_visible_triangle_count();
// call update_stats() every second
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
void stats::update_display_stats()
@@ -71,7 +61,7 @@ int stats::get_total_vertex_count() const
{
if (obj)
{
totalVertices += obj->GetVertexCount();
totalVertices += obj->get_model()->GetVertexCount();
}
}
// Ajoutez le nombre de sommets pour les cubes
@@ -79,7 +69,7 @@ int stats::get_total_vertex_count() const
{
if (cube)
{
totalVertices += cube->GetVertexCount();
totalVertices += cube->get_model()->GetVertexCount();
}
}
// Ajoutez le nombre de sommets pour le terrain
@@ -87,7 +77,7 @@ int stats::get_total_vertex_count() const
{
if (chunk)
{
totalVertices += chunk->GetVertexCount();
totalVertices += chunk->get_model()->GetVertexCount();
}
}
return totalVertices;
@@ -101,7 +91,7 @@ int stats::get_total_triangle_count() const
if (obj)
{
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
totalTriangles += obj->GetIndexCount() / 3;
totalTriangles += obj->get_model()->GetIndexCount() / 3;
}
}
// Ajoutez le nombre de triangles pour les cubes
@@ -109,7 +99,7 @@ int stats::get_total_triangle_count() const
{
if (cube)
{
totalTriangles += cube->GetIndexCount() / 3;
totalTriangles += cube->get_model()->GetIndexCount() / 3;
}
}
// Ajoutez le nombre de triangles pour le terrain
@@ -117,7 +107,7 @@ int stats::get_total_triangle_count() const
{
if (chunk)
{
totalTriangles += chunk->GetIndexCount() / 3;
totalTriangles += chunk->get_model()->GetIndexCount() / 3;
}
}
return totalTriangles;
@@ -130,7 +120,7 @@ int stats::get_visible_triangle_count() const
{
if (obj && obj->IsVisible())
{
visibleTriangles += obj->GetIndexCount() / 3;
visibleTriangles += obj->get_model()->GetIndexCount() / 3;
}
}
// Ajoutez le nombre de triangles visibles pour les cubes
@@ -138,7 +128,7 @@ int stats::get_visible_triangle_count() const
{
if (cube && cube->IsVisible())
{
visibleTriangles += cube->GetIndexCount() / 3;
visibleTriangles += cube->get_model()->GetIndexCount() / 3;
}
}
// Ajoutez le nombre de triangles visibles pour le terrain
@@ -146,7 +136,7 @@ int stats::get_visible_triangle_count() const
{
if (chunk && chunk->IsVisible())
{
visibleTriangles += chunk->GetIndexCount() / 3;
visibleTriangles += chunk->get_model()->GetIndexCount() / 3;
}
}
return visibleTriangles;

View File

@@ -20,27 +20,6 @@ system_class::system_class()
system_class::~system_class()
{
if (application_handle)
{
delete application_handle;
application_handle = 0;
}
if (input_)
{
delete input_;
input_ = 0;
}
if (imgui_manager_)
{
delete imgui_manager_;
imgui_manager_ = 0;
}
}
bool system_class::initialize()
@@ -56,7 +35,7 @@ bool system_class::initialize()
initialize_windows(screenWidth, screenHeight);
// Create and initialize the input object. This object will be used to handle reading the keyboard input from the user.
input_ = new input_class;
input_ = std::make_shared<input_class>();
result = input_->Initialize(hinstance_, hwnd_, screenWidth, screenHeight);
if (!result)
@@ -66,7 +45,7 @@ bool system_class::initialize()
}
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
application_ = new application_class;
application_ = std::make_shared<application_class>();
result = application_->initialize(screenWidth, screenHeight, hwnd_, false);
if (!result)
@@ -85,7 +64,7 @@ bool system_class::initialize()
// initialize imgui
if(DEBUG_MODE)
{
imgui_manager_ = new imguiManager;
imgui_manager_ = std::make_shared<imguiManager>();
imgui_manager_->SetApp(application_);
result = imgui_manager_->Initialize(hwnd_, application_->get_direct_3d()->get_device(), application_->get_direct_3d()->get_device_context());
if (!result)
@@ -112,49 +91,11 @@ void system_class::shutdown()
std::lock_guard<std::mutex> guard(render_mutex_);
// shutdown imgui
if (imgui_manager_)
{
Logger::Get().Log("Shutting down imgui manager", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
imgui_manager_->Shutdown();
delete imgui_manager_;
imgui_manager_ = 0;
Logger::Get().Log("Imgui manager shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the application class object.
if (application_)
{
Logger::Get().Log("Shutting down application", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
application_->shutdown();
delete application_;
application_ = 0;
Logger::Get().Log("Application shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// Release the input object.
if (input_)
{
Logger::Get().Log("Shutting down input", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
delete input_;
input_ = 0;
Logger::Get().Log("Input shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
}
// shutdown the window.
shutdown_windows();
Logger::Get().Log("System class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
return;
}
void system_class::run()
@@ -224,7 +165,7 @@ bool system_class::frame()
}
// Do the frame processing for the application class object.
result = application_->frame(input_);
result = application_->frame(input_.get());
if (!result)
{
Logger::Get().Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);