Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
f8bfb62e98 | |||
94fd900ce8 | |||
2744c809d3 | |||
b80f66fec3 | |||
8bcd3eed48 | |||
2b1e64ffbd | |||
96aa41f649 | |||
00e6749d01 | |||
5a3a4f73a8 | |||
c442a87883 | |||
e681943aa8 | |||
e68f1d5dd0 | |||
8e6b7409d9 | |||
7dbd735416 |
6
.idea/.idea.KhaoticEngineReborn/.idea/AndroidProjectSystem.xml
generated
Normal file
6
.idea/.idea.KhaoticEngineReborn/.idea/AndroidProjectSystem.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="RiderAndroidProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@@ -2,6 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RiderProjectSettingsUpdater">
|
<component name="RiderProjectSettingsUpdater">
|
||||||
<option name="singleClickDiffPreview" value="1" />
|
<option name="singleClickDiffPreview" value="1" />
|
||||||
|
<option name="unhandledExceptionsIgnoreList" value="1" />
|
||||||
<option name="vcsConfiguration" value="3" />
|
<option name="vcsConfiguration" value="3" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
75
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
75
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@@ -6,7 +6,10 @@
|
|||||||
<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$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Model/OBJ/skysphere.obj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Model/OBJ/skysphere.obj" 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/applicationclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/applicationclass.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
||||||
</list>
|
</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" />
|
||||||
@@ -20,6 +23,13 @@
|
|||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
|
<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://4" root0="FORCE_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" />
|
||||||
@@ -36,25 +46,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">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"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": "dotTrace Profiler",
|
||||||
"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.pluginManager",
|
"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">
|
||||||
@@ -165,6 +175,17 @@
|
|||||||
<workItem from="1746113092234" duration="1477000" />
|
<workItem from="1746113092234" duration="1477000" />
|
||||||
<workItem from="1746117455914" duration="5976000" />
|
<workItem from="1746117455914" duration="5976000" />
|
||||||
<workItem from="1746126812110" duration="180000" />
|
<workItem from="1746126812110" duration="180000" />
|
||||||
|
<workItem from="1746188920194" duration="1870000" />
|
||||||
|
<workItem from="1746274246641" duration="89000" />
|
||||||
|
<workItem from="1746274352144" duration="8039000" />
|
||||||
|
<workItem from="1746444660572" duration="7742000" />
|
||||||
|
<workItem from="1746456965664" duration="13000" />
|
||||||
|
<workItem from="1746469494034" duration="799000" />
|
||||||
|
<workItem from="1746526901276" duration="2023000" />
|
||||||
|
<workItem from="1746536290167" duration="1908000" />
|
||||||
|
<workItem from="1746538260893" duration="5781000" />
|
||||||
|
<workItem from="1746546014271" duration="1814000" />
|
||||||
|
<workItem from="1746619988287" duration="12282000" />
|
||||||
</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" />
|
||||||
@@ -208,6 +229,22 @@
|
|||||||
<option name="LAST_COMMIT_MESSAGE" value="Patch update - add menu button" />
|
<option name="LAST_COMMIT_MESSAGE" value="Patch update - add menu button" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<component name="XDebuggerManager">
|
||||||
|
<breakpoint-manager>
|
||||||
|
<breakpoints>
|
||||||
|
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||||
|
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
|
||||||
|
<option name="timeStamp" value="1" />
|
||||||
|
</breakpoint>
|
||||||
|
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||||
|
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
|
||||||
|
<option name="timeStamp" value="2" />
|
||||||
|
</breakpoint>
|
||||||
|
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||||
|
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
|
||||||
|
<option name="timeStamp" value="3" />
|
||||||
|
</breakpoint>
|
||||||
|
</breakpoints>
|
||||||
|
</breakpoint-manager>
|
||||||
<watches-manager>
|
<watches-manager>
|
||||||
<configuration name="CppProject">
|
<configuration name="CppProject">
|
||||||
<watch expression="((class ModelClass &) (*(*(*this).m_Application).m_object[0]))" />
|
<watch expression="((class ModelClass &) (*(*(*this).m_Application).m_object[0]))" />
|
||||||
|
12
README.md
12
README.md
@@ -36,13 +36,20 @@ This **DirectX11** based engine uses **ImGui** with an abstraction layer to enab
|
|||||||
**SHADER** :
|
**SHADER** :
|
||||||
|
|
||||||
+ Sunlight shader
|
+ Sunlight shader
|
||||||
+ Cel Shading (Work In Progress)
|
+ Cel Shading
|
||||||
|
+ Skysphere
|
||||||
|
|
||||||
**Interface Graphique** :
|
**Interface Graphique** :
|
||||||
|
|
||||||
+ Console link to the Logger object
|
+ Console link to the Logger object
|
||||||
+ Shader Manager
|
+ Shader Manager
|
||||||
+ Engine Settings
|
+ Engine Settings
|
||||||
|
+ Sunlight Settings
|
||||||
|
|
||||||
|
**Save And Load of a Scene** :
|
||||||
|
|
||||||
|
+ Save All Custom object
|
||||||
|
+ Save All Custom Texture for Custom Object
|
||||||
|
|
||||||
**Texture File** :
|
**Texture File** :
|
||||||
|
|
||||||
@@ -53,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 :
|
||||||
|
|
||||||
|
0
enginecustom/DemoScene_V10.1.2.ker
Normal file
0
enginecustom/DemoScene_V10.1.2.ker
Normal file
@@ -1,49 +1,89 @@
|
|||||||
[Window][DockSpace]
|
|
||||||
Pos=0,0
|
|
||||||
Size=2048,1129
|
|
||||||
Collapsed=0
|
|
||||||
|
|
||||||
[Window][Debug##Default]
|
[Window][Debug##Default]
|
||||||
Pos=60,60
|
Pos=60,60
|
||||||
Size=400,400
|
Size=400,400
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1687,27
|
Pos=1697,27
|
||||||
Size=353,1094
|
Size=343,1094
|
||||||
Collapsed=0
|
|
||||||
DockId=0x00000002,0
|
|
||||||
|
|
||||||
[Window][Objects]
|
|
||||||
Pos=8,27
|
|
||||||
Size=345,896
|
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,0
|
DockId=0x00000005,0
|
||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Objects]
|
||||||
Pos=1687,27
|
Pos=8,27
|
||||||
Size=353,1094
|
Size=289,547
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000002,1
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=8,576
|
||||||
Size=345,896
|
Size=289,545
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000005,1
|
DockId=0x00000008,0
|
||||||
|
|
||||||
[Window][Light]
|
[Window][Light]
|
||||||
Pos=8,925
|
Pos=8,27
|
||||||
Size=345,196
|
Size=290,866
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000B,1
|
||||||
|
|
||||||
|
[Window][Shader Manager]
|
||||||
|
Pos=8,27
|
||||||
|
Size=330,487
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000001,2
|
||||||
|
|
||||||
|
[Window][Engine Settings]
|
||||||
|
Pos=8,27
|
||||||
|
Size=289,547
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000007,1
|
||||||
|
|
||||||
|
[Window][DockSpace Demo]
|
||||||
|
Size=1584,861
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Render Window]
|
||||||
|
Pos=8,27
|
||||||
|
Size=1559,974
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x00000007,0
|
||||||
|
|
||||||
|
[Window][DockSpace]
|
||||||
|
Pos=0,0
|
||||||
|
Size=2048,1129
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Add Object]
|
||||||
|
Pos=1188,0
|
||||||
|
Size=396,430
|
||||||
|
Collapsed=0
|
||||||
|
|
||||||
|
[Window][Log]
|
||||||
|
Pos=8,518
|
||||||
|
Size=1568,335
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000C,0
|
||||||
|
|
||||||
|
[Window][Log Window]
|
||||||
|
Pos=8,37
|
||||||
|
Size=16,19
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
[Docking][Data]
|
[Docking][Data]
|
||||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=X
|
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||||
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=345,826 Split=Y Selected=0x393905AB
|
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=345,896 Selected=0x393905AB
|
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=345,196 Selected=0x321620B2
|
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=Y
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1221,826 Split=X
|
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
||||||
DockNode ID=0x00000001 Parent=0x00000004 SizeRef=866,826 CentralNode=1
|
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x00000002 Parent=0x00000004 SizeRef=353,826 Selected=0x9F035453
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x0B098C4B
|
||||||
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
|
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
||||||
|
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
||||||
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 CentralNode=1
|
||||||
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
|
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
||||||
|
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
||||||
|
|
||||||
|
@@ -1 +1 @@
|
|||||||
0 86 111.063 12.7056 0 0 -0 0 1 1 1 Content/Assets/Kobject/86.obj CEL_SHADING 1 Cube 1 1
|
1 isosphere 0 10 0 0 -0 0 1 1 1 F:\Github_Repo\khaotic-engine-Reborn\x64\Debug\Content/Assets/Kobject/isosphere.obj SUNLIGHT 1 Unknown 1 0 2 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\stone01.png F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\dirt01.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\alpha01.png
|
||||||
|
@@ -310,6 +310,22 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<CopyFileToFolders Include="font01.tga" />
|
<CopyFileToFolders Include="font01.tga" />
|
||||||
|
<CopyFileToFolders Include="assets\Texture\Bricks2K.png">
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Texture\BricksGLOSS2K.png">
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Texture\BricksNRM2K.png">
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Skybox\skybox.png">
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox</DestinationFolders>
|
||||||
|
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Skybox</DestinationFolders>
|
||||||
|
</CopyFileToFolders>
|
||||||
<Image Include="KhaoticIcon.ico" />
|
<Image Include="KhaoticIcon.ico" />
|
||||||
<CopyFileToFolders Include="sprite01.tga" />
|
<CopyFileToFolders Include="sprite01.tga" />
|
||||||
<CopyFileToFolders Include="sprite02.tga" />
|
<CopyFileToFolders Include="sprite02.tga" />
|
||||||
|
@@ -480,5 +480,17 @@
|
|||||||
<CopyFileToFolders Include="assets\Model\OBJ\skysphere.obj">
|
<CopyFileToFolders Include="assets\Model\OBJ\skysphere.obj">
|
||||||
<Filter>Assets\Model\OBJ</Filter>
|
<Filter>Assets\Model\OBJ</Filter>
|
||||||
</CopyFileToFolders>
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Texture\BricksNRM2K.png">
|
||||||
|
<Filter>Texture</Filter>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Texture\BricksGLOSS2K.png">
|
||||||
|
<Filter>Texture</Filter>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Texture\Bricks2K.png">
|
||||||
|
<Filter>Texture</Filter>
|
||||||
|
</CopyFileToFolders>
|
||||||
|
<CopyFileToFolders Include="assets\Skybox\skybox.png">
|
||||||
|
<Filter>Assets\Skybox</Filter>
|
||||||
|
</CopyFileToFolders>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@@ -5,27 +5,27 @@ Collapsed=0
|
|||||||
|
|
||||||
[Window][Khaotic Engine]
|
[Window][Khaotic Engine]
|
||||||
Pos=1233,27
|
Pos=1233,27
|
||||||
Size=343,826
|
Size=343,599
|
||||||
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
|
Collapsed=0
|
||||||
DockId=0x00000009,1
|
DockId=0x00000007,0
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=250,974
|
Size=281,599
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000007,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,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,627
|
Pos=8,37
|
||||||
Size=1568,226
|
Size=16,19
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000006,0
|
DockId=0x00000006,0
|
||||||
|
|
||||||
|
[Window][Render Stats]
|
||||||
|
Pos=8,628
|
||||||
|
Size=1568,225
|
||||||
|
Collapsed=0
|
||||||
|
DockId=0x0000000E,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=1568,826 Split=Y
|
||||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
DockNode ID=0x0000000A Parent=0xCCBD8CF7 SizeRef=1568,599 Split=Y
|
||||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Selected=0x031DC75C
|
DockNode ID=0x00000004 Parent=0x0000000A SizeRef=1568,598 Split=X
|
||||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=281,974 Split=Y Selected=0x031DC75C
|
||||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,547 Selected=0x031DC75C
|
||||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=X
|
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,545 Selected=0x393905AB
|
||||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
|
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1285,974 Split=X
|
||||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
|
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=940,826 Split=Y
|
||||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 CentralNode=1
|
||||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
||||||
|
DockNode ID=0x00000006 Parent=0x0000000A SizeRef=1568,226 Selected=0xAB74BEE9
|
||||||
|
DockNode ID=0x0000000E Parent=0xCCBD8CF7 SizeRef=1568,225 Selected=0xD99DEA49
|
||||||
|
|
||||||
|
@@ -46,19 +46,6 @@ public:
|
|||||||
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
bool RenderCelShadingShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||||
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
bool RenderSunlightShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||||
bool RenderSkyboxShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
bool RenderSkyboxShader(ID3D11DeviceContext*, int, XMMATRIX, XMMATRIX, XMMATRIX, ID3D11ShaderResourceView*, XMFLOAT4, XMFLOAT4, XMFLOAT3, float);
|
||||||
// ID3D11DeviceContext* deviceContext,
|
|
||||||
// int indexCount,
|
|
||||||
// XMMATRIX worldMatrix,
|
|
||||||
// XMMATRIX viewMatrix,
|
|
||||||
// XMMATRIX projectionMatrix,
|
|
||||||
// ID3D11ShaderResourceView* front,
|
|
||||||
// ID3D11ShaderResourceView* back,
|
|
||||||
// ID3D11ShaderResourceView* left,
|
|
||||||
// ID3D11ShaderResourceView* right,
|
|
||||||
// ID3D11ShaderResourceView* top,
|
|
||||||
// ID3D11ShaderResourceView* bottom,
|
|
||||||
// XMFLOAT4 sunDiffuseColor
|
|
||||||
// );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextureShaderClass* m_TextureShader;
|
TextureShaderClass* m_TextureShader;
|
||||||
|
@@ -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 ------------- //
|
||||||
// ----------------------------------- //
|
// ----------------------------------- //
|
||||||
@@ -151,7 +171,7 @@ public:
|
|||||||
|
|
||||||
// Save and load scene
|
// Save and load scene
|
||||||
void SaveScene();
|
void SaveScene();
|
||||||
void LoadScene();
|
bool LoadScene();
|
||||||
|
|
||||||
void SetScenePath(std::string path) { m_scenePath = path; };
|
void SetScenePath(std::string path) { m_scenePath = path; };
|
||||||
std::wstring GetScenePath();
|
std::wstring GetScenePath();
|
||||||
@@ -176,6 +196,12 @@ public :
|
|||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
|
|
||||||
|
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 +228,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,11 @@ private:
|
|||||||
bool showOldSceneWindow;
|
bool showOldSceneWindow;
|
||||||
bool showEngineSettingsWindow;
|
bool showEngineSettingsWindow;
|
||||||
bool showLogWindow;
|
bool showLogWindow;
|
||||||
|
bool showStatsWindow;
|
||||||
|
|
||||||
|
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;
|
||||||
|
@@ -22,7 +22,128 @@ using namespace std;
|
|||||||
///////////////////////
|
///////////////////////
|
||||||
#include "textureclass.h"
|
#include "textureclass.h"
|
||||||
|
|
||||||
|
enum class TextureType
|
||||||
|
{
|
||||||
|
Diffuse,
|
||||||
|
Normal,
|
||||||
|
Specular,
|
||||||
|
Alpha
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TextureContainer
|
||||||
|
{
|
||||||
|
|
||||||
|
// Textures
|
||||||
|
std::vector<ID3D11ShaderResourceView*> diffuse;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> normal;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> specular;
|
||||||
|
std::vector<ID3D11ShaderResourceView*> alpha;
|
||||||
|
|
||||||
|
// Textures Paths
|
||||||
|
std::vector<std::wstring> diffusePaths;
|
||||||
|
std::vector<std::wstring> normalPaths;
|
||||||
|
std::vector<std::wstring> specularPaths;
|
||||||
|
std::vector<std::wstring> alphaPaths;
|
||||||
|
|
||||||
|
|
||||||
|
// Get the vector of textures based on the type
|
||||||
|
std::vector<ID3D11ShaderResourceView*>& Get(TextureType type) const {
|
||||||
|
switch (type) {
|
||||||
|
case TextureType::Diffuse: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
|
||||||
|
case TextureType::Normal: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(normal);
|
||||||
|
case TextureType::Specular: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(specular);
|
||||||
|
case TextureType::Alpha: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(alpha);
|
||||||
|
default: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the vector of textures paths based on the type
|
||||||
|
std::vector<std::wstring> GetPaths(TextureType type) const {
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case TextureType::Diffuse: return std::vector<std::wstring>(diffusePaths);
|
||||||
|
case TextureType::Normal: return std::vector<std::wstring>(normalPaths);
|
||||||
|
case TextureType::Specular: return std::vector<std::wstring>(specularPaths);
|
||||||
|
case TextureType::Alpha: return std::vector<std::wstring>(alphaPaths);
|
||||||
|
default: return std::vector<std::wstring>(diffusePaths);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get The texture based on the type and index
|
||||||
|
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const {
|
||||||
|
auto& vec = Get(type);
|
||||||
|
if (index >= 0 && index < vec.size())
|
||||||
|
return vec[index];
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get The texture path based on the type and index
|
||||||
|
std::wstring GetTexturePath(TextureType type, int index) const
|
||||||
|
{
|
||||||
|
std::vector<std::wstring> path = GetPaths(type);
|
||||||
|
if (index >= 0 && index < path.size())
|
||||||
|
return path[index];
|
||||||
|
return L"";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Release all textures and textures paths
|
||||||
|
|
||||||
|
void ReleaseAll() {
|
||||||
|
ReleaseVector(diffuse);
|
||||||
|
ReleaseVector(normal);
|
||||||
|
ReleaseVector(specular);
|
||||||
|
ReleaseVector(alpha);
|
||||||
|
|
||||||
|
ReleaseVector(diffusePaths);
|
||||||
|
ReleaseVector(normalPaths);
|
||||||
|
ReleaseVector(specularPaths);
|
||||||
|
ReleaseVector(alphaPaths);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign a texture and its path to the appropriate vector based on the index
|
||||||
|
void AssignTexture(TextureContainer& textContainer, ID3D11ShaderResourceView* texture , const std::wstring paths, int index)
|
||||||
|
{
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
textContainer.diffuse.push_back(texture);
|
||||||
|
textContainer.diffusePaths.push_back(paths);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
textContainer.normal.push_back(texture);
|
||||||
|
textContainer.normalPaths.push_back(paths);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
textContainer.specular.push_back(texture);
|
||||||
|
textContainer.specularPaths.push_back(paths);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
textContainer.alpha.push_back(texture);
|
||||||
|
textContainer.alphaPaths.push_back(paths);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
textContainer.diffuse.push_back(texture);
|
||||||
|
textContainer.diffusePaths.push_back(paths);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ReleaseVector(std::vector<ID3D11ShaderResourceView*>& vec) {
|
||||||
|
for (auto& tex : vec) {
|
||||||
|
if (tex) {
|
||||||
|
tex->Release();
|
||||||
|
tex = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vec.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ReleaseVector(std::vector<std::wstring>& vec) {
|
||||||
|
vec.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Class name: ModelClass
|
// Class name: ModelClass
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -83,15 +204,38 @@ public:
|
|||||||
ModelClass(const ModelClass&);
|
ModelClass(const ModelClass&);
|
||||||
~ModelClass();
|
~ModelClass();
|
||||||
|
|
||||||
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
||||||
|
// Nouvelle surcharge avec TextureContainer
|
||||||
|
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, const TextureContainer&);
|
||||||
|
// Nouvelle m<>thode - initialisation sans textures
|
||||||
|
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*);
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void Render(ID3D11DeviceContext*);
|
void Render(ID3D11DeviceContext*);
|
||||||
|
|
||||||
int GetIndexCount();
|
int GetIndexCount();
|
||||||
ID3D11ShaderResourceView* GetTexture(int index) const;
|
int GetVertexCount() const { return m_vertexCount; }
|
||||||
bool ChangeTexture(ID3D11Device*, ID3D11DeviceContext*, std::wstring filename, int index);
|
|
||||||
|
|
||||||
|
// TEXTURE //
|
||||||
|
|
||||||
|
//ID3D11ShaderResourceView* GetTexture(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, TextureType type, int index);
|
||||||
|
|
||||||
|
// M<>thodes pour ajouter une nouvelle texture
|
||||||
|
bool AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type);
|
||||||
|
bool AddTexture(ID3D11ShaderResourceView* texture, TextureType type);
|
||||||
|
|
||||||
|
void SetTextureContainer (TextureContainer& texturesContainer) { m_Textures = texturesContainer; }
|
||||||
|
TextureContainer GetTextureContainer() const { return m_Textures; }
|
||||||
|
|
||||||
|
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();
|
||||||
@@ -106,11 +250,8 @@ private:
|
|||||||
|
|
||||||
void CalculateModelVectors();
|
void CalculateModelVectors();
|
||||||
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
||||||
|
|
||||||
private:
|
TextureContainer m_Textures;
|
||||||
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
|
||||||
int m_vertexCount, m_indexCount;
|
|
||||||
std::vector<ID3D11ShaderResourceView*> m_Textures;
|
|
||||||
ModelType* m_model;
|
ModelType* m_model;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -3,6 +3,8 @@
|
|||||||
#include <WICTextureLoader.h>
|
#include <WICTextureLoader.h>
|
||||||
#include <SimpleMath.h>
|
#include <SimpleMath.h>
|
||||||
|
|
||||||
|
#include "d3dclass.h"
|
||||||
|
|
||||||
enum class ObjectType
|
enum class ObjectType
|
||||||
{
|
{
|
||||||
Sphere,
|
Sphere,
|
||||||
@@ -48,6 +50,7 @@ public:
|
|||||||
|
|
||||||
XMVECTOR GetPosition();
|
XMVECTOR GetPosition();
|
||||||
XMVECTOR GetRotation();
|
XMVECTOR GetRotation();
|
||||||
|
void Render(ID3D11DeviceContext* deviceContext);
|
||||||
XMVECTOR GetScale();
|
XMVECTOR GetScale();
|
||||||
|
|
||||||
void SetVelocity(XMVECTOR);
|
void SetVelocity(XMVECTOR);
|
||||||
@@ -61,7 +64,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();
|
||||||
@@ -96,6 +100,14 @@ public:
|
|||||||
std::string ObjectTypeToString(ObjectType objectType);
|
std::string ObjectTypeToString(ObjectType objectType);
|
||||||
|
|
||||||
void LaunchObject();
|
void LaunchObject();
|
||||||
|
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; }
|
||||||
@@ -124,18 +136,22 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
ShaderType m_activeShader = ShaderType::LIGHTING;
|
ShaderType m_activeShader = ShaderType::LIGHTING;
|
||||||
|
|
||||||
float m_boundingRadius;
|
float m_boundingRadius;
|
||||||
std::wstring m_modelPath;
|
std::wstring m_modelPath;
|
||||||
|
TextureContainer m_texturesContainer;
|
||||||
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;
|
||||||
|
|
||||||
|
bool m_instancingEnabled;
|
||||||
|
int m_instanceCount;
|
||||||
|
ID3D11Buffer* m_instanceBuffer;
|
||||||
|
std::vector<XMMATRIX> m_instanceTransforms;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -29,12 +29,13 @@ Object* Skybox::ConstructSkybox()
|
|||||||
|
|
||||||
char modelFilename[128];
|
char modelFilename[128];
|
||||||
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
|
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
|
||||||
|
|
||||||
textures.clear();
|
|
||||||
std::vector<std::wstring> skyboxTextures = {
|
std::vector<std::wstring> skyboxTextures = {
|
||||||
L"assets/Skybox/skybox.png",
|
L"assets/Skybox/skybox.png",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TextureContainer SkyboxTextures;
|
||||||
|
|
||||||
// Load the textures
|
// Load the textures
|
||||||
for (const auto& textureFilename : skyboxTextures)
|
for (const auto& textureFilename : skyboxTextures)
|
||||||
{
|
{
|
||||||
@@ -45,12 +46,13 @@ Object* Skybox::ConstructSkybox()
|
|||||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
textures.push_back(texture);
|
SkyboxTextures.diffuse.push_back(texture);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the model object
|
// Create the model object
|
||||||
m_Skybox = new Object();
|
m_Skybox = new Object();
|
||||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), modelFilename, textures);
|
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), modelFilename, SkyboxTextures);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -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()
|
||||||
@@ -92,9 +99,9 @@ void imguiManager::SetupDockspace(ApplicationClass* app) {
|
|||||||
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
ImGui::MenuItem("Object Window", NULL, &showObjectWindow);
|
||||||
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
ImGui::MenuItem("Terrain Window", NULL, &showTerrainWindow);
|
||||||
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
ImGui::MenuItem("Light Window", NULL, &showLightWindow);
|
||||||
ImGui::MenuItem("Old Scene Window", NULL, &showOldSceneWindow);
|
|
||||||
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
ImGui::MenuItem("Engine Settings Window", NULL, &showEngineSettingsWindow);
|
||||||
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
ImGui::MenuItem("Log Window", NULL, &showLogWindow);
|
||||||
|
ImGui::MenuItem("Render Stats", NULL, &showStatsWindow);
|
||||||
ImGui::EndMenu();
|
ImGui::EndMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -135,11 +142,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"))
|
||||||
@@ -272,69 +274,116 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
// Texture
|
// D<>finir les types de textures
|
||||||
// add all texture category names to a vector
|
std::vector<std::string> textureCategories = {
|
||||||
std::vector<std::string> textureCategories = {
|
"Diffuse", "Normal", "Specular", "Alpha"
|
||||||
"Diffuse",
|
};
|
||||||
"Normal",
|
|
||||||
"Specular",
|
|
||||||
"Reflection",
|
|
||||||
"Refraction"
|
|
||||||
};
|
|
||||||
|
|
||||||
// Display all images
|
std::vector<TextureType> textureTypes = {
|
||||||
ImGui::BeginChild("TextureChild", ImVec2(0, 100), false, ImGuiWindowFlags_HorizontalScrollbar);
|
TextureType::Diffuse, TextureType::Normal,
|
||||||
for (int count = 0; count < textureCategories.size(); count++)
|
TextureType::Specular, TextureType::Alpha
|
||||||
{
|
};
|
||||||
std::string textureLabel = "Texture##" + std::to_string(index) + "##" + std::to_string(count);
|
|
||||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
|
||||||
if (texture != nullptr)
|
|
||||||
{
|
|
||||||
ImGui::Text(textureCategories[count].c_str());
|
|
||||||
ImGui::SameLine();
|
|
||||||
|
|
||||||
std::string buttonLabel = "button " + std::to_string(count);
|
// Cr<43>er un espace pour afficher les textures avec d<>filement
|
||||||
if (ImGui::ImageButton(buttonLabel.c_str(), (ImTextureID)texture, ImVec2(64, 64)))
|
ImGui::BeginChild("TextureChild", ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||||
{
|
|
||||||
// Open file dialog
|
// Pour chaque type de texture
|
||||||
OPENFILENAME ofn;
|
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||||
WCHAR szFile[260];
|
{
|
||||||
ZeroMemory(&ofn, sizeof(ofn));
|
TextureType type = textureTypes[typeIndex];
|
||||||
ofn.lStructSize = sizeof(ofn);
|
std::string typeName = textureCategories[typeIndex];
|
||||||
ofn.hwndOwner = NULL;
|
|
||||||
ofn.lpstrFile = szFile;
|
// Afficher le titre de la cat<61>gorie
|
||||||
szFile[0] = '\0';
|
ImGui::Text("%s:", typeName.c_str());
|
||||||
ofn.nMaxFile = sizeof(szFile);
|
ImGui::SameLine();
|
||||||
ofn.lpstrFilter = L"Texture\0*.png\0";
|
|
||||||
ofn.nFilterIndex = 1;
|
|
||||||
ofn.lpstrFileTitle = NULL;
|
|
||||||
ofn.nMaxFileTitle = 0;
|
|
||||||
ofn.lpstrInitialDir = NULL;
|
|
||||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
|
||||||
|
|
||||||
if (GetOpenFileName(&ofn))
|
// Compter combien de textures de ce type existent
|
||||||
{
|
int textureCount = 0;
|
||||||
// Load the selected texture
|
while (object->GetTexture(type, textureCount) != nullptr)
|
||||||
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, count);
|
{
|
||||||
}
|
textureCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::IsItemHovered())
|
// Afficher toutes les textures existantes
|
||||||
{
|
ImGui::BeginGroup();
|
||||||
ImGui::BeginTooltip();
|
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||||
ImGui::Image((ImTextureID)texture, ImVec2(256, 256));
|
{
|
||||||
ImGui::EndTooltip();
|
ID3D11ShaderResourceView* texture = object->GetTexture(type, texIndex);
|
||||||
}
|
if (texture)
|
||||||
|
{
|
||||||
|
// ID unique pour chaque bouton de texture
|
||||||
|
std::string buttonId = "tex##" + std::to_string(index) + "_" +
|
||||||
|
std::to_string(typeIndex) + "_" +
|
||||||
|
std::to_string(texIndex);
|
||||||
|
|
||||||
|
if (ImGui::ImageButton(buttonId.c_str(), (ImTextureID)texture, ImVec2(48, 48)))
|
||||||
|
{
|
||||||
|
// Ouvrir une bo<62>te de dialogue pour changer la texture
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
WCHAR szFile[260];
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = NULL;
|
||||||
|
ofn.lpstrFile = szFile;
|
||||||
|
szFile[0] = '\0';
|
||||||
|
ofn.nMaxFile = sizeof(szFile);
|
||||||
|
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||||
|
ofn.nFilterIndex = 1;
|
||||||
|
ofn.lpstrInitialDir = NULL;
|
||||||
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||||
|
|
||||||
if (count < textureCategories.size() - 1)
|
if (GetOpenFileName(&ofn))
|
||||||
{
|
{
|
||||||
ImGui::SameLine();
|
// Changer la texture existante
|
||||||
}
|
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::EndChild();
|
|
||||||
|
// Afficher l'indice de texture et pr<70>visualisation au survol
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text("%s %d", typeName.c_str(), texIndex);
|
||||||
|
ImGui::Image((ImTextureID)texture, ImVec2(192, 192));
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::SameLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bouton pour ajouter une nouvelle texture
|
||||||
|
std::string addButtonLabel = "+##" + std::to_string(index) + "_" + std::to_string(typeIndex);
|
||||||
|
if (ImGui::Button(addButtonLabel.c_str(), ImVec2(48, 48)))
|
||||||
|
{
|
||||||
|
// Ouvrir une bo<62>te de dialogue pour ajouter une texture
|
||||||
|
OPENFILENAME ofn;
|
||||||
|
WCHAR szFile[260];
|
||||||
|
ZeroMemory(&ofn, sizeof(ofn));
|
||||||
|
ofn.lStructSize = sizeof(ofn);
|
||||||
|
ofn.hwndOwner = NULL;
|
||||||
|
ofn.lpstrFile = szFile;
|
||||||
|
szFile[0] = '\0';
|
||||||
|
ofn.nMaxFile = sizeof(szFile);
|
||||||
|
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||||
|
ofn.nFilterIndex = 1;
|
||||||
|
ofn.lpstrInitialDir = NULL;
|
||||||
|
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||||
|
|
||||||
|
if (GetOpenFileName(&ofn))
|
||||||
|
{
|
||||||
|
// Ajouter une nouvelle texture
|
||||||
|
object->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndGroup();
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndChild();
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
|
||||||
@@ -483,18 +532,36 @@ 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::SameLine();
|
ImGui::Separator();
|
||||||
|
|
||||||
|
// int input area for the number of cubes
|
||||||
|
static int numCubes = 10;
|
||||||
|
ImGui::InputInt("Number of Cubes", &numCubes);
|
||||||
|
if (numCubes < 1)
|
||||||
|
{
|
||||||
|
numCubes = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
|
if (ImGui::Button("Generate Big Cube Terrain"))
|
||||||
|
{
|
||||||
|
app->CreateBigCube(numCubes);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
|
||||||
if (ImGui::Button("Delete All Terrain Cubes"))
|
if (ImGui::Button("Delete All Terrain Cubes"))
|
||||||
{
|
{
|
||||||
app->DeleteTerrain();
|
app->DeleteTerrain();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
@@ -514,7 +581,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();
|
||||||
@@ -549,6 +616,11 @@ bool imguiManager::ImGuiWidgetRenderer(ApplicationClass* app)
|
|||||||
{
|
{
|
||||||
WidgetRenderWindow(app, ImVec2(800, 600));
|
WidgetRenderWindow(app, ImVec2(800, 600));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (showStatsWindow)
|
||||||
|
{
|
||||||
|
WidgetRenderStats(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//render imgui
|
//render imgui
|
||||||
@@ -797,4 +869,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();
|
||||||
}
|
}
|
@@ -18,8 +18,19 @@ ModelClass::~ModelClass()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, std::vector<ID3D11ShaderResourceView*> textures) {
|
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
|
||||||
Logger::Get().Log("Initializing model class with preloaded textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
bool result = Initialize(device, deviceContext, modelFilename);
|
||||||
|
if (!result) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Textures = textures; // Copie de la structure de textures
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
|
||||||
|
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
@@ -39,15 +50,10 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Textures = textures;
|
|
||||||
|
|
||||||
Logger::Get().Log("Model class initialized with preloaded textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ModelClass::Shutdown()
|
void ModelClass::Shutdown()
|
||||||
{
|
{
|
||||||
// Release the model textures.
|
// Release the model textures.
|
||||||
@@ -77,16 +83,12 @@ int ModelClass::GetIndexCount()
|
|||||||
return m_indexCount;
|
return m_indexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11ShaderResourceView* ModelClass::GetTexture(int index) const {
|
ID3D11ShaderResourceView* ModelClass::GetTexture(TextureType type, int index) const {
|
||||||
if (index >= 0 && index < m_Textures.size()) {
|
return m_Textures.GetTexture(type, index);
|
||||||
return m_Textures[index];
|
|
||||||
}
|
|
||||||
return nullptr; // Retourne nullptr si l'index est hors limites
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -161,16 +163,12 @@ 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);
|
|
||||||
// Release the index buffer.
|
// Release the index buffer.
|
||||||
if (m_indexBuffer)
|
if (m_indexBuffer)
|
||||||
{
|
{
|
||||||
@@ -184,10 +182,7 @@ void ModelClass::ShutdownBuffers()
|
|||||||
m_vertexBuffer->Release();
|
m_vertexBuffer->Release();
|
||||||
m_vertexBuffer = 0;
|
m_vertexBuffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Buffers shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -215,26 +210,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
|
||||||
// Release the texture object array.
|
m_Textures.ReleaseAll();
|
||||||
for (auto& texture : m_Textures)
|
|
||||||
{
|
|
||||||
if (texture)
|
|
||||||
{
|
|
||||||
texture->Release();
|
|
||||||
texture = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Textures.clear();
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -258,8 +240,7 @@ bool ModelClass::LoadModel(char* filename)
|
|||||||
|
|
||||||
bool ModelClass::LoadObjModel(char* filename)
|
bool ModelClass::LoadObjModel(char* filename)
|
||||||
{
|
{
|
||||||
Logger::Get().Log("Loading model", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
std::string line;
|
std::string line;
|
||||||
std::ifstream fin(filename);
|
std::ifstream fin(filename);
|
||||||
|
|
||||||
@@ -343,16 +324,12 @@ bool ModelClass::LoadObjModel(char* filename)
|
|||||||
|
|
||||||
fin.close();
|
fin.close();
|
||||||
|
|
||||||
Logger::Get().Log("Model loaded", __FILE__, __LINE__);
|
|
||||||
|
|
||||||
return true;
|
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;
|
||||||
@@ -403,16 +380,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;
|
||||||
@@ -474,10 +447,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)
|
||||||
@@ -532,60 +501,200 @@ 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)
|
bool ModelClass::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext, TextureContainer& textureContainer)
|
||||||
{
|
{
|
||||||
|
HRESULT hResult;
|
||||||
|
|
||||||
|
// Charger les textures diffuses
|
||||||
|
for (const auto& texturePath : textureContainer.diffusePaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.diffuse.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures normales
|
||||||
|
for (const auto& texturePath : textureContainer.normalPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.normal.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures sp<73>culaires
|
||||||
|
for (const auto& texturePath : textureContainer.specularPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.specular.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Charger les textures alpha
|
||||||
|
for (const auto& texturePath : textureContainer.alphaPaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(hResult))
|
||||||
|
{
|
||||||
|
Logger::Get().Log("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
textureContainer.alpha.push_back(texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
||||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
HRESULT result;
|
HRESULT result;
|
||||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||||
|
|
||||||
// Load the new texture using WICTextureLoader.
|
// Charger la nouvelle texture
|
||||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||||
if (FAILED(result))
|
if (FAILED(result)) {
|
||||||
{
|
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
Logger::Get().Log("Failed to load new texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release the old texture if it exists.
|
// R<EFBFBD>cup<EFBFBD>rer le vecteur correspondant au type de texture
|
||||||
if (index >= 0 && index < m_Textures.size() && m_Textures[index])
|
auto& textureVector = m_Textures.Get(type);
|
||||||
{
|
|
||||||
m_Textures[index]->Release();
|
// Si l'index est hors limites, redimensionner le vecteur
|
||||||
m_Textures[index] = nullptr;
|
if (index >= textureVector.size()) {
|
||||||
|
textureVector.resize(index + 1, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the new texture to the specified index.
|
// Lib<EFBFBD>rer l'ancienne texture si elle existe
|
||||||
if (index >= 0 && index < m_Textures.size())
|
if (textureVector[index]) {
|
||||||
{
|
textureVector[index]->Release();
|
||||||
m_Textures[index] = newTexture;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// Assigner la nouvelle texture
|
||||||
// If the index is out of range, log an error and release the new texture.
|
textureVector[index] = newTexture;
|
||||||
Logger::Get().Log("Texture index out of range", __FILE__, __LINE__, Logger::LogLevel::Error);
|
|
||||||
newTexture->Release();
|
// Mettre <20> jour le chemin dans le conteneur appropri<72> selon le type
|
||||||
return false;
|
switch (type) {
|
||||||
|
case TextureType::Diffuse:
|
||||||
|
if (index >= m_Textures.diffusePaths.size()) {
|
||||||
|
m_Textures.diffusePaths.resize(index + 1, L"");
|
||||||
|
}
|
||||||
|
m_Textures.diffusePaths[index] = filename;
|
||||||
|
break;
|
||||||
|
case TextureType::Normal:
|
||||||
|
if (index >= m_Textures.normalPaths.size()) {
|
||||||
|
m_Textures.normalPaths.resize(index + 1, L"");
|
||||||
|
}
|
||||||
|
m_Textures.normalPaths[index] = filename;
|
||||||
|
break;
|
||||||
|
case TextureType::Specular:
|
||||||
|
if (index >= m_Textures.specularPaths.size()) {
|
||||||
|
m_Textures.specularPaths.resize(index + 1, L"");
|
||||||
|
}
|
||||||
|
m_Textures.specularPaths[index] = filename;
|
||||||
|
break;
|
||||||
|
case TextureType::Alpha:
|
||||||
|
if (index >= m_Textures.alphaPaths.size()) {
|
||||||
|
m_Textures.alphaPaths.resize(index + 1, L"");
|
||||||
|
}
|
||||||
|
m_Textures.alphaPaths[index] = filename;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger::Get().Log("Texture changed successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
Logger::Get().Log("Texture changed successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ModelClass::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
|
||||||
|
Logger::Get().Log("Adding texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
|
||||||
|
HRESULT result;
|
||||||
|
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||||
|
|
||||||
|
// Charger la nouvelle texture
|
||||||
|
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||||
|
if (FAILED(result)) {
|
||||||
|
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajouter la texture au vecteur appropri<72> selon le type
|
||||||
|
auto& textureVector = m_Textures.Get(type);
|
||||||
|
textureVector.push_back(newTexture);
|
||||||
|
|
||||||
|
// Ajouter le chemin de la texture au vecteur appropri<72> selon le type
|
||||||
|
switch (type) {
|
||||||
|
case TextureType::Diffuse:
|
||||||
|
m_Textures.diffusePaths.push_back(filename);
|
||||||
|
break;
|
||||||
|
case TextureType::Normal:
|
||||||
|
m_Textures.normalPaths.push_back(filename);
|
||||||
|
break;
|
||||||
|
case TextureType::Specular:
|
||||||
|
m_Textures.specularPaths.push_back(filename);
|
||||||
|
break;
|
||||||
|
case TextureType::Alpha:
|
||||||
|
m_Textures.alphaPaths.push_back(filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Get().Log("Texture added successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ModelClass::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
|
||||||
|
if (!texture) {
|
||||||
|
Logger::Get().Log("Cannot add null texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajouter la texture au vecteur appropri<72>
|
||||||
|
auto& textureVector = m_Textures.Get(type);
|
||||||
|
textureVector.push_back(texture);
|
||||||
|
|
||||||
|
// Ajouter un chemin vide ou g<>n<EFBFBD>rique pour maintenir la synchronisation
|
||||||
|
switch (type) {
|
||||||
|
case TextureType::Diffuse:
|
||||||
|
m_Textures.diffusePaths.push_back(L"[texture pr<70>charg<72>e]");
|
||||||
|
break;
|
||||||
|
case TextureType::Normal:
|
||||||
|
m_Textures.normalPaths.push_back(L"[texture pr<70>charg<72>e]");
|
||||||
|
break;
|
||||||
|
case TextureType::Specular:
|
||||||
|
m_Textures.specularPaths.push_back(L"[texture pr<70>charg<72>e]");
|
||||||
|
break;
|
||||||
|
case TextureType::Alpha:
|
||||||
|
m_Textures.alphaPaths.push_back(L"[texture pr<70>charg<72>e]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
#include "object.h"
|
#include "object.h"
|
||||||
|
|
||||||
|
#include <comdef.h>
|
||||||
|
|
||||||
|
#include "d3dclass.h"
|
||||||
|
|
||||||
Object::Object()// Initialize the reference here
|
Object::Object()// Initialize the reference here
|
||||||
{
|
{
|
||||||
m_scaleMatrix = XMMatrixIdentity();
|
m_scaleMatrix = XMMatrixIdentity();
|
||||||
@@ -14,11 +18,19 @@ Object::Object()// Initialize the reference here
|
|||||||
m_isGrounded = false;
|
m_isGrounded = false;
|
||||||
m_id = NULL;
|
m_id = NULL;
|
||||||
m_boundingRadius = 1.0f;
|
m_boundingRadius = 1.0f;
|
||||||
|
m_instancingEnabled = false;
|
||||||
|
m_instanceCount = 0;
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object::~Object()
|
Object::~Object()
|
||||||
{
|
{
|
||||||
|
// Lib<69>rer le buffer d'instances
|
||||||
|
if (m_instanceBuffer)
|
||||||
|
{
|
||||||
|
m_instanceBuffer->Release();
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
void Object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||||
@@ -88,6 +100,44 @@ XMVECTOR Object::GetRotation()
|
|||||||
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Object::Render(ID3D11DeviceContext* deviceContext)
|
||||||
|
{
|
||||||
|
unsigned int strides[2];
|
||||||
|
unsigned int offsets[2];
|
||||||
|
ID3D11Buffer* bufferPointers[2];
|
||||||
|
|
||||||
|
// Configurer les vertex et index buffers
|
||||||
|
strides[0] = sizeof(VertexType);
|
||||||
|
offsets[0] = 0;
|
||||||
|
bufferPointers[0] = m_vertexBuffer;
|
||||||
|
|
||||||
|
// Si l'instanciation est activ<69>e
|
||||||
|
if (m_instancingEnabled && m_instanceBuffer)
|
||||||
|
{
|
||||||
|
// Configurer le buffer d'instances
|
||||||
|
strides[1] = sizeof(XMMATRIX);
|
||||||
|
offsets[1] = 0;
|
||||||
|
bufferPointers[1] = m_instanceBuffer;
|
||||||
|
|
||||||
|
// D<>finir les deux buffers (vertex et instance) sur le pipeline
|
||||||
|
deviceContext->IASetVertexBuffers(0, 2, bufferPointers, strides, offsets);
|
||||||
|
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
|
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
|
// Dessiner les instances
|
||||||
|
deviceContext->DrawIndexedInstanced(m_indexCount, m_instanceCount, 0, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Rendu normal sans instanciation
|
||||||
|
deviceContext->IASetVertexBuffers(0, 1, bufferPointers, strides, offsets);
|
||||||
|
deviceContext->IASetIndexBuffer(m_indexBuffer, DXGI_FORMAT_R32_UINT, 0);
|
||||||
|
deviceContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
|
// Dessiner l'objet normalement
|
||||||
|
deviceContext->DrawIndexed(m_indexCount, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
XMVECTOR Object::GetScale()
|
XMVECTOR Object::GetScale()
|
||||||
{
|
{
|
||||||
@@ -348,4 +398,103 @@ void Object::LaunchObject()
|
|||||||
char buffer[256];
|
char buffer[256];
|
||||||
sprintf_s(buffer, "Launch velocity: %f m/s at angle %f degrees", XMVectorGetX(XMVector3Length(velocity)), m_alpha);
|
sprintf_s(buffer, "Launch velocity: %f m/s at angle %f degrees", XMVectorGetX(XMVector3Length(velocity)), m_alpha);
|
||||||
OutputDebugStringA(buffer);
|
OutputDebugStringA(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
||||||
|
D3DClass* m_Direct3D)
|
||||||
|
{
|
||||||
|
|
||||||
|
HRESULT result;
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
TextureType type;
|
||||||
|
for (const auto& texturePath : texturePaths)
|
||||||
|
{
|
||||||
|
ID3D11ShaderResourceView* texture = nullptr;
|
||||||
|
result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), texturePath.c_str(), nullptr, &texture);
|
||||||
|
if (FAILED(result))
|
||||||
|
{
|
||||||
|
|
||||||
|
// Utiliser _com_error pour obtenir des informations d<>taill<6C>es sur l'erreur
|
||||||
|
_com_error err(result);
|
||||||
|
LPCTSTR errMsg = err.ErrorMessage();
|
||||||
|
|
||||||
|
//convertie errMessage en std::wstring
|
||||||
|
std::wstring ws(errMsg);
|
||||||
|
std::string str(ws.begin(), ws.end());
|
||||||
|
|
||||||
|
Logger::Get().Log("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
|
||||||
|
"\nError: " + std::to_string(result) +
|
||||||
|
"\nDescription: " + str,
|
||||||
|
__FILE__, __LINE__, Logger::LogLevel::Error);
|
||||||
|
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);
|
||||||
|
i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Object::SetupInstancing(ID3D11Device* device, const std::vector<XMMATRIX>& instanceTransforms)
|
||||||
|
{
|
||||||
|
// Stocker les matrices de transformation
|
||||||
|
m_instanceTransforms = instanceTransforms;
|
||||||
|
m_instanceCount = static_cast<int>(instanceTransforms.size());
|
||||||
|
|
||||||
|
// Lib<69>rer le buffer d'instances existant si n<>cessaire
|
||||||
|
if (m_instanceBuffer)
|
||||||
|
{
|
||||||
|
m_instanceBuffer->Release();
|
||||||
|
m_instanceBuffer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cr<43>er le buffer d'instances
|
||||||
|
D3D11_BUFFER_DESC instanceBufferDesc;
|
||||||
|
ZeroMemory(&instanceBufferDesc, sizeof(instanceBufferDesc));
|
||||||
|
instanceBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||||
|
instanceBufferDesc.ByteWidth = sizeof(XMMATRIX) * m_instanceCount;
|
||||||
|
instanceBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
|
||||||
|
instanceBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||||
|
instanceBufferDesc.MiscFlags = 0;
|
||||||
|
instanceBufferDesc.StructureByteStride = 0;
|
||||||
|
|
||||||
|
D3D11_SUBRESOURCE_DATA instanceData;
|
||||||
|
ZeroMemory(&instanceData, sizeof(instanceData));
|
||||||
|
instanceData.pSysMem = instanceTransforms.data();
|
||||||
|
|
||||||
|
HRESULT result = device->CreateBuffer(&instanceBufferDesc, &instanceData, &m_instanceBuffer);
|
||||||
|
if (FAILED(result))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::EnableInstancing(bool enabled)
|
||||||
|
{
|
||||||
|
m_instancingEnabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::SetInstanceCount(int count)
|
||||||
|
{
|
||||||
|
m_instanceCount = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajoutez <20>galement ces m<>thodes pour acc<63>der aux donn<6E>es d'instanciation
|
||||||
|
bool Object::IsInstancingEnabled() const
|
||||||
|
{
|
||||||
|
return m_instancingEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Object::GetInstanceCount() const
|
||||||
|
{
|
||||||
|
return m_instanceCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3D11Buffer* Object::GetInstanceBuffer() const
|
||||||
|
{
|
||||||
|
return m_instanceBuffer;
|
||||||
}
|
}
|
Reference in New Issue
Block a user