Minor - bigcube generation + using shared model - V11.4.0
This commit is contained in:
parent
f5331444cb
commit
de16b97f8e
125
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
125
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -6,19 +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/assets/Texture/imgui.ini" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/assets/imgui.ini" beforeDir="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/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/system_class.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/system_class.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/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.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/scene_manager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/scene_manager.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" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/system_class.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/system_class.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -38,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" />
|
||||
@ -64,26 +134,26 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.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"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Debug",
|
||||
"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"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1 setup="1">
|
||||
@ -229,6 +299,7 @@
|
||||
<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" />
|
||||
|
@ -10,13 +10,13 @@ Collapsed=0
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=1267,19
|
||||
Size=317,842
|
||||
Size=317,609
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Window][render Stats]
|
||||
Pos=0,630
|
||||
Size=792,231
|
||||
Size=1584,231
|
||||
Collapsed=0
|
||||
DockId=0x00000009,0
|
||||
|
||||
@ -28,7 +28,7 @@ DockId=0x0000000B,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=0,19
|
||||
Size=266,842
|
||||
Size=266,609
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
|
||||
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
|
||||
|
||||
object* ConstructSkybox();
|
||||
object* ConstructSkybox(application_class* app);
|
||||
|
||||
|
||||
// Variables
|
||||
|
@ -55,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;
|
||||
@ -79,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*);
|
||||
|
@ -29,6 +29,7 @@ enum class ShaderType
|
||||
class object
|
||||
{
|
||||
public:
|
||||
object(application_class& app);
|
||||
object();
|
||||
~object();
|
||||
|
||||
@ -137,6 +138,9 @@ public :
|
||||
bool m_gravityEnabled = true;
|
||||
|
||||
private:
|
||||
|
||||
application_class& m_Application;
|
||||
|
||||
XMMATRIX m_scaleMatrix;
|
||||
XMMATRIX m_rotateMatrix;
|
||||
XMMATRIX m_translateMatrix;
|
||||
|
@ -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_;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
@ -1133,10 +1131,10 @@ bool application_class::render(float rotation, float x, float y, float z, float
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
// set the active camera to the sun camera for rendering the shadow map.
|
||||
active_camera_ = sun_camera_;
|
||||
active_camera_->render();
|
||||
// Render the objects in the render queues. with depth only pass.
|
||||
active_camera_->get_view_matrix(viewMatrix);
|
||||
// active_camera_ = sun_camera_;
|
||||
// active_camera_->render();
|
||||
// // Render the objects in the render queues. with depth only pass.
|
||||
// active_camera_->get_view_matrix(viewMatrix);
|
||||
result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
@ -1145,18 +1143,19 @@ bool application_class::render(float rotation, float x, float y, float z, float
|
||||
}
|
||||
|
||||
// Reset the active camera to the main camera.
|
||||
active_camera_ = camera_;
|
||||
active_camera_->render();
|
||||
active_camera_->get_view_matrix(viewMatrix);
|
||||
|
||||
// render the objects in the render queues. with standard pass.
|
||||
result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using any shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// active_camera_ = camera_;
|
||||
// active_camera_->render();
|
||||
// active_camera_->get_view_matrix(viewMatrix);
|
||||
//
|
||||
// // render the objects in the render queues. with standard pass.
|
||||
// result = render_pass(render_queues_, diffuseColor, lightPosition, ambientColor, viewMatrix, projectionMatrix);
|
||||
// if (!result)
|
||||
// {
|
||||
// Logger::Get().Log("Could not render the model using any shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
stats_->update_geometric_stats();
|
||||
|
||||
// Update the render count text.
|
||||
result = update_render_count_string(get_render_count());
|
||||
@ -1329,7 +1328,7 @@ void application_class::generate_terrain()
|
||||
for (int j = 0; j < gridSizeZ; j++)
|
||||
{
|
||||
// Créer un nouvel objet de terrain
|
||||
object* terrain = new object();
|
||||
object* terrain = new object(*this);
|
||||
|
||||
// Initialiser avec le modèle et les textures_ préchargées
|
||||
if (!terrain->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, textureContainer))
|
||||
@ -1362,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];
|
||||
@ -1382,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);
|
||||
@ -1404,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];
|
||||
@ -1418,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));
|
||||
@ -1429,6 +1430,7 @@ 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())
|
||||
@ -1439,6 +1441,7 @@ void application_class::delete_kobject(int index)
|
||||
|
||||
void application_class::delete_terrain()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(objects_mutex_);
|
||||
Logger::Get().Log("Deleting terrain", __FILE__, __LINE__);
|
||||
terrain_chunk_.clear();
|
||||
}
|
||||
@ -2151,126 +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ération du terrain dans un thread séparé", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
// Créer un thread qui exécutera la génération du terrain
|
||||
std::thread generationThread([this, side_count]() {
|
||||
Logger::Get().Log("Thread de génération de terrain démarré", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
std::string modelName = "assets/Model/TXT/cube.txt";
|
||||
std::shared_ptr<model_class> sharedModel;
|
||||
|
||||
// Vérifier si le modèle existe déjà
|
||||
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éer et initialiser le modèle si non trouvé
|
||||
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è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éer temporairement les cubes dans un vecteur local
|
||||
std::vector<object*> tempCubes;
|
||||
tempCubes.reserve(side_count * side_count * side_count);
|
||||
|
||||
// Préparer les données pour la création des cubes
|
||||
std::vector<std::tuple<float, float, float, std::string, int>> cubeData;
|
||||
int objectId = object_id_;
|
||||
|
||||
// Générer les donné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êter le thread
|
||||
if (should_quit_) {
|
||||
Logger::Get().Log("Génération de terrain annulé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ées du cube
|
||||
cubeData.push_back(std::make_tuple(posX, posY, posZ, name, objectId++));
|
||||
}
|
||||
// Générer side_count³ 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éer les objets
|
||||
// Cette partie doit être exécuté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ées de génération de terrain préparées (" + std::to_string(terrain_generation_data_.size()) + " cubes)", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
});
|
||||
|
||||
// Détacher le thread pour qu'il s'exécute en arrière-plan
|
||||
generationThread.detach();
|
||||
}
|
||||
|
||||
void application_class::process_terrain_generation()
|
||||
{
|
||||
// Vérifier si des données de terrain sont prêtes à être traitées
|
||||
if (!terrain_generation_ready_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Acquérir les données généré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éation des objets terrain à partir des données préparées", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
// Transférer les cubes du vecteur temporaire au vecteur membre
|
||||
cubes_ = std::move(tempCubes);
|
||||
|
||||
terrain_chunk_.clear();
|
||||
|
||||
// Créer un conteneur de textures_ partagé
|
||||
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é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éer les objets à partir des données
|
||||
for (const auto& [posX, posY, posZ, name, id] : cubeData)
|
||||
{
|
||||
// Créer un nouvel objet de terrain
|
||||
object* terrain = new object();
|
||||
|
||||
// Initialiser avec le modèle et les textures_
|
||||
if (!terrain->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, textureContainer))
|
||||
{
|
||||
Logger::Get().Log("É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 à la liste des chunks de terrain
|
||||
terrain_chunk_.push_back(terrain);
|
||||
}
|
||||
|
||||
delete sharedModel;
|
||||
|
||||
Logger::Get().Log("Génération du terrain terminée avec " + std::to_string(terrain_chunk_.size()) + " cubes", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
return true;
|
||||
}
|
@ -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();
|
||||
@ -31,8 +49,25 @@ bool object::Initialize(
|
||||
TextureContainer& texturesContainer
|
||||
)
|
||||
{
|
||||
m_model_ = std::make_shared<model_class>();
|
||||
return m_model_->Initialize(device, deviceContext, modelFilename, 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)
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user