summaryrefslogtreecommitdiff
path: root/indra/newview/gltf/accessor.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/gltf/accessor.h')
-rw-r--r--indra/newview/gltf/accessor.h83
1 files changed, 54 insertions, 29 deletions
diff --git a/indra/newview/gltf/accessor.h b/indra/newview/gltf/accessor.h
index 9b8265d8da..ec68c5f624 100644
--- a/indra/newview/gltf/accessor.h
+++ b/indra/newview/gltf/accessor.h
@@ -26,16 +26,16 @@
* $/LicenseInfo$
*/
-#include "../lltinygltfhelper.h"
#include "llstrider.h"
+#include "boost/json.hpp"
+
+#include "common.h"
// LL GLTF Implementation
namespace LL
{
namespace GLTF
{
- class Asset;
-
constexpr S32 INVALID_INDEX = -1;
class Buffer
@@ -44,52 +44,77 @@ namespace LL
std::vector<U8> mData;
std::string mName;
std::string mUri;
+ S32 mByteLength = 0;
+
+ // erase the given range from this buffer.
+ // also updates all buffer views in given asset that reference this buffer
+ void erase(Asset& asset, S32 offset, S32 length);
+
+ bool prep(Asset& asset);
- const Buffer& operator=(const tinygltf::Buffer& src);
+ void serialize(boost::json::object& obj) const;
+ const Buffer& operator=(const Value& value);
+
+ bool save(Asset& asset, const std::string& folder);
};
class BufferView
{
public:
S32 mBuffer = INVALID_INDEX;
- S32 mByteLength;
- S32 mByteOffset;
- S32 mByteStride;
- S32 mTarget;
- S32 mComponentType;
+ S32 mByteLength = 0;
+ S32 mByteOffset = 0;
+ S32 mByteStride = 0;
+ S32 mTarget = -1;
std::string mName;
- const BufferView& operator=(const tinygltf::BufferView& src);
-
+ void serialize(boost::json::object& obj) const;
+ const BufferView& operator=(const Value& value);
};
-
+
class Accessor
{
public:
- S32 mBufferView = INVALID_INDEX;
- S32 mByteOffset;
- S32 mComponentType;
- S32 mCount;
- std::vector<double> mMax;
- std::vector<double> mMin;
+ enum class Type : U8
+ {
+ SCALAR,
+ VEC2,
+ VEC3,
+ VEC4,
+ MAT2,
+ MAT3,
+ MAT4
+ };
- enum class Type : S32
+ enum class ComponentType : U32
{
- SCALAR = TINYGLTF_TYPE_SCALAR,
- VEC2 = TINYGLTF_TYPE_VEC2,
- VEC3 = TINYGLTF_TYPE_VEC3,
- VEC4 = TINYGLTF_TYPE_VEC4,
- MAT2 = TINYGLTF_TYPE_MAT2,
- MAT3 = TINYGLTF_TYPE_MAT3,
- MAT4 = TINYGLTF_TYPE_MAT4
+ BYTE = 5120,
+ UNSIGNED_BYTE = 5121,
+ SHORT = 5122,
+ UNSIGNED_SHORT = 5123,
+ UNSIGNED_INT = 5125,
+ FLOAT = 5126
};
- S32 mType;
- bool mNormalized;
+ std::vector<double> mMax;
+ std::vector<double> mMin;
std::string mName;
+ S32 mBufferView = INVALID_INDEX;
+ S32 mByteOffset = 0;
+ ComponentType mComponentType = ComponentType::BYTE;
+ S32 mCount = 0;
+ Type mType = Type::SCALAR;
+ bool mNormalized = false;
- const Accessor& operator=(const tinygltf::Accessor& src);
+ void serialize(boost::json::object& obj) const;
+ const Accessor& operator=(const Value& value);
};
+
+ // convert from "SCALAR", "VEC2", etc to Accessor::Type
+ Accessor::Type gltf_type_to_enum(const std::string& type);
+
+ // convert from Accessor::Type to "SCALAR", "VEC2", etc
+ std::string enum_to_gltf_type(Accessor::Type type);
}
}