Major Update - Complete Rework Texture System - V10.0.0
This commit is contained in:
parent
7dbd735416
commit
8e6b7409d9
6
.idea/.idea.KhaoticEngineReborn/.idea/AndroidProjectSystem.xml
generated
Normal file
6
.idea/.idea.KhaoticEngineReborn/.idea/AndroidProjectSystem.xml
generated
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AndroidProjectSystem">
|
||||
<option name="providerId" value="RiderAndroidProjectSystem" />
|
||||
</component>
|
||||
</project>
|
@ -2,6 +2,7 @@
|
||||
<project version="4">
|
||||
<component name="RiderProjectSettingsUpdater">
|
||||
<option name="singleClickDiffPreview" value="1" />
|
||||
<option name="unhandledExceptionsIgnoreList" value="1" />
|
||||
<option name="vcsConfiguration" value="3" />
|
||||
</component>
|
||||
</project>
|
76
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
76
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -5,10 +5,15 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/assets/Texture/imgui.ini" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/shader/shadermanagerclass.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/modelclass.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/Skybox.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/modelclass.cpp" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -22,6 +27,21 @@
|
||||
<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="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock:///dummy.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="cidr-memory-view://0" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/../../IDE_VS/VC/Tools/MSVC/14.38.33130/include/type_traits" root0="SKIP_HIGHLIGHTING" />
|
||||
@ -38,25 +58,25 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.enginecustom.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.git.unshallow": "true",
|
||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"nodejs_package_manager_path": "npm",
|
||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||
"C++ Project.enginecustom.executor": "Run",
|
||||
"C/C++ Project.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.build.unityPlugin",
|
||||
"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">
|
||||
@ -168,6 +188,8 @@
|
||||
<workItem from="1746117455914" duration="5976000" />
|
||||
<workItem from="1746126812110" duration="180000" />
|
||||
<workItem from="1746188920194" duration="1870000" />
|
||||
<workItem from="1746274246641" duration="89000" />
|
||||
<workItem from="1746274352144" duration="8039000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||
<option name="closed" value="true" />
|
||||
@ -211,6 +233,22 @@
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Patch update - add menu button" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||
<properties exception="System.OperationCanceledException" breakIfHandledByOtherCode="false" displayValue="System.OperationCanceledException" />
|
||||
<option name="timeStamp" value="1" />
|
||||
</breakpoint>
|
||||
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||
<properties exception="System.Threading.Tasks.TaskCanceledException" breakIfHandledByOtherCode="false" displayValue="System.Threading.Tasks.TaskCanceledException" />
|
||||
<option name="timeStamp" value="2" />
|
||||
</breakpoint>
|
||||
<breakpoint enabled="true" type="DotNet_Exception_Breakpoints">
|
||||
<properties exception="System.Threading.ThreadAbortException" breakIfHandledByOtherCode="false" displayValue="System.Threading.ThreadAbortException" />
|
||||
<option name="timeStamp" value="3" />
|
||||
</breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<watches-manager>
|
||||
<configuration name="CppProject">
|
||||
<watch expression="((class ModelClass &) (*(*(*this).m_Application).m_object[0]))" />
|
||||
|
@ -1,49 +1,89 @@
|
||||
[Window][DockSpace]
|
||||
Pos=0,0
|
||||
Size=2048,1129
|
||||
Collapsed=0
|
||||
|
||||
[Window][Debug##Default]
|
||||
Pos=60,60
|
||||
Size=400,400
|
||||
Collapsed=0
|
||||
|
||||
[Window][Khaotic Engine]
|
||||
Pos=1687,27
|
||||
Size=353,1094
|
||||
Collapsed=0
|
||||
DockId=0x00000002,0
|
||||
|
||||
[Window][Objects]
|
||||
Pos=8,27
|
||||
Size=345,896
|
||||
Pos=1233,27
|
||||
Size=343,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,0
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=1687,27
|
||||
Size=353,1094
|
||||
[Window][Objects]
|
||||
Pos=8,27
|
||||
Size=289,826
|
||||
Collapsed=0
|
||||
DockId=0x00000002,1
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=8,27
|
||||
Size=345,896
|
||||
Pos=299,27
|
||||
Size=250,826
|
||||
Collapsed=0
|
||||
DockId=0x00000005,1
|
||||
DockId=0x00000007,0
|
||||
|
||||
[Window][Light]
|
||||
Pos=8,925
|
||||
Size=345,196
|
||||
Pos=8,27
|
||||
Size=290,866
|
||||
Collapsed=0
|
||||
DockId=0x00000007,1
|
||||
|
||||
[Window][Shader Manager]
|
||||
Pos=8,27
|
||||
Size=330,487
|
||||
Collapsed=0
|
||||
DockId=0x00000001,2
|
||||
|
||||
[Window][Engine Settings]
|
||||
Pos=8,27
|
||||
Size=289,826
|
||||
Collapsed=0
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Window][DockSpace Demo]
|
||||
Size=1584,861
|
||||
Collapsed=0
|
||||
|
||||
[Window][Render Window]
|
||||
Pos=8,27
|
||||
Size=1559,974
|
||||
Collapsed=0
|
||||
DockId=0x00000009,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=8,627
|
||||
Size=1568,226
|
||||
Collapsed=0
|
||||
DockId=0x00000006,0
|
||||
|
||||
[Docking][Data]
|
||||
DockSpace ID=0xCCBD8CF7 Window=0x3DA2F1DE Pos=8,27 Size=2032,1094 Split=X
|
||||
DockNode ID=0x00000003 Parent=0xCCBD8CF7 SizeRef=345,826 Split=Y Selected=0x393905AB
|
||||
DockNode ID=0x00000005 Parent=0x00000003 SizeRef=345,896 Selected=0x393905AB
|
||||
DockNode ID=0x00000006 Parent=0x00000003 SizeRef=345,196 Selected=0x321620B2
|
||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1221,826 Split=X
|
||||
DockNode ID=0x00000001 Parent=0x00000004 SizeRef=866,826 CentralNode=1
|
||||
DockNode ID=0x00000002 Parent=0x00000004 SizeRef=353,826 Selected=0x9F035453
|
||||
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=Y
|
||||
DockNode ID=0x00000004 Parent=0xCCBD8CF7 SizeRef=1568,598 Split=X
|
||||
DockNode ID=0x00000009 Parent=0x00000004 SizeRef=289,974 Selected=0x031DC75C
|
||||
DockNode ID=0x0000000D Parent=0x00000004 SizeRef=1613,974 Split=X
|
||||
DockNode ID=0x00000002 Parent=0x0000000D SizeRef=1268,826 Split=Y
|
||||
DockNode ID=0x0000000B Parent=0x00000002 SizeRef=1568,637 Split=X
|
||||
DockNode ID=0x00000007 Parent=0x0000000B SizeRef=250,826 Selected=0x393905AB
|
||||
DockNode ID=0x00000008 Parent=0x0000000B SizeRef=971,826 CentralNode=1 Selected=0x031DC75C
|
||||
DockNode ID=0x0000000C Parent=0x00000002 SizeRef=1568,335 Selected=0x139FDA3F
|
||||
DockNode ID=0x00000005 Parent=0x0000000D SizeRef=343,826 Selected=0x9F035453
|
||||
DockNode ID=0x00000006 Parent=0xCCBD8CF7 SizeRef=1568,226 Selected=0xAB74BEE9
|
||||
|
||||
|
@ -310,6 +310,22 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CopyFileToFolders Include="font01.tga" />
|
||||
<CopyFileToFolders Include="assets\Texture\Bricks2K.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Texture\BricksGLOSS2K.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Texture\BricksNRM2K.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Texture</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox.png">
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(OutDir)\assets\Skybox</DestinationFolders>
|
||||
<DestinationFolders Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\assets\Skybox</DestinationFolders>
|
||||
</CopyFileToFolders>
|
||||
<Image Include="KhaoticIcon.ico" />
|
||||
<CopyFileToFolders Include="sprite01.tga" />
|
||||
<CopyFileToFolders Include="sprite02.tga" />
|
||||
|
@ -480,5 +480,17 @@
|
||||
<CopyFileToFolders Include="assets\Model\OBJ\skysphere.obj">
|
||||
<Filter>Assets\Model\OBJ</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Texture\BricksNRM2K.png">
|
||||
<Filter>Texture</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Texture\BricksGLOSS2K.png">
|
||||
<Filter>Texture</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Texture\Bricks2K.png">
|
||||
<Filter>Texture</Filter>
|
||||
</CopyFileToFolders>
|
||||
<CopyFileToFolders Include="assets\Skybox\skybox.png">
|
||||
<Filter>Assets\Skybox</Filter>
|
||||
</CopyFileToFolders>
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -13,7 +13,7 @@ DockId=0x00000005,0
|
||||
Pos=8,27
|
||||
Size=289,826
|
||||
Collapsed=0
|
||||
DockId=0x00000009,1
|
||||
DockId=0x00000009,0
|
||||
|
||||
[Window][Terrain]
|
||||
Pos=8,27
|
||||
|
@ -22,7 +22,78 @@ using namespace std;
|
||||
///////////////////////
|
||||
#include "textureclass.h"
|
||||
|
||||
enum class TextureType
|
||||
{
|
||||
Diffuse,
|
||||
Normal,
|
||||
Specular,
|
||||
Alpha
|
||||
};
|
||||
|
||||
struct TextureContainer
|
||||
{
|
||||
std::vector<ID3D11ShaderResourceView*> diffuse;
|
||||
std::vector<ID3D11ShaderResourceView*> normal;
|
||||
std::vector<ID3D11ShaderResourceView*> specular;
|
||||
std::vector<ID3D11ShaderResourceView*> alpha;
|
||||
|
||||
std::vector<ID3D11ShaderResourceView*>& Get(TextureType type) const {
|
||||
switch (type) {
|
||||
case TextureType::Diffuse: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
|
||||
case TextureType::Normal: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(normal);
|
||||
case TextureType::Specular: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(specular);
|
||||
case TextureType::Alpha: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(alpha);
|
||||
default: return const_cast<std::vector<ID3D11ShaderResourceView*>&>(diffuse);
|
||||
}
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const {
|
||||
auto& vec = Get(type);
|
||||
if (index >= 0 && index < vec.size())
|
||||
return vec[index];
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void ReleaseAll() {
|
||||
ReleaseVector(diffuse);
|
||||
ReleaseVector(normal);
|
||||
ReleaseVector(specular);
|
||||
ReleaseVector(alpha);
|
||||
}
|
||||
|
||||
void AssignTexture(TextureContainer& textContainer, ID3D11ShaderResourceView* texture, int index)
|
||||
{
|
||||
switch (index)
|
||||
{
|
||||
case 0:
|
||||
textContainer.diffuse.push_back(texture);
|
||||
break;
|
||||
case 1:
|
||||
textContainer.normal.push_back(texture);
|
||||
break;
|
||||
case 2:
|
||||
textContainer.specular.push_back(texture);
|
||||
break;
|
||||
case 3:
|
||||
textContainer.alpha.push_back(texture);
|
||||
break;
|
||||
default:
|
||||
textContainer.diffuse.push_back(texture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
void ReleaseVector(std::vector<ID3D11ShaderResourceView*>& vec) {
|
||||
for (auto& tex : vec) {
|
||||
if (tex) {
|
||||
tex->Release();
|
||||
tex = nullptr;
|
||||
}
|
||||
}
|
||||
vec.clear();
|
||||
}
|
||||
};
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: ModelClass
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -83,15 +154,25 @@ public:
|
||||
ModelClass(const ModelClass&);
|
||||
~ModelClass();
|
||||
|
||||
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
||||
|
||||
//bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, std::vector<ID3D11ShaderResourceView*>);
|
||||
// Nouvelle surcharge avec TextureContainer
|
||||
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*, const TextureContainer&);
|
||||
// Nouvelle méthode - initialisation sans textures
|
||||
bool Initialize(ID3D11Device*, ID3D11DeviceContext*, char*);
|
||||
void Shutdown();
|
||||
void Render(ID3D11DeviceContext*);
|
||||
|
||||
int GetIndexCount();
|
||||
ID3D11ShaderResourceView* GetTexture(int index) const;
|
||||
bool ChangeTexture(ID3D11Device*, ID3D11DeviceContext*, std::wstring filename, int index);
|
||||
//ID3D11ShaderResourceView* GetTexture(int index) const;
|
||||
ID3D11ShaderResourceView* GetTexture(TextureType type, int index) const;
|
||||
|
||||
//bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index);
|
||||
bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type, int index);
|
||||
|
||||
// Méthodes pour ajouter une nouvelle texture
|
||||
bool AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type);
|
||||
bool AddTexture(ID3D11ShaderResourceView* texture, TextureType type);
|
||||
|
||||
private:
|
||||
bool InitializeBuffers(ID3D11Device*);
|
||||
void ShutdownBuffers();
|
||||
@ -106,11 +187,10 @@ private:
|
||||
|
||||
void CalculateModelVectors();
|
||||
void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);
|
||||
|
||||
private:
|
||||
|
||||
ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
|
||||
int m_vertexCount, m_indexCount;
|
||||
std::vector<ID3D11ShaderResourceView*> m_Textures;
|
||||
TextureContainer m_Textures;
|
||||
ModelType* m_model;
|
||||
};
|
||||
|
||||
|
@ -29,12 +29,13 @@ Object* Skybox::ConstructSkybox()
|
||||
|
||||
char modelFilename[128];
|
||||
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
|
||||
|
||||
textures.clear();
|
||||
|
||||
std::vector<std::wstring> skyboxTextures = {
|
||||
L"assets/Skybox/skybox.png",
|
||||
};
|
||||
|
||||
TextureContainer SkyboxTextures;
|
||||
|
||||
// Load the textures
|
||||
for (const auto& textureFilename : skyboxTextures)
|
||||
{
|
||||
@ -45,12 +46,14 @@ Object* Skybox::ConstructSkybox()
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return nullptr;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
SkyboxTextures.diffuse.push_back(texture);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Create the model object
|
||||
m_Skybox = new Object();
|
||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), modelFilename, textures);
|
||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->GetDevice(), m_d3dClassRef->GetDeviceContext(), modelFilename, SkyboxTextures);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
|
@ -78,10 +78,10 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
bool result;
|
||||
HRESULT Hresult;
|
||||
|
||||
m_RenderQueues.push_back(std::ref(m_Skybox)); // Skybox doit être rendu en premier pour être derrière touts les autres objets
|
||||
m_RenderQueues.push_back(std::ref(m_object));
|
||||
m_RenderQueues.push_back(std::ref(m_cubes));
|
||||
m_RenderQueues.push_back(std::ref(m_terrainChunk));
|
||||
m_RenderQueues.push_back(std::ref(m_Skybox));
|
||||
|
||||
m_screenWidth = screenWidth;
|
||||
m_screenHeight = screenHeight;
|
||||
@ -226,6 +226,8 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
L"assets/Texture/stone01.png"
|
||||
};
|
||||
|
||||
TextureContainer CubeTextures;
|
||||
|
||||
for (const auto& textureFilename : textureFilenames)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
@ -235,13 +237,14 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
CubeTextures.diffuse.push_back(texture);
|
||||
}
|
||||
|
||||
// Create and initialize the model object.
|
||||
m_Model = new ModelClass;
|
||||
|
||||
|
||||
result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
result = m_Model->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, CubeTextures);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not initialize the model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
@ -337,6 +340,8 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
L"assets/Texture/marble01.png"
|
||||
};
|
||||
|
||||
TextureContainer BathTextures;
|
||||
|
||||
textures.clear();
|
||||
for (const auto& textureFilename : bathTextures)
|
||||
{
|
||||
@ -347,7 +352,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
BathTextures.diffuse.push_back(texture);
|
||||
}
|
||||
|
||||
// Set the file name of the bath model.
|
||||
@ -356,7 +361,7 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
// Create and initialize the bath model object.
|
||||
m_BathModel = new ModelClass;
|
||||
|
||||
result = m_BathModel->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
result = m_BathModel->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, BathTextures);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the bath model object.", L"Error", MB_OK);
|
||||
@ -370,6 +375,8 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
L"assets/Texture/water01.png"
|
||||
};
|
||||
|
||||
TextureContainer WaterTextures;
|
||||
|
||||
textures.clear();
|
||||
for (const auto& textureFilename : waterTextures)
|
||||
{
|
||||
@ -380,13 +387,13 @@ bool ApplicationClass::Initialize(int screenWidth, int screenHeight, HWND hwnd,
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
WaterTextures.diffuse.push_back(texture);
|
||||
}
|
||||
|
||||
// Create and initialize the water model object.
|
||||
m_WaterModel = new ModelClass;
|
||||
|
||||
result = m_WaterModel->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
result = m_WaterModel->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, WaterTextures);
|
||||
if (!result)
|
||||
{
|
||||
MessageBox(hwnd, L"Could not initialize the water model object.", L"Error", MB_OK);
|
||||
@ -890,7 +897,7 @@ bool ApplicationClass::RenderRefractionToTexture()
|
||||
m_BathModel->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderRefractionShader(m_Direct3D->GetDeviceContext(), m_BathModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_BathModel->GetTexture(0), m_Lights[0]->GetDirection(), ambientColor, diffuseColor, lightPosition, clipPlane);
|
||||
m_BathModel->GetTexture(TextureType::Diffuse,0), m_Lights[0]->GetDirection(), ambientColor, diffuseColor, lightPosition, clipPlane);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@ -946,7 +953,7 @@ bool ApplicationClass::RenderSceneToTexture(float rotation)
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0));
|
||||
m_Model->GetTexture(TextureType::Diffuse,0));
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@ -1026,7 +1033,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
// Render the model using the light shader.
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0),
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(TextureType::Diffuse,0),
|
||||
diffuseColor, lightPosition, ambientColor);
|
||||
|
||||
UpdateSkyboxPosition(); // Update the position of the skybox to match the camera position.
|
||||
@ -1061,7 +1068,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// Render the bath model using the light shader.
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_BathModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_BathModel->GetTexture(0), diffuseColor, lightPosition, ambientColor);
|
||||
m_BathModel->GetTexture(TextureType::Diffuse,0), diffuseColor, lightPosition, ambientColor);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
@ -1081,7 +1088,7 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// Render the water model using the water shader.
|
||||
result = m_ShaderManager->RenderWaterShader(m_Direct3D->GetDeviceContext(), m_WaterModel->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, reflectionMatrix,
|
||||
m_ReflectionTexture->GetShaderResourceView(), m_RefractionTexture->GetShaderResourceView(), m_WaterModel->GetTexture(0),
|
||||
m_ReflectionTexture->GetShaderResourceView(), m_RefractionTexture->GetShaderResourceView(), m_WaterModel->GetTexture(TextureType::Diffuse,0),
|
||||
m_waterTranslation, 0.01f);
|
||||
if (!result)
|
||||
{
|
||||
@ -1152,178 +1159,19 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t
|
||||
|
||||
// turn on the Z buffer
|
||||
m_Direct3D->TurnZBufferOn();
|
||||
|
||||
// Render the model using the multitexture shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
scaleMatrix = XMMatrixScaling(2.0f, 2.0f, 2.0f); // Build the scaling matrix.
|
||||
rotateMatrix = XMMatrixRotationY(-rotation); // Build the rotation matrix.
|
||||
translateMatrix = XMMatrixTranslation(-x, -y, -z); // Build the translation matrix.
|
||||
|
||||
// Multiply the scale, rotation, and translation matrices together to create the final world transformation matrix.
|
||||
srMatrix = XMMatrixMultiply(scaleMatrix, rotateMatrix);
|
||||
worldMatrix = XMMatrixMultiply(srMatrix, translateMatrix);
|
||||
|
||||
|
||||
// Get the light properties.
|
||||
for (i = 0; i < m_numLights; i++)
|
||||
{
|
||||
// Create the diffuse color array from the four light colors.
|
||||
diffuseColor[i] = m_Lights[i]->GetDiffuseColor();
|
||||
|
||||
|
||||
// Create the light position array from the four light positions.
|
||||
lightPosition[i] = m_Lights[i]->GetPosition();
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-5.0f, 1.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the alpha map shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderAlphaMapShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(5), m_Model->GetTexture(3));
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the alpha map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-5.0f, -5.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the texture shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderTextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0));
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the texture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(0.0f, 1.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the render map shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderNormalMapShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(1), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor());
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the normal map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(0.0f, -2.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the multitexture shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderMultitextureShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(5));
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the multitexture shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(0.0f, -5.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the translate shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderTranslateShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0), textureTranslation);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the translate shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-5.0f, -2.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the specular map shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderSpecMapShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix,
|
||||
m_Model->GetTexture(0), m_Model->GetTexture(1), m_Model->GetTexture(2), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(),
|
||||
m_Camera->GetPosition(), m_Lights[0]->GetSpecularColor(), m_Lights[0]->GetSpecularPower());
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the specular map shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-10.0f, -5.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the transparent shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderTransparentShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), blendAmount);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not render the model using the transparent shader", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-10.0f, -2.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the transparent shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), diffuseColor, lightPosition, ambientColor);
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup matrices.
|
||||
rotateMatrix = XMMatrixRotationY(rotation);
|
||||
translateMatrix = XMMatrixTranslation(-10.0f, 1.0f, -20.0f);
|
||||
worldMatrix = XMMatrixMultiply(rotateMatrix, translateMatrix);
|
||||
|
||||
// Render the model using the transparent shader.
|
||||
m_Model->Render(m_Direct3D->GetDeviceContext());
|
||||
|
||||
result = m_ShaderManager->RenderlightMapShader(m_Direct3D->GetDeviceContext(), m_Model->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, m_Model->GetTexture(0), m_Model->GetTexture(4));
|
||||
if (!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable the Z buffer and disable alpha blending now that 2D rendering is complete.
|
||||
// Réinitialiser la cible de rendu au back buffer.
|
||||
m_Direct3D->SetBackBufferRenderTarget();
|
||||
m_Direct3D->TurnZBufferOn();
|
||||
m_Direct3D->DisableAlphaBlending();
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1368,11 +1216,10 @@ void ApplicationClass::GenerateTerrain()
|
||||
L"assets/Texture/BricksGLOSS2K.png"
|
||||
};
|
||||
|
||||
|
||||
textures.clear();
|
||||
TextureContainer TerrainTextures;
|
||||
int i = 0;
|
||||
for (const auto& textureFilename : terrainTexture)
|
||||
{
|
||||
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), textureFilename.c_str(), nullptr, &texture);
|
||||
if (FAILED(result))
|
||||
@ -1391,7 +1238,9 @@ void ApplicationClass::GenerateTerrain()
|
||||
__FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return ; // Assurez-vous de retourner false ou de gérer l'erreur de manière appropriée
|
||||
}
|
||||
textures.push_back(texture);
|
||||
TerrainTextures.AssignTexture(TerrainTextures, texture, i);
|
||||
i++;
|
||||
|
||||
|
||||
// log success message
|
||||
Logger::Get().Log("Texture loaded: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
@ -1408,7 +1257,7 @@ void ApplicationClass::GenerateTerrain()
|
||||
for (int j = 0; j < 20; j++)
|
||||
{
|
||||
Object* newTerrain = new Object();
|
||||
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
newTerrain->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, TerrainTextures);
|
||||
newTerrain->SetScaleMatrix(scaleMatrix);
|
||||
newTerrain->SetTranslateMatrix(XMMatrixTranslation(i / 2 * scaleX , -12.0f, j * scaleZ));
|
||||
newTerrain->SetName(filenameWithoutExtension);
|
||||
@ -1437,14 +1286,16 @@ void ApplicationClass::AddKobject(std::wstring& filepath)
|
||||
|
||||
filesystem::current_path(m_WFolder);
|
||||
|
||||
TextureContainer KobjectsTextures;
|
||||
|
||||
// Liste des fichiers de texture
|
||||
std::vector<std::wstring> kobjTexture = {
|
||||
L"assets/Texture/Bricks2K.png",
|
||||
L"assets/Texture/BricksNRM2K.png",
|
||||
L"assets/Texture/EmptyTexture.png"
|
||||
L"assets/Texture/BricksGLOSS2K.png"
|
||||
};
|
||||
|
||||
textures.clear();
|
||||
int i = 0;
|
||||
for (const auto& textureFilename : kobjTexture)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
@ -1453,11 +1304,13 @@ void ApplicationClass::AddKobject(std::wstring& filepath)
|
||||
{
|
||||
// Handle error
|
||||
}
|
||||
textures.push_back(texture);
|
||||
KobjectsTextures.AssignTexture(KobjectsTextures, texture, i);
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
Object* newObject = new Object();
|
||||
newObject->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
newObject->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, KobjectsTextures);
|
||||
newObject->SetMass(1.0f);
|
||||
newObject->SetTranslateMatrix(XMMatrixTranslation(0.0f, 50.0f, 0.0f));
|
||||
newObject->SetName(filename);
|
||||
@ -1469,7 +1322,7 @@ void ApplicationClass::AddKobject(std::wstring& filepath)
|
||||
m_object.push_back(newObject);
|
||||
|
||||
// Vérifiez que l'objet a bien reçu les textures
|
||||
if (newObject->GetTexture(0) == nullptr)
|
||||
if (newObject->GetTexture(TextureType::Diffuse,0) == nullptr)
|
||||
{
|
||||
Logger::Get().Log("Object texture is null after initialization", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
}
|
||||
@ -1491,8 +1344,9 @@ void ApplicationClass::AddCube()
|
||||
L"assets/Texture/Bricks2K.png"
|
||||
};
|
||||
|
||||
|
||||
textures.clear();
|
||||
TextureContainer CubeTexture;
|
||||
int i = 0;
|
||||
|
||||
for (const auto& textureFilename : cubeTexture)
|
||||
{
|
||||
ID3D11ShaderResourceView* texture = nullptr;
|
||||
@ -1502,13 +1356,14 @@ void ApplicationClass::AddCube()
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return;
|
||||
}
|
||||
textures.push_back(texture);
|
||||
CubeTexture.AssignTexture(CubeTexture, texture, i);
|
||||
i++;
|
||||
}
|
||||
|
||||
static int cubeCount = 0;
|
||||
float position = cubeCount * 2.0f;
|
||||
Object* newCube = new Object();
|
||||
newCube->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, textures);
|
||||
newCube->Initialize(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), modelFilename, CubeTexture);
|
||||
|
||||
newCube->SetTranslateMatrix(XMMatrixTranslation(position, 0.0f, 0.0f));
|
||||
|
||||
@ -1789,7 +1644,8 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
for (const auto& RenderQueue : RenderQueues)
|
||||
{
|
||||
// Désactiver le Z-buffer si la RenderQueue est m_Skybox
|
||||
if (&RenderQueue.get() == &m_Skybox)
|
||||
bool isSkybox = (&RenderQueue.get() == &m_Skybox);
|
||||
if (isSkybox)
|
||||
{
|
||||
m_Direct3D->TurnZBufferOff();
|
||||
}
|
||||
@ -1846,9 +1702,9 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(5),
|
||||
object->GetTexture(3)
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
object->GetTexture(TextureType::Diffuse,1),
|
||||
object->GetTexture(TextureType::Alpha,0)
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
@ -1866,7 +1722,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
m_SunLight->GetDiffuseColor(),
|
||||
m_SunLight->GetAmbientColor(),
|
||||
m_SunLight->GetDirection(),
|
||||
@ -1886,8 +1742,8 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(1),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
object->GetTexture(TextureType::Normal,0),
|
||||
m_Lights[0]->GetDirection(),
|
||||
m_Lights[0]->GetDiffuseColor()
|
||||
);
|
||||
@ -1905,9 +1761,9 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(1),
|
||||
object->GetTexture(2),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
object->GetTexture(TextureType::Normal,0),
|
||||
object->GetTexture(TextureType::Specular,0),
|
||||
m_Lights[0]->GetDirection(),
|
||||
m_Lights[0]->GetDiffuseColor(),
|
||||
m_Camera->GetPosition(),
|
||||
@ -1928,7 +1784,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0)
|
||||
object->GetTexture(TextureType::Diffuse,0)
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
@ -1944,7 +1800,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
diffuse,
|
||||
position,
|
||||
ambient
|
||||
@ -1963,7 +1819,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
m_SunLight->GetDiffuseColor(),
|
||||
m_SunLight->GetAmbientColor(),
|
||||
m_SunLight->GetDirection(),
|
||||
@ -1983,7 +1839,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
m_SunLight->GetDiffuseColor(),
|
||||
m_SunLight->GetAmbientColor(),
|
||||
m_SunLight->GetDirection(),
|
||||
@ -2002,7 +1858,7 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
worldMatrix,
|
||||
view,
|
||||
projection,
|
||||
object->GetTexture(0),
|
||||
object->GetTexture(TextureType::Diffuse,0),
|
||||
diffuse,
|
||||
position,
|
||||
ambient
|
||||
@ -2015,7 +1871,13 @@ bool ApplicationClass::RenderPass(const std::vector<std::reference_wrapper<std::
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isSkybox)
|
||||
{
|
||||
m_Direct3D->TurnZBufferOn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SetRenderCount(renderCount);
|
||||
|
||||
|
@ -272,69 +272,116 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
||||
object->SetScale(XMVectorSet(scl[0], scl[1], scl[2], 0.0f));
|
||||
}
|
||||
|
||||
ImGui::Separator();
|
||||
ImGui::Separator();
|
||||
|
||||
// Texture
|
||||
// add all texture category names to a vector
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse",
|
||||
"Normal",
|
||||
"Specular",
|
||||
"Reflection",
|
||||
"Refraction"
|
||||
};
|
||||
// Définir les types de textures
|
||||
std::vector<std::string> textureCategories = {
|
||||
"Diffuse", "Normal", "Specular", "Alpha"
|
||||
};
|
||||
|
||||
// Display all images
|
||||
ImGui::BeginChild("TextureChild", ImVec2(0, 100), false, ImGuiWindowFlags_HorizontalScrollbar);
|
||||
for (int count = 0; count < textureCategories.size(); count++)
|
||||
{
|
||||
std::string textureLabel = "Texture##" + std::to_string(index) + "##" + std::to_string(count);
|
||||
ID3D11ShaderResourceView* texture = object->GetTexture(count);
|
||||
if (texture != nullptr)
|
||||
{
|
||||
ImGui::Text(textureCategories[count].c_str());
|
||||
ImGui::SameLine();
|
||||
std::vector<TextureType> textureTypes = {
|
||||
TextureType::Diffuse, TextureType::Normal,
|
||||
TextureType::Specular, TextureType::Alpha
|
||||
};
|
||||
|
||||
std::string buttonLabel = "button " + std::to_string(count);
|
||||
if (ImGui::ImageButton(buttonLabel.c_str(), (ImTextureID)texture, ImVec2(64, 64)))
|
||||
{
|
||||
// Open file dialog
|
||||
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\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrFileTitle = NULL;
|
||||
ofn.nMaxFileTitle = 0;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
// Cré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égorie
|
||||
ImGui::Text("%s:", typeName.c_str());
|
||||
ImGui::SameLine();
|
||||
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Load the selected texture
|
||||
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, count);
|
||||
}
|
||||
}
|
||||
// Compter combien de textures de ce type existent
|
||||
int textureCount = 0;
|
||||
while (object->GetTexture(type, textureCount) != nullptr)
|
||||
{
|
||||
textureCount++;
|
||||
}
|
||||
|
||||
if (ImGui::IsItemHovered())
|
||||
{
|
||||
ImGui::BeginTooltip();
|
||||
ImGui::Image((ImTextureID)texture, ImVec2(256, 256));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
// 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îte de dialogue pour changer la texture
|
||||
OPENFILENAME ofn;
|
||||
WCHAR szFile[260];
|
||||
ZeroMemory(&ofn, sizeof(ofn));
|
||||
ofn.lStructSize = sizeof(ofn);
|
||||
ofn.hwndOwner = NULL;
|
||||
ofn.lpstrFile = szFile;
|
||||
szFile[0] = '\0';
|
||||
ofn.nMaxFile = sizeof(szFile);
|
||||
ofn.lpstrFilter = L"Texture\0*.png;*.jpg;*.dds\0";
|
||||
ofn.nFilterIndex = 1;
|
||||
ofn.lpstrInitialDir = NULL;
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
|
||||
if (count < textureCategories.size() - 1)
|
||||
{
|
||||
ImGui::SameLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui::EndChild();
|
||||
if (GetOpenFileName(&ofn))
|
||||
{
|
||||
// Changer la texture existante
|
||||
object->ChangeTexture(m_device, m_deviceContext, ofn.lpstrFile, type, texIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Afficher l'indice de texture et pré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î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();
|
||||
|
||||
|
@ -18,8 +18,41 @@ ModelClass::~ModelClass()
|
||||
{
|
||||
}
|
||||
|
||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, std::vector<ID3D11ShaderResourceView*> textures) {
|
||||
Logger::Get().Log("Initializing model class with preloaded textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
// bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, std::vector<ID3D11ShaderResourceView*> textures) {
|
||||
// Logger::Get().Log("Initializing model class with preloaded textures (vector)", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
//
|
||||
// bool result = Initialize(device, deviceContext, modelFilename);
|
||||
// if (!result) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// // Ajouter toutes les textures au container comme textures diffuses
|
||||
// for (auto& tex : textures) {
|
||||
// m_Textures.diffuse.push_back(tex);
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename, const TextureContainer& textures) {
|
||||
Logger::Get().Log("Initializing model class with preloaded texture container", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
bool result = Initialize(device, deviceContext, modelFilename);
|
||||
if (!result) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copie de toutes les textures de la structure
|
||||
for (auto& tex : textures.diffuse) m_Textures.diffuse.push_back(tex);
|
||||
for (auto& tex : textures.normal) m_Textures.normal.push_back(tex);
|
||||
for (auto& tex : textures.specular) m_Textures.specular.push_back(tex);
|
||||
for (auto& tex : textures.alpha) m_Textures.alpha.push_back(tex);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceContext, char* modelFilename) {
|
||||
Logger::Get().Log("Initializing model class without textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
bool result;
|
||||
|
||||
@ -40,14 +73,11 @@ bool ModelClass::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCon
|
||||
return false;
|
||||
}
|
||||
|
||||
m_Textures = textures;
|
||||
|
||||
Logger::Get().Log("Model class initialized with preloaded textures", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
Logger::Get().Log("Model class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void ModelClass::Shutdown()
|
||||
{
|
||||
// Release the model textures.
|
||||
@ -77,11 +107,13 @@ int ModelClass::GetIndexCount()
|
||||
return m_indexCount;
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* ModelClass::GetTexture(int index) const {
|
||||
if (index >= 0 && index < m_Textures.size()) {
|
||||
return m_Textures[index];
|
||||
}
|
||||
return nullptr; // Retourne nullptr si l'index est hors limites
|
||||
// ID3D11ShaderResourceView* ModelClass::GetTexture(int index) const {
|
||||
// // Pour compatibilité, utilise la texture diffuse par défaut
|
||||
// return m_Textures.GetTexture(TextureType::Diffuse, index);
|
||||
// }
|
||||
|
||||
ID3D11ShaderResourceView* ModelClass::GetTexture(TextureType type, int index) const {
|
||||
return m_Textures.GetTexture(type, index);
|
||||
}
|
||||
|
||||
bool ModelClass::InitializeBuffers(ID3D11Device* device)
|
||||
@ -216,19 +248,10 @@ void ModelClass::RenderBuffers(ID3D11DeviceContext* deviceContext)
|
||||
void ModelClass::ReleaseTextures()
|
||||
{
|
||||
Logger::Get().Log("Releasing textures", __FILE__, __LINE__);
|
||||
|
||||
// Release the texture object array.
|
||||
for (auto& texture : m_Textures)
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
texture->Release();
|
||||
texture = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
m_Textures.clear();
|
||||
|
||||
|
||||
// Utilise la méthode ReleaseAll de TextureContainer
|
||||
m_Textures.ReleaseAll();
|
||||
|
||||
Logger::Get().Log("Textures released", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
@ -551,41 +574,71 @@ void ModelClass::ReleaseModel()
|
||||
return;
|
||||
}
|
||||
|
||||
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index)
|
||||
{
|
||||
// bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, int index) {
|
||||
// // Pour compatibilité, utilise la texture diffuse par défaut
|
||||
// return ChangeTexture(device, deviceContext, filename, TextureType::Diffuse, index);
|
||||
// }
|
||||
|
||||
bool ModelClass::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
|
||||
// Load the new texture using WICTextureLoader.
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to load new texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Release the old texture if it exists.
|
||||
if (index >= 0 && index < m_Textures.size() && m_Textures[index])
|
||||
{
|
||||
m_Textures[index]->Release();
|
||||
m_Textures[index] = nullptr;
|
||||
// Récupérer le vecteur correspondant au type de texture
|
||||
auto& textureVector = m_Textures.Get(type);
|
||||
|
||||
// Si l'index est hors limites, redimensionner le vecteur
|
||||
if (index >= textureVector.size()) {
|
||||
textureVector.resize(index + 1, nullptr);
|
||||
}
|
||||
|
||||
// Assign the new texture to the specified index.
|
||||
if (index >= 0 && index < m_Textures.size())
|
||||
{
|
||||
m_Textures[index] = newTexture;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the index is out of range, log an error and release the new texture.
|
||||
Logger::Get().Log("Texture index out of range", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
newTexture->Release();
|
||||
return false;
|
||||
// Libérer l'ancienne texture si elle existe
|
||||
if (textureVector[index]) {
|
||||
textureVector[index]->Release();
|
||||
}
|
||||
|
||||
// Assigner la nouvelle texture
|
||||
textureVector[index] = newTexture;
|
||||
|
||||
Logger::Get().Log("Texture changed successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModelClass::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
|
||||
Logger::Get().Log("Adding texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ajouter la texture au vecteur correspondant
|
||||
m_Textures.Get(type).push_back(newTexture);
|
||||
|
||||
Logger::Get().Log("Texture added successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ModelClass::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
|
||||
if (!texture) {
|
||||
Logger::Get().Log("Cannot add null texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Ajouter la texture au vecteur correspondant
|
||||
m_Textures.Get(type).push_back(texture);
|
||||
return true;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user