37 std::vector<ID3D11ShaderResourceView*> diffuse;
38 std::vector<ID3D11ShaderResourceView*> normal;
39 std::vector<ID3D11ShaderResourceView*> specular;
40 std::vector<ID3D11ShaderResourceView*> alpha;
43 std::vector<std::wstring> diffusePaths;
44 std::vector<std::wstring> normalPaths;
45 std::vector<std::wstring> specularPaths;
46 std::vector<std::wstring> alphaPaths;
50 std::vector<ID3D11ShaderResourceView*>& Get(TextureType type)
const {
52 case TextureType::Diffuse:
return const_cast<std::vector<ID3D11ShaderResourceView*>&
>(diffuse);
53 case TextureType::Normal:
return const_cast<std::vector<ID3D11ShaderResourceView*>&
>(normal);
54 case TextureType::Specular:
return const_cast<std::vector<ID3D11ShaderResourceView*>&
>(specular);
55 case TextureType::Alpha:
return const_cast<std::vector<ID3D11ShaderResourceView*>&
>(alpha);
56 default:
return const_cast<std::vector<ID3D11ShaderResourceView*>&
>(diffuse);
61 std::vector<std::wstring> GetPaths(TextureType type)
const {
64 case TextureType::Diffuse:
return std::vector<std::wstring>(diffusePaths);
65 case TextureType::Normal:
return std::vector<std::wstring>(normalPaths);
66 case TextureType::Specular:
return std::vector<std::wstring>(specularPaths);
67 case TextureType::Alpha:
return std::vector<std::wstring>(alphaPaths);
68 default:
return std::vector<std::wstring>(diffusePaths);
74 ID3D11ShaderResourceView* GetTexture(TextureType type,
int index)
const {
75 auto& vec = Get(type);
76 if (index >= 0 && index < vec.size())
82 std::wstring GetTexturePath(TextureType type,
int index)
const
84 std::vector<std::wstring> path = GetPaths(type);
85 if (index >= 0 && index < path.size())
93 ReleaseVector(diffuse);
94 ReleaseVector(normal);
95 ReleaseVector(specular);
98 ReleaseVector(diffusePaths);
99 ReleaseVector(normalPaths);
100 ReleaseVector(specularPaths);
101 ReleaseVector(alphaPaths);
105 void AssignTexture(
TextureContainer& textContainer, ID3D11ShaderResourceView* texture ,
const std::wstring paths,
int index)
110 textContainer.diffuse.push_back(texture);
111 textContainer.diffusePaths.push_back(paths);
114 textContainer.normal.push_back(texture);
115 textContainer.normalPaths.push_back(paths);
118 textContainer.specular.push_back(texture);
119 textContainer.specularPaths.push_back(paths);
122 textContainer.alpha.push_back(texture);
123 textContainer.alphaPaths.push_back(paths);
126 textContainer.diffuse.push_back(texture);
127 textContainer.diffusePaths.push_back(paths);
133 void ReleaseVector(std::vector<ID3D11ShaderResourceView*>& vec) {
134 for (
auto& tex : vec) {
143 void ReleaseVector(std::vector<std::wstring>& vec) {
210 bool Initialize(ID3D11Device*, ID3D11DeviceContext*,
char*,
const TextureContainer&);
212 bool Initialize(ID3D11Device*, ID3D11DeviceContext*,
char*);
214 void Render(ID3D11DeviceContext*);
217 int GetVertexCount()
const {
return m_vertexCount; }
222 ID3D11ShaderResourceView* GetTexture(TextureType type,
int index)
const;
225 bool ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type,
int index);
228 bool AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext,std::wstring filename, TextureType type);
229 bool AddTexture(ID3D11ShaderResourceView* texture, TextureType type);
231 void SetTextureContainer (
TextureContainer& texturesContainer) { m_Textures = texturesContainer; }
234 bool PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* deviceContext,
TextureContainer& textureContainer);
237 int m_vertexCount, m_indexCount;
238 ID3D11Buffer* m_vertexBuffer, * m_indexBuffer;
241 bool InitializeBuffers(ID3D11Device*);
242 void ShutdownBuffers();
243 void RenderBuffers(ID3D11DeviceContext*);
244 void ReleaseTextures();
246 bool LoadModel(
char*);
247 bool LoadObjModel(
char*);
248 bool LoadTxtModel(
char*);
251 void CalculateModelVectors();
252 void CalculateTangentBinormal(TempVertexType, TempVertexType, TempVertexType, VectorType&, VectorType&);