-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnglMaterialManager.cpp
More file actions
58 lines (38 loc) · 1.03 KB
/
nglMaterialManager.cpp
File metadata and controls
58 lines (38 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "nglMaterialManager.h"
nglMaterialManager::nglMaterialManager(std::string& dir)
{
this->_matDefLoader = new nglMaterialDefinitionLoader();
this->_matDirectory = dir;
}
nglMaterialManager::~nglMaterialManager()
{
}
nglMaterial* nglMaterialManager::GetMaterial(std::string& name)
{
//load material definition!
nglMaterial* material = this->GetLoadedMaterial(name);
if (material != NULL)
{
//material already exists.
return material;
}
else {
material = this->_matDefLoader->LoadDefinitionFile(this->_matDirectory, name + ".nmd");
if (material != NULL)
this->_materials.push_back(material);
return material;
}
}
bool nglMaterialManager::HasMaterialLoaded(std::string& name)
{
return (this->GetLoadedMaterial(name) != NULL);
}
nglMaterial* nglMaterialManager::GetLoadedMaterial(std::string& name)
{
for (int i = 0; i< this->_materials.size();i++)
{
if (this->_materials[i]->GetName() == name)
return this->_materials[i];
}
return NULL;
}