Compare commits
15 Commits
V10.1.2
...
8b77b189a8
Author | SHA1 | Date | |
---|---|---|---|
8b77b189a8 | |||
e5ee8fdad3 | |||
3a2d19dff4 | |||
dbc7003569 | |||
c5bfa2e621 | |||
32b71ac97f | |||
5c3c6d944c | |||
8d32f51e8c | |||
644fc57762 | |||
f8bfb62e98 | |||
94fd900ce8 | |||
2744c809d3 | |||
b80f66fec3 | |||
8bcd3eed48 | |||
2b1e64ffbd |
146
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
146
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@@ -4,7 +4,14 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
|
<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/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" 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/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" 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/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@@ -53,7 +60,98 @@
|
|||||||
<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="cidr-memory-view://6" 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="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://$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$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||||
@@ -70,25 +168,25 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"C++ Project.enginecustom.executor": "Run",
|
"C++ Project.enginecustom.executor": "Run",
|
||||||
"C/C++ Project.enginecustom.executor": "Run",
|
"C/C++ Project.enginecustom.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.build.unityPlugin",
|
"settings.editor.selected.configurable": "preferences.build.unityPlugin",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
||||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1 setup="1">
|
||||||
@@ -208,6 +306,14 @@
|
|||||||
<workItem from="1746526901276" duration="2023000" />
|
<workItem from="1746526901276" duration="2023000" />
|
||||||
<workItem from="1746536290167" duration="1908000" />
|
<workItem from="1746536290167" duration="1908000" />
|
||||||
<workItem from="1746538260893" duration="5781000" />
|
<workItem from="1746538260893" duration="5781000" />
|
||||||
|
<workItem from="1746546014271" duration="1814000" />
|
||||||
|
<workItem from="1746619988287" duration="12282000" />
|
||||||
|
<workItem from="1746711806997" duration="6736000" />
|
||||||
|
<workItem from="1746719840054" duration="991000" />
|
||||||
|
<workItem from="1746795732153" duration="33000" />
|
||||||
|
<workItem from="1746795828588" duration="592000" />
|
||||||
|
<workItem from="1747049871967" duration="9350000" />
|
||||||
|
<workItem from="1747136509645" duration="3939000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
Khaotic Engine Reborn reprend comme base le moteur Khaotic Engine pour lui ajouter plus de fonctionalité.
|
Khaotic Engine Reborn reprend comme base le moteur Khaotic Engine pour lui ajouter plus de fonctionalité.
|
||||||
|
|
||||||
Ce moteur est basé sur **DirectX11** utilise **ImGui** avec une couche d'abstraction pour permetre son usage avec d'autres API.
|
Ce moteur est basé sur **DirectX11** et utilise **ImGui** pour son interface graphique.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
Khaotic Engine is a rendering engine made in **C++** by a small team with the aim of learning how to use rendering APIs (OpenGL, DirectX 11/12 and Vulkan).
|
Khaotic Engine is a rendering engine made in **C++** by a small team with the aim of learning how to use rendering APIs (OpenGL, DirectX 11/12 and Vulkan).
|
||||||
|
|
||||||
This **DirectX11** based engine uses **ImGui** with an abstraction layer to enable its use with other APIs.
|
This **DirectX11** based engine uses **ImGui** for the user interface.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -60,10 +60,11 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab
|
|||||||
- Shader rendering
|
- Shader rendering
|
||||||
- Frustum culling
|
- Frustum culling
|
||||||
- Object rendering
|
- Object rendering
|
||||||
|
- Terrain Instancing
|
||||||
|
|
||||||
## Demo :
|
## Demo :
|
||||||
|
|
||||||
[](https://www.youtube.com/watch?v=qCOCTyB_97c)
|
[](https://youtu.be/DYgT1Nu7B4c)
|
||||||
|
|
||||||
## Engine Build by :
|
## Engine Build by :
|
||||||
|
|
||||||
@@ -76,7 +77,7 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab
|
|||||||
- [@Harpie94](https://github.com/Harpie94)
|
- [@Harpie94](https://github.com/Harpie94)
|
||||||
- [@axelpicou](https://github.com/axelpicou)
|
- [@axelpicou](https://github.com/axelpicou)
|
||||||
- [@GolfOcean334](https://github.com/GolfOcean334)
|
- [@GolfOcean334](https://github.com/GolfOcean334)
|
||||||
- [@sutabasuto](https://github.com/sutabasuto)
|
- [@sutabasuto](https://github.com/sutabasuto)
|
||||||
|
|
||||||
|
|
||||||
**Moteur Reborn** :
|
**Moteur Reborn** :
|
||||||
|
0
enginecustom/DemoScene_V10.1.2.ker
Normal file
0
enginecustom/DemoScene_V10.1.2.ker
Normal file
@@ -4,28 +4,28 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1233,27
|
Pos=1697,27
|
||||||
Size=343,826
|
Size=343,1094
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,547
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000009,0
|
|
||||||
|
|
||||||
[Window][Terrain]
|
|
||||||
Pos=8,27
|
|
||||||
Size=250,826
|
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
|
[Window][Terrain]
|
||||||
|
Pos=8,576
|
||||||
|
Size=289,545
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=290,866
|
Size=290,866
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,1
|
DockId=0x0000000B,1
|
||||||
|
|
||||||
[Window][Shader Manager]
|
[Window][Shader Manager]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
@@ -35,9 +35,9 @@ DockId=0x00000001,2
|
|||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,547
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,1
|
||||||
|
|
||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Size=1584,861
|
Size=1584,861
|
||||||
@@ -47,11 +47,11 @@ Collapsed=0
|
|||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=1559,974
|
Size=1559,974
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][DockSpace]
|
[Window][DockSpace]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
Size=1584,861
|
Size=2048,1129
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Add Object]
|
[Window][Add Object]
|
||||||
@@ -66,24 +66,24 @@ Collapsed=0
|
|||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
[Window][Log Window]
|
[Window][Log Window]
|
||||||
Pos=8,627
|
Pos=8,37
|
||||||
Size=1568,226
|
Size=16,19
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=Y
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
||||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Selected=0x031DC75C
|
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
|
||||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=X
|
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
|
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
||||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 CentralNode=1
|
||||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
||||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
||||||
|
|
||||||
|
@@ -4,28 +4,28 @@ Size=400,400
|
|||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1233,27
|
Pos=1281,19
|
||||||
Size=343,826
|
Size=303,842
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Objects]
|
[Window][Objects]
|
||||||
Pos=8,27
|
Pos=0,19
|
||||||
Size=289,826
|
Size=281,615
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000009,0
|
|
||||||
|
|
||||||
[Window][Terrain]
|
|
||||||
Pos=8,27
|
|
||||||
Size=250,826
|
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=0,19
|
||||||
Size=290,866
|
Size=281,615
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,1
|
DockId=0x00000008,0
|
||||||
|
|
||||||
|
[Window][Light]
|
||||||
|
Pos=0,328
|
||||||
|
Size=281,306
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000008,1
|
||||||
|
|
||||||
[Window][Shader Manager]
|
[Window][Shader Manager]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
@@ -34,10 +34,10 @@ Collapsed=0
|
|||||||
DockId=0x00000001,2
|
DockId=0x00000001,2
|
||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=8,27
|
Pos=0,19
|
||||||
Size=289,826
|
Size=281,615
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,1
|
||||||
|
|
||||||
[Window][DockSpace Demo]
|
[Window][DockSpace Demo]
|
||||||
Size=1584,861
|
Size=1584,861
|
||||||
@@ -47,7 +47,7 @@ Collapsed=0
|
|||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=1559,974
|
Size=1559,974
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][DockSpace]
|
[Window][DockSpace]
|
||||||
Pos=0,0
|
Pos=0,0
|
||||||
@@ -66,24 +66,32 @@ Collapsed=0
|
|||||||
DockId=0x0000000C,0
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
[Window][Log Window]
|
[Window][Log Window]
|
||||||
Pos=8,37
|
Pos=641,636
|
||||||
Size=16,19
|
Size=638,225
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Window][Render Stats]
|
||||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
Pos=0,636
|
||||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
Size=1279,225
|
||||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
Collapsed=0
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=Y
|
DockId=0x00000004,0
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
|
||||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Selected=0x031DC75C
|
[Docking][Data]
|
||||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=X
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
|
||||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
|
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
|
||||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
|
||||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
|
||||||
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
|
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
|
||||||
|
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 CentralNode=1 Selected=0x321620B2
|
||||||
|
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=882,225 Selected=0xD99DEA49
|
||||||
|
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=881,225 Selected=0xAB74BEE9
|
||||||
|
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Selected=0x9F035453
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <DirectXMath.h>
|
#include <DirectXMath.h>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
@@ -67,12 +68,18 @@ public:
|
|||||||
ApplicationClass();
|
ApplicationClass();
|
||||||
~ApplicationClass();
|
~ApplicationClass();
|
||||||
D3DClass* GetDirect3D();
|
D3DClass* GetDirect3D();
|
||||||
|
|
||||||
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
|
RenderTextureClass* GetSceneTexture() const { return m_SceneTexture; };
|
||||||
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
|
RenderTextureClass* GetRenderTexture() const { return m_RenderTexture; };
|
||||||
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
|
RenderTextureClass* GetRefractionTexture() const { return m_RefractionTexture; };
|
||||||
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
|
RenderTextureClass* GetReflectionTexture() const { return m_ReflectionTexture; };
|
||||||
|
|
||||||
|
|
||||||
|
int GetTotalVertexCount() const;
|
||||||
|
int GetTotalTriangleCount() const;
|
||||||
|
int GetVisibleTriangleCount() const;
|
||||||
|
|
||||||
|
void CreateBigCube(int sideCount);
|
||||||
|
void ProcessTerrainGeneration();
|
||||||
bool Initialize(int, int, HWND, bool IsVulkan);
|
bool Initialize(int, int, HWND, bool IsVulkan);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
bool Frame(InputClass*);
|
bool Frame(InputClass*);
|
||||||
@@ -131,6 +138,19 @@ public:
|
|||||||
|
|
||||||
Physics* GetPhysics() const { return m_Physics; };
|
Physics* GetPhysics() const { return m_Physics; };
|
||||||
|
|
||||||
|
// ------------------------------------- //
|
||||||
|
// --------------- Stats --------------- //
|
||||||
|
// ------------------------------------- //
|
||||||
|
|
||||||
|
int GetCurrentFps() const;
|
||||||
|
int GetMinFps() const;
|
||||||
|
int GetMaxFps() const;
|
||||||
|
float GetFrameTime() const;
|
||||||
|
int GetDrawCalls() const;
|
||||||
|
void ResetFpsStats();
|
||||||
|
void IncrementDrawCallCount();
|
||||||
|
void ResetDrawCallCount();
|
||||||
|
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
// ------------- Culling ------------- //
|
// ------------- Culling ------------- //
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
@@ -176,6 +196,18 @@ public :
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
// Thread de culling
|
||||||
|
std::thread m_CullingThread;
|
||||||
|
std::atomic<bool> m_CullingActive;
|
||||||
|
std::mutex m_ObjectsMutex;
|
||||||
|
void CullingThreadFunction();
|
||||||
|
|
||||||
|
|
||||||
|
std::mutex m_TerrainMutex;
|
||||||
|
std::vector<std::tuple<float, float, float, std::string, int>> m_TerrainGenerationData;
|
||||||
|
bool m_TerrainGenerationReady;
|
||||||
|
int m_NextTerrainObjectId;
|
||||||
|
|
||||||
// ------------------------------------- //
|
// ------------------------------------- //
|
||||||
// ------------- DIRECT3D -------------- //
|
// ------------- DIRECT3D -------------- //
|
||||||
// ------------------------------------- //
|
// ------------------------------------- //
|
||||||
@@ -202,6 +234,7 @@ private :
|
|||||||
int m_screenWidth, m_screenHeight;
|
int m_screenWidth, m_screenHeight;
|
||||||
CameraClass* m_Camera;
|
CameraClass* m_Camera;
|
||||||
PositionClass* m_Position;
|
PositionClass* m_Position;
|
||||||
|
int m_drawcalls;
|
||||||
|
|
||||||
// ------------------------------------ //
|
// ------------------------------------ //
|
||||||
// ------------- OBJECTS -------------- //
|
// ------------- OBJECTS -------------- //
|
||||||
|
@@ -28,9 +28,19 @@ public:
|
|||||||
void Frame();
|
void Frame();
|
||||||
int GetFps();
|
int GetFps();
|
||||||
|
|
||||||
|
int GetMinFps() const;
|
||||||
|
int GetMaxFps() const;
|
||||||
|
float GetFrameTime() const;
|
||||||
|
void ResetStats();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_fps, m_count;
|
int m_fps, m_count;
|
||||||
unsigned long m_startTime;
|
unsigned long m_startTime;
|
||||||
|
|
||||||
|
int m_minFps;
|
||||||
|
int m_maxFps;
|
||||||
|
float m_frameTime;
|
||||||
|
unsigned long m_previousTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
@@ -38,6 +38,7 @@ public:
|
|||||||
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
void WidgetEngineSettingsWindow(ApplicationClass* app);
|
||||||
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
|
||||||
void WidgetLogWindow(ApplicationClass* app);
|
void WidgetLogWindow(ApplicationClass* app);
|
||||||
|
void WidgetRenderStats(ApplicationClass* app);
|
||||||
|
|
||||||
bool ImGuiWidgetRenderer(ApplicationClass* app);
|
bool ImGuiWidgetRenderer(ApplicationClass* app);
|
||||||
|
|
||||||
@@ -65,6 +66,13 @@ private:
|
|||||||
bool showOldSceneWindow;
|
bool showOldSceneWindow;
|
||||||
bool showEngineSettingsWindow;
|
bool showEngineSettingsWindow;
|
||||||
bool showLogWindow;
|
bool showLogWindow;
|
||||||
|
bool showStatsWindow;
|
||||||
|
|
||||||
|
int m_SideCount = 0;
|
||||||
|
|
||||||
|
static const int FRAME_HISTORY_COUNT = 3600; // 1min secondes <20> 60 FPS
|
||||||
|
float m_frameTimeHistory[FRAME_HISTORY_COUNT] = {};
|
||||||
|
int m_frameTimeHistoryIndex = 0;
|
||||||
|
|
||||||
bool m_isPhyiscsEnabled = false;
|
bool m_isPhyiscsEnabled = false;
|
||||||
bool m_isGravityEnabled = false;
|
bool m_isGravityEnabled = false;
|
||||||
|
@@ -201,7 +201,8 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
ModelClass();
|
ModelClass();
|
||||||
ModelClass(const ModelClass&);
|
ModelClass(const ModelClass&) = delete;
|
||||||
|
ModelClass& operator=(const ModelClass&) = delete;
|
||||||
~ModelClass();
|
~ModelClass();
|
||||||
|
|
||||||
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
||||||
@@ -213,9 +214,13 @@ public:
|
|||||||
void Render(ID3D11DeviceContext*);
|
void Render(ID3D11DeviceContext*);
|
||||||
|
|
||||||
int GetIndexCount();
|
int GetIndexCount();
|
||||||
|
int GetVertexCount() const { return m_vertexCount; }
|
||||||
|
|
||||||
|
// TEXTURE //
|
||||||
|
|
||||||
//ID3D11ShaderResourceView* GetTexture(int index) const;
|
//ID3D11ShaderResourceView* GetTexture(int index) const;
|
||||||
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
|
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
|
||||||
|
|
||||||
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
|
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
|
||||||
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
|
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
|
||||||
|
|
||||||
@@ -227,12 +232,15 @@ public:
|
|||||||
TextureContainer GetTextureContainer() const { return m_Textures; }
|
TextureContainer GetTextureContainer() const { return m_Textures; }
|
||||||
|
|
||||||
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
int m_vertexCount, m_indexCount;
|
||||||
|
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool InitializeBuffers(ID3D11Device*);
|
bool InitializeBuffers(ID3D11Device*);
|
||||||
void ShutdownBuffers();
|
void ShutdownBuffers();
|
||||||
void RenderBuffers(ID3D11DeviceContext*);
|
void RenderBuffers(ID3D11DeviceContext*);
|
||||||
bool LoadTextures(ID3D11Device*, ID3D11DeviceContext*, vector<string> filename);
|
|
||||||
void ReleaseTextures();
|
void ReleaseTextures();
|
||||||
|
|
||||||
bool LoadModel(char*);
|
bool LoadModel(char*);
|
||||||
@@ -243,8 +251,6 @@ private:
|
|||||||
void CalculateModelVectors();
|
void CalculateModelVectors();
|
||||||
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
||||||
|
|
||||||
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
|
||||||
int m_vertexCount, m_indexCount;
|
|
||||||
TextureContainer m_Textures;
|
TextureContainer m_Textures;
|
||||||
ModelType* m_model;
|
ModelType* m_model;
|
||||||
};
|
};
|
||||||
|
@@ -32,6 +32,9 @@ public:
|
|||||||
Object();
|
Object();
|
||||||
~Object();
|
~Object();
|
||||||
|
|
||||||
|
Object(const Object&) = delete;
|
||||||
|
Object& operator=(const Object&) = delete;
|
||||||
|
|
||||||
void SetScaleMatrix(XMMATRIX scaleMatrix);
|
void SetScaleMatrix(XMMATRIX scaleMatrix);
|
||||||
void SetRotateMatrix(XMMATRIX rotateMatrix);
|
void SetRotateMatrix(XMMATRIX rotateMatrix);
|
||||||
void SetTranslateMatrix(XMMATRIX translateMatrix);
|
void SetTranslateMatrix(XMMATRIX translateMatrix);
|
||||||
@@ -63,7 +66,8 @@ public:
|
|||||||
bool IsGrounded() const;
|
bool IsGrounded() const;
|
||||||
bool IsPhysicsEnabled() const;
|
bool IsPhysicsEnabled() const;
|
||||||
void SetPhysicsEnabled(bool state);
|
void SetPhysicsEnabled(bool state);
|
||||||
|
void SetVisible (bool state) { m_isVisible = state; }
|
||||||
|
bool IsVisible() const { return m_isVisible; }
|
||||||
|
|
||||||
void UpdateWorldMatrix();
|
void UpdateWorldMatrix();
|
||||||
void UpdateSRMatrix();
|
void UpdateSRMatrix();
|
||||||
@@ -98,7 +102,14 @@ public:
|
|||||||
std::string ObjectTypeToString(ObjectType objectType);
|
std::string ObjectTypeToString(ObjectType objectType);
|
||||||
|
|
||||||
void LaunchObject();
|
void LaunchObject();
|
||||||
void LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer, D3DClass* m_Direct3D);
|
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
||||||
|
D3DClass* m_Direct3D);
|
||||||
|
bool SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms);
|
||||||
|
void EnableInstancing(bool enabled);
|
||||||
|
void SetInstanceCount(int count);
|
||||||
|
bool IsInstancingEnabled() const;
|
||||||
|
int GetInstanceCount() const;
|
||||||
|
ID3D11Buffer* GetInstanceBuffer() const;
|
||||||
void SetAlpha(float alpha) { m_alpha = alpha; }
|
void SetAlpha(float alpha) { m_alpha = alpha; }
|
||||||
float GetAlpha() const { return m_alpha; }
|
float GetAlpha() const { return m_alpha; }
|
||||||
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
|
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
|
||||||
@@ -127,6 +138,7 @@ private:
|
|||||||
float m_mass;
|
float m_mass;
|
||||||
bool m_isGrounded;
|
bool m_isGrounded;
|
||||||
bool m_isPhysicsEnabled;
|
bool m_isPhysicsEnabled;
|
||||||
|
bool m_isVisible;
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
ObjectType m_type = ObjectType::Unknown;
|
ObjectType m_type = ObjectType::Unknown;
|
||||||
@@ -138,6 +150,5 @@ private:
|
|||||||
float m_alpha = 0.0f;
|
float m_alpha = 0.0f;
|
||||||
float m_initialStretch = 0.0f;
|
float m_initialStretch = 0.0f;
|
||||||
float m_springConstant = 10.0f;
|
float m_springConstant = 10.0f;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -48,17 +48,24 @@ ApplicationClass::ApplicationClass() : m_ShouldQuit(false)
|
|||||||
TrueLightPosition = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
TrueLightPosition = XMFLOAT3(0.0f, 0.0f, 0.0f);
|
||||||
m_LightModel = nullptr;
|
m_LightModel = nullptr;
|
||||||
m_renderCount = 0;
|
m_renderCount = 0;
|
||||||
|
m_drawcalls = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApplicationClass::~ApplicationClass()
|
ApplicationClass::~ApplicationClass()
|
||||||
{
|
{
|
||||||
m_ShouldQuit = true;
|
m_ShouldQuit = true;
|
||||||
|
m_CullingActive = false;
|
||||||
|
|
||||||
// Joindre le thread pour s'assurer qu'il se termine correctement
|
// Joindre les threads pour s'assurer qu'ils se terminent correctement
|
||||||
if (m_PhysicsThread.joinable())
|
if (m_PhysicsThread.joinable())
|
||||||
{
|
{
|
||||||
m_PhysicsThread.join();
|
m_PhysicsThread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_CullingThread.joinable())
|
||||||
|
{
|
||||||
|
m_CullingThread.join();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,6 +474,9 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
|||||||
skybox->Initialize(m_Direct3D);
|
skybox->Initialize(m_Direct3D);
|
||||||
m_Skybox.push_back(skybox->ConstructSkybox());
|
m_Skybox.push_back(skybox->ConstructSkybox());
|
||||||
|
|
||||||
|
m_CullingActive = true;
|
||||||
|
m_CullingThread = std::thread(&ApplicationClass::CullingThreadFunction, this);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
@@ -708,6 +718,9 @@ void ApplicationClass::Shutdown()
|
|||||||
|
|
||||||
bool ApplicationClass::Frame(InputClass* Input)
|
bool ApplicationClass::Frame(InputClass* Input)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ProcessTerrainGeneration();
|
||||||
|
ResetDrawCallCount();
|
||||||
|
|
||||||
int mouseX, mouseY, currentMouseX, currentMouseY;
|
int mouseX, mouseY, currentMouseX, currentMouseY;
|
||||||
bool result, leftMouseDown, rightMouseDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE, scrollUp, scrollDown;
|
bool result, leftMouseDown, rightMouseDown, buttonQ, buttonD, buttonZ, buttonS, buttonA, buttonE, scrollUp, scrollDown;
|
||||||
@@ -1192,50 +1205,74 @@ int ApplicationClass::GetScreenHeight() const
|
|||||||
|
|
||||||
void ApplicationClass::GenerateTerrain()
|
void ApplicationClass::GenerateTerrain()
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Generating terrain", __FILE__, __LINE__);
|
Logger::Get().Log("G<EFBFBD>n<EFBFBD>ration du terrain avec instanciation", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
char modelFilename[128];
|
// Nettoyer les objets terrain existants pour <20>viter les fuites
|
||||||
TextureContainer TerrainTextures;
|
for (auto* chunk : m_terrainChunk)
|
||||||
XMMATRIX scaleMatrix;
|
{
|
||||||
float scaleX, scaleY, scaleZ;
|
if (chunk)
|
||||||
|
{
|
||||||
|
chunk->Shutdown();
|
||||||
|
delete chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_terrainChunk.clear();
|
||||||
|
|
||||||
scaleX = 10.0f;
|
// Dimensions du terrain
|
||||||
scaleY = 1.0f;
|
float scaleX = 10.0f;
|
||||||
scaleZ = 10.0f;
|
float scaleY = 1.0f;
|
||||||
|
float scaleZ = 10.0f;
|
||||||
|
int gridSizeX = 20;
|
||||||
|
int gridSizeZ = 20;
|
||||||
|
|
||||||
scaleMatrix = XMMatrixScaling(scaleX, scaleY, scaleZ);
|
// 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");
|
||||||
|
|
||||||
// Set the file name of the model.
|
// Pr<50>charger les textures une seule fois
|
||||||
strcpy_s(modelFilename, "assets/Model/OBJ/plane.obj");
|
ModelClass* sharedModel = new ModelClass();
|
||||||
|
sharedModel->PreloadTextures(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), textureContainer);
|
||||||
|
|
||||||
// Liste des fichiers de texture
|
char modelFilename[128];
|
||||||
std::vector<std::wstring> terrainTexture = {
|
strcpy_s(modelFilename, "assets/Model/OBJ/plane.obj");
|
||||||
L"assets/Texture/Bricks2K.png",
|
|
||||||
L"assets/Texture/BricksNRM2K.png",
|
|
||||||
L"assets/Texture/BricksGLOSS2K.png"
|
|
||||||
};
|
|
||||||
|
|
||||||
std::filesystem::path p(modelFilename);
|
// G<>n<EFBFBD>rer les tuiles de terrain
|
||||||
std::string filenameWithoutExtension = p.stem().string();
|
for (int i = 0; i < gridSizeX; i++)
|
||||||
|
{
|
||||||
// for loop to generate terrain chunks for a 10x10 grid
|
for (int j = 0; j < gridSizeZ; j++)
|
||||||
for (int i = 0; i < 20; i++)
|
{
|
||||||
{
|
// Cr<43>er un nouvel objet de terrain
|
||||||
for (int j = 0; j < 20; j++)
|
Object* terrain = new Object();
|
||||||
{
|
|
||||||
Object* newTerrain = new Object();
|
|
||||||
newTerrain->LoadTexturesFromPath(terrainTexture, TerrainTextures, m_Direct3D); // Load textures from the path
|
|
||||||
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, TerrainTextures);
|
|
||||||
newTerrain->SetScaleMatrix(scaleMatrix);
|
|
||||||
newTerrain->SetTranslateMatrix(XMMatrixTranslation(i / 2 * scaleX , -12.0f, j * scaleZ));
|
|
||||||
newTerrain->SetName(filenameWithoutExtension);
|
|
||||||
newTerrain->SetType(ObjectType::Cube);
|
|
||||||
newTerrain->SetActiveShader(ShaderType::SUNLIGHT);
|
|
||||||
m_terrainChunk.push_back(newTerrain);
|
|
||||||
|
|
||||||
}
|
// Initialiser avec le mod<6F>le et les textures pr<70>charg<72>es
|
||||||
}
|
if (!terrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textureContainer))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec de l'initialisation d'une tuile de terrain", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
delete terrain;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// D<>finir la position dans la grille
|
||||||
|
XMFLOAT3 position(i * scaleX, -12.0f, j * scaleZ);
|
||||||
|
XMFLOAT3 scale(scaleX, scaleY, scaleZ);
|
||||||
|
|
||||||
|
terrain->SetPosition(XMLoadFloat3(&position));
|
||||||
|
terrain->SetScale(XMLoadFloat3(&scale));
|
||||||
|
|
||||||
|
// Configurer les propri<72>t<EFBFBD>s
|
||||||
|
terrain->SetName("TerrainTile_" + std::to_string(i) + "_" + std::to_string(j));
|
||||||
|
terrain->SetType(ObjectType::Cube);
|
||||||
|
terrain->SetActiveShader(ShaderType::SUNLIGHT);
|
||||||
|
terrain->SetId(m_ObjectId++);
|
||||||
|
|
||||||
|
// Ajouter <20> la liste des chunks de terrain
|
||||||
|
m_terrainChunk.push_back(terrain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("Terrain g<>n<EFBFBD>r<EFBFBD> avec " + std::to_string(m_terrainChunk.size()) + " tuiles", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplicationClass::AddKobject(std::wstring& filepath)
|
void ApplicationClass::AddKobject(std::wstring& filepath)
|
||||||
@@ -1249,7 +1286,7 @@ void ApplicationClass::AddKobject(std::wstring& filepath)
|
|||||||
string filename = p.stem().string();
|
string filename = p.stem().string();
|
||||||
|
|
||||||
size_t convertedChars = 0;
|
size_t convertedChars = 0;
|
||||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), filepath.c_str(), _TRUNCATE);
|
(void)wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), filepath.c_str(), _TRUNCATE);
|
||||||
|
|
||||||
filesystem::current_path(m_WFolder);
|
filesystem::current_path(m_WFolder);
|
||||||
|
|
||||||
@@ -1565,15 +1602,77 @@ void ApplicationClass::SetScreenWidth(int width)
|
|||||||
m_screenWidth = width;
|
m_screenWidth = width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::CullingThreadFunction()
|
||||||
|
{
|
||||||
|
Logger::Get().Log("Thread de culling d<>marr<72>", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
|
while (m_CullingActive)
|
||||||
|
{
|
||||||
|
// Construction du frustum une fois par cycle de culling
|
||||||
|
ConstructFrustum();
|
||||||
|
|
||||||
|
// S'assurer que la skybox est toujours visible
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(m_ObjectsMutex);
|
||||||
|
for (auto* skyboxObject : m_Skybox)
|
||||||
|
{
|
||||||
|
if (skyboxObject)
|
||||||
|
{
|
||||||
|
skyboxObject->SetVisible(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Traitement des files d'objets normaux (sans la skybox)
|
||||||
|
std::vector<std::reference_wrapper<std::vector<Object*>>> queues = {
|
||||||
|
std::ref(m_object), std::ref(m_cubes), std::ref(m_terrainChunk)
|
||||||
|
};
|
||||||
|
|
||||||
|
for (auto& queueRef : queues)
|
||||||
|
{
|
||||||
|
std::vector<Object*>& queue = queueRef.get();
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(m_ObjectsMutex);
|
||||||
|
|
||||||
|
for (auto* object : queue)
|
||||||
|
{
|
||||||
|
if (!object) continue;
|
||||||
|
|
||||||
|
// Extraction des donn<6E>es de position
|
||||||
|
XMVECTOR position = object->GetPosition();
|
||||||
|
float x = XMVectorGetX(position);
|
||||||
|
float y = XMVectorGetY(position);
|
||||||
|
float z = XMVectorGetZ(position);
|
||||||
|
|
||||||
|
// Calcul du rayon approximatif
|
||||||
|
XMVECTOR scale = object->GetScale();
|
||||||
|
float radius = max(max(XMVectorGetX(scale), XMVectorGetY(scale)), XMVectorGetZ(scale));
|
||||||
|
|
||||||
|
// V<>rification du frustum
|
||||||
|
bool visible = m_FrustumCulling.CheckCube(x, y, z, radius, GetFrustumTolerance());
|
||||||
|
object->SetVisible(visible);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pause pour <20>viter de surcharger le CPU
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(16)); // ~60 Hz
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("Thread de culling termin<69>", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::vector<Object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection)
|
bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::vector<Object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection)
|
||||||
{
|
{
|
||||||
XMMATRIX worldMatrix, scaleMatrix, rotateMatrix, translateMatrix, srMatrix;
|
std::lock_guard<std::mutex> lock(m_ObjectsMutex);
|
||||||
|
XMMATRIX scaleMatrix, rotateMatrix, translateMatrix ;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
int renderCount = 0;
|
int renderCount = 0;
|
||||||
|
|
||||||
ConstructFrustum();
|
//ConstructFrustum();
|
||||||
|
|
||||||
|
|
||||||
for (const auto& RenderQueue : RenderQueues)
|
for (const auto& RenderQueue : RenderQueues)
|
||||||
{
|
{
|
||||||
@@ -1592,32 +1691,27 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
XMVECTOR objposition = object->GetPosition();
|
|
||||||
float x = XMVectorGetX(objposition);
|
|
||||||
float y = XMVectorGetY(objposition);
|
|
||||||
float z = XMVectorGetZ(objposition);
|
|
||||||
float radius = object->GetBoundingRadius();
|
|
||||||
|
|
||||||
// Check if the object has physics enabled
|
// Check if the object has physics enabled
|
||||||
if (object->IsPhysicsEnabled())
|
if (object->IsPhysicsEnabled())
|
||||||
{
|
{
|
||||||
object->UpdatePosition(m_Timer->GetTime());
|
object->UpdatePosition(m_Timer->GetTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
// V<>rifie si l'objet est dans le frustum
|
if (!object->IsVisible())
|
||||||
if (!m_FrustumCulling.CheckCube(x, y, z, radius, GetFrustumTolerance()))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderCount++;
|
renderCount++;
|
||||||
|
|
||||||
scaleMatrix = object->GetScaleMatrix();
|
scaleMatrix = object->GetScaleMatrix();
|
||||||
rotateMatrix = object->GetRotateMatrix();
|
rotateMatrix = object->GetRotateMatrix();
|
||||||
translateMatrix = object->GetTranslateMatrix();
|
translateMatrix = object->GetTranslateMatrix();
|
||||||
|
|
||||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
XMMATRIX worldMatrix = XMMatrixMultiply(
|
||||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
XMMatrixMultiply(scaleMatrix, rotateMatrix),
|
||||||
|
translateMatrix
|
||||||
|
);
|
||||||
|
|
||||||
object->Render(m_Direct3D->GetDeviceContext());
|
object->Render(m_Direct3D->GetDeviceContext());
|
||||||
|
|
||||||
@@ -1804,6 +1898,8 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IncrementDrawCallCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSkybox)
|
if (isSkybox)
|
||||||
@@ -2228,4 +2324,264 @@ std::wstring ApplicationClass::GetScenePath()
|
|||||||
return filepath.wstring();
|
return filepath.wstring();
|
||||||
}
|
}
|
||||||
return L"";
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetTotalVertexCount() const
|
||||||
|
{
|
||||||
|
int totalVertices = 0;
|
||||||
|
for (const auto& obj : m_object)
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
totalVertices += obj->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour les cubes
|
||||||
|
for (const auto& cube : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalVertices += cube->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de sommets pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalVertices += chunk->GetVertexCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalVertices;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetTotalTriangleCount() const
|
||||||
|
{
|
||||||
|
int totalTriangles = 0;
|
||||||
|
for (const auto& obj : m_object)
|
||||||
|
{
|
||||||
|
if (obj)
|
||||||
|
{
|
||||||
|
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
||||||
|
totalTriangles += obj->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles pour les cubes
|
||||||
|
for (const auto& cube : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube)
|
||||||
|
{
|
||||||
|
totalTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk)
|
||||||
|
{
|
||||||
|
totalTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return totalTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetVisibleTriangleCount() const
|
||||||
|
{
|
||||||
|
int visibleTriangles = 0;
|
||||||
|
for (const auto& obj : m_object)
|
||||||
|
{
|
||||||
|
if (obj && obj->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += obj->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour les cubes
|
||||||
|
for (const auto& cube : m_cubes)
|
||||||
|
{
|
||||||
|
if (cube && cube->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += cube->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Ajoutez le nombre de triangles visibles pour le terrain
|
||||||
|
for (const auto& chunk : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk && chunk->IsVisible())
|
||||||
|
{
|
||||||
|
visibleTriangles += chunk->GetIndexCount() / 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return visibleTriangles;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetCurrentFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetMinFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetMinFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetMaxFps() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetMaxFps();
|
||||||
|
}
|
||||||
|
|
||||||
|
float ApplicationClass::GetFrameTime() const
|
||||||
|
{
|
||||||
|
return m_Fps->GetFrameTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
int ApplicationClass::GetDrawCalls() const
|
||||||
|
{
|
||||||
|
return m_drawcalls;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::ResetFpsStats()
|
||||||
|
{
|
||||||
|
m_Fps->ResetStats();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::IncrementDrawCallCount()
|
||||||
|
{
|
||||||
|
m_drawcalls++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::ResetDrawCallCount()
|
||||||
|
{
|
||||||
|
m_drawcalls = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ApplicationClass::CreateBigCube(int sideCount)
|
||||||
|
{
|
||||||
|
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, sideCount]() {
|
||||||
|
Logger::Get().Log("Thread de g<>n<EFBFBD>ration de terrain d<>marr<72>", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
|
|
||||||
|
// Stockage temporaire pour les nouveaux objets
|
||||||
|
std::vector<Object*> newTerrainChunks;
|
||||||
|
|
||||||
|
// Dimensions du terrain
|
||||||
|
float scaleX = 1.0f;
|
||||||
|
float scaleY = 1.0f;
|
||||||
|
float scaleZ = 1.0f;
|
||||||
|
|
||||||
|
// Pr<50>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 = m_ObjectId;
|
||||||
|
|
||||||
|
// G<>n<EFBFBD>rer les donn<6E>es des cubes
|
||||||
|
for (int i = 0; i < sideCount; i++) {
|
||||||
|
for (int j = 0; j < sideCount; j++) {
|
||||||
|
for (int k = 0; k < sideCount; k++) {
|
||||||
|
// V<>rifier si nous devons arr<72>ter le thread
|
||||||
|
if (m_ShouldQuit) {
|
||||||
|
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++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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(m_TerrainMutex);
|
||||||
|
m_TerrainGenerationData = std::move(cubeData);
|
||||||
|
m_TerrainGenerationReady = true;
|
||||||
|
m_NextTerrainObjectId = objectId;
|
||||||
|
|
||||||
|
Logger::Get().Log("Donn<EFBFBD>es de g<>n<EFBFBD>ration de terrain pr<70>par<61>es (" + std::to_string(m_TerrainGenerationData.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 ApplicationClass::ProcessTerrainGeneration()
|
||||||
|
{
|
||||||
|
// V<>rifier si des donn<6E>es de terrain sont pr<70>tes <20> <20>tre trait<69>es
|
||||||
|
if (!m_TerrainGenerationReady) {
|
||||||
|
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(m_TerrainMutex);
|
||||||
|
cubeData = std::move(m_TerrainGenerationData);
|
||||||
|
m_TerrainGenerationData.clear();
|
||||||
|
m_TerrainGenerationReady = false;
|
||||||
|
m_ObjectId = m_NextTerrainObjectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
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 : m_terrainChunk)
|
||||||
|
{
|
||||||
|
if (chunk) {
|
||||||
|
chunk->Shutdown();
|
||||||
|
delete chunk;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_terrainChunk.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
|
||||||
|
ModelClass* sharedModel = new ModelClass();
|
||||||
|
sharedModel->PreloadTextures(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 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(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 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
|
||||||
|
m_terrainChunk.push_back(terrain);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete sharedModel;
|
||||||
|
|
||||||
|
Logger::Get().Log("G<EFBFBD>n<EFBFBD>ration du terrain termin<69>e avec " + std::to_string(m_terrainChunk.size()) + " cubes", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||||
}
|
}
|
@@ -19,27 +19,63 @@ void FpsClass::Initialize()
|
|||||||
{
|
{
|
||||||
m_fps = 0;
|
m_fps = 0;
|
||||||
m_count = 0;
|
m_count = 0;
|
||||||
|
m_minFps = INT_MAX;
|
||||||
m_startTime = timeGetTime();
|
m_maxFps = 0;
|
||||||
|
m_frameTime = 0.0f;
|
||||||
|
m_previousTime = timeGetTime();
|
||||||
|
m_startTime = m_previousTime;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FpsClass::Frame()
|
void FpsClass::Frame()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
unsigned int currentTime = timeGetTime();
|
||||||
|
|
||||||
|
m_frameTime = (currentTime - m_previousTime) * 0.001f;
|
||||||
|
m_previousTime = currentTime;
|
||||||
|
|
||||||
m_count++;
|
m_count++;
|
||||||
|
|
||||||
if (timeGetTime() >= (m_startTime + 1000))
|
if (timeGetTime() >= (m_startTime + 1000))
|
||||||
{
|
{
|
||||||
m_fps = m_count;
|
m_fps = m_count;
|
||||||
m_count = 0;
|
|
||||||
|
|
||||||
|
if (m_fps < m_minFps)
|
||||||
|
m_minFps = m_fps;
|
||||||
|
|
||||||
|
if (m_fps > m_maxFps)
|
||||||
|
m_maxFps = m_fps;
|
||||||
|
|
||||||
|
m_count = 0;
|
||||||
m_startTime = timeGetTime();
|
m_startTime = timeGetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int FpsClass::GetMinFps() const
|
||||||
|
{
|
||||||
|
return m_minFps;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FpsClass::GetMaxFps() const
|
||||||
|
{
|
||||||
|
return m_maxFps;
|
||||||
|
}
|
||||||
|
|
||||||
|
float FpsClass::GetFrameTime() const
|
||||||
|
{
|
||||||
|
return m_frameTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FpsClass::ResetStats()
|
||||||
|
{
|
||||||
|
m_minFps = INT_MAX;
|
||||||
|
m_maxFps = 0;
|
||||||
|
}
|
||||||
|
|
||||||
int FpsClass::GetFps()
|
int FpsClass::GetFps()
|
||||||
{
|
{
|
||||||
return m_fps;
|
return m_fps;
|
||||||
|
@@ -4,6 +4,13 @@
|
|||||||
imguiManager::imguiManager()
|
imguiManager::imguiManager()
|
||||||
{
|
{
|
||||||
io = nullptr;
|
io = nullptr;
|
||||||
|
m_frameTimeHistoryIndex = 0;
|
||||||
|
|
||||||
|
// Initialiser l'historique des frametimes <20> z<>ro
|
||||||
|
for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
|
||||||
|
{
|
||||||
|
m_frameTimeHistory[i] = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
imguiManager::~imguiManager()
|
imguiManager::~imguiManager()
|
||||||
@@ -12,32 +19,130 @@ imguiManager::~imguiManager()
|
|||||||
|
|
||||||
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
|
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Initializing imgui", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("Initializing imgui", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
m_device = device;
|
m_device = device;
|
||||||
m_deviceContext = deviceContext;
|
m_deviceContext = deviceContext;
|
||||||
|
|
||||||
IMGUI_CHECKVERSION();
|
|
||||||
ImGui::CreateContext();
|
|
||||||
io = &ImGui::GetIO();
|
|
||||||
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
|
||||||
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
|
|
||||||
|
|
||||||
|
IMGUI_CHECKVERSION();
|
||||||
|
ImGui::CreateContext();
|
||||||
|
io = &ImGui::GetIO();
|
||||||
|
io->ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
|
||||||
|
io->ConfigFlags |= ImGuiConfigFlags_DockingEnable;
|
||||||
|
io->FontGlobalScale = 1.0f;
|
||||||
|
|
||||||
ImGui_ImplWin32_Init(hwnd);
|
ImGui_ImplWin32_Init(hwnd);
|
||||||
ImGui_ImplDX11_Init(m_device, m_deviceContext);
|
ImGui_ImplDX11_Init(m_device, m_deviceContext);
|
||||||
|
|
||||||
// Setup style
|
// Appliquer un th<74>me sombre de base
|
||||||
ImGui::StyleColorsDark();
|
ImGui::StyleColorsDark();
|
||||||
// Set the window background color to be a transparent black/gray
|
|
||||||
ImGui::GetStyle().Colors[ImGuiCol_WindowBg] = ImVec4(0, 0, 0, 0.5f);
|
// D<>finir les couleurs pour une interface de type <20>diteur sobre
|
||||||
// Set the menu bar background color to be a transparent black/gray
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
ImGui::GetStyle().Colors[ImGuiCol_MenuBarBg] = ImVec4(0, 0, 0, 0.5f);
|
|
||||||
|
// Palette de couleurs sobres inspir<69>e des <20>diteurs modernes
|
||||||
|
ImVec4 background_dark = ImVec4(0.10f, 0.10f, 0.10f, 1.00f); // Fond fonc<6E>
|
||||||
|
ImVec4 background = ImVec4(0.15f, 0.15f, 0.15f, 1.00f); // Fond principal
|
||||||
|
ImVec4 background_light = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); // Fond clair
|
||||||
|
ImVec4 accent = ImVec4(0.14f, 0.44f, 0.80f, 0.50f); // Accent bleu
|
||||||
|
ImVec4 accent_light = ImVec4(0.14f, 0.44f, 0.80f, 1.00f); // Accent bleu vif
|
||||||
|
ImVec4 text = ImVec4(1.0f, 1.0f, 1.0f, 1.00f); // Texte plus blanc
|
||||||
|
ImVec4 text_dim = ImVec4(0.70f, 0.70f, 0.70f, 1.00f);
|
||||||
|
|
||||||
|
// Ajustements de style g<>n<EFBFBD>raux
|
||||||
|
style.WindowPadding = ImVec2(4.0f, 4.0f); // Moins de padding dans les fen<65>tres
|
||||||
|
style.FramePadding = ImVec2(4.0f, 3.0f); // Moins de padding dans les cadres
|
||||||
|
style.ItemSpacing = ImVec2(4.0f, 3.0f); // Moins d'espace entre les widgets
|
||||||
|
style.ItemInnerSpacing = ImVec2(3.0f, 3.0f); // Moins d'espace interne
|
||||||
|
style.DisplayWindowPadding = ImVec2(0.0f, 0.0f); // Pas de padding pour l'affichage
|
||||||
|
style.DisplaySafeAreaPadding = ImVec2(0.0f, 0.0f);
|
||||||
|
style.TouchExtraPadding = ImVec2(0.0f, 0.0f);
|
||||||
|
style.IndentSpacing = 20.0f;
|
||||||
|
style.ScrollbarSize = 14.0f;
|
||||||
|
style.GrabMinSize = 10.0f;
|
||||||
|
|
||||||
|
// Arrondis
|
||||||
|
style.WindowRounding = 4.0f;
|
||||||
|
style.ChildRounding = 4.0f;
|
||||||
|
style.FrameRounding = 3.0f;
|
||||||
|
style.PopupRounding = 4.0f;
|
||||||
|
style.ScrollbarRounding = 9.0f;
|
||||||
|
style.GrabRounding = 3.0f;
|
||||||
|
style.TabRounding = 4.0f;
|
||||||
|
|
||||||
|
// Couleurs principales
|
||||||
|
style.Colors[ImGuiCol_Text] = text;
|
||||||
|
style.Colors[ImGuiCol_TextDisabled] = text_dim;
|
||||||
|
style.Colors[ImGuiCol_WindowBg] = background;
|
||||||
|
style.Colors[ImGuiCol_ChildBg] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_PopupBg] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_Border] = ImVec4(0.25f, 0.25f, 0.27f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f);
|
||||||
|
|
||||||
|
// Encadrements
|
||||||
|
style.Colors[ImGuiCol_FrameBg] = background_light;
|
||||||
|
style.Colors[ImGuiCol_FrameBgHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_FrameBgActive] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
|
||||||
|
|
||||||
|
// Titres
|
||||||
|
style.Colors[ImGuiCol_TitleBg] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_TitleBgActive] = accent;
|
||||||
|
style.Colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.12f, 0.12f, 0.12f, 0.90f);
|
||||||
|
|
||||||
|
// <20>l<EFBFBD>ments de menu
|
||||||
|
style.Colors[ImGuiCol_MenuBarBg] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_ScrollbarBg] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.40f, 0.40f, 0.40f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.50f, 0.50f, 0.50f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.60f, 0.60f, 0.60f, 1.00f);
|
||||||
|
|
||||||
|
// Boutons et interactions
|
||||||
|
style.Colors[ImGuiCol_CheckMark] = accent_light;
|
||||||
|
style.Colors[ImGuiCol_SliderGrab] = accent;
|
||||||
|
style.Colors[ImGuiCol_SliderGrabActive] = accent_light;
|
||||||
|
style.Colors[ImGuiCol_Button] = background_light;
|
||||||
|
style.Colors[ImGuiCol_ButtonHovered] = ImVec4(0.30f, 0.30f, 0.30f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_ButtonActive] = accent;
|
||||||
|
|
||||||
|
// En-t<>tes et onglets
|
||||||
|
style.Colors[ImGuiCol_Header] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_HeaderHovered] = ImVec4(0.25f, 0.25f, 0.25f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_HeaderActive] = accent;
|
||||||
|
|
||||||
|
style.Colors[ImGuiCol_Separator] = ImVec4(0.28f, 0.28f, 0.28f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_SeparatorHovered] = ImVec4(0.45f, 0.45f, 0.45f, 1.00f);
|
||||||
|
style.Colors[ImGuiCol_SeparatorActive] = accent;
|
||||||
|
|
||||||
|
style.Colors[ImGuiCol_Tab] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_TabHovered] = accent;
|
||||||
|
style.Colors[ImGuiCol_TabActive] = accent;
|
||||||
|
style.Colors[ImGuiCol_TabUnfocused] = background_dark;
|
||||||
|
style.Colors[ImGuiCol_TabUnfocusedActive] = background;
|
||||||
|
|
||||||
|
// Autres <20>l<EFBFBD>ments
|
||||||
|
style.Colors[ImGuiCol_DockingPreview] = accent;
|
||||||
|
style.Colors[ImGuiCol_DockingEmptyBg] = background_light;
|
||||||
|
|
||||||
|
// Charger une police avec une meilleure nettet<65>
|
||||||
|
ImFontConfig fontConfig;
|
||||||
|
fontConfig.OversampleH = 2; // Sur<75>chantillonnage horizontal
|
||||||
|
fontConfig.OversampleV = 2; // Sur<75>chantillonnage vertical
|
||||||
|
fontConfig.PixelSnapH = true; // Alignement sur la grille de pixels
|
||||||
|
fontConfig.RasterizerMultiply = 1.2f; // L<>g<EFBFBD>re augmentation de l'<27>paisseur
|
||||||
|
|
||||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
io->Fonts->AddFontDefault(&fontConfig);
|
||||||
|
|
||||||
return true;
|
// OU charger une police personnalis<69>e (d<>commenter si vous avez la police)
|
||||||
|
// io->Fonts->AddFontFromFileTTF("assets/fonts/roboto.ttf", 16.0f, &fontConfig);
|
||||||
|
|
||||||
|
|
||||||
|
unsigned char* pixels;
|
||||||
|
int width, height;
|
||||||
|
io->Fonts->GetTexDataAsRGBA32(&pixels, &width, &height);
|
||||||
|
|
||||||
|
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::Shutdown()
|
void imguiManager::Shutdown()
|
||||||
@@ -70,53 +175,61 @@ void imguiManager::NewFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::SetupDockspace(ApplicationClass* app) {
|
void imguiManager::SetupDockspace(ApplicationClass* app) {
|
||||||
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
// Configuration du style pour supprimer l'espace autour des fen<65>tres dock<63>es
|
||||||
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
|
||||||
ImGui::SetNextWindowPos(viewport->Pos);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
||||||
ImGui::SetNextWindowSize(viewport->Size);
|
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
||||||
ImGui::SetNextWindowViewport(viewport->ID);
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
|
// Configuration du style pour les n<>uds de dock
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
|
ImGui::PushStyleVar(ImGuiStyleVar_DockingSeparatorSize, 1.0f); // R<>duit l'<27>paisseur des s<>parateurs
|
||||||
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
|
||||||
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
// Configuration de la fen<65>tre principale
|
||||||
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_MenuBar | ImGuiWindowFlags_NoDocking;
|
||||||
|
ImGuiViewport* viewport = ImGui::GetMainViewport();
|
||||||
|
ImGui::SetNextWindowPos(viewport->Pos);
|
||||||
|
ImGui::SetNextWindowSize(viewport->Size);
|
||||||
|
ImGui::SetNextWindowViewport(viewport->ID);
|
||||||
|
window_flags |= ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
||||||
|
window_flags |= ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoNavFocus;
|
||||||
|
|
||||||
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0, 0, 0, 0));
|
||||||
|
|
||||||
|
ImGui::Begin("DockSpace", nullptr, window_flags);
|
||||||
|
|
||||||
|
// Pop des styles apr<70>s avoir cr<63><72> la fen<65>tre principale
|
||||||
|
ImGui::PopStyleVar(4); // 4 car nous avons pouss<73> 4 variables de style
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
|
||||||
ImGui::Begin("DockSpace", nullptr, window_flags);
|
// Configuration du DockSpace
|
||||||
ImGui::PopStyleVar(2);
|
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
|
||||||
ImGui::PopStyleColor();
|
ImGuiDockNodeFlags dockspace_flags = ImGuiDockNodeFlags_PassthruCentralNode;
|
||||||
|
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), dockspace_flags);
|
||||||
|
|
||||||
|
if (ImGui::BeginMenuBar()) {
|
||||||
|
if (ImGui::BeginMenu("Windows")) {
|
||||||
|
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
||||||
|
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
||||||
|
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||||
|
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||||
|
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||||
|
ImGui::MenuItem("Render Stats", NULL, &showStatsWindow);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
|
||||||
if (ImGui::BeginMenuBar()) {
|
if (ImGui::BeginMenu("Scene")) {
|
||||||
if (ImGui::BeginMenu("Windows")) {
|
if (ImGui::MenuItem("Save Scene")) {
|
||||||
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
app->SaveScene();
|
||||||
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
}
|
||||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
if (ImGui::MenuItem("Load Scene")) {
|
||||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
app->LoadScene();
|
||||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
}
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scene file menu
|
ImGui::EndMenuBar();
|
||||||
if (ImGui::BeginMenu("Scene")) {
|
}
|
||||||
if (ImGui::MenuItem("Save Scene")) {
|
|
||||||
// Save the scene
|
|
||||||
app->SaveScene();
|
|
||||||
}
|
|
||||||
if (ImGui::MenuItem("Load Scene")) {
|
|
||||||
// Load the scene
|
|
||||||
app->LoadScene();
|
|
||||||
}
|
|
||||||
ImGui::EndMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGui::EndMenuBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
ImGuiID dockspace_id = ImGui::GetID("MainDockSpace");
|
ImGui::End();
|
||||||
ImGui::DockSpace(dockspace_id, ImVec2(0.0f, 0.0f), ImGuiDockNodeFlags_PassthruCentralNode);
|
|
||||||
|
|
||||||
ImGui::End();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::WidgetSpeedSlider(float* speed)
|
void imguiManager::WidgetSpeedSlider(float* speed)
|
||||||
@@ -134,11 +247,6 @@ void imguiManager::WidgetButton()
|
|||||||
ImGui::Text("counter = %d", counter);
|
ImGui::Text("counter = %d", counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void imguiManager::WidgetFPS()
|
|
||||||
{
|
|
||||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io->Framerate, io->Framerate);
|
|
||||||
}
|
|
||||||
|
|
||||||
void imguiManager::WidgetAddObject(ApplicationClass* app)
|
void imguiManager::WidgetAddObject(ApplicationClass* app)
|
||||||
{
|
{
|
||||||
if (ImGui::CollapsingHeader("Objects"))
|
if (ImGui::CollapsingHeader("Objects"))
|
||||||
@@ -529,18 +637,37 @@ void imguiManager::WidgetTerrainWindow(ApplicationClass* app)
|
|||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Generate Terrain"))
|
if (ImGui::Button("Generate Flat Terrain"))
|
||||||
{
|
{
|
||||||
app->GenerateTerrain();
|
app->GenerateTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Input for the number of cubes on each side
|
||||||
|
ImGui::Text("Number of cubes on each side: ");
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
ImGui::InputInt("##SideCount", &m_SideCount);
|
||||||
|
if (m_SideCount < 1)
|
||||||
|
{
|
||||||
|
m_SideCount = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::Button("Generate BigCube Terrain"))
|
||||||
|
{
|
||||||
|
app->CreateBigCube(m_SideCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Delete All Terrain Cubes"))
|
if (ImGui::Button("Delete All Terrain Cubes"))
|
||||||
{
|
{
|
||||||
app->DeleteTerrain();
|
app->DeleteTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@@ -560,7 +687,7 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
WidgetSpeedSlider(&speed);
|
WidgetSpeedSlider(&speed);
|
||||||
app->SetSpeed(speed);
|
app->SetSpeed(speed);
|
||||||
WidgetButton();
|
WidgetButton();
|
||||||
WidgetFPS();
|
// WidgetFPS();
|
||||||
WidgetAddObject(app);
|
WidgetAddObject(app);
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
@@ -595,6 +722,11 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
{
|
{
|
||||||
WidgetRenderWindow(app, ImVec2(800, 600));
|
WidgetRenderWindow(app, ImVec2(800, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showStatsWindow)
|
||||||
|
{
|
||||||
|
WidgetRenderStats(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//render imgui
|
//render imgui
|
||||||
@@ -843,4 +975,64 @@ void imguiManager::WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSiz
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
void imguiManager::WidgetRenderStats(ApplicationClass* app)
|
||||||
|
{
|
||||||
|
ImGui::Begin("Render Stats");
|
||||||
|
|
||||||
|
// R<>cup<75>rer le frametime actuel et le mettre dans l'historique
|
||||||
|
float currentFrameTime = app->GetFrameTime();
|
||||||
|
m_frameTimeHistory[m_frameTimeHistoryIndex] = currentFrameTime;
|
||||||
|
m_frameTimeHistoryIndex = (m_frameTimeHistoryIndex + 1) % FRAME_HISTORY_COUNT;
|
||||||
|
|
||||||
|
ImGui::Text("FPS: %d", app->GetCurrentFps());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Min Fps: %d", app->GetMinFps());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Max Fps: %d", app->GetMaxFps());
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// Trouver les valeurs min/max pour l'<27>chelle du graphique
|
||||||
|
float frameTimeMin = FLT_MAX;
|
||||||
|
float frameTimeMax = 0.0f;
|
||||||
|
for (int i = 0; i < FRAME_HISTORY_COUNT; i++) {
|
||||||
|
if (m_frameTimeHistory[i] > 0.0f) {
|
||||||
|
frameTimeMin = min(frameTimeMin, m_frameTimeHistory[i]);
|
||||||
|
frameTimeMax = max(frameTimeMax, m_frameTimeHistory[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// S'assurer d'avoir au moins une petite plage
|
||||||
|
if (frameTimeMax == 0.0f) frameTimeMax = 0.033f; // ~30 FPS
|
||||||
|
if (frameTimeMin == FLT_MAX) frameTimeMin = 0.0f;
|
||||||
|
|
||||||
|
// Ajouter 10% de marge pour la lisibilit<69>
|
||||||
|
float margin = (frameTimeMax - frameTimeMin) * 0.1f;
|
||||||
|
frameTimeMin = max(0.0f, frameTimeMin - margin);
|
||||||
|
frameTimeMax += margin;
|
||||||
|
|
||||||
|
// Afficher le graphique
|
||||||
|
ImGui::Text("Frame Time: %.3f ms", currentFrameTime * 1000.0f);
|
||||||
|
ImGui::PlotLines("FrameTimeGraph", // Au lieu de cha<68>ne vide ""
|
||||||
|
m_frameTimeHistory,
|
||||||
|
FRAME_HISTORY_COUNT,
|
||||||
|
m_frameTimeHistoryIndex,
|
||||||
|
"",
|
||||||
|
frameTimeMin,
|
||||||
|
frameTimeMax,
|
||||||
|
ImVec2(0, 80));
|
||||||
|
|
||||||
|
ImGui::Text("Draw Calls: %d", app->GetDrawCalls());
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
ImGui::Text("Statistiques de rendu:");
|
||||||
|
ImGui::Text("Vertices total: %d", app->GetTotalVertexCount());
|
||||||
|
|
||||||
|
ImGui::Text("Triangles total: %d", app->GetTotalTriangleCount());
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::Text("Triangles visibles: %d", app->GetVisibleTriangleCount());
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
}
|
}
|
@@ -6,36 +6,26 @@ ModelClass::ModelClass()
|
|||||||
m_vertexBuffer = 0;
|
m_vertexBuffer = 0;
|
||||||
m_indexBuffer = 0;
|
m_indexBuffer = 0;
|
||||||
m_model = 0;
|
m_model = 0;
|
||||||
|
m_vertexCount = 0;
|
||||||
|
m_indexCount = 0;
|
||||||
|
m_Textures.diffuse.clear();
|
||||||
|
m_Textures.normal.clear();
|
||||||
|
m_Textures.specular.clear();
|
||||||
|
m_Textures.alpha.clear();
|
||||||
|
m_Textures.diffusePaths.clear();
|
||||||
|
m_Textures.normalPaths.clear();
|
||||||
|
m_Textures.specularPaths.clear();
|
||||||
|
m_Textures.alphaPaths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModelClass::ModelClass(const ModelClass& other)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ModelClass::~ModelClass()
|
ModelClass::~ModelClass()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, std::vector<ID3D11ShaderResourceView*> textures) {
|
|
||||||
// Logger::Get().Log("Initializing model class with preloaded textures (vector)", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
//
|
|
||||||
// bool result = Initialize(device, deviceContext, modelFilename);
|
|
||||||
// if (!result) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Ajouter toutes les textures au container comme textures diffuses
|
|
||||||
// for (auto& tex : textures) {
|
|
||||||
// m_Textures.diffuse.push_back(tex);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
|
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
|
||||||
Logger::Get().Log("Initializing model class with preloaded texture container", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
bool result = Initialize(device, deviceContext, modelFilename);
|
bool result = Initialize(device, deviceContext, modelFilename);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -48,7 +38,6 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
|
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
|
||||||
Logger::Get().Log("Initializing model class without textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
@@ -68,9 +57,7 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
|||||||
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Model class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,18 +90,12 @@ int ModelClass::GetIndexCount()
|
|||||||
return m_indexCount;
|
return m_indexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ID3D11ShaderResourceView* ModelClass::GetTexture(int index) const {
|
|
||||||
// // Pour compatibilit<69>, utilise la texture diffuse par d<>faut
|
|
||||||
// return m_Textures.GetTexture(TextureType::Diffuse, index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
ID3D11ShaderResourceView* ModelClass::GetTexture(TextureType type, int index) const {
|
ID3D11ShaderResourceView* ModelClass::GetTexture(TextureType type, int index) const {
|
||||||
return m_Textures.GetTexture(type, index);
|
return m_Textures.GetTexture(type, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Initializing buffers", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
VertexType* vertices;
|
VertexType* vertices;
|
||||||
unsigned long* indices;
|
unsigned long* indices;
|
||||||
@@ -189,36 +170,16 @@ bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
|||||||
|
|
||||||
delete[] indices;
|
delete[] indices;
|
||||||
indices = 0;
|
indices = 0;
|
||||||
|
|
||||||
Logger::Get().Log("Buffers initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelClass::ShutdownBuffers()
|
void ModelClass::ShutdownBuffers()
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Shutting down buffers", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
if (m_indexBuffer) { m_indexBuffer->Release(); m_indexBuffer = nullptr; }
|
||||||
// Release the index buffer.
|
if (m_vertexBuffer) { m_vertexBuffer->Release(); m_vertexBuffer = nullptr; }
|
||||||
if (m_indexBuffer)
|
|
||||||
{
|
|
||||||
m_indexBuffer->Release();
|
|
||||||
m_indexBuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release the vertex buffer.
|
|
||||||
if (m_vertexBuffer)
|
|
||||||
{
|
|
||||||
m_vertexBuffer->Release();
|
|
||||||
m_vertexBuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger::Get().Log("Buffers shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
|
void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
|
||||||
{
|
{
|
||||||
unsigned int stride;
|
unsigned int stride;
|
||||||
@@ -243,17 +204,13 @@ void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
|
|||||||
|
|
||||||
void ModelClass::ReleaseTextures()
|
void ModelClass::ReleaseTextures()
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Releasing textures", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
// Utilise la m<>thode ReleaseAll de TextureContainer
|
// Utilise la m<>thode ReleaseAll de TextureContainer
|
||||||
m_Textures.ReleaseAll();
|
m_Textures.ReleaseAll();
|
||||||
|
|
||||||
Logger::Get().Log("Textures released", __FILE__, __LINE__);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelClass::LoadModel(char* filename)
|
bool ModelClass::LoadModel(char* filename)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Loading model: " + std::string(filename), __FILE__, __LINE__);
|
|
||||||
|
|
||||||
std::string fileStr(filename);
|
std::string fileStr(filename);
|
||||||
std::string extension = fileStr.substr(fileStr.find_last_of(".") + 1);
|
std::string extension = fileStr.substr(fileStr.find_last_of(".") + 1);
|
||||||
@@ -277,101 +234,112 @@ bool ModelClass::LoadModel(char* filename)
|
|||||||
|
|
||||||
bool ModelClass::LoadObjModel(char* filename)
|
bool ModelClass::LoadObjModel(char* filename)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Loading model", __FILE__, __LINE__);
|
// Lecture optimis<69>e du fichier en mode binaire
|
||||||
|
std::ifstream fin(filename, std::ios::in | std::ios::binary);
|
||||||
|
if (!fin)
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec d'ouverture du fichier mod<6F>le", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
std::string line;
|
// Lecture du fichier entier d'un coup (<28>vite la lecture ligne par ligne)
|
||||||
std::ifstream fin(filename);
|
fin.seekg(0, std::ios::end);
|
||||||
|
const size_t fileSize = fin.tellg();
|
||||||
|
fin.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
|
std::string fileContent;
|
||||||
|
fileContent.resize(fileSize);
|
||||||
|
fin.read(&fileContent[0], fileSize);
|
||||||
|
fin.close();
|
||||||
|
|
||||||
// If it could not open the file then exit.
|
// Pr<50>-allocation des vecteurs (<28>vite les r<>allocations)
|
||||||
if (!fin)
|
const size_t estimatedVertices = fileSize / 150;
|
||||||
{
|
std::vector<XMFLOAT3> temp_positions;
|
||||||
Logger::Get().Log("Failed to open model file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
std::vector<XMFLOAT2> temp_texcoords;
|
||||||
return false;
|
std::vector<XMFLOAT3> temp_normals;
|
||||||
}
|
std::vector<ModelType> temp_model;
|
||||||
|
|
||||||
std::vector<XMFLOAT3> temp_positions;
|
temp_positions.reserve(estimatedVertices);
|
||||||
std::vector<XMFLOAT2> temp_texcoords;
|
temp_texcoords.reserve(estimatedVertices);
|
||||||
std::vector<XMFLOAT3> temp_normals;
|
temp_normals.reserve(estimatedVertices);
|
||||||
std::vector<ModelType> temp_model;
|
temp_model.reserve(estimatedVertices * 3);
|
||||||
|
|
||||||
// Read the file line by line.
|
// Analyse du contenu
|
||||||
while (std::getline(fin, line))
|
std::istringstream iss(fileContent);
|
||||||
{
|
std::string line;
|
||||||
std::istringstream iss(line);
|
|
||||||
std::string type;
|
|
||||||
iss >> type;
|
|
||||||
|
|
||||||
if (type == "v") // Vertex position
|
while (std::getline(iss, line))
|
||||||
{
|
{
|
||||||
XMFLOAT3 pos;
|
if (line.empty() || line[0] == '#') continue;
|
||||||
iss >> pos.x >> pos.y >> pos.z;
|
|
||||||
temp_positions.push_back(pos);
|
|
||||||
}
|
|
||||||
else if (type == "vt") // Texture coordinate
|
|
||||||
{
|
|
||||||
XMFLOAT2 tex;
|
|
||||||
iss >> tex.x >> tex.y;
|
|
||||||
temp_texcoords.push_back(tex);
|
|
||||||
}
|
|
||||||
else if (type == "vn") // Vertex normal
|
|
||||||
{
|
|
||||||
XMFLOAT3 norm;
|
|
||||||
iss >> norm.x >> norm.y >> norm.z;
|
|
||||||
temp_normals.push_back(norm);
|
|
||||||
}
|
|
||||||
else if (type == "f") // Face
|
|
||||||
{
|
|
||||||
int posIndex[3], texIndex[3], normIndex[3];
|
|
||||||
char slash; // To skip the slashes '/' in the .obj file format
|
|
||||||
for (int i = 0; i < 3; i++) // Each face in .obj format has 3 vertices
|
|
||||||
{
|
|
||||||
iss >> posIndex[i] >> slash >> texIndex[i] >> slash >> normIndex[i];
|
|
||||||
|
|
||||||
// Handle negative indices
|
// Analyse plus rapide bas<61>e sur le premier caract<63>re
|
||||||
if (posIndex[i] < 0) posIndex[i] += temp_positions.size() + 1;
|
if (line[0] == 'v')
|
||||||
if (texIndex[i] < 0) texIndex[i] += temp_texcoords.size() + 1;
|
{
|
||||||
if (normIndex[i] < 0) normIndex[i] += temp_normals.size() + 1;
|
if (line[1] == ' ') // Position de sommet
|
||||||
}
|
{
|
||||||
|
XMFLOAT3 pos;
|
||||||
|
sscanf_s(line.c_str() + 2, "%f %f %f", &pos.x, &pos.y, &pos.z);
|
||||||
|
temp_positions.push_back(pos);
|
||||||
|
}
|
||||||
|
else if (line[1] == 't') // Coordonn<6E>es de texture
|
||||||
|
{
|
||||||
|
XMFLOAT2 tex;
|
||||||
|
sscanf_s(line.c_str() + 3, "%f %f", &tex.x, &tex.y);
|
||||||
|
temp_texcoords.push_back(tex);
|
||||||
|
}
|
||||||
|
else if (line[1] == 'n') // Normales
|
||||||
|
{
|
||||||
|
XMFLOAT3 norm;
|
||||||
|
sscanf_s(line.c_str() + 3, "%f %f %f", &norm.x, &norm.y, &norm.z);
|
||||||
|
temp_normals.push_back(norm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (line[0] == 'f')
|
||||||
|
{
|
||||||
|
int posIndex[3], texIndex[3], normIndex[3];
|
||||||
|
const char* linePtr = line.c_str() + 2; // Sauter "f "
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
// Analyse rapide du format v/vt/vn
|
||||||
|
sscanf_s(linePtr, "%d/%d/%d", &posIndex[i], &texIndex[i], &normIndex[i]);
|
||||||
|
|
||||||
|
// Avancer au prochain ensemble d'indices
|
||||||
|
while (*linePtr && *linePtr != ' ') linePtr++;
|
||||||
|
while (*linePtr == ' ') linePtr++;
|
||||||
|
|
||||||
// .obj indices start from 1, not 0
|
if (posIndex[i] < 0) posIndex[i] += temp_positions.size() + 1;
|
||||||
for (int i = 0; i < 3; i++)
|
if (texIndex[i] < 0) texIndex[i] += temp_texcoords.size() + 1;
|
||||||
{
|
if (normIndex[i] < 0) normIndex[i] += temp_normals.size() + 1;
|
||||||
ModelType vertex;
|
}
|
||||||
vertex.x = temp_positions[posIndex[i] - 1].x;
|
|
||||||
vertex.y = temp_positions[posIndex[i] - 1].y;
|
|
||||||
vertex.z = temp_positions[posIndex[i] - 1].z;
|
|
||||||
vertex.tu = temp_texcoords[texIndex[i] - 1].x;
|
|
||||||
vertex.tv = temp_texcoords[texIndex[i] - 1].y;
|
|
||||||
vertex.nx = temp_normals[normIndex[i] - 1].x;
|
|
||||||
vertex.ny = temp_normals[normIndex[i] - 1].y;
|
|
||||||
vertex.nz = temp_normals[normIndex[i] - 1].z;
|
|
||||||
temp_model.push_back(vertex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_vertexCount = temp_model.size();
|
for (int i = 0; i < 3; i++)
|
||||||
m_indexCount = temp_model.size();
|
{
|
||||||
|
ModelType vertex{};
|
||||||
|
vertex.x = temp_positions[posIndex[i] - 1].x;
|
||||||
|
vertex.y = temp_positions[posIndex[i] - 1].y;
|
||||||
|
vertex.z = temp_positions[posIndex[i] - 1].z;
|
||||||
|
vertex.tu = temp_texcoords[texIndex[i] - 1].x;
|
||||||
|
vertex.tv = temp_texcoords[texIndex[i] - 1].y;
|
||||||
|
vertex.nx = temp_normals[normIndex[i] - 1].x;
|
||||||
|
vertex.ny = temp_normals[normIndex[i] - 1].y;
|
||||||
|
vertex.nz = temp_normals[normIndex[i] - 1].z;
|
||||||
|
temp_model.push_back(vertex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Create the model using the vertex count that was read in.
|
// Allocation et copie efficace du mod<6F>le final
|
||||||
m_model = new ModelType[m_vertexCount];
|
m_vertexCount = temp_model.size();
|
||||||
for (int i = 0; i < m_vertexCount; i++)
|
m_indexCount = temp_model.size();
|
||||||
{
|
m_model = new ModelType[m_vertexCount];
|
||||||
m_model[i] = temp_model[i];
|
std::memcpy(m_model, temp_model.data(), m_vertexCount * sizeof(ModelType));
|
||||||
}
|
|
||||||
|
|
||||||
fin.close();
|
return true;
|
||||||
|
|
||||||
Logger::Get().Log("Model loaded", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ModelClass::LoadTxtModel(char* filename)
|
bool ModelClass::LoadTxtModel(char* filename)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Loading model", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
ifstream fin;
|
ifstream fin;
|
||||||
char input;
|
char input;
|
||||||
int i;
|
int i;
|
||||||
@@ -422,16 +390,12 @@ bool ModelClass::LoadTxtModel(char* filename)
|
|||||||
|
|
||||||
// Close the model file.
|
// Close the model file.
|
||||||
fin.close();
|
fin.close();
|
||||||
|
|
||||||
Logger::Get().Log("Model loaded "+ std::string(filename), __FILE__, __LINE__);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelClass::CalculateModelVectors()
|
void ModelClass::CalculateModelVectors()
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Calculating model vectors", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
int faceCount, i, index;
|
int faceCount, i, index;
|
||||||
TempVertexType vertex1, vertex2, vertex3;
|
TempVertexType vertex1, vertex2, vertex3;
|
||||||
VectorType tangent, binormal;
|
VectorType tangent, binormal;
|
||||||
@@ -493,10 +457,6 @@ void ModelClass::CalculateModelVectors()
|
|||||||
m_model[index - 3].by = binormal.y;
|
m_model[index - 3].by = binormal.y;
|
||||||
m_model[index - 3].bz = binormal.z;
|
m_model[index - 3].bz = binormal.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Model vectors calculated", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& tangent, VectorType& binormal)
|
void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType vertex2, TempVertexType vertex3, VectorType& tangent, VectorType& binormal)
|
||||||
@@ -551,30 +511,18 @@ void ModelClass::CalculateTangentBinormal(TempVertexType vertex1, TempVertexType
|
|||||||
binormal.x = binormal.x / length;
|
binormal.x = binormal.x / length;
|
||||||
binormal.y = binormal.y / length;
|
binormal.y = binormal.y / length;
|
||||||
binormal.z = binormal.z / length;
|
binormal.z = binormal.z / length;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelClass::ReleaseModel()
|
void ModelClass::ReleaseModel()
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Releasing model", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
if (m_model)
|
if (m_model)
|
||||||
{
|
{
|
||||||
delete[] m_model;
|
delete[] m_model;
|
||||||
m_model = 0;
|
m_model = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Model released", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index) {
|
|
||||||
// // Pour compatibilit<69>, utilise la texture diffuse par d<>faut
|
|
||||||
// return ChangeTexture(device, deviceContext, filename, TextureType::Diffuse, index);
|
|
||||||
// }
|
|
||||||
|
|
||||||
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
||||||
{
|
{
|
||||||
HRESULT hResult;
|
HRESULT hResult;
|
||||||
|
@@ -22,7 +22,6 @@ Object::Object()// Initialize the reference here
|
|||||||
|
|
||||||
Object::~Object()
|
Object::~Object()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||||
@@ -92,7 +91,6 @@ XMVECTOR Object::GetRotation()
|
|||||||
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
XMVECTOR Object::GetScale()
|
XMVECTOR Object::GetScale()
|
||||||
{
|
{
|
||||||
XMFLOAT4X4 matrix;
|
XMFLOAT4X4 matrix;
|
||||||
@@ -354,7 +352,8 @@ void Object::LaunchObject()
|
|||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer, D3DClass* m_Direct3D)
|
bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
||||||
|
D3DClass* m_Direct3D)
|
||||||
{
|
{
|
||||||
|
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
@@ -380,10 +379,12 @@ void Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
|||||||
"\nError: " + std::to_string(result) +
|
"\nError: " + std::to_string(result) +
|
||||||
"\nDescription: " + str,
|
"\nDescription: " + str,
|
||||||
__FILE__, __LINE__, Logger::LogLevel::Error);
|
__FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return ; // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
|
return false; // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
|
||||||
}
|
}
|
||||||
texturesContainer.AssignTexture(texturesContainer, texture,texturePath , i);
|
texturesContainer.AssignTexture(texturesContainer, texture,texturePath , i);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
Reference in New Issue
Block a user