summaryrefslogtreecommitdiff
path: root/indra/newview/gltf/asset.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/gltf/asset.h')
-rw-r--r--indra/newview/gltf/asset.h81
1 files changed, 78 insertions, 3 deletions
diff --git a/indra/newview/gltf/asset.h b/indra/newview/gltf/asset.h
index 6e576a1ffe..5a62313705 100644
--- a/indra/newview/gltf/asset.h
+++ b/indra/newview/gltf/asset.h
@@ -45,11 +45,59 @@ namespace LL
class Material
{
public:
+ class TextureInfo
+ {
+ public:
+ S32 mIndex = INVALID_INDEX;
+ S32 mTexCoord = 0;
+
+ const TextureInfo& operator=(const tinygltf::TextureInfo& src);
+ };
+
+ class NormalTextureInfo : public TextureInfo
+ {
+ public:
+ F32 mScale = 1.0f;
+
+ const NormalTextureInfo& operator=(const tinygltf::NormalTextureInfo& src);
+ };
+
+ class OcclusionTextureInfo : public TextureInfo
+ {
+ public:
+ F32 mStrength = 1.0f;
+
+ const OcclusionTextureInfo& operator=(const tinygltf::OcclusionTextureInfo& src);
+ };
+
+ class PbrMetallicRoughness
+ {
+ public:
+ glh::vec4f mBaseColorFactor = glh::vec4f(1.f,1.f,1.f,1.f);
+ TextureInfo mBaseColorTexture;
+ F32 mMetallicFactor = 1.0f;
+ F32 mRoughnessFactor = 1.0f;
+ TextureInfo mMetallicRoughnessTexture;
+ const PbrMetallicRoughness& operator=(const tinygltf::PbrMetallicRoughness& src);
+ };
+
+
// use LLFetchedGLTFMaterial for now, but eventually we'll want to use
// a more flexible GLTF material implementation instead of the fixed packing
// version we use for sharable GLTF material assets
LLPointer<LLFetchedGLTFMaterial> mMaterial;
+ PbrMetallicRoughness mPbrMetallicRoughness;
+ NormalTextureInfo mNormalTexture;
+ OcclusionTextureInfo mOcclusionTexture;
+ TextureInfo mEmissiveTexture;
+
+
std::string mName;
+ glh::vec3f mEmissiveFactor = glh::vec3f(0.f, 0.f, 0.f);
+ std::string mAlphaMode = "OPAQUE";
+ F32 mAlphaCutoff = 0.5f;
+ bool mDoubleSided = false;
+
const Material& operator=(const tinygltf::Material& src);
@@ -179,11 +227,16 @@ namespace LL
std::string mName;
std::string mUri;
std::string mMimeType;
+
+ S32 mBufferView = INVALID_INDEX;
+
std::vector<U8> mData;
S32 mWidth;
S32 mHeight;
S32 mComponent;
S32 mBits;
+ S32 mPixelType;
+
LLPointer<LLViewerFetchedTexture> mTexture;
const Image& operator=(const tinygltf::Image& src)
@@ -196,10 +249,14 @@ namespace LL
mHeight = src.height;
mComponent = src.component;
mBits = src.bits;
-
+ mBufferView = src.bufferView;
+ mPixelType = src.pixel_type;
return *this;
}
+ // save image clear local data, and set uri
+ void decompose(Asset& asset, const std::string& filename);
+
void allocateGLResources()
{
// allocate texture
@@ -208,7 +265,7 @@ namespace LL
};
// C++ representation of a GLTF Asset
- class Asset : public LLRefCount
+ class Asset
{
public:
std::vector<Scene> mScenes;
@@ -224,6 +281,15 @@ namespace LL
std::vector<Animation> mAnimations;
std::vector<Skin> mSkins;
+ std::string mVersion;
+ std::string mGenerator;
+ std::string mMinVersion;
+ std::string mCopyright;
+
+ S32 mDefaultScene = INVALID_INDEX;
+ tinygltf::Value mExtras;
+
+
// the last time update() was called according to gFrameTimeSeconds
F32 mLastUpdateTime = gFrameTimeSeconds;
@@ -258,7 +324,16 @@ namespace LL
);
const Asset& operator=(const tinygltf::Model& src);
-
+
+ // save the asset to a tinygltf model
+ void save(tinygltf::Model& dst);
+
+ // decompose the asset to the given .gltf file
+ void decompose(const std::string& filename);
+
+ // remove the bufferview at the given index
+ // updates all bufferview indices in this Asset as needed
+ void eraseBufferView(S32 bufferView);
};
}
}