123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- /**
- * @file llfetchedgltfmaterial.h
- *
- * $LicenseInfo:firstyear=2022&license=viewergpl$
- *
- * Copyright (c) 2022, Linden Research, Inc.
- *
- * Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
- * $/LicenseInfo$
- */
- #ifndef LL_LLFETCHEDGLTFMATERIAL_H
- #define LL_LLFETCHEDGLTFMATERIAL_H
- #include <functional>
- #include "hbfastset.h"
- #include "llgltfmaterial.h"
- #include "llpointer.h"
- class LLViewerTexture;
- class LLViewerFetchedTexture;
- class LLFetchedGLTFMaterial : public LLGLTFMaterial
- {
- friend class LLGLTFMaterialList;
- protected:
- LOG_CLASS(LLFetchedGLTFMaterial);
- public:
- LL_INLINE LLFetchedGLTFMaterial()
- : mExpectedFlushTime(0.f),
- mActive(true),
- mFetching(false),
- mFetchSuccess(false)
- {
- }
- LLFetchedGLTFMaterial& operator=(const LLFetchedGLTFMaterial& rhs);
- bool operator==(const LLGLTFMaterial& rhs) const = delete;
- LLFetchedGLTFMaterial* asFetched() override { return this; }
- void onMaterialComplete(std::function<void()> mat_complete_callback);
- // Bind this material for rendering. media_texp is an optional media
- // texture that may override the base color texture.
- void bind(LLViewerTexture* media_texp, F32 vsize);
- LL_INLINE bool isFetching() const { return mFetching; }
- LL_INLINE bool isLoaded() const { return !mFetching && mFetchSuccess; }
- void addTextureEntry(LLTextureEntry* tep) override;
- void removeTextureEntry(LLTextureEntry* tep) override;
- bool replaceLocalTexture(const LLUUID& tracking_id, const LLUUID& old_id,
- const LLUUID& new_id) override;
- void updateTextureTracking() override;
- typedef fast_hset<LLTextureEntry*> te_list_t;
- LL_INLINE const te_list_t& getTexEntries() const
- {
- return mTextureEntries;
- }
- // Handy methods to easily setup a material preview. HB
- LLViewerTexture* getPreview();
- LL_INLINE void clearPreview() { mPreview = NULL; }
- protected:
- // Lifetime management
- LL_INLINE void materialBegin() { mFetching = true; }
- void materialComplete(bool success);
- public:
- // Textures used for fetching/rendering
- LLPointer<LLViewerFetchedTexture> mBaseColorTexture;
- LLPointer<LLViewerFetchedTexture> mNormalTexture;
- LLPointer<LLViewerFetchedTexture> mMetallicRoughnessTexture;
- LLPointer<LLViewerFetchedTexture> mEmissiveTexture;
- protected:
- te_list_t mTextureEntries;
- LLPointer<LLViewerTexture> mPreview;
- // Lifetime management
- std::vector<std::function<void()> > mCompleteCallbacks;
- F32 mExpectedFlushTime;
- bool mActive;
- bool mFetching;
- bool mFetchSuccess;
- };
- // Used in the llgltf library, to create and bind a fetched material. HB
- extern LLGLTFMaterial* create_fetch_material();
- extern void bind_fetched_material(LLGLTFMaterial* matp);
- // For the new implementation of the llgltf library (WIP).
- extern LLGLTexture* gl_texture_from_fetched(const LLUUID& id);
- extern LLGLTexture* gl_texture_from_local_file(const std::string& filename);
- extern LLGLTexture* gl_texture_from_memory(U8* datap, S32 size,
- const std::string& mime_type);
- #endif // LL_LLFETCHEDGLTFMATERIAL_H
|