Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
763ecff93d | |||
e527e85b9c | |||
9d0d2d1dfd | |||
7755150ae8 | |||
ddf5ea30a6 | |||
8f0e583c62 | |||
bf1b5d78e5 | |||
3adfddf44f | |||
039b034175 | |||
688fe7ff1c | |||
de16b97f8e | |||
f5331444cb |
72
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
72
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@@ -4,11 +4,7 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
|
||||
</list>
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@@ -21,17 +17,20 @@
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<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://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/d3d11.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/dinput.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.44.35207/include/memory" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Inc/VertexTypes.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/identity_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/physics_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/render_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/shader_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/components/transform_component.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/entity_manager.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/inc/system/ecs/systems/render_system.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
</component>
|
||||
<component name="KubernetesApiPersistence">{}</component>
|
||||
@@ -53,26 +52,26 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.KhaoticDemo.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.environmentSetup",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||
<configuration_1 setup="1">
|
||||
@@ -213,6 +212,17 @@
|
||||
<workItem from="1748869642637" duration="3049000" />
|
||||
<workItem from="1748954607174" duration="14202000" />
|
||||
<workItem from="1748969487337" duration="402000" />
|
||||
<workItem from="1750187491423" duration="4397000" />
|
||||
<workItem from="1750191969842" duration="162000" />
|
||||
<workItem from="1750248915365" duration="442000" />
|
||||
<workItem from="1750335650897" duration="2051000" />
|
||||
<workItem from="1750344288223" duration="1751000" />
|
||||
<workItem from="1750351735497" duration="9648000" />
|
||||
<workItem from="1750417484899" duration="2384000" />
|
||||
<workItem from="1750420267631" duration="148000" />
|
||||
<workItem from="1750592598277" duration="332000" />
|
||||
<workItem from="1750699146323" duration="10385000" />
|
||||
<workItem from="1750763086646" duration="4874000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
|
@@ -1 +0,0 @@
|
||||
1 isosphere 0 10 0 0 -0 0 1 1 1 Content/Assets/Kobject/isosphere.obj ALPHA_MAPPING 1 Unknown 1 0 2 assets/Texture/Bricks2K.png F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\moss01.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\alpha01.png
|
@@ -1 +0,0 @@
|
||||
0 vaisseautri 0 50 0 0 -0 0 1 1 1 Content/Assets/Kobject/vaisseautri.obj CEL_SHADING 1 Unknown 1 0 1 F:\Github_Repo\khaotic-engine-Reborn\enginecustom\assets\Texture\marble01.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 0
|
1
enginecustom/DemoScene_V12.6.0.ker
Normal file
1
enginecustom/DemoScene_V12.6.0.ker
Normal file
@@ -0,0 +1 @@
|
||||
1 CubePart_0_0_0 0 0 0 0 -0 0 1 1 1 LIGHTING 0 Terrain 0 0 1 assets/Texture/Bricks2K.png 1 assets/Texture/BricksNRM2K.png 1 assets/Texture/BricksGLOSS2K.png 0
|
@@ -1,106 +0,0 @@
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=1281,19
|
||||
Size=303,842
|
||||
Collapsed=0
|
||||
DockId=0x0000000F,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=0,19
|
||||
Size=281,842
|
||||
Collapsed=0
|
||||
DockId=0x00000011,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=0,19
|
||||
Size=280,842
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Light]
|
||||
Pos=0,19
|
||||
Size=281,842
|
||||
Collapsed=0
|
||||
DockId=0x00000012,0
|
||||
|
||||
[Window][Shader Manager]
|
||||
Pos=8,27
|
||||
Size=330,487
|
||||
Collapsed=0
|
||||
DockId=0x00000001,2
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1281,527
|
||||
Size=303,334
|
||||
Collapsed=0
|
||||
DockId=0x00000010,0
|
||||
|
||||
[Window][DockSpace Demo]
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Render Window]
|
||||
Pos=8,27
|
||||
Size=1559,974
|
||||
Collapsed=0
|
||||
DockId=0x00000011,0
|
||||
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Add Object]
|
||||
Pos=1188,0
|
||||
Size=396,430
|
||||
Collapsed=0
|
||||
|
||||
[Window][Log]
|
||||
Pos=8,518
|
||||
Size=1568,335
|
||||
Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=0,636
|
||||
Size=1279,225
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Window][Render Stats]
|
||||
Pos=0,636
|
||||
Size=1279,225
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
|
||||
[Window][render Window]
|
||||
Pos=16,718
|
||||
Size=997,758
|
||||
Collapsed=1
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
|
||||
DockNode ID=0x00000002 Parent=0xCCBD8CF7 SizeRef=1743,826 Split=Y
|
||||
DockNode ID=0x0000000A Parent=0x00000002 SizeRef=1568,599 Split=X
|
||||
DockNode ID=0x00000009 Parent=0x0000000A SizeRef=281,974 Split=Y Selected=0x031DC75C
|
||||
DockNode ID=0x00000011 Parent=0x00000009 SizeRef=281,441 Selected=0x031DC75C
|
||||
DockNode ID=0x00000012 Parent=0x00000009 SizeRef=281,440 Selected=0x321620B2
|
||||
DockNode ID=0x0000000D Parent=0x0000000A SizeRef=1460,974 Split=Y
|
||||
DockNode ID=0x0000000B Parent=0x0000000D SizeRef=1568,637 Split=X Selected=0x321620B2
|
||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=280,883 Selected=0x393905AB
|
||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=1178,883 CentralNode=1 Selected=0x4FC83240
|
||||
DockNode ID=0x0000000C Parent=0x0000000D SizeRef=1568,335 Selected=0x139FDA3F
|
||||
DockNode ID=0x0000000E Parent=0x00000002 SizeRef=1568,225 Split=X Selected=0xD99DEA49
|
||||
DockNode ID=0x00000004 Parent=0x0000000E SizeRef=871,225 Selected=0xD99DEA49
|
||||
DockNode ID=0x00000006 Parent=0x0000000E SizeRef=870,225 Selected=0xAB74BEE9
|
||||
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=303,826 Split=Y Selected=0x9F035453
|
||||
DockNode ID=0x0000000F Parent=0x00000005 SizeRef=303,667 Selected=0x9F035453
|
||||
DockNode ID=0x00000010 Parent=0x00000005 SizeRef=303,441 Selected=0x0B098C4B
|
||||
|
@@ -1,89 +0,0 @@
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=1233,27
|
||||
Size=343,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=8,27
|
||||
Size=289,413
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=8,442
|
||||
Size=289,411
|
||||
Collapsed=0
|
||||
DockId=0x00000008,0
|
||||
|
||||
[Window][Light]
|
||||
Pos=8,27
|
||||
Size=290,866
|
||||
Collapsed=0
|
||||
DockId=0x00000004,1
|
||||
|
||||
[Window][Shader Manager]
|
||||
Pos=8,27
|
||||
Size=330,487
|
||||
Collapsed=0
|
||||
DockId=0x00000001,2
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1233,27
|
||||
Size=343,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,1
|
||||
|
||||
[Window][DockSpace Demo]
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Render Window]
|
||||
Pos=8,27
|
||||
Size=1559,974
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Add Object]
|
||||
Pos=1188,0
|
||||
Size=396,430
|
||||
Collapsed=0
|
||||
|
||||
[Window][Log]
|
||||
Pos=8,518
|
||||
Size=1568,335
|
||||
Collapsed=0
|
||||
DockId=0x0000000C,0
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=299,627
|
||||
Size=932,226
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xC0DFADC4 Pos=8,27 Size=1568,826 Split=X
|
||||
DockNode ID=0x00000001 Parent=0xC0DFADC4 SizeRef=330,1094 Selected=0x393905AB
|
||||
DockNode ID=0x00000003 Parent=0xC0DFADC4 SizeRef=1700,1094 CentralNode=1
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=1568,826 Split=X
|
||||
DockNode ID=0x00000009 Parent=0xCCBD8CF7 SizeRef=289,974 Split=Y Selected=0x031DC75C
|
||||
DockNode ID=0x00000007 Parent=0x00000009 SizeRef=289,299 Selected=0x031DC75C
|
||||
DockNode ID=0x00000008 Parent=0x00000009 SizeRef=289,297 Selected=0x393905AB
|
||||
DockNode ID=0x0000000D Parent=0xCCBD8CF7 SizeRef=1613,974 Split=X
|
||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=Y
|
||||
DockNode ID=0x00000004 Parent=0x0000000B SizeRef=932,598 CentralNode=1
|
||||
DockNode ID=0x00000006 Parent=0x0000000B SizeRef=932,226 Selected=0xAB74BEE9
|
||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x0B098C4B
|
||||
|
@@ -119,6 +119,16 @@
|
||||
<ClInclude Include="src\inc\system\camera_class.h" />
|
||||
<ClInclude Include="src\inc\system\d_3d_class.h" />
|
||||
<ClInclude Include="src\inc\system\display_plane_class.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\identity_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\model_path_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\physics_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\render_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\shader_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\components\transform_component.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\entity.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\entity_manager.h" />
|
||||
<ClInclude Include="src\inc\system\ecs\systems\render_system.h" />
|
||||
<ClInclude Include="src\inc\system\font_class.h" />
|
||||
<ClInclude Include="src\inc\system\fps_class.h" />
|
||||
<ClInclude Include="src\inc\system\fps_limiter.h" />
|
||||
@@ -134,7 +144,6 @@
|
||||
<ClInclude Include="src\inc\system\physics.h" />
|
||||
<ClInclude Include="src\inc\system\position_class.h" />
|
||||
<ClInclude Include="src\inc\system\render_texture_class.h" />
|
||||
<ClInclude Include="src\inc\system\sceneManager.h" />
|
||||
<ClInclude Include="src\inc\system\scene_manager.h" />
|
||||
<ClInclude Include="src\inc\system\shadow_map.h" />
|
||||
<ClInclude Include="src\inc\system\Skybox.h" />
|
||||
|
@@ -12,26 +12,56 @@ Collapsed=0
|
||||
Pos=1267,19
|
||||
Size=317,842
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][render Stats]
|
||||
Pos=275,630
|
||||
Size=1309,231
|
||||
Pos=0,630
|
||||
Size=1584,231
|
||||
Collapsed=0
|
||||
DockId=0x00000004,0
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=0,19
|
||||
Size=273,842
|
||||
Size=234,842
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
DockId=0x0000000B,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=236,19
|
||||
Size=266,842
|
||||
Collapsed=0
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Log Window]
|
||||
Pos=0,630
|
||||
Size=1584,231
|
||||
Collapsed=0
|
||||
DockId=0x0000000A,0
|
||||
|
||||
[Window][Light]
|
||||
Pos=0,19
|
||||
Size=234,609
|
||||
Collapsed=0
|
||||
DockId=0x0000000B,0
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1267,462
|
||||
Size=317,166
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=X
|
||||
DockNode ID=0x00000005 Parent=0xCCBD8CF7 SizeRef=273,842 Selected=0x031DC75C
|
||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1309,842 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0x00000006 SizeRef=1584,609 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000003 SizeRef=990,842 CentralNode=1
|
||||
DockNode ID=0x00000002 Parent=0x00000003 SizeRef=317,842 Selected=0x9F035453
|
||||
DockNode ID=0x00000004 Parent=0x00000006 SizeRef=1584,231 Selected=0xF5D1BB37
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=0,19 Size=1584,842 Split=Y
|
||||
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=1584,609 Split=X
|
||||
DockNode ID=0x0000000B Parent=0x00000003 SizeRef=234,842 Selected=0x031DC75C
|
||||
DockNode ID=0x0000000C Parent=0x00000003 SizeRef=1348,842 Split=X
|
||||
DockNode ID=0x00000007 Parent=0x0000000C SizeRef=266,842 Selected=0x393905AB
|
||||
DockNode ID=0x00000008 Parent=0x0000000C SizeRef=1316,842 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000008 SizeRef=1265,842 CentralNode=1
|
||||
DockNode ID=0x00000002 Parent=0x00000008 SizeRef=317,842 Split=Y Selected=0x9F035453
|
||||
DockNode ID=0x00000005 Parent=0x00000002 SizeRef=317,441 Selected=0x9F035453
|
||||
DockNode ID=0x00000006 Parent=0x00000002 SizeRef=317,166 Selected=0x0B098C4B
|
||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1584,231 Split=X Selected=0xF5D1BB37
|
||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=792,231 Selected=0xF5D1BB37
|
||||
DockNode ID=0x0000000A Parent=0x00000004 SizeRef=790,231 Selected=0xAB74BEE9
|
||||
|
||||
|
@@ -13,7 +13,7 @@ public:
|
||||
|
||||
void Initialize(d_3d_class* d3dClassRef); // Get all the required references
|
||||
|
||||
object* ConstructSkybox();
|
||||
object* ConstructSkybox(application_class* app);
|
||||
|
||||
|
||||
// Variables
|
||||
|
@@ -7,10 +7,7 @@
|
||||
///////////////////////
|
||||
#include "d_3d_class.h"
|
||||
#include "camera_class.h"
|
||||
#include "object.h"
|
||||
#include "light_class.h"
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#include "bitmap_class.h"
|
||||
#include "sprite_class.h"
|
||||
@@ -31,7 +28,16 @@
|
||||
#include "physics.h"
|
||||
#include "frustum.h"
|
||||
#include "skybox.h"
|
||||
#include "shadow_map.h"
|
||||
#include "stats.h"
|
||||
|
||||
#include "ecs/components/identity_component.h"
|
||||
#include "ecs/components/render_component.h"
|
||||
#include "ecs/components/transform_component.h"
|
||||
#include "ecs/components/physics_component.h"
|
||||
#include "ecs/components/shader_component.h"
|
||||
#include "ecs/systems/render_system.h"
|
||||
#include "ecs/components/model_path_component.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <WICTextureLoader.h>
|
||||
@@ -42,9 +48,11 @@
|
||||
#include <algorithm>
|
||||
#include <DirectXMath.h>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
|
||||
#include "shadow_map.h"
|
||||
#include "stats.h"
|
||||
#include "ecs/entity_manager.h"
|
||||
|
||||
|
||||
/////////////
|
||||
@@ -54,6 +62,8 @@ constexpr bool full_screen = false;
|
||||
constexpr float screen_depth = 1000.0f;
|
||||
constexpr float screen_near = 0.3f;
|
||||
|
||||
static std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
|
||||
|
||||
struct input
|
||||
{
|
||||
bool key_left = false;
|
||||
@@ -78,8 +88,7 @@ public:
|
||||
render_texture_class* get_refraction_texture() const { return refraction_texture_; };
|
||||
render_texture_class* get_reflection_texture() const { return reflection_texture_; };
|
||||
|
||||
void create_big_cube(int side_count);
|
||||
void process_terrain_generation();
|
||||
bool create_big_cube(int side_count);
|
||||
virtual bool initialize(int, int, HWND, bool is_vulkan);
|
||||
void shutdown();
|
||||
virtual bool frame(input_class*);
|
||||
@@ -96,17 +105,12 @@ public:
|
||||
void set_speed(const float speed) { this->speed_ = speed; };
|
||||
|
||||
void add_cube();
|
||||
void delete_kobject(int index);
|
||||
size_t get_cube_count() const { return cubes_.size(); };
|
||||
size_t get_terrain_cube_count() const { return terrain_chunk_.size(); };
|
||||
std::vector<object*> get_cubes() const { return cubes_; };
|
||||
std::vector<object*> get_terrain_cubes() const { return terrain_chunk_; };
|
||||
std::vector<object*> get_kobjects() const { return object_; };
|
||||
void set_kobjects(std::vector<object*> kobjects) { object_ = kobjects; };
|
||||
void delete_entity_by_id(int entity_id);
|
||||
void add_kobject(std::wstring& filepath);
|
||||
void set_path(WCHAR* path) { path_ = path; };
|
||||
void set_w_folder(const std::filesystem::path& w_folder) { w_folder_ = w_folder; };
|
||||
std::filesystem::path get_w_folder() const { return w_folder_; };
|
||||
int get_terrain_entity_count();
|
||||
|
||||
int get_object_id() const { return object_id_; };
|
||||
void set_object_id(int object_id) { object_id_ = object_id; };
|
||||
@@ -126,14 +130,20 @@ public:
|
||||
|
||||
void set_cel_shading(const bool enable) { enable_cel_shading_ = enable; };
|
||||
|
||||
void set_vsync(bool vsync);
|
||||
void set_vsync(bool vsync) {
|
||||
vsync_enabled_ = vsync;
|
||||
if (direct_3d_) {
|
||||
direct_3d_->set_vsync(vsync);
|
||||
Logger::Get().Log("Setting Vsync to " + std::to_string(vsync), __FILE__, __LINE__);
|
||||
}
|
||||
};
|
||||
bool get_vsync() const { return vsync_enabled_; };
|
||||
|
||||
HWND get_hwnd() const;
|
||||
void set_hwnd(HWND hwnd);
|
||||
HWND get_hwnd() const { return hwnd_; };
|
||||
void set_hwnd(HWND hwnd) { hwnd_ = hwnd; };
|
||||
|
||||
bool is_windowed() const;
|
||||
void set_windowed(bool windowed);
|
||||
bool is_windowed() const { return windowed_; };
|
||||
void set_windowed(bool windowed) { windowed_ = windowed; };
|
||||
|
||||
void set_window_size(const ImVec2 size) { window_size_ = size; };
|
||||
ImVec2 get_window_size() const { return window_size_; };
|
||||
@@ -149,6 +159,7 @@ public:
|
||||
void set_frustum(const frustum& frustum) { frustum_culling_ = frustum; };
|
||||
|
||||
void construct_frustum();
|
||||
|
||||
int get_render_count() const { return render_count_; };
|
||||
void set_render_count(const int render_count) { render_count_ = render_count; };
|
||||
float get_frustum_tolerance() const { return frustum_culling_tolerance_; };
|
||||
@@ -162,18 +173,23 @@ public:
|
||||
stats* get_stats() const { return stats_; };
|
||||
fps_class* get_fps() const { return fps_; };
|
||||
|
||||
ecs::EntityManager* get_entity_manager() const { return entity_manager_.get(); };
|
||||
void update_stats_after_modification();
|
||||
std::map<std::string, std::shared_ptr<model_class>>& get_model_cache() { return g_model_cache; }
|
||||
|
||||
private:
|
||||
bool render(float, float, float, float, float);
|
||||
bool render_physics(bool key_left, bool key_right, bool key_up, bool key_down, float delta_time);
|
||||
bool render_physics(float delta_time);
|
||||
bool update_mouse_strings(int, int, bool);
|
||||
bool update_fps();
|
||||
bool update_render_count_string(int);
|
||||
bool render_scene_to_texture(float);
|
||||
bool render_refraction_to_texture();
|
||||
bool render_reflection_to_texture();
|
||||
bool render_pass(const std::vector<std::reference_wrapper<std::vector<object*>>>& RenderQueues, XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
|
||||
bool render_pass(XMFLOAT4* diffuse, XMFLOAT4* position, XMFLOAT4* ambient, XMMATRIX view, XMMATRIX projection);
|
||||
|
||||
void update_skybox_position();
|
||||
void culling_thread_function();
|
||||
|
||||
public :
|
||||
std::vector<ID3D11ShaderResourceView*> textures;
|
||||
@@ -184,8 +200,6 @@ private :
|
||||
std::thread culling_thread_;
|
||||
std::atomic<bool> culling_active_;
|
||||
std::mutex objects_mutex_;
|
||||
void culling_thread_function();
|
||||
|
||||
|
||||
std::mutex terrain_mutex_;
|
||||
std::vector<std::tuple<float, float, float, std::string, int>> terrain_generation_data_;
|
||||
@@ -226,14 +240,13 @@ private :
|
||||
// ------------- OBJECTS -------------- //
|
||||
// ------------------------------------ //
|
||||
|
||||
std::unique_ptr<ecs::EntityManager> entity_manager_;
|
||||
|
||||
object* selected_object_;
|
||||
std::vector<object*> cubes_;
|
||||
std::vector<object*> terrain_chunk_;
|
||||
|
||||
float speed_ = 0.1f; // speed for the demo spinning object
|
||||
std::vector<object*> object_;
|
||||
std::vector<object*> imported_object_;
|
||||
int object_id_ = 0;
|
||||
std::vector<std::reference_wrapper<std::vector<object*>>> render_queues_;
|
||||
std::vector<object*> skybox_;
|
||||
|
||||
// ----------------------------------- //
|
||||
|
40
enginecustom/src/inc/system/ecs/component.h
Normal file
40
enginecustom/src/inc/system/ecs/component.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#pragma once
|
||||
#include <memory>
|
||||
#include <typeindex>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
// Classe de base pour tous les composants
|
||||
class Component {
|
||||
public:
|
||||
Component() = default;
|
||||
virtual ~Component() = default;
|
||||
|
||||
// Emp<6D>cher la copie
|
||||
Component(const Component&) = delete;
|
||||
Component& operator=(const Component&) = delete;
|
||||
|
||||
// Permettre le d<>placement
|
||||
Component(Component&&) = default;
|
||||
Component& operator=(Component&&) = default;
|
||||
|
||||
// Fonction virtuelle pour initialiser le composant
|
||||
virtual void Initialize() {}
|
||||
|
||||
// Fonction virtuelle pour la mise <20> jour du composant
|
||||
virtual void Update(float deltaTime) {}
|
||||
};
|
||||
|
||||
// Alias utiles
|
||||
using ComponentPtr = std::shared_ptr<Component>;
|
||||
using ComponentTypeID = std::type_index;
|
||||
|
||||
// Fonction pour obtenir l'ID de type d'un composant
|
||||
template<typename T>
|
||||
ComponentTypeID GetComponentTypeID() {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
return std::type_index(typeid(T));
|
||||
}
|
||||
|
||||
} // namespace ecs
|
@@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include <string>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
enum class ObjectType
|
||||
{
|
||||
Sphere,
|
||||
Cube,
|
||||
Terrain,
|
||||
Unknown
|
||||
};
|
||||
|
||||
class IdentityComponent : public Component {
|
||||
public:
|
||||
IdentityComponent() : m_id(0), m_type(ObjectType::Unknown) {}
|
||||
explicit IdentityComponent(int id) : m_id(id), m_type(ObjectType::Unknown) {}
|
||||
IdentityComponent(int id, const std::string& name) : m_id(id), m_name(name), m_type(ObjectType::Unknown) {}
|
||||
~IdentityComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
// Getters et setters
|
||||
int GetId() const { return m_id; }
|
||||
void SetId(int id) { m_id = id; }
|
||||
|
||||
const std::string& GetName() const { return m_name; }
|
||||
void SetName(const std::string& name) { m_name = name; }
|
||||
|
||||
ObjectType GetType() const { return m_type; }
|
||||
void SetType(ObjectType type) { m_type = type; }
|
||||
|
||||
// Conversions utiles
|
||||
static std::string ObjectTypeToString(ObjectType type) {
|
||||
switch (type) {
|
||||
case ObjectType::Cube: return "Cube";
|
||||
case ObjectType::Sphere: return "Sphere";
|
||||
case ObjectType::Terrain: return "Terrain";
|
||||
default: return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
static ObjectType StringToObjectType(const std::string& str) {
|
||||
if (str == "Cube") return ObjectType::Cube;
|
||||
if (str == "Sphere") return ObjectType::Sphere;
|
||||
if (str == "Terrain") return ObjectType::Terrain;
|
||||
return ObjectType::Unknown;
|
||||
}
|
||||
|
||||
private:
|
||||
int m_id;
|
||||
std::string m_name;
|
||||
ObjectType m_type;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include <string>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class ModelPathComponent : public Component {
|
||||
public:
|
||||
ModelPathComponent() = default;
|
||||
explicit ModelPathComponent(const std::wstring& path) : m_path(path) {}
|
||||
~ModelPathComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
// Getters et setters
|
||||
const std::wstring& GetPath() const { return m_path; }
|
||||
void SetPath(const std::wstring& path) { m_path = path; }
|
||||
|
||||
private:
|
||||
std::wstring m_path;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
110
enginecustom/src/inc/system/ecs/components/physics_component.h
Normal file
110
enginecustom/src/inc/system/ecs/components/physics_component.h
Normal file
@@ -0,0 +1,110 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include <DirectXMath.h>
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class PhysicsComponent : public Component {
|
||||
public:
|
||||
PhysicsComponent() {
|
||||
m_Velocity = XMVectorZero();
|
||||
m_Acceleration = XMVectorZero();
|
||||
m_PreviousPosition = XMVectorZero();
|
||||
m_Mass = 1.0f;
|
||||
m_BoundingRadius = 1.0f;
|
||||
m_IsGrounded = false;
|
||||
m_IsPhysicsEnabled = false;
|
||||
m_GravityEnabled = true;
|
||||
}
|
||||
|
||||
~PhysicsComponent() = default;
|
||||
|
||||
void Initialize() override {
|
||||
// Initialisation du composant physique
|
||||
}
|
||||
|
||||
void Update(float deltaTime) override {
|
||||
if (!m_IsPhysicsEnabled) return;
|
||||
|
||||
// Mise <20> jour de la v<>locit<69> bas<61>e sur l'acc<63>l<EFBFBD>ration
|
||||
m_Velocity = m_Velocity + m_Acceleration * deltaTime;
|
||||
|
||||
// Si la physique est activ<69>e et qu'une fonction de mise <20> jour de position est d<>finie
|
||||
if (m_UpdatePositionCallback) {
|
||||
m_UpdatePositionCallback(m_Velocity * deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
// Lancement d'un objet
|
||||
void LaunchObject(float alpha, float initialStretch, float springConstant) {
|
||||
// Constants
|
||||
const float gravity = -9.81f;
|
||||
|
||||
// Convert alpha from degrees to radians if needed
|
||||
float alphaRadians = alpha * (XM_PI / 180.0f);
|
||||
|
||||
// Scale factors to make the physics simulation more visible
|
||||
float scaleFactor = 200.0f; // Adjust this based on your world scale
|
||||
|
||||
// Calculate initial velocity magnitude
|
||||
float velocityMagnitude = initialStretch * sqrtf(springConstant / m_Mass) *
|
||||
sqrtf(1.0f - powf((m_Mass * gravity * sinf(alphaRadians) /
|
||||
(springConstant * initialStretch)), 2.0f));
|
||||
|
||||
// Apply scale factor
|
||||
velocityMagnitude *= scaleFactor;
|
||||
|
||||
// Calculate velocity components
|
||||
XMVECTOR velocity = XMVectorSet(
|
||||
velocityMagnitude * cosf(alphaRadians), // vx = v0 * cos(alpha)
|
||||
velocityMagnitude * sinf(alphaRadians), // vy = v0 * sin(alpha)
|
||||
0.0f, // z-component (0 for 2D trajectory)
|
||||
0.0f
|
||||
);
|
||||
|
||||
// Apply velocity
|
||||
SetVelocity(velocity);
|
||||
|
||||
// Enable physics and reset grounded state
|
||||
SetPhysicsEnabled(true);
|
||||
SetGrounded(false);
|
||||
}
|
||||
|
||||
// Setters
|
||||
void SetVelocity(XMVECTOR velocity) { m_Velocity = velocity; }
|
||||
void SetAcceleration(XMVECTOR acceleration) { m_Acceleration = acceleration; }
|
||||
void SetMass(float mass) { m_Mass = mass; }
|
||||
void SetGrounded(bool isGrounded) { m_IsGrounded = isGrounded; }
|
||||
void SetPhysicsEnabled(bool enabled) { m_IsPhysicsEnabled = enabled; }
|
||||
void SetBoundingRadius(float radius) { m_BoundingRadius = radius; }
|
||||
void SetPreviousPosition(XMVECTOR position) { m_PreviousPosition = position; }
|
||||
void SetGravityEnabled(bool enabled) { m_GravityEnabled = enabled; }
|
||||
void SetUpdatePositionCallback(std::function<void(XMVECTOR)> callback) { m_UpdatePositionCallback = callback; }
|
||||
|
||||
// Getters
|
||||
XMVECTOR GetVelocity() const { return m_Velocity; }
|
||||
XMVECTOR GetAcceleration() const { return m_Acceleration; }
|
||||
float GetMass() const { return m_Mass; }
|
||||
bool IsGrounded() const { return m_IsGrounded; }
|
||||
bool IsPhysicsEnabled() const { return m_IsPhysicsEnabled; }
|
||||
float GetBoundingRadius() const { return m_BoundingRadius; }
|
||||
XMVECTOR GetPreviousPosition() const { return m_PreviousPosition; }
|
||||
bool IsGravityEnabled() const { return m_GravityEnabled; }
|
||||
|
||||
private:
|
||||
XMVECTOR m_Velocity;
|
||||
XMVECTOR m_Acceleration;
|
||||
XMVECTOR m_PreviousPosition;
|
||||
float m_Mass;
|
||||
float m_BoundingRadius;
|
||||
bool m_IsGrounded;
|
||||
bool m_IsPhysicsEnabled;
|
||||
bool m_GravityEnabled;
|
||||
|
||||
// Callback pour mettre <20> jour la position (sera connect<63> au TransformComponent)
|
||||
std::function<void(XMVECTOR)> m_UpdatePositionCallback;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
124
enginecustom/src/inc/system/ecs/components/render_component.h
Normal file
124
enginecustom/src/inc/system/ecs/components/render_component.h
Normal file
@@ -0,0 +1,124 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include "model_class.h"
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <WICTextureLoader.h>
|
||||
|
||||
// D<>claration externe de la variable globale d<>finie dans application_class.h
|
||||
extern std::map<std::string, std::shared_ptr<model_class>> g_model_cache;
|
||||
|
||||
namespace ecs {
|
||||
|
||||
enum class TextureType
|
||||
{
|
||||
Diffuse,
|
||||
Normal,
|
||||
Specular,
|
||||
Alpha,
|
||||
Reflection
|
||||
};
|
||||
|
||||
class RenderComponent : public Component {
|
||||
public:
|
||||
RenderComponent() : m_model(nullptr), m_isVisible(true) {}
|
||||
~RenderComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
// Initialisation avec un mod<6F>le existant
|
||||
bool InitializeWithModel(std::shared_ptr<model_class> model) {
|
||||
if (!model) return false;
|
||||
m_model = model;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Initialisation avec un chemin de fichier
|
||||
bool InitializeFromFile(ID3D11Device* device, ID3D11DeviceContext* deviceContext,
|
||||
const char* modelFilename, TextureContainer& textureContainer) {
|
||||
// V<>rifier si le mod<6F>le existe d<>j<EFBFBD> dans le cache
|
||||
std::string filename(modelFilename);
|
||||
auto it = g_model_cache.find(filename);
|
||||
if (it != g_model_cache.end()) {
|
||||
m_model = it->second;
|
||||
} else {
|
||||
// Cr<43>er un nouveau mod<6F>le
|
||||
auto new_model = std::make_shared<model_class>();
|
||||
if (!new_model->Initialize(device, deviceContext, const_cast<char*>(modelFilename), textureContainer)) {
|
||||
return false;
|
||||
}
|
||||
g_model_cache[filename] = new_model;
|
||||
m_model = new_model;
|
||||
}
|
||||
|
||||
m_modelFilePath = modelFilename;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Charger des textures depuis un chemin
|
||||
bool LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, TextureContainer& texturesContainer,
|
||||
ID3D11Device* device, ID3D11DeviceContext* deviceContext) {
|
||||
HRESULT result;
|
||||
|
||||
int i = 0;
|
||||
for (const auto& texturePath : texturePaths) {
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(result)) {
|
||||
return false;
|
||||
}
|
||||
texturesContainer.AssignTexture(texturesContainer, texture, texturePath, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Getters et setters
|
||||
std::shared_ptr<model_class> GetModel() const { return m_model; }
|
||||
void SetModel(std::shared_ptr<model_class> model) { m_model = model; }
|
||||
|
||||
const std::string& GetModelFilePath() const { return m_modelFilePath; }
|
||||
void SetModelFilePath(const std::string& path) { m_modelFilePath = path; }
|
||||
|
||||
bool IsVisible() const { return m_isVisible; }
|
||||
void SetVisible(bool visible) { m_isVisible = visible; }
|
||||
|
||||
// Acc<63>s aux textures
|
||||
ID3D11ShaderResourceView* GetTexture(TextureType type, int index = 0) {
|
||||
if (!m_model) return nullptr;
|
||||
|
||||
switch (type) {
|
||||
case TextureType::Diffuse:
|
||||
return m_model->GetTexture(::TextureType::Diffuse, index);
|
||||
case TextureType::Normal:
|
||||
return m_model->GetTexture(::TextureType::Normal, index);
|
||||
case TextureType::Specular:
|
||||
return m_model->GetTexture(::TextureType::Specular, index);
|
||||
case TextureType::Alpha:
|
||||
return m_model->GetTexture(::TextureType::Alpha, index);
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Pour le rendu
|
||||
int GetIndexCount() const {
|
||||
return m_model ? m_model->GetIndexCount() : 0;
|
||||
}
|
||||
|
||||
void Render(ID3D11DeviceContext* deviceContext) {
|
||||
if (m_model && m_isVisible) {
|
||||
m_model->Render(deviceContext);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::shared_ptr<model_class> m_model;
|
||||
std::string m_modelFilePath;
|
||||
bool m_isVisible;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
@@ -0,0 +1,67 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
|
||||
namespace ecs {
|
||||
|
||||
enum class ShaderType
|
||||
{
|
||||
CEL_SHADING,
|
||||
LIGHTING,
|
||||
NORMAL_MAPPING,
|
||||
SPECULAR_MAPPING,
|
||||
REFLECTION,
|
||||
REFRACTION,
|
||||
TEXTURE,
|
||||
SKYBOX,
|
||||
SUNLIGHT,
|
||||
ALPHA_MAPPING
|
||||
};
|
||||
|
||||
class ShaderComponent : public Component {
|
||||
public:
|
||||
ShaderComponent() : m_activeShader(ShaderType::LIGHTING) {}
|
||||
~ShaderComponent() = default;
|
||||
|
||||
void Initialize() override {}
|
||||
void Update(float deltaTime) override {}
|
||||
|
||||
// Getters et setters
|
||||
ShaderType GetActiveShader() const { return m_activeShader; }
|
||||
void SetActiveShader(ShaderType shader) { m_activeShader = shader; }
|
||||
|
||||
// Conversions utiles
|
||||
static ShaderType StringToShaderType(const std::string& str) {
|
||||
if (str == "ALPHA_MAPPING") return ShaderType::ALPHA_MAPPING;
|
||||
if (str == "CEL_SHADING") return ShaderType::CEL_SHADING;
|
||||
if (str == "NORMAL_MAPPING") return ShaderType::NORMAL_MAPPING;
|
||||
if (str == "SPECULAR_MAPPING") return ShaderType::SPECULAR_MAPPING;
|
||||
if (str == "TEXTURE") return ShaderType::TEXTURE;
|
||||
if (str == "LIGHTING") return ShaderType::LIGHTING;
|
||||
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
|
||||
if (str == "SKYBOX") return ShaderType::SKYBOX;
|
||||
if (str == "REFLECTION") return ShaderType::REFLECTION;
|
||||
if (str == "REFRACTION") return ShaderType::REFRACTION;
|
||||
return ShaderType::TEXTURE;
|
||||
}
|
||||
|
||||
static std::string ShaderTypeToString(ShaderType type) {
|
||||
switch (type) {
|
||||
case ShaderType::ALPHA_MAPPING: return "ALPHA_MAPPING";
|
||||
case ShaderType::CEL_SHADING: return "CEL_SHADING";
|
||||
case ShaderType::NORMAL_MAPPING: return "NORMAL_MAPPING";
|
||||
case ShaderType::SPECULAR_MAPPING: return "SPECULAR_MAPPING";
|
||||
case ShaderType::TEXTURE: return "TEXTURE";
|
||||
case ShaderType::LIGHTING: return "LIGHTING";
|
||||
case ShaderType::SUNLIGHT: return "SUNLIGHT";
|
||||
case ShaderType::SKYBOX: return "SKYBOX";
|
||||
case ShaderType::REFLECTION: return "REFLECTION";
|
||||
case ShaderType::REFRACTION: return "REFRACTION";
|
||||
default: return "TEXTURE";
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
ShaderType m_activeShader;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
101
enginecustom/src/inc/system/ecs/components/transform_component.h
Normal file
101
enginecustom/src/inc/system/ecs/components/transform_component.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
#include "../component.h"
|
||||
#include <DirectXMath.h>
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class TransformComponent : public Component {
|
||||
public:
|
||||
TransformComponent() {
|
||||
m_ScaleMatrix = XMMatrixIdentity();
|
||||
m_RotateMatrix = XMMatrixIdentity();
|
||||
m_TranslateMatrix = XMMatrixIdentity();
|
||||
m_WorldMatrix = XMMatrixIdentity();
|
||||
}
|
||||
|
||||
~TransformComponent() = default;
|
||||
|
||||
// M<>thodes pour les matrices
|
||||
void SetPosition(XMVECTOR position) {
|
||||
XMFLOAT4X4 matrix;
|
||||
XMStoreFloat4x4(&matrix, m_TranslateMatrix);
|
||||
matrix._41 = XMVectorGetX(position);
|
||||
matrix._42 = XMVectorGetY(position);
|
||||
matrix._43 = XMVectorGetZ(position);
|
||||
m_TranslateMatrix = XMLoadFloat4x4(&matrix);
|
||||
UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
void SetRotation(XMVECTOR rotation) {
|
||||
m_RotateMatrix = XMMatrixRotationRollPitchYawFromVector(rotation);
|
||||
UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
void SetScale(XMVECTOR scale) {
|
||||
XMFLOAT4X4 matrix;
|
||||
XMStoreFloat4x4(&matrix, m_ScaleMatrix);
|
||||
matrix._11 = XMVectorGetX(scale);
|
||||
matrix._22 = XMVectorGetY(scale);
|
||||
matrix._33 = XMVectorGetZ(scale);
|
||||
m_ScaleMatrix = XMLoadFloat4x4(&matrix);
|
||||
UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
XMVECTOR GetPosition() const {
|
||||
XMFLOAT4X4 matrix;
|
||||
XMStoreFloat4x4(&matrix, m_TranslateMatrix);
|
||||
return XMVectorSet(matrix._41, matrix._42, matrix._43, 0.0f);
|
||||
}
|
||||
|
||||
XMVECTOR GetRotation() const {
|
||||
XMFLOAT4X4 matrix;
|
||||
XMStoreFloat4x4(&matrix, m_RotateMatrix);
|
||||
float rotationX = atan2f(matrix._32, matrix._33);
|
||||
float rotationY = atan2f(-matrix._31, sqrtf(matrix._32 * matrix._32 + matrix._33 * matrix._33));
|
||||
float rotationZ = atan2f(matrix._21, matrix._11);
|
||||
return XMVectorSet(rotationX, rotationY, rotationZ, 0.0f);
|
||||
}
|
||||
|
||||
XMVECTOR GetScale() const {
|
||||
XMFLOAT4X4 matrix;
|
||||
XMStoreFloat4x4(&matrix, m_ScaleMatrix);
|
||||
|
||||
XMVECTOR row1 = XMLoadFloat3(reinterpret_cast<XMFLOAT3*>(&matrix._11));
|
||||
XMVECTOR row2 = XMLoadFloat3(reinterpret_cast<XMFLOAT3*>(&matrix._21));
|
||||
XMVECTOR row3 = XMLoadFloat3(reinterpret_cast<XMFLOAT3*>(&matrix._31));
|
||||
|
||||
XMVECTOR scale = XMVectorSet(
|
||||
XMVectorGetX(XMVector3Length(row1)),
|
||||
XMVectorGetX(XMVector3Length(row2)),
|
||||
XMVectorGetX(XMVector3Length(row3)),
|
||||
0.0f
|
||||
);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
void UpdateWorldMatrix() {
|
||||
m_WorldMatrix = m_ScaleMatrix * m_RotateMatrix * m_TranslateMatrix;
|
||||
}
|
||||
|
||||
// Getters pour les matrices
|
||||
XMMATRIX GetScaleMatrix() const { return m_ScaleMatrix; }
|
||||
XMMATRIX GetRotateMatrix() const { return m_RotateMatrix; }
|
||||
XMMATRIX GetTranslateMatrix() const { return m_TranslateMatrix; }
|
||||
XMMATRIX GetWorldMatrix() const { return m_WorldMatrix; }
|
||||
|
||||
// Setters pour les matrices
|
||||
void SetScaleMatrix(XMMATRIX matrix) { m_ScaleMatrix = matrix; UpdateWorldMatrix(); }
|
||||
void SetRotateMatrix(XMMATRIX matrix) { m_RotateMatrix = matrix; UpdateWorldMatrix(); }
|
||||
void SetTranslateMatrix(XMMATRIX matrix) { m_TranslateMatrix = matrix; UpdateWorldMatrix(); }
|
||||
|
||||
private:
|
||||
XMMATRIX m_ScaleMatrix;
|
||||
XMMATRIX m_RotateMatrix;
|
||||
XMMATRIX m_TranslateMatrix;
|
||||
XMMATRIX m_WorldMatrix;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
101
enginecustom/src/inc/system/ecs/entity.h
Normal file
101
enginecustom/src/inc/system/ecs/entity.h
Normal file
@@ -0,0 +1,101 @@
|
||||
#pragma once
|
||||
#include "component.h"
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
// Identifiant unique pour les entit<69>s
|
||||
using EntityID = uint32_t;
|
||||
|
||||
class Entity {
|
||||
public:
|
||||
explicit Entity(EntityID id) : m_ID(id) {}
|
||||
~Entity() = default;
|
||||
|
||||
// Emp<6D>cher la copie
|
||||
Entity(const Entity&) = delete;
|
||||
Entity& operator=(const Entity&) = delete;
|
||||
|
||||
// Permettre le d<>placement
|
||||
Entity(Entity&&) = default;
|
||||
Entity& operator=(Entity&&) = default;
|
||||
|
||||
// Getter pour l'ID
|
||||
EntityID GetID() const { return m_ID; }
|
||||
|
||||
// Ajouter un composant
|
||||
template<typename T, typename... Args>
|
||||
std::shared_ptr<T> AddComponent(Args&&... args) {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
|
||||
ComponentTypeID typeID = GetComponentTypeID<T>();
|
||||
|
||||
// V<>rifier si le composant existe d<>j<EFBFBD>
|
||||
if (m_Components.find(typeID) != m_Components.end()) {
|
||||
return std::static_pointer_cast<T>(m_Components[typeID]);
|
||||
}
|
||||
|
||||
// Cr<43>er et ajouter le composant
|
||||
auto component = std::make_shared<T>(std::forward<Args>(args)...);
|
||||
m_Components[typeID] = component;
|
||||
|
||||
// Initialiser le composant
|
||||
component->Initialize();
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
// R<>cup<75>rer un composant
|
||||
template<typename T>
|
||||
std::shared_ptr<T> GetComponent() {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
|
||||
ComponentTypeID typeID = GetComponentTypeID<T>();
|
||||
|
||||
auto it = m_Components.find(typeID);
|
||||
if (it != m_Components.end()) {
|
||||
return std::static_pointer_cast<T>(it->second);
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// V<>rifier si l'entit<69> poss<73>de un composant
|
||||
template<typename T>
|
||||
bool HasComponent() const {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
|
||||
ComponentTypeID typeID = GetComponentTypeID<T>();
|
||||
return m_Components.find(typeID) != m_Components.end();
|
||||
}
|
||||
|
||||
// Supprimer un composant
|
||||
template<typename T>
|
||||
void RemoveComponent() {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
|
||||
ComponentTypeID typeID = GetComponentTypeID<T>();
|
||||
auto it = m_Components.find(typeID);
|
||||
|
||||
if (it != m_Components.end()) {
|
||||
m_Components.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// Mettre <20> jour tous les composants
|
||||
void UpdateComponents(float deltaTime) {
|
||||
for (auto& [typeID, component] : m_Components) {
|
||||
component->Update(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
EntityID m_ID;
|
||||
std::unordered_map<ComponentTypeID, ComponentPtr> m_Components;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
107
enginecustom/src/inc/system/ecs/entity_manager.h
Normal file
107
enginecustom/src/inc/system/ecs/entity_manager.h
Normal file
@@ -0,0 +1,107 @@
|
||||
#pragma once
|
||||
#include "entity.h"
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <queue>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class EntityManager {
|
||||
public:
|
||||
EntityManager() : m_NextEntityID(0) {}
|
||||
~EntityManager() = default;
|
||||
|
||||
// Cr<43>er une nouvelle entit<69>
|
||||
std::shared_ptr<Entity> CreateEntity() {
|
||||
EntityID id;
|
||||
|
||||
// R<>utiliser les IDs des entit<69>s supprim<69>es si possible
|
||||
if (!m_FreeIDs.empty()) {
|
||||
id = m_FreeIDs.front();
|
||||
m_FreeIDs.pop();
|
||||
} else {
|
||||
id = m_NextEntityID++;
|
||||
}
|
||||
|
||||
auto entity = std::make_shared<Entity>(id);
|
||||
m_Entities[id] = entity;
|
||||
|
||||
return entity;
|
||||
}
|
||||
|
||||
// Supprimer une entit<69>
|
||||
void DestroyEntity(EntityID id) {
|
||||
auto it = m_Entities.find(id);
|
||||
if (it != m_Entities.end()) {
|
||||
m_Entities.erase(it);
|
||||
m_FreeIDs.push(id); // Recycler l'ID
|
||||
}
|
||||
}
|
||||
|
||||
// Obtenir une entit<69> par son ID
|
||||
std::shared_ptr<Entity> GetEntity(EntityID id) {
|
||||
auto it = m_Entities.find(id);
|
||||
if (it != m_Entities.end()) {
|
||||
return it->second;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Mettre <20> jour toutes les entit<69>s
|
||||
void UpdateEntities(float deltaTime) {
|
||||
for (auto& [id, entity] : m_Entities) {
|
||||
entity->UpdateComponents(deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
// Obtenir toutes les entit<69>s
|
||||
std::vector<std::shared_ptr<Entity>> GetAllEntities() {
|
||||
std::vector<std::shared_ptr<Entity>> result;
|
||||
result.reserve(m_Entities.size());
|
||||
|
||||
for (const auto& [id, entity] : m_Entities) {
|
||||
result.push_back(entity);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Obtenir toutes les entit<69>s qui ont un composant sp<73>cifique
|
||||
template<typename T>
|
||||
std::vector<std::shared_ptr<Entity>> GetEntitiesWithComponent() {
|
||||
static_assert(std::is_base_of<Component, T>::value, "T must derive from Component");
|
||||
|
||||
std::vector<std::shared_ptr<Entity>> result;
|
||||
|
||||
for (auto& [id, entity] : m_Entities) {
|
||||
if (entity->HasComponent<T>()) {
|
||||
result.push_back(entity);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Obtenir le nombre d'entit<69>s
|
||||
size_t GetEntityCount() const {
|
||||
return m_Entities.size();
|
||||
}
|
||||
|
||||
// Vider toutes les entit<69>s
|
||||
void Clear() {
|
||||
m_Entities.clear();
|
||||
|
||||
// Vider la file des IDs libres
|
||||
std::queue<EntityID> empty;
|
||||
std::swap(m_FreeIDs, empty);
|
||||
|
||||
m_NextEntityID = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
EntityID m_NextEntityID;
|
||||
std::unordered_map<EntityID, std::shared_ptr<Entity>> m_Entities;
|
||||
std::queue<EntityID> m_FreeIDs; // IDs <20> r<>utiliser
|
||||
};
|
||||
|
||||
} // namespace ecs
|
222
enginecustom/src/inc/system/ecs/systems/render_system.h
Normal file
222
enginecustom/src/inc/system/ecs/systems/render_system.h
Normal file
@@ -0,0 +1,222 @@
|
||||
#pragma once
|
||||
#include "../entity_manager.h"
|
||||
#include "../components/render_component.h"
|
||||
#include "../components/transform_component.h"
|
||||
#include "../components/shader_component.h"
|
||||
#include "shader_manager_class.h"
|
||||
#include <DirectXMath.h>
|
||||
|
||||
namespace ecs {
|
||||
|
||||
class RenderSystem {
|
||||
public:
|
||||
RenderSystem(ID3D11DeviceContext* deviceContext, shader_manager_class* shaderManager)
|
||||
: m_deviceContext(deviceContext), m_shaderManager(shaderManager) {}
|
||||
|
||||
// Rendu d'une entit<69> sp<73>cifique
|
||||
bool RenderEntity(std::shared_ptr<Entity> entity,
|
||||
const DirectX::XMMATRIX& viewMatrix,
|
||||
const DirectX::XMMATRIX& projectionMatrix,
|
||||
const DirectX::XMFLOAT4* diffuseColors,
|
||||
const DirectX::XMFLOAT4* lightPositions,
|
||||
const DirectX::XMFLOAT4* ambientColors,
|
||||
const DirectX::XMFLOAT3& cameraPosition,
|
||||
const DirectX::XMFLOAT4& sunlightDiffuse,
|
||||
const DirectX::XMFLOAT4& sunlightAmbient,
|
||||
const DirectX::XMFLOAT3& sunlightDirection,
|
||||
float sunlightIntensity) {
|
||||
|
||||
// V<>rifier si l'entit<69> a tous les composants n<>cessaires
|
||||
auto transform = entity->GetComponent<TransformComponent>();
|
||||
auto render = entity->GetComponent<RenderComponent>();
|
||||
auto shader = entity->GetComponent<ShaderComponent>();
|
||||
|
||||
if (!transform || !render || !shader || !render->GetModel())
|
||||
return false;
|
||||
|
||||
// Calculer la matrice monde
|
||||
XMMATRIX scaleMatrix = transform->GetScaleMatrix();
|
||||
XMMATRIX rotateMatrix = transform->GetRotateMatrix();
|
||||
XMMATRIX translateMatrix = transform->GetTranslateMatrix();
|
||||
|
||||
XMMATRIX worldMatrix = XMMatrixMultiply(
|
||||
XMMatrixMultiply(scaleMatrix, rotateMatrix),
|
||||
translateMatrix
|
||||
);
|
||||
|
||||
// Rendre le mod<6F>le
|
||||
render->Render(m_deviceContext);
|
||||
|
||||
// S<>lectionner le shader appropri<72>
|
||||
switch (shader->GetActiveShader()) {
|
||||
case ShaderType::ALPHA_MAPPING:
|
||||
return m_shaderManager->render_alpha_map_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
render->GetTexture(TextureType::Diffuse, 1),
|
||||
render->GetTexture(TextureType::Alpha, 0)
|
||||
);
|
||||
|
||||
case ShaderType::CEL_SHADING:
|
||||
return m_shaderManager->render_cel_shading_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
sunlightDiffuse,
|
||||
sunlightAmbient,
|
||||
sunlightDirection,
|
||||
sunlightIntensity
|
||||
);
|
||||
|
||||
case ShaderType::NORMAL_MAPPING:
|
||||
return m_shaderManager->render_normal_map_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
render->GetTexture(TextureType::Normal, 0),
|
||||
sunlightDirection,
|
||||
sunlightDiffuse
|
||||
);
|
||||
|
||||
case ShaderType::SPECULAR_MAPPING:
|
||||
|
||||
return m_shaderManager->render_spec_map_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
render->GetTexture(TextureType::Normal, 0),
|
||||
render->GetTexture(TextureType::Specular, 0),
|
||||
sunlightDirection,
|
||||
sunlightDiffuse,
|
||||
cameraPosition,
|
||||
sunlightDiffuse, // Couleur speculaire (<28> ajuster)
|
||||
16.0f // Puissance speculaire (<28> ajuster)
|
||||
);
|
||||
|
||||
case ShaderType::LIGHTING:
|
||||
{
|
||||
// Cr<43>er des copies locales non constantes des tableaux
|
||||
DirectX::XMFLOAT4 localDiffuseColors[4];
|
||||
DirectX::XMFLOAT4 localLightPositions[4];
|
||||
DirectX::XMFLOAT4 localAmbientColors[4];
|
||||
|
||||
// Copier les donn<6E>es
|
||||
for (int i = 0; i < 4; i++) {
|
||||
localDiffuseColors[i] = diffuseColors[i];
|
||||
localLightPositions[i] = lightPositions[i];
|
||||
localAmbientColors[i] = ambientColors[i];
|
||||
}
|
||||
|
||||
return m_shaderManager->renderlight_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
localDiffuseColors,
|
||||
localLightPositions,
|
||||
localAmbientColors
|
||||
);
|
||||
}
|
||||
|
||||
case ShaderType::SUNLIGHT:
|
||||
return m_shaderManager->render_sunlight_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
sunlightDiffuse,
|
||||
sunlightAmbient,
|
||||
sunlightDirection,
|
||||
sunlightIntensity
|
||||
);
|
||||
|
||||
case ShaderType::SKYBOX:
|
||||
return m_shaderManager->render_skybox_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0),
|
||||
sunlightDiffuse,
|
||||
sunlightAmbient,
|
||||
sunlightDirection,
|
||||
sunlightIntensity
|
||||
);
|
||||
|
||||
case ShaderType::TEXTURE:
|
||||
default:
|
||||
return m_shaderManager->render_texture_shader(
|
||||
m_deviceContext,
|
||||
render->GetIndexCount(),
|
||||
worldMatrix,
|
||||
viewMatrix,
|
||||
projectionMatrix,
|
||||
render->GetTexture(TextureType::Diffuse, 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Rendu de toutes les entit<69>s avec les composants n<>cessaires
|
||||
int RenderAllEntities(EntityManager* entityManager,
|
||||
const DirectX::XMMATRIX& viewMatrix,
|
||||
const DirectX::XMMATRIX& projectionMatrix,
|
||||
const DirectX::XMFLOAT4* diffuseColors,
|
||||
const DirectX::XMFLOAT4* lightPositions,
|
||||
const DirectX::XMFLOAT4* ambientColors,
|
||||
const DirectX::XMFLOAT3& cameraPos,
|
||||
const DirectX::XMFLOAT4& sunlightDiffuse,
|
||||
const DirectX::XMFLOAT4& sunlightAmbient,
|
||||
const DirectX::XMFLOAT3& sunlightDirection,
|
||||
float sunlightIntensity) {
|
||||
|
||||
int renderCount = 0;
|
||||
|
||||
// R<>cup<75>rer toutes les entit<69>s qui ont les composants RenderComponent et TransformComponent
|
||||
auto entities = entityManager->GetEntitiesWithComponent<RenderComponent>();
|
||||
|
||||
for (auto& entity : entities) {
|
||||
auto render = entity->GetComponent<RenderComponent>();
|
||||
|
||||
// V<>rifier si l'entit<69> a un TransformComponent
|
||||
auto transform = entity->GetComponent<TransformComponent>();
|
||||
if (!transform) continue;
|
||||
|
||||
// V<>rifier si le mod<6F>le est visible
|
||||
if (!render->IsVisible()) continue;
|
||||
|
||||
// Effectuer le rendu
|
||||
if (RenderEntity(entity, viewMatrix, projectionMatrix,
|
||||
diffuseColors, lightPositions, ambientColors,cameraPos,
|
||||
sunlightDiffuse, sunlightAmbient, sunlightDirection,
|
||||
sunlightIntensity)) {
|
||||
renderCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return renderCount;
|
||||
}
|
||||
|
||||
private:
|
||||
ID3D11DeviceContext* m_deviceContext;
|
||||
shader_manager_class* m_shaderManager;
|
||||
};
|
||||
|
||||
} // namespace ecs
|
@@ -57,7 +57,7 @@ public:
|
||||
ImVec2 GetWindowSize() const { return windowSize; }
|
||||
|
||||
// Getters
|
||||
void SetApp(application_class* app) { app_ = app; }
|
||||
void SetApp(std::shared_ptr<application_class> app) { app_ = app; }
|
||||
|
||||
// Shader toggles
|
||||
|
||||
@@ -75,7 +75,7 @@ private:
|
||||
|
||||
std::vector<widget_entry> widgets_;
|
||||
|
||||
application_class* app_;
|
||||
std::shared_ptr<application_class> app_;
|
||||
scene_manager* scene_manager_;
|
||||
stats* stats_;
|
||||
|
||||
@@ -106,9 +106,12 @@ private:
|
||||
|
||||
const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer();
|
||||
|
||||
int current_fps_, min_fps_, max_fps_, draw_calls_, total_vertex_count_, total_triangle_count_, visible_triangle_count_;
|
||||
int current_fps_, min_fps_, max_fps_, draw_calls_, visible_triangle_count_;
|
||||
float current_frame_time_, min_frame_time_, max_frame_time_ ;
|
||||
|
||||
std::shared_ptr<int> total_vertex_count_;
|
||||
std::shared_ptr<int> total_triangle_count_;
|
||||
|
||||
// gpu information
|
||||
char card_name_[128];
|
||||
int video_memory_ = 0;
|
||||
|
@@ -26,15 +26,23 @@ enum class ShaderType
|
||||
ALPHA_MAPPING
|
||||
};
|
||||
|
||||
class object : public model_class
|
||||
class object
|
||||
{
|
||||
public:
|
||||
object(application_class& app);
|
||||
object();
|
||||
~object();
|
||||
|
||||
object(const object&) = delete;
|
||||
object& operator=(const object&) = delete;
|
||||
|
||||
bool Initialize(
|
||||
ID3D11Device* device,
|
||||
ID3D11DeviceContext* deviceContext,
|
||||
char* modelFilename,
|
||||
TextureContainer& texturesContainer
|
||||
);
|
||||
|
||||
void SetScaleMatrix(XMMATRIX scaleMatrix);
|
||||
void SetRotateMatrix(XMMATRIX rotateMatrix);
|
||||
void SetTranslateMatrix(XMMATRIX translateMatrix);
|
||||
@@ -119,6 +127,9 @@ public:
|
||||
bool IsGravityEnabled() const { return m_gravityEnabled; }
|
||||
void SetGravityEnabled(bool state) { m_gravityEnabled = state; }
|
||||
|
||||
std::shared_ptr<model_class> get_model() const { return m_model_; }
|
||||
void SetModel(std::shared_ptr<model_class> model) { m_model_ = model; }
|
||||
|
||||
public :
|
||||
bool m_demoSpinning = false;
|
||||
XMVECTOR m_previousPosition;
|
||||
@@ -127,6 +138,9 @@ public :
|
||||
bool m_gravityEnabled = true;
|
||||
|
||||
private:
|
||||
|
||||
application_class& m_Application;
|
||||
|
||||
XMMATRIX m_scaleMatrix;
|
||||
XMMATRIX m_rotateMatrix;
|
||||
XMMATRIX m_translateMatrix;
|
||||
@@ -150,4 +164,6 @@ private:
|
||||
float m_initialStretch = 0.0f;
|
||||
float m_springConstant = 10.0f;
|
||||
|
||||
std::shared_ptr<model_class> m_model_;
|
||||
|
||||
};
|
||||
|
@@ -3,6 +3,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "ecs/entity.h"
|
||||
|
||||
class d_3d_class;
|
||||
class object;
|
||||
class application_class;
|
||||
@@ -26,6 +28,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
std::vector<std::shared_ptr<ecs::Entity>> entity_;
|
||||
|
||||
application_class* app_;
|
||||
std::string scene_path_;
|
||||
std::vector<object*> object_vec_;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#include "object.h"
|
||||
#include <intrin.h> // Pour __cpuid
|
||||
#include <dxgi.h> // Pour DXGI
|
||||
#include <mutex>
|
||||
#pragma comment(lib, "dxgi.lib")
|
||||
|
||||
class stats
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
|
||||
bool initialize(application_class* app);
|
||||
void update_geometric_stats();
|
||||
void update_visible_count();
|
||||
void update_display_stats();
|
||||
|
||||
int get_total_vertex_count() const;
|
||||
@@ -35,8 +37,11 @@ public:
|
||||
std::string get_cpu_name();
|
||||
std::string get_gpu_driver_version(ID3D11Device* device);
|
||||
|
||||
std::shared_ptr<int>& get_vertex_count_ptr() { return total_vertex_count_; }
|
||||
std::shared_ptr<int>& get_triangle_count_ptr() { return total_triangle_count_; }
|
||||
|
||||
|
||||
private:
|
||||
std::thread update_geometric_thread_;
|
||||
std::thread update_display_thread_;
|
||||
|
||||
fps_class* fps_;
|
||||
@@ -47,8 +52,9 @@ private:
|
||||
std::vector<object*> cubes_vec_;
|
||||
std::vector<object*> terrain_chunk_vec_;
|
||||
|
||||
int total_vertex_count_;
|
||||
int total_triangle_count_;
|
||||
std::shared_ptr<int> total_vertex_count_;
|
||||
std::shared_ptr<int> total_triangle_count_;
|
||||
|
||||
int visible_triangle_count_ = 0;
|
||||
int current_fps_ = 0;
|
||||
int min_fps_ = 0;
|
||||
|
@@ -32,20 +32,12 @@ public:
|
||||
|
||||
void send_path(wchar_t* path, std::filesystem::path w_folder);
|
||||
|
||||
application_class* get_application_class() const { return application_; }
|
||||
void set_application_class(application_class* application) {
|
||||
if (application_) {
|
||||
delete application_;
|
||||
}
|
||||
application_ = application;
|
||||
}
|
||||
input_class* get_input_class() const { return input_; }
|
||||
void set_input(input_class* input) {
|
||||
if (input_) {
|
||||
delete input_;
|
||||
}
|
||||
input_ = input;
|
||||
}
|
||||
std::shared_ptr<application_class> get_application_class() const { return application_; }
|
||||
void set_application_class(std::shared_ptr<application_class> application) { application_ = std::move(application); }
|
||||
|
||||
std::shared_ptr<input_class> get_input_class() const { return input_; }
|
||||
void set_input(std::shared_ptr<input_class> input) { input_ = std::move(input); }
|
||||
|
||||
HWND get_hwnd() const { return hwnd_; }
|
||||
|
||||
void set_d_3D_mock(d_3d_class* mock) {application_->set_direct_3d(mock);}
|
||||
@@ -61,9 +53,9 @@ private:
|
||||
HINSTANCE hinstance_;
|
||||
HWND hwnd_;
|
||||
|
||||
input_class* input_;
|
||||
application_class* application_;
|
||||
imguiManager* imgui_manager_;
|
||||
std::shared_ptr<input_class> input_;
|
||||
std::shared_ptr<application_class> application_;
|
||||
std::shared_ptr<imguiManager> imgui_manager_;
|
||||
|
||||
int initial_window_width_;
|
||||
int initial_window_height_;
|
||||
|
@@ -23,7 +23,7 @@ void Skybox::Initialize(d_3d_class* d3dClassRef)
|
||||
m_d3dClassRef = d3dClassRef;
|
||||
}
|
||||
|
||||
object* Skybox::ConstructSkybox()
|
||||
object* Skybox::ConstructSkybox(application_class* app)
|
||||
{
|
||||
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
@@ -51,7 +51,7 @@ object* Skybox::ConstructSkybox()
|
||||
}
|
||||
|
||||
// Create the model object
|
||||
m_Skybox = new object();
|
||||
m_Skybox = new object(*app);
|
||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
|
||||
if (!result)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -18,6 +18,14 @@ imguiManager::imguiManager()
|
||||
visible_triangle_count_ = 0;
|
||||
current_frame_time_ = 0;
|
||||
|
||||
showObjectWindow = false;
|
||||
showTerrainWindow = false;
|
||||
showLightWindow = false;
|
||||
showOldSceneWindow = false;
|
||||
showEngineSettingsWindow = false;
|
||||
showLogWindow = false;
|
||||
showStatsWindow = false;
|
||||
|
||||
// Initialiser l'historique des frametimes <20> z<>ro
|
||||
for (int i = 0; i < FRAME_HISTORY_COUNT; i++)
|
||||
{
|
||||
@@ -165,13 +173,16 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
|
||||
// initialize the scene manager
|
||||
scene_manager_ = new scene_manager;
|
||||
if (!scene_manager_->initialize(app_)) {
|
||||
if (!scene_manager_->initialize(app_.get())) {
|
||||
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
stats_ = app_->get_stats();
|
||||
|
||||
total_triangle_count_ = stats_->get_triangle_count_ptr();
|
||||
total_vertex_count_ = stats_->get_vertex_count_ptr();
|
||||
|
||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
@@ -375,290 +386,313 @@ void imguiManager::WidgetAddObject()
|
||||
|
||||
}
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Number of cubes: %d", app_->get_cube_count());
|
||||
ImGui::Text("Number of cubes: %d", app_->get_entity_manager()->GetEntityCount());
|
||||
}
|
||||
}
|
||||
|
||||
void imguiManager::WidgetObjectWindow()
|
||||
{
|
||||
ImGui::Begin("Objects", &showObjectWindow);
|
||||
|
||||
// Obtenir toutes les entit<69>s avec un composant d'identit<69> et de transformation
|
||||
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::IdentityComponent>();
|
||||
|
||||
int index = 0;
|
||||
for (auto& object : app_->get_kobjects())
|
||||
for (auto& entity : entities)
|
||||
{
|
||||
std::string headerName = object->GetName() + " " + std::to_string(index);
|
||||
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||
auto identity = entity->GetComponent<ecs::IdentityComponent>();
|
||||
auto transform = entity->GetComponent<ecs::TransformComponent>();
|
||||
auto render = entity->GetComponent<ecs::RenderComponent>();
|
||||
auto shader = entity->GetComponent<ecs::ShaderComponent>();
|
||||
auto physics = entity->GetComponent<ecs::PhysicsComponent>();
|
||||
|
||||
if (identity && transform)
|
||||
{
|
||||
|
||||
XMVECTOR position = object->GetPosition();
|
||||
XMVECTOR rotation = object->GetRotation();
|
||||
XMVECTOR scale = object->GetScale();
|
||||
|
||||
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
|
||||
std::string posLabel = "Position##" + std::to_string(index);
|
||||
if (ImGui::DragFloat3(posLabel.c_str(), pos))
|
||||
std::string headerName = identity->GetName() + " " + std::to_string(identity->GetId());
|
||||
if (ImGui::CollapsingHeader(headerName.c_str()))
|
||||
{
|
||||
object->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
|
||||
}
|
||||
// Position, Rotation, Scale
|
||||
XMVECTOR position = transform->GetPosition();
|
||||
XMVECTOR rotation = transform->GetRotation();
|
||||
XMVECTOR scale = transform->GetScale();
|
||||
|
||||
float rot[3] = { XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation) };
|
||||
std::string rotLabel = "Rotation##" + std::to_string(index);
|
||||
if (ImGui::DragFloat3(rotLabel.c_str(), rot))
|
||||
{
|
||||
object->SetRotation(XMVectorSet(rot[0], rot[1], rot[2], 0.0f));
|
||||
}
|
||||
|
||||
float scl[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
||||
std::string sclLabel = "Scale##" + std::to_string(index);
|
||||
if (ImGui::DragFloat3(sclLabel.c_str(), scl))
|
||||
{
|
||||
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// D<>finir les types de textures_
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse", "Normal", "Specular", "Alpha"
|
||||
};
|
||||
|
||||
std::vector<TextureType> textureTypes = {
|
||||
TextureType::Diffuse, TextureType::Normal,
|
||||
TextureType::Specular, TextureType::Alpha
|
||||
};
|
||||
|
||||
// Cr<43>er un espace pour afficher les textures_ avec d<>filement
|
||||
ImGui::BeginChild("TextureChild", ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
|
||||
// Pour chaque type de texture
|
||||
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||
{
|
||||
TextureType type = textureTypes[typeIndex];
|
||||
std::string typeName = textureCategories[typeIndex];
|
||||
|
||||
// Afficher le titre de la cat<61>gorie
|
||||
ImGui::Text("%s:", typeName.c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
// Compter combien de textures_ de ce type existent
|
||||
int textureCount = 0;
|
||||
while (object->GetTexture(type, textureCount) != nullptr)
|
||||
{
|
||||
textureCount++;
|
||||
}
|
||||
|
||||
// Afficher toutes les textures_ existantes
|
||||
ImGui::BeginGroup();
|
||||
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||
{
|
||||
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 (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Changer la texture existante
|
||||
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 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();
|
||||
|
||||
// Delete button
|
||||
std::string deleteLabel = "Delete##" + std::to_string(index);
|
||||
if (ImGui::Button(deleteLabel.c_str()))
|
||||
{
|
||||
app_->delete_kobject(index);
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Liste des options
|
||||
const char* shaderOptions[] = {
|
||||
"Enable Global Lighting",
|
||||
"Enable Lighting",
|
||||
"Enable Cel Shading",
|
||||
"Enable Normal Mapping",
|
||||
"Enable Specular Mapping",
|
||||
"Enable Alpha Mapping"
|
||||
};
|
||||
|
||||
ShaderType shaderTypes[] = {
|
||||
ShaderType::SUNLIGHT,
|
||||
ShaderType::LIGHTING,
|
||||
ShaderType::CEL_SHADING,
|
||||
ShaderType::NORMAL_MAPPING,
|
||||
ShaderType::SPECULAR_MAPPING,
|
||||
ShaderType::ALPHA_MAPPING
|
||||
};
|
||||
|
||||
// Variable pour stocker l'option s<>lectionn<6E>e
|
||||
static int currentShader = 0; // Index de l'option actuellement s<>lectionn<6E>e
|
||||
|
||||
// Cr<43>ation du menu d<>roulant
|
||||
if (ImGui::BeginCombo("Shader Options", shaderOptions[currentShader]))
|
||||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
|
||||
float pos[3] = { XMVectorGetX(position), XMVectorGetY(position), XMVectorGetZ(position) };
|
||||
std::string posLabel = "Position##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(posLabel.c_str(), pos))
|
||||
{
|
||||
// Cr<43>e une option s<>lectionnable pour chaque shader
|
||||
bool isSelected = (currentShader == i);
|
||||
if (ImGui::Selectable(shaderOptions[i], isSelected))
|
||||
transform->SetPosition(XMVectorSet(pos[0], pos[1], pos[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
float rot[3] = { XMVectorGetX(rotation), XMVectorGetY(rotation), XMVectorGetZ(rotation) };
|
||||
std::string rotLabel = "Rotation##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(rotLabel.c_str(), rot))
|
||||
{
|
||||
transform->SetRotation(XMVectorSet(rot[0], rot[1], rot[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
float scl[3] = { XMVectorGetX(scale), XMVectorGetY(scale), XMVectorGetZ(scale) };
|
||||
std::string sclLabel = "Scale##" + std::to_string(identity->GetId());
|
||||
if (ImGui::DragFloat3(sclLabel.c_str(), scl))
|
||||
{
|
||||
transform->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||
transform->UpdateWorldMatrix();
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Textures - Seulement si le composant de rendu existe
|
||||
if (render && render->GetModel())
|
||||
{
|
||||
// D<>finir les types de textures_
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse", "Normal", "Specular", "Alpha"
|
||||
};
|
||||
|
||||
std::vector<TextureType> textureTypes = {
|
||||
TextureType::Diffuse, TextureType::Normal,
|
||||
TextureType::Specular, TextureType::Alpha
|
||||
};
|
||||
|
||||
// Cr<43>er un espace pour afficher les textures_ avec d<>filement
|
||||
std::string textureChildId = "TextureChild##" + std::to_string(identity->GetId());
|
||||
ImGui::BeginChild(textureChildId.c_str(), ImVec2(0, 200), true, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
|
||||
// Pour chaque type de texture
|
||||
for (int typeIndex = 0; typeIndex < textureCategories.size(); typeIndex++)
|
||||
{
|
||||
// Met <20> jour l'option s<>lectionn<6E>e
|
||||
currentShader = i;
|
||||
object->SetActiveShader(shaderTypes[i]);
|
||||
TextureType type = textureTypes[typeIndex];
|
||||
std::string typeName = textureCategories[typeIndex];
|
||||
|
||||
// Afficher le titre de la cat<61>gorie
|
||||
std::string categoryLabel = typeName + "##" + std::to_string(identity->GetId());
|
||||
ImGui::Text("%s:", typeName.c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
// Compter combien de textures_ de ce type existent
|
||||
int textureCount = 0;
|
||||
while (render->GetModel()->GetTexture(type, textureCount) != nullptr)
|
||||
{
|
||||
textureCount++;
|
||||
}
|
||||
|
||||
// Afficher toutes les textures_ existantes
|
||||
std::string groupId = "TextureGroup_" + std::to_string(identity->GetId()) + "_" + std::to_string(typeIndex);
|
||||
ImGui::BeginGroup();
|
||||
for (int texIndex = 0; texIndex < textureCount; texIndex++)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = render->GetModel()->GetTexture(type, texIndex);
|
||||
if (texture)
|
||||
{
|
||||
// ID unique pour chaque bouton de texture
|
||||
std::string buttonId = "tex##" + std::to_string(identity->GetId()) + "_" +
|
||||
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] = {0};
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
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))
|
||||
{
|
||||
// Changer la texture existante
|
||||
render->GetModel()->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// 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(identity->GetId()) + "_" + 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] = {0};
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
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
|
||||
render->GetModel()->AddTexture(m_device, m_deviceContext, ofn.lpstrFile, type);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndGroup();
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
// Si l'option s<>lectionn<6E>e est active, nous mettons en surbrillance
|
||||
if (isSelected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
ImGui::EndChild();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Delete button
|
||||
std::string deleteLabel = "Delete##" + std::to_string(identity->GetId());
|
||||
if (ImGui::Button(deleteLabel.c_str()))
|
||||
{
|
||||
app_->delete_entity_by_id(identity->GetId());
|
||||
// Sortir du boucle apr<70>s suppression pour <20>viter des acc<63>s invalides
|
||||
break;
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Shader options
|
||||
if (shader)
|
||||
{
|
||||
// Liste des options de shader
|
||||
const char* shaderOptions[] = {
|
||||
"Enable Global Lighting",
|
||||
"Enable Lighting",
|
||||
"Enable Cel Shading",
|
||||
"Enable Normal Mapping",
|
||||
"Enable Specular Mapping",
|
||||
"Enable Alpha Mapping"
|
||||
};
|
||||
|
||||
std::vector<ecs::ShaderType> shaderTypes = {
|
||||
ecs::ShaderType::SUNLIGHT,
|
||||
ecs::ShaderType::LIGHTING,
|
||||
ecs::ShaderType::CEL_SHADING,
|
||||
ecs::ShaderType::NORMAL_MAPPING,
|
||||
ecs::ShaderType::SPECULAR_MAPPING,
|
||||
ecs::ShaderType::ALPHA_MAPPING
|
||||
};
|
||||
|
||||
// Trouver l'index actuel du shader pour cette entit<69> sp<73>cifique
|
||||
int currentShader = 0;
|
||||
ecs::ShaderType activeShader = shader->GetActiveShader();
|
||||
for (size_t i = 0; i < shaderTypes.size(); i++)
|
||||
{
|
||||
if (shaderTypes[i] == activeShader)
|
||||
{
|
||||
currentShader = static_cast<int>(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Cr<43>ation du menu d<>roulant avec un ID unique pour chaque entit<69>
|
||||
std::string shaderComboId = "Shader Options##" + std::to_string(identity->GetId());
|
||||
if (ImGui::BeginCombo(shaderComboId.c_str(), shaderOptions[currentShader]))
|
||||
{
|
||||
for (int i = 0; i < IM_ARRAYSIZE(shaderOptions); i++)
|
||||
{
|
||||
// Cr<43>e une option s<>lectionnable pour chaque shader avec ID unique
|
||||
std::string shaderSelectableId = std::to_string(i) + "##shader_" + std::to_string(identity->GetId());
|
||||
bool isSelected = (currentShader == i);
|
||||
if (ImGui::Selectable(shaderOptions[i], isSelected))
|
||||
{
|
||||
// Met <20> jour l'option s<>lectionn<6E>e uniquement pour cette entit<69>
|
||||
currentShader = i;
|
||||
shader->SetActiveShader(shaderTypes[i]);
|
||||
}
|
||||
|
||||
// Si l'option s<>lectionn<6E>e est active, nous mettons en surbrillance
|
||||
if (isSelected)
|
||||
ImGui::SetItemDefaultFocus();
|
||||
}
|
||||
ImGui::EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Physics
|
||||
bool isPhysicsEnabled = (physics != nullptr);
|
||||
std::string physicsLabel = "Physics##" + std::to_string(identity->GetId());
|
||||
|
||||
if (ImGui::Checkbox(physicsLabel.c_str(), &isPhysicsEnabled))
|
||||
{
|
||||
if (isPhysicsEnabled && !physics)
|
||||
{
|
||||
// Ajouter un composant de physique
|
||||
physics = entity->AddComponent<ecs::PhysicsComponent>();
|
||||
physics->Initialize();
|
||||
}
|
||||
else if (!isPhysicsEnabled && physics)
|
||||
{
|
||||
// Retirer le composant de physique
|
||||
entity->RemoveComponent<ecs::PhysicsComponent>();
|
||||
physics = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (physics)
|
||||
{
|
||||
// Gravity Enabled checkbox
|
||||
bool gravityEnabled = physics->IsGravityEnabled();
|
||||
std::string gravityLabel = "Gravity##" + std::to_string(identity->GetId());
|
||||
if (ImGui::Checkbox(gravityLabel.c_str(), &gravityEnabled))
|
||||
{
|
||||
physics->SetGravityEnabled(gravityEnabled);
|
||||
}
|
||||
|
||||
// 3 radio buttons pour le type d'objet physique avec IDs uniques
|
||||
std::string typeLabel = "Type##" + std::to_string(identity->GetId());
|
||||
ecs::ObjectType type = identity->GetType();
|
||||
|
||||
if (ImGui::RadioButton(("None##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Unknown))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Unknown);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Cube##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Cube))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Cube);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Sphere##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Sphere))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Sphere);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton(("Terrain##" + std::to_string(identity->GetId())).c_str(),
|
||||
type == ecs::ObjectType::Terrain))
|
||||
{
|
||||
identity->SetType(ecs::ObjectType::Terrain);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
}
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// physics
|
||||
std::string physicsLabel = "physics##" + std::to_string(index);
|
||||
|
||||
if (ImGui::Checkbox(physicsLabel.c_str(), &m_isPhyiscsEnabled))
|
||||
{
|
||||
object->SetPhysicsEnabled(m_isPhyiscsEnabled);
|
||||
}
|
||||
|
||||
// Gravity Enabled checkbox
|
||||
std::string gravityLabel = "Gravity##" + std::to_string(index);
|
||||
if (ImGui::Checkbox(gravityLabel.c_str(), &object->m_gravityEnabled))
|
||||
{
|
||||
object->SetGravityEnabled(object->m_gravityEnabled);
|
||||
}
|
||||
|
||||
|
||||
// 3 radio button on the same line to set the ObjectType
|
||||
std::string typeLabel = "Type##" + std::to_string(index);
|
||||
ObjectType type = object->GetType();
|
||||
if (ImGui::RadioButton("None", type == ObjectType::Unknown))
|
||||
{
|
||||
object->SetType(ObjectType::Unknown);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Cube", type == ObjectType::Cube))
|
||||
{
|
||||
object->SetType(ObjectType::Cube);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::RadioButton("Sphere", type == ObjectType::Sphere))
|
||||
{
|
||||
object->SetType(ObjectType::Sphere);
|
||||
}
|
||||
|
||||
// button to launch the object
|
||||
std::string launchLabel = "Launch##" + std::to_string(index);
|
||||
|
||||
// paraeter to set the alpha, initial stretch and spring constant
|
||||
float alpha = object->GetAlpha();
|
||||
float initialStretch = object->GetInitialStretch();
|
||||
float springConstant = object->GetSpringConstant();
|
||||
if (ImGui::DragFloat("Alpha##" , &alpha, 0.01f, 0.0f, 1.0f))
|
||||
{
|
||||
object->SetAlpha(alpha);
|
||||
}
|
||||
if (ImGui::DragFloat("Initial Stretch##", &initialStretch, 0.01f, 0.0f, 1.0f))
|
||||
{
|
||||
object->SetInitialStretch(initialStretch);
|
||||
}
|
||||
if (ImGui::DragFloat("Spring Constant##", &springConstant, 0.01f, 0.0f, 100.0f))
|
||||
{
|
||||
object->SetSpringConstant(springConstant);
|
||||
}
|
||||
|
||||
if (ImGui::Button(launchLabel.c_str()))
|
||||
{
|
||||
object->LaunchObject();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
// button to stop the object
|
||||
std::string stopLabel = "Stop##" + std::to_string(index);
|
||||
if (ImGui::Button(stopLabel.c_str()))
|
||||
{
|
||||
object->SetVelocity(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
object->SetPosition(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
// Demo spinning
|
||||
std::string demoLabel = "Demo spinning##" + std::to_string(index);
|
||||
ImGui::Checkbox(demoLabel.c_str(), &object->m_demoSpinning);
|
||||
index++;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
ImGui::End();
|
||||
@@ -668,7 +702,7 @@ void imguiManager::WidgetTerrainWindow()
|
||||
{
|
||||
ImGui::Begin("Terrain", &showTerrainWindow);
|
||||
|
||||
ImGui::Text("Number of terrain cubes: %d", app_->get_terrain_cube_count());
|
||||
ImGui::Text("Number of terrain cubes: %d", app_->get_terrain_entity_count());
|
||||
|
||||
ImGui::Separator();
|
||||
|
||||
@@ -989,8 +1023,11 @@ void imguiManager::WidgetRenderStats()
|
||||
min_fps_ = stats_->get_min_fps();
|
||||
max_fps_ = stats_->get_max_fps();
|
||||
draw_calls_ = stats_->get_draw_calls();
|
||||
total_vertex_count_ = stats_->get_total_vertex_count();
|
||||
total_triangle_count_ = stats_->get_total_triangle_count();
|
||||
|
||||
|
||||
// total_vertex_count_ = stats_->get_total_vertex_count();
|
||||
// total_triangle_count_ = stats_->get_total_triangle_count();
|
||||
|
||||
visible_triangle_count_ = stats_->get_visible_triangle_count();
|
||||
current_frame_time_ = stats_->get_frame_time();
|
||||
|
||||
@@ -1039,9 +1076,9 @@ void imguiManager::WidgetRenderStats()
|
||||
ImGui::Separator();
|
||||
|
||||
ImGui::Text("Statistiques de rendu:");
|
||||
ImGui::Text("Vertices total: %d", total_vertex_count_);
|
||||
ImGui::Text("Vertices total: %d", *total_vertex_count_);
|
||||
|
||||
ImGui::Text("Triangles total: %d", total_triangle_count_);
|
||||
ImGui::Text("Triangles total: %d", *total_triangle_count_);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("Triangles visibles: %d", visible_triangle_count_);
|
||||
|
||||
@@ -1093,3 +1130,4 @@ void imguiManager::WidgetRenderStats()
|
||||
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
|
@@ -2,9 +2,27 @@
|
||||
|
||||
#include <comdef.h>
|
||||
|
||||
#include "application_class.h"
|
||||
#include "d_3d_class.h"
|
||||
|
||||
object::object()// initialize the reference here
|
||||
object::object(application_class& app) : m_Application(app)// initialize the reference here
|
||||
{
|
||||
m_scaleMatrix = XMMatrixIdentity();
|
||||
m_rotateMatrix = XMMatrixIdentity();
|
||||
m_translateMatrix = XMMatrixIdentity();
|
||||
m_srMatrix = XMMatrixIdentity();
|
||||
m_worldMatrix = XMMatrixIdentity();
|
||||
m_previousPosition = XMVectorZero();
|
||||
m_velocity = XMVectorZero();
|
||||
m_acceleration = XMVectorZero();
|
||||
m_mass = NULL;
|
||||
m_isGrounded = false;
|
||||
m_id = NULL;
|
||||
m_boundingRadius = 1.0f;
|
||||
}
|
||||
|
||||
object::object()
|
||||
: m_Application(*static_cast<application_class*>(nullptr)) // Remplacer suivant votre logique
|
||||
{
|
||||
m_scaleMatrix = XMMatrixIdentity();
|
||||
m_rotateMatrix = XMMatrixIdentity();
|
||||
@@ -24,6 +42,34 @@ object::~object()
|
||||
{
|
||||
}
|
||||
|
||||
bool object::Initialize(
|
||||
ID3D11Device* device,
|
||||
ID3D11DeviceContext* deviceContext,
|
||||
char* modelFilename,
|
||||
TextureContainer& texturesContainer
|
||||
)
|
||||
{
|
||||
|
||||
std::string filename(modelFilename);
|
||||
auto it = g_model_cache.find(filename);
|
||||
if (it != g_model_cache.end())
|
||||
{
|
||||
m_model_ = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto new_model = std::make_shared<model_class>();
|
||||
if (!new_model->Initialize(device, deviceContext, modelFilename, texturesContainer))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
g_model_cache[filename] = new_model;
|
||||
m_model_ = new_model;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void object::SetScaleMatrix(XMMATRIX scaleMatrix)
|
||||
{
|
||||
m_scaleMatrix = scaleMatrix;
|
||||
|
@@ -52,7 +52,7 @@ bool scene_manager::save_scene_as() {
|
||||
|
||||
// Mettre <20> jour le chemin de sc<73>ne
|
||||
scene_path_ = convert_w_string_to_string(filepath.wstring());
|
||||
object_vec_ = app_->get_kobjects();
|
||||
//object_vec_ = app_->get_kobjects(); // TODO
|
||||
|
||||
// Sauvegarder la sc<73>ne avec le nouveau chemin
|
||||
save_scene();
|
||||
@@ -67,36 +67,32 @@ bool scene_manager::save_scene_as() {
|
||||
bool scene_manager::load_scene() {
|
||||
Logger::Get().Log("Loading scene from " , __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
object_vec_ = app_->get_kobjects();
|
||||
object_id_ = app_->get_object_id();
|
||||
w_folder_ = app_->get_w_folder();
|
||||
direct_3d_ = app_->get_direct_3d();
|
||||
std::wstring scenePath = get_scene_path();
|
||||
|
||||
|
||||
if (!scenePath.empty())
|
||||
{
|
||||
if (!scenePath.empty()) {
|
||||
scene_path_ = convert_w_string_to_string(scenePath);
|
||||
}
|
||||
|
||||
std::ifstream inFile(scene_path_);
|
||||
if (!inFile.is_open()) {
|
||||
Logger::Get().Log("Failed to open file for loading scene: ", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
Logger::Get().Log("Failed to open file for loading scene: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Nettoyer les objets existants
|
||||
for (auto& obj : object_vec_) {
|
||||
if (obj) {
|
||||
obj->Shutdown();
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
object_vec_.clear();
|
||||
// R<EFBFBD>initialiser l'ID d'objet le plus <20>lev<65>
|
||||
object_id_ = 0;
|
||||
|
||||
// Sauvegarder le r<EFBFBD>pertoire de travail actuel
|
||||
std::wstring currentDirectory = w_folder_;
|
||||
// R<>cup<75>rer l'EntityManager pour cr<EFBFBD>er de nouvelles entit<69>s
|
||||
auto entity_manager = app_->get_entity_manager();
|
||||
|
||||
// Supprimer toutes les entit<69>s existantes
|
||||
entity_manager->Clear();
|
||||
|
||||
// Sauvegarder le r<>pertoire de travail actuel
|
||||
std::wstring currentDirectory = w_folder_;
|
||||
|
||||
std::string line;
|
||||
while (std::getline(inFile, line)) {
|
||||
@@ -111,47 +107,61 @@ bool scene_manager::load_scene() {
|
||||
float mass;
|
||||
bool physicsEnabled;
|
||||
|
||||
// Lire les donn<6E>es de base de l'objet
|
||||
// Lire les donn<6E>es de base de l'entit<EFBFBD>
|
||||
iss >> id >> name
|
||||
>> position.x >> position.y >> position.z
|
||||
>> rotation.x >> rotation.y >> rotation.z
|
||||
>> scale.x >> scale.y >> scale.z
|
||||
>> modelPath >> shaderTypeStr
|
||||
>> scale.x >> scale.y >> scale.z;
|
||||
|
||||
// Lire le chemin du mod<6F>le - v<>rifier s'il est vide
|
||||
iss >> modelPath;
|
||||
|
||||
// Si le chemin du mod<6F>le est vide ou commence par une lettre majuscule (probablement un type de shader),
|
||||
// c'est qu'il a <20>t<EFBFBD> omis - utilisez une valeur par d<>faut
|
||||
if (modelPath.empty() || (modelPath[0] >= 'A' && modelPath[0] <= 'Z')) {
|
||||
// Reculer le curseur de lecture pour lire le type de shader <20> la place
|
||||
iss.seekg(-static_cast<int>(modelPath.length()), std::ios::cur);
|
||||
modelPath = "assets/Model/TXT/cube.txt"; // Valeur par d<>faut
|
||||
}
|
||||
|
||||
iss >> shaderTypeStr
|
||||
>> boundingRadius >> objectTypeStr
|
||||
>> mass >> physicsEnabled;
|
||||
|
||||
if (iss.fail()) {
|
||||
Logger::Get().Log("Failed to parse object data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
Logger::Get().Log("Failed to parse entity data: " + line, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Cr<EFBFBD>er un nouvel objet
|
||||
object* newObject = new object();
|
||||
// Mettre <20> jour l'ID d'objet le plus <20>lev<65> si n<>cessaire
|
||||
if (id >= object_id_) {
|
||||
object_id_ = id + 1;
|
||||
}
|
||||
|
||||
// Convertir le chemin du mod<6F>le en wstring
|
||||
std::wstring wModelPath(modelPath.begin(), modelPath.end());
|
||||
|
||||
// V<>rifier si le chemin est relatif (ne commence pas par un disque comme C:)
|
||||
if (modelPath.length() > 1 && modelPath[1] != ':') {
|
||||
// C'est un chemin relatif, pr<70>fixer avec le r<>pertoire de travail
|
||||
if (currentDirectory.back() != L'/' && currentDirectory.back() != L'\\') {
|
||||
// Ajouter un s<>parateur si n<>cessaire
|
||||
wModelPath = currentDirectory + L"\\" + wModelPath;
|
||||
} else {
|
||||
wModelPath = currentDirectory + wModelPath;
|
||||
}
|
||||
}
|
||||
// V<>rifier si le chemin est relatif
|
||||
if (modelPath != "NoModel" && modelPath.length() > 1 && modelPath[1] != ':') {
|
||||
// C'est un chemin relatif, pr<70>fixer avec le r<>pertoire de travail
|
||||
if (currentDirectory.back() != L'/' && currentDirectory.back() != L'\\') {
|
||||
// Ajouter un s<>parateur si n<>cessaire
|
||||
wModelPath = currentDirectory + L"\\" + wModelPath;
|
||||
} else {
|
||||
wModelPath = currentDirectory + wModelPath;
|
||||
}
|
||||
}
|
||||
|
||||
// Cr<43>er le conteneur de textures_ pour stocker les chemins
|
||||
// Cr<43>er le conteneur de textures pour stocker les chemins
|
||||
TextureContainer objectTextures;
|
||||
|
||||
// IMPORTANT: Vider les conteneurs de chemins de textures_
|
||||
// Vider les conteneurs de chemins de textures
|
||||
objectTextures.diffusePaths.clear();
|
||||
objectTextures.normalPaths.clear();
|
||||
objectTextures.specularPaths.clear();
|
||||
objectTextures.alphaPaths.clear();
|
||||
|
||||
// Lire les chemins des textures_ diffuses
|
||||
// Lire les chemins des textures diffuses
|
||||
int diffuseTextureCount;
|
||||
iss >> diffuseTextureCount;
|
||||
for (int i = 0; i < diffuseTextureCount; i++) {
|
||||
@@ -161,7 +171,7 @@ bool scene_manager::load_scene() {
|
||||
objectTextures.diffusePaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Lire les chemins des textures_ normales
|
||||
// Lire les chemins des textures normales
|
||||
int normalTextureCount;
|
||||
iss >> normalTextureCount;
|
||||
for (int i = 0; i < normalTextureCount; i++) {
|
||||
@@ -171,7 +181,7 @@ bool scene_manager::load_scene() {
|
||||
objectTextures.normalPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Lire les chemins des textures_ sp<73>culaires
|
||||
// Lire les chemins des textures sp<73>culaires
|
||||
int specularTextureCount;
|
||||
iss >> specularTextureCount;
|
||||
for (int i = 0; i < specularTextureCount; i++) {
|
||||
@@ -181,7 +191,7 @@ bool scene_manager::load_scene() {
|
||||
objectTextures.specularPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// Lire les chemins des textures_ alpha
|
||||
// Lire les chemins des textures alpha
|
||||
int alphaTextureCount;
|
||||
iss >> alphaTextureCount;
|
||||
for (int i = 0; i < alphaTextureCount; i++) {
|
||||
@@ -191,60 +201,100 @@ bool scene_manager::load_scene() {
|
||||
objectTextures.alphaPaths.push_back(wTexturePath);
|
||||
}
|
||||
|
||||
// preload texture
|
||||
if (!newObject->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), objectTextures))
|
||||
{
|
||||
// G<>rer l'erreur
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialiser l'objet avec le mod<6F>le et les chemins de textures_
|
||||
char modelFilename[256];
|
||||
size_t convertedChars = 0;
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
||||
|
||||
Logger::Get().Log("Loading model: " + std::string(modelFilename), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
// NE PAS charger les textures_ avant initialize
|
||||
// Laisser la m<>thode initialize s'en charger <20> partir des chemins
|
||||
if (!newObject->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, objectTextures)) {
|
||||
Logger::Get().Log("Failed to initialize object: " + name, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
delete newObject;
|
||||
// V<>rifier si on a un mod<6F>le <20> charger
|
||||
if (modelPath == "NoModel") {
|
||||
Logger::Get().Log("Skipping entity without model: " + name, __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
continue;
|
||||
}
|
||||
|
||||
// D<EFBFBD>finir les propri<72>t<EFBFBD>s de l'objet
|
||||
newObject->SetId(id);
|
||||
newObject->SetName(name);
|
||||
newObject->SetPosition(XMLoadFloat3(&position));
|
||||
newObject->SetRotation(XMLoadFloat3(&rotation));
|
||||
newObject->SetScale(XMLoadFloat3(&scale));
|
||||
newObject->SetModelPath(wModelPath);
|
||||
newObject->SetActiveShader(newObject->StringToShaderType(shaderTypeStr));
|
||||
newObject->SetBoundingRadius(boundingRadius);
|
||||
newObject->SetType(newObject->StringToObjectType(objectTypeStr));
|
||||
newObject->SetMass(mass);
|
||||
newObject->SetPhysicsEnabled(physicsEnabled);
|
||||
// R<EFBFBD>cup<EFBFBD>rer le cache de mod<6F>les de l'application
|
||||
auto& modelCache = app_->get_model_cache();
|
||||
std::shared_ptr<model_class> sharedModel;
|
||||
|
||||
// Mettre <20> jour l'ID global si n<>cessaire
|
||||
if (id >= object_id_) {
|
||||
object_id_ = id + 1;
|
||||
app_->set_object_id(object_id_);
|
||||
// V<EFBFBD>rifier si le mod<6F>le existe d<>j<EFBFBD> dans le cache
|
||||
std::string modelKey = modelPath;
|
||||
auto it = modelCache.find(modelKey);
|
||||
if (it != modelCache.end()) {
|
||||
// Utiliser le mod<6F>le existant du cache
|
||||
Logger::Get().Log("Using cached model for: " + modelKey, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
sharedModel = it->second;
|
||||
} else {
|
||||
// Cr<43>er un nouveau mod<6F>le
|
||||
char modelFilename[256];
|
||||
size_t convertedChars = 0;
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), wModelPath.c_str(), _TRUNCATE);
|
||||
|
||||
Logger::Get().Log("Loading model: " + std::string(modelFilename), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
|
||||
// Cr<43>er et initialiser le mod<6F>le
|
||||
auto newModel = std::make_shared<model_class>();
|
||||
|
||||
// Pr<50>charger les textures
|
||||
if (!newModel->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), objectTextures)) {
|
||||
Logger::Get().Log("Failed to preload textures for: " + name, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!newModel->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, objectTextures)) {
|
||||
Logger::Get().Log("Failed to initialize model: " + name, __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ajouter le mod<6F>le au cache
|
||||
modelCache[modelKey] = newModel;
|
||||
sharedModel = newModel;
|
||||
}
|
||||
|
||||
object_vec_.push_back(newObject);
|
||||
Logger::Get().Log("Loaded object: " + name, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
// Cr<43>er une nouvelle entit<69> avec l'EntityManager
|
||||
auto entity = entity_manager->CreateEntity();
|
||||
|
||||
// Ajouter un composant d'identit<69>
|
||||
auto identityComponent = entity->AddComponent<ecs::IdentityComponent>(id);
|
||||
identityComponent->SetName(name);
|
||||
identityComponent->SetType(ecs::IdentityComponent::StringToObjectType(objectTypeStr));
|
||||
|
||||
// Ajouter un composant de transformation
|
||||
auto transformComponent = entity->AddComponent<ecs::TransformComponent>();
|
||||
transformComponent->SetPosition(XMLoadFloat3(&position));
|
||||
transformComponent->SetRotation(XMLoadFloat3(&rotation));
|
||||
transformComponent->SetScale(XMLoadFloat3(&scale));
|
||||
transformComponent->UpdateWorldMatrix();
|
||||
|
||||
// Ajouter un composant de rendu avec le mod<6F>le
|
||||
auto renderComponent = entity->AddComponent<ecs::RenderComponent>();
|
||||
renderComponent->InitializeWithModel(sharedModel);
|
||||
|
||||
// Ajouter un composant de shader
|
||||
auto shaderComponent = entity->AddComponent<ecs::ShaderComponent>();
|
||||
shaderComponent->SetActiveShader(ecs::ShaderComponent::StringToShaderType(shaderTypeStr));
|
||||
|
||||
// Ajouter un composant de chemin de mod<6F>le
|
||||
auto modelPathComponent = entity->AddComponent<ecs::ModelPathComponent>();
|
||||
modelPathComponent->SetPath(wModelPath);
|
||||
|
||||
// Ajouter un composant de physique si n<>cessaire
|
||||
auto physicsComponent = entity->AddComponent<ecs::PhysicsComponent>();
|
||||
physicsComponent->Initialize();
|
||||
physicsComponent->SetMass(mass);
|
||||
physicsComponent->SetBoundingRadius(boundingRadius);
|
||||
physicsComponent->SetPhysicsEnabled(physicsEnabled);
|
||||
|
||||
Logger::Get().Log("Entity loaded: " + name + " with ID: " + std::to_string(id), __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
}
|
||||
|
||||
// pass the vec to the application
|
||||
app_->set_kobjects(object_vec_);
|
||||
// Mettre <20> jour l'ID global dans l'application
|
||||
app_->set_object_id(object_id_);
|
||||
|
||||
Logger::Get().Log("Scene loaded successfully from ", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
// Mettre <20> jour les statistiques apr<70>s le chargement
|
||||
app_->update_stats_after_modification();
|
||||
|
||||
Logger::Get().Log("Scene loaded successfully from " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool scene_manager::save_scene() {
|
||||
|
||||
entity_ = app_->get_entity_manager()->GetAllEntities();
|
||||
|
||||
if (scene_path_.empty()) {
|
||||
Logger::Get().Log("Scene path is empty. Cannot save scene.", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@@ -257,56 +307,104 @@ bool scene_manager::save_scene() {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& object : object_vec_) {
|
||||
for (const auto& object : entity_) {
|
||||
XMFLOAT3 position, scale, rotation;
|
||||
XMStoreFloat3(&position, object->GetPosition());
|
||||
XMStoreFloat3(&scale, object->GetScale());
|
||||
XMStoreFloat3(&rotation, object->GetRotation());
|
||||
int id = 0;
|
||||
int mass = 0;
|
||||
float boundingRadius = 0;
|
||||
std::string name = "NONE";
|
||||
std::string shaderType = "NONE";
|
||||
std::string objectType = "NONE";
|
||||
std::wstring model_path = L"";
|
||||
bool physics_enabled = false;
|
||||
|
||||
auto transform = object->GetComponent<ecs::TransformComponent>();
|
||||
if (transform) {
|
||||
// convert XMVECTOR to XMFLOAT3
|
||||
XMStoreFloat3(&position, transform->GetPosition());
|
||||
XMStoreFloat3(&rotation, transform->GetRotation());
|
||||
XMStoreFloat3(&scale, transform->GetScale());
|
||||
}
|
||||
|
||||
|
||||
auto identity = object->GetComponent<ecs::IdentityComponent>();
|
||||
if (identity) {
|
||||
|
||||
id = identity->GetId();
|
||||
name = identity->GetName();
|
||||
objectType = identity->ObjectTypeToString(identity->GetType());
|
||||
|
||||
}
|
||||
|
||||
auto model_path_component = object->GetComponent<ecs::ModelPathComponent>();
|
||||
if (model_path_component) {
|
||||
|
||||
model_path = model_path_component->GetPath();
|
||||
}
|
||||
|
||||
auto shader = object->GetComponent<ecs::ShaderComponent>();
|
||||
if (shader)
|
||||
{
|
||||
shaderType = shader->ShaderTypeToString(shader->GetActiveShader());
|
||||
}
|
||||
|
||||
auto physics = object->GetComponent<ecs::PhysicsComponent>();
|
||||
if (physics) {
|
||||
physics_enabled = physics->IsPhysicsEnabled();
|
||||
mass = physics->GetMass();
|
||||
boundingRadius = physics->GetBoundingRadius();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// <20>crire les donn<6E>es de base de l'objet
|
||||
outFile << object->GetId() << " "
|
||||
<< object->GetName() << " "
|
||||
outFile << id << " "
|
||||
<< name << " "
|
||||
<< position.x << " " << position.y << " " << position.z << " "
|
||||
<< rotation.x << " " << rotation.y << " " << rotation.z << " "
|
||||
<< scale.x << " " << scale.y << " " << scale.z << " "
|
||||
<< convert_w_string_to_string(object->GetModelPath()) << " "
|
||||
<< object->ShaderTypeToString(object->GetActiveShader()) << " "
|
||||
<< object->GetBoundingRadius() << " "
|
||||
<< object->ObjectTypeToString(object->GetType()) << " "
|
||||
<< object->GetMass() << " "
|
||||
<< object->IsPhysicsEnabled();
|
||||
<< convert_w_string_to_string(model_path) << " "
|
||||
<< shaderType << " "
|
||||
<< boundingRadius << " "
|
||||
<< objectType << " "
|
||||
<< mass << " "
|
||||
<< physics_enabled;
|
||||
|
||||
// Sauvegarder les chemins des textures_
|
||||
// Format: nombre de textures_ diffuses, puis les chemins
|
||||
// M<>me chose pour les autres types de textures_
|
||||
|
||||
// Textures diffuses
|
||||
const auto& diffusePaths = object->GetTextureContainer().GetPaths(TextureType::Diffuse);
|
||||
outFile << " " << diffusePaths.size();
|
||||
for (const auto& path : diffusePaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
|
||||
auto render = object->GetComponent<ecs::RenderComponent>();
|
||||
if (render)
|
||||
{
|
||||
const auto& model = render->GetModel();
|
||||
|
||||
const auto& textureContainer = model->GetTextureContainer();
|
||||
|
||||
const auto& diffusePaths = textureContainer.GetPaths(TextureType::Diffuse);
|
||||
outFile << " " << diffusePaths.size();
|
||||
for (const auto& path : diffusePaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
|
||||
const auto& normalPaths = textureContainer.GetPaths(TextureType::Normal);
|
||||
outFile << " " << normalPaths.size();
|
||||
for (const auto& path : normalPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
const auto& specularPaths = textureContainer.GetPaths(TextureType::Specular);
|
||||
outFile << " " << specularPaths.size();
|
||||
for (const auto& path : specularPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
const auto& alphaPaths = textureContainer.GetPaths(TextureType::Alpha);
|
||||
outFile << " " << alphaPaths.size();
|
||||
for (const auto& path : alphaPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
}
|
||||
|
||||
// Textures normales
|
||||
const auto& normalPaths = object->GetTextureContainer().GetPaths(TextureType::Normal);
|
||||
outFile << " " << normalPaths.size();
|
||||
for (const auto& path : normalPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
|
||||
// Textures sp<73>culaires
|
||||
const auto& specularPaths = object->GetTextureContainer().GetPaths(TextureType::Specular);
|
||||
outFile << " " << specularPaths.size();
|
||||
for (const auto& path : specularPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
|
||||
// Textures alpha
|
||||
const auto& alphaPaths = object->GetTextureContainer().GetPaths(TextureType::Alpha);
|
||||
outFile << " " << alphaPaths.size();
|
||||
for (const auto& path : alphaPaths) {
|
||||
outFile << " " << convert_w_string_to_string(path);
|
||||
}
|
||||
|
||||
outFile << std::endl;
|
||||
}
|
||||
@@ -351,3 +449,4 @@ std::string scene_manager::convert_w_string_to_string(const std::wstring& wstr)
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size_needed, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
stats::stats() : fps_(nullptr), drawcalls_(0)
|
||||
{
|
||||
total_triangle_count_ = std::make_shared<int>(0);
|
||||
total_vertex_count_ = std::make_shared<int>(0);
|
||||
}
|
||||
|
||||
stats::~stats()
|
||||
@@ -27,11 +29,6 @@ bool stats::initialize(application_class* app)
|
||||
return false;
|
||||
}
|
||||
|
||||
// call update() in a separate thread
|
||||
std::thread update_geometric_thread(&stats::update_geometric_stats, this);
|
||||
update_geometric_thread_ = std::move(update_geometric_thread); // Move the thread to the member variable
|
||||
update_geometric_thread_.detach(); // Detach the thread to run independently
|
||||
|
||||
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
@@ -39,21 +36,23 @@ bool stats::initialize(application_class* app)
|
||||
|
||||
void stats::update_geometric_stats()
|
||||
{
|
||||
while (true)
|
||||
// Utiliser le syst<73>me ECS pour acc<63>der aux entit<69>s avec des composants de rendu
|
||||
if (app_ && app_->get_entity_manager())
|
||||
{
|
||||
object_vec_ = app_->get_kobjects();
|
||||
cubes_vec_ = app_->get_cubes();
|
||||
terrain_chunk_vec_ = app_->get_terrain_cubes();
|
||||
*total_vertex_count_ = get_total_vertex_count();
|
||||
*total_triangle_count_ = get_total_triangle_count();
|
||||
|
||||
total_vertex_count_ = get_total_vertex_count();
|
||||
total_triangle_count_ = get_total_triangle_count();
|
||||
visible_triangle_count_ = get_visible_triangle_count();
|
||||
update_visible_count();
|
||||
|
||||
// call update_stats() every second
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
Logger::Get().Log("Statistics updated: " + std::to_string(*total_vertex_count_) + " vertices, " + std::to_string(*total_triangle_count_) + " triangles", __FILE__, __LINE__, Logger::LogLevel::Debug);
|
||||
}
|
||||
}
|
||||
|
||||
void stats::update_visible_count()
|
||||
{
|
||||
visible_triangle_count_ = get_visible_triangle_count();
|
||||
}
|
||||
|
||||
void stats::update_display_stats()
|
||||
{
|
||||
|
||||
@@ -67,88 +66,143 @@ void stats::update_display_stats()
|
||||
int stats::get_total_vertex_count() const
|
||||
{
|
||||
int totalVertices = 0;
|
||||
|
||||
// Utiliser le syst<73>me ECS pour acc<63>der aux entit<69>s avec des composants de rendu
|
||||
if (app_ && app_->get_entity_manager())
|
||||
{
|
||||
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::RenderComponent>();
|
||||
|
||||
for (const auto& entity : entities)
|
||||
{
|
||||
auto renderComponent = entity->GetComponent<ecs::RenderComponent>();
|
||||
if (renderComponent && renderComponent->GetModel())
|
||||
{
|
||||
totalVertices += renderComponent->GetModel()->GetVertexCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter <20>galement les <20>ventuels objets restants de l'ancien syst<73>me
|
||||
for (const auto& obj : object_vec_)
|
||||
{
|
||||
if (obj)
|
||||
if (obj && obj->get_model())
|
||||
{
|
||||
totalVertices += obj->GetVertexCount();
|
||||
totalVertices += obj->get_model()->GetVertexCount();
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de sommets pour les cubes
|
||||
|
||||
for (const auto& cube : cubes_vec_)
|
||||
{
|
||||
if (cube)
|
||||
if (cube && cube->get_model())
|
||||
{
|
||||
totalVertices += cube->GetVertexCount();
|
||||
totalVertices += cube->get_model()->GetVertexCount();
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de sommets pour le terrain
|
||||
|
||||
for (const auto& chunk : terrain_chunk_vec_)
|
||||
{
|
||||
if (chunk)
|
||||
if (chunk && chunk->get_model())
|
||||
{
|
||||
totalVertices += chunk->GetVertexCount();
|
||||
totalVertices += chunk->get_model()->GetVertexCount();
|
||||
}
|
||||
}
|
||||
|
||||
return totalVertices;
|
||||
}
|
||||
|
||||
int stats::get_total_triangle_count() const
|
||||
{
|
||||
int totalTriangles = 0;
|
||||
|
||||
// Utiliser le syst<73>me ECS pour acc<63>der aux entit<69>s avec des composants de rendu
|
||||
if (app_ && app_->get_entity_manager())
|
||||
{
|
||||
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::RenderComponent>();
|
||||
|
||||
for (const auto& entity : entities)
|
||||
{
|
||||
auto renderComponent = entity->GetComponent<ecs::RenderComponent>();
|
||||
if (renderComponent && renderComponent->GetModel())
|
||||
{
|
||||
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
||||
totalTriangles += renderComponent->GetModel()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter <20>galement les <20>ventuels objets restants de l'ancien syst<73>me
|
||||
for (const auto& obj : object_vec_)
|
||||
{
|
||||
if (obj)
|
||||
if (obj && obj->get_model())
|
||||
{
|
||||
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
||||
totalTriangles += obj->GetIndexCount() / 3;
|
||||
totalTriangles += obj->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de triangles pour les cubes
|
||||
|
||||
for (const auto& cube : cubes_vec_)
|
||||
{
|
||||
if (cube)
|
||||
if (cube && cube->get_model())
|
||||
{
|
||||
totalTriangles += cube->GetIndexCount() / 3;
|
||||
totalTriangles += cube->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de triangles pour le terrain
|
||||
|
||||
for (const auto& chunk : terrain_chunk_vec_)
|
||||
{
|
||||
if (chunk)
|
||||
if (chunk && chunk->get_model())
|
||||
{
|
||||
totalTriangles += chunk->GetIndexCount() / 3;
|
||||
totalTriangles += chunk->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
|
||||
return totalTriangles;
|
||||
}
|
||||
|
||||
int stats::get_visible_triangle_count() const
|
||||
{
|
||||
int visibleTriangles = 0;
|
||||
|
||||
// Utiliser le syst<73>me ECS pour acc<63>der aux entit<69>s avec des composants de rendu
|
||||
if (app_ && app_->get_entity_manager())
|
||||
{
|
||||
auto entities = app_->get_entity_manager()->GetEntitiesWithComponent<ecs::RenderComponent>();
|
||||
|
||||
for (const auto& entity : entities)
|
||||
{
|
||||
auto renderComponent = entity->GetComponent<ecs::RenderComponent>();
|
||||
if (renderComponent && renderComponent->GetModel() && renderComponent->IsVisible())
|
||||
{
|
||||
// Dans une topologie de liste de triangles, chaque triangle utilise 3 indices
|
||||
visibleTriangles += renderComponent->GetModel()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ajouter <20>galement les <20>ventuels objets restants de l'ancien syst<73>me
|
||||
for (const auto& obj : object_vec_)
|
||||
{
|
||||
if (obj && obj->IsVisible())
|
||||
if (obj && obj->get_model() && obj->IsVisible())
|
||||
{
|
||||
visibleTriangles += obj->GetIndexCount() / 3;
|
||||
visibleTriangles += obj->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de triangles visibles pour les cubes
|
||||
|
||||
for (const auto& cube : cubes_vec_)
|
||||
{
|
||||
if (cube && cube->IsVisible())
|
||||
if (cube && cube->get_model() && cube->IsVisible())
|
||||
{
|
||||
visibleTriangles += cube->GetIndexCount() / 3;
|
||||
visibleTriangles += cube->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
// Ajoutez le nombre de triangles visibles pour le terrain
|
||||
|
||||
for (const auto& chunk : terrain_chunk_vec_)
|
||||
{
|
||||
if (chunk && chunk->IsVisible())
|
||||
if (chunk && chunk->get_model() && chunk->IsVisible())
|
||||
{
|
||||
visibleTriangles += chunk->GetIndexCount() / 3;
|
||||
visibleTriangles += chunk->get_model()->GetIndexCount() / 3;
|
||||
}
|
||||
}
|
||||
|
||||
return visibleTriangles;
|
||||
}
|
||||
|
||||
|
@@ -20,27 +20,6 @@ system_class::system_class()
|
||||
|
||||
system_class::~system_class()
|
||||
{
|
||||
|
||||
if (application_handle)
|
||||
{
|
||||
delete application_handle;
|
||||
application_handle = 0;
|
||||
}
|
||||
|
||||
if (input_)
|
||||
{
|
||||
delete input_;
|
||||
input_ = 0;
|
||||
}
|
||||
|
||||
if (imgui_manager_)
|
||||
{
|
||||
delete imgui_manager_;
|
||||
imgui_manager_ = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool system_class::initialize()
|
||||
@@ -56,7 +35,7 @@ bool system_class::initialize()
|
||||
initialize_windows(screenWidth, screenHeight);
|
||||
|
||||
// Create and initialize the input object. This object will be used to handle reading the keyboard input from the user.
|
||||
input_ = new input_class;
|
||||
input_ = std::make_shared<input_class>();
|
||||
|
||||
result = input_->Initialize(hinstance_, hwnd_, screenWidth, screenHeight);
|
||||
if (!result)
|
||||
@@ -66,7 +45,7 @@ bool system_class::initialize()
|
||||
}
|
||||
|
||||
// Create and initialize the application class object. This object will handle rendering all the graphics for this application.
|
||||
application_ = new application_class;
|
||||
application_ = std::make_shared<application_class>();
|
||||
|
||||
result = application_->initialize(screenWidth, screenHeight, hwnd_, false);
|
||||
if (!result)
|
||||
@@ -85,7 +64,7 @@ bool system_class::initialize()
|
||||
// initialize imgui
|
||||
if(DEBUG_MODE)
|
||||
{
|
||||
imgui_manager_ = new imguiManager;
|
||||
imgui_manager_ = std::make_shared<imguiManager>();
|
||||
imgui_manager_->SetApp(application_);
|
||||
result = imgui_manager_->Initialize(hwnd_, application_->get_direct_3d()->get_device(), application_->get_direct_3d()->get_device_context());
|
||||
if (!result)
|
||||
@@ -112,49 +91,11 @@ void system_class::shutdown()
|
||||
|
||||
std::lock_guard<std::mutex> guard(render_mutex_);
|
||||
|
||||
// shutdown imgui
|
||||
if (imgui_manager_)
|
||||
{
|
||||
Logger::Get().Log("Shutting down imgui manager", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
imgui_manager_->Shutdown();
|
||||
delete imgui_manager_;
|
||||
imgui_manager_ = 0;
|
||||
|
||||
Logger::Get().Log("Imgui manager shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
||||
|
||||
// Release the application class object.
|
||||
if (application_)
|
||||
{
|
||||
Logger::Get().Log("Shutting down application", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
application_->shutdown();
|
||||
delete application_;
|
||||
application_ = 0;
|
||||
|
||||
Logger::Get().Log("Application shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
||||
|
||||
// Release the input object.
|
||||
if (input_)
|
||||
{
|
||||
Logger::Get().Log("Shutting down input", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
delete input_;
|
||||
input_ = 0;
|
||||
|
||||
Logger::Get().Log("Input shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// shutdown the window.
|
||||
shutdown_windows();
|
||||
|
||||
Logger::Get().Log("System class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void system_class::run()
|
||||
@@ -224,7 +165,7 @@ bool system_class::frame()
|
||||
}
|
||||
|
||||
// Do the frame processing for the application class object.
|
||||
result = application_->frame(input_);
|
||||
result = application_->frame(input_.get());
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
|
Reference in New Issue
Block a user