Extended Model to support specular and normal maps
This commit is contained in:
+9
-1
@@ -17,11 +17,19 @@ Model::Model(OBJ &obj, ResourceManager* rm)
|
|||||||
if (face.Material != currentMaterial)
|
if (face.Material != currentMaterial)
|
||||||
{
|
{
|
||||||
currentMaterial = face.Material;
|
currentMaterial = face.Material;
|
||||||
|
|
||||||
// Load texture
|
// Load texture
|
||||||
auto texture = std::shared_ptr<Texture>(rm->Load<Texture>("Texture", currentMaterial->DiffuseTexture.FileName));
|
auto texture = std::shared_ptr<Texture>(rm->Load<Texture>("Texture", currentMaterial->DiffuseTexture.FileName));
|
||||||
|
// TODO: Load normal map
|
||||||
|
std::shared_ptr<Texture> normalMap = nullptr;
|
||||||
|
// Load specular map
|
||||||
|
std::shared_ptr<Texture> specularMap = nullptr;
|
||||||
|
if (!currentMaterial->SpecularMap.FileName.empty())
|
||||||
|
specularMap = std::shared_ptr<Texture>(rm->Load<Texture>("Texture", currentMaterial->SpecularMap.FileName));
|
||||||
|
|
||||||
// TODO: Load material parameters
|
// TODO: Load material parameters
|
||||||
// Create new texture group (start index of new group is upcoming index)
|
// Create new texture group (start index of new group is upcoming index)
|
||||||
TextureGroup texGroup = { texture, index, index };
|
TextureGroup texGroup = { texture, normalMap, specularMap, index, index };
|
||||||
TextureGroups.push_back(texGroup);
|
TextureGroups.push_back(texGroup);
|
||||||
currentTexGroup = &TextureGroups.back();
|
currentTexGroup = &TextureGroups.back();
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -21,7 +21,9 @@ public:
|
|||||||
|
|
||||||
struct TextureGroup
|
struct TextureGroup
|
||||||
{
|
{
|
||||||
std::shared_ptr<Texture> Texture;
|
std::shared_ptr<::Texture> Texture;
|
||||||
|
std::shared_ptr<::Texture> NormalMap;
|
||||||
|
std::shared_ptr<::Texture> SpecularMap;
|
||||||
unsigned int StartIndex;
|
unsigned int StartIndex;
|
||||||
unsigned int EndIndex;
|
unsigned int EndIndex;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user