diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 16:36:22 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-14 16:36:22 +0100 |
commit | 32a2da41e0946c1d6d364b7763d1829bfa8b74db (patch) | |
tree | bb7c1014d204dabfcf10cd88623c1f7996b6f049 | |
parent | Define our own enum for texture mapmode (diff) | |
download | ilt-32a2da41e0946c1d6d364b7763d1829bfa8b74db.tar.bz2 ilt-32a2da41e0946c1d6d364b7763d1829bfa8b74db.tar.xz ilt-32a2da41e0946c1d6d364b7763d1829bfa8b74db.zip |
Configure texture fragment mapmode from material
-rw-r--r-- | assetFactory/assimp.cpp | 7 | ||||
-rw-r--r-- | assetFactory/textureFragment.h | 2 |
2 files changed, 9 insertions, 0 deletions
diff --git a/assetFactory/assimp.cpp b/assetFactory/assimp.cpp index 9a49717..840c5a9 100644 --- a/assetFactory/assimp.cpp +++ b/assetFactory/assimp.cpp @@ -85,6 +85,11 @@ public: } }; +static_assert(TextureOptions::MapMode::Repeat == static_cast<TextureOptions::MapMode>(aiTextureMapMode_Wrap)); +static_assert(TextureOptions::MapMode::Clamp == static_cast<TextureOptions::MapMode>(aiTextureMapMode_Clamp)); +static_assert(TextureOptions::MapMode::Decal == static_cast<TextureOptions::MapMode>(aiTextureMapMode_Decal)); +static_assert(TextureOptions::MapMode::Mirror == static_cast<TextureOptions::MapMode>(aiTextureMapMode_Mirror)); + void AssImp::postLoad() { @@ -107,6 +112,8 @@ AssImp::postLoad() auto texture = std::make_shared<TextureFragment>(); texture->id = m->GetName().C_Str(); texture->path = path.C_Str(); + m->Get(AI_MATKEY_MAPPINGMODE_U_DIFFUSE(0), texture->mapmodeU); + m->Get(AI_MATKEY_MAPPINGMODE_V_DIFFUSE(0), texture->mapmodeV); texture->image = Worker::addWork([t = scene->GetEmbeddedTexture(path.C_Str())]() { return std::make_unique<Image>( std::span {reinterpret_cast<unsigned char *>(t->pcData), t->mWidth}, STBI_rgb_alpha); diff --git a/assetFactory/textureFragment.h b/assetFactory/textureFragment.h index 75fe96e..e6f07f3 100644 --- a/assetFactory/textureFragment.h +++ b/assetFactory/textureFragment.h @@ -1,6 +1,7 @@ #pragma once #include "gfx/image.h" +#include "gfx/models/texture.h" #include "persistence.h" #include "stdTypeDefs.hpp" #include "worker.h" @@ -9,6 +10,7 @@ class TextureFragment : public Persistence::Persistable, public StdTypeDefs<Text public: std::string id; std::string path; + TextureOptions::MapMode mapmodeU, mapmodeV; Worker::WorkPtrT<std::unique_ptr<Image>> image; private: |