closes https://github.com/assimp/assimp/issues/2119: initial version.
parent
aa25c815bd
commit
04db5cd5ea
|
@ -1427,9 +1427,6 @@ inline void Asset::ReadExtensionsUsed(Document& doc)
|
|||
}
|
||||
}
|
||||
|
||||
#define CHECK_EXT(EXT) \
|
||||
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
|
||||
|
||||
CHECK_EXT(KHR_binary_glTF);
|
||||
CHECK_EXT(KHR_materials_common);
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ namespace glTFCommon {
|
|||
size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out);
|
||||
|
||||
inline
|
||||
size_t DecodeBase64(const char* in, uint8_t*& out) {
|
||||
size_t DecodeBase64(const char* in, uint8_t*& out) {
|
||||
return DecodeBase64(in, strlen(in), out);
|
||||
}
|
||||
|
||||
|
@ -221,25 +221,22 @@ namespace glTFCommon {
|
|||
};
|
||||
|
||||
inline
|
||||
char EncodeCharBase64(uint8_t b) {
|
||||
char EncodeCharBase64(uint8_t b) {
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="[size_t(b)];
|
||||
}
|
||||
|
||||
inline
|
||||
uint8_t DecodeCharBase64(char c) {
|
||||
uint8_t DecodeCharBase64(char c) {
|
||||
return DATA<true>::tableDecodeBase64[size_t(c)]; // TODO faster with lookup table or ifs?
|
||||
/*if (c >= 'A' && c <= 'Z') return c - 'A';
|
||||
if (c >= 'a' && c <= 'z') return c - 'a' + 26;
|
||||
if (c >= '0' && c <= '9') return c - '0' + 52;
|
||||
if (c == '+') return 62;
|
||||
if (c == '/') return 63;
|
||||
return 64; // '-' */
|
||||
}
|
||||
|
||||
size_t DecodeBase64(const char* in, size_t inLength, uint8_t*& out);
|
||||
|
||||
void EncodeBase64(const uint8_t* in, size_t inLength, std::string& out);
|
||||
}
|
||||
} // namespace Util
|
||||
|
||||
#define CHECK_EXT(EXT) \
|
||||
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -685,6 +685,10 @@ namespace glTF2
|
|||
Ref<Texture> texture;
|
||||
unsigned int index;
|
||||
unsigned int texCoord = 0;
|
||||
|
||||
float offset[2];
|
||||
float rotation;
|
||||
float scale[2];
|
||||
};
|
||||
|
||||
struct NormalTextureInfo : TextureInfo
|
||||
|
@ -1024,7 +1028,7 @@ namespace glTF2
|
|||
bool KHR_materials_pbrSpecularGlossiness;
|
||||
bool KHR_materials_unlit;
|
||||
bool KHR_lights_punctual;
|
||||
|
||||
bool KHR_texture_transform;
|
||||
} extensionsUsed;
|
||||
|
||||
AssetMetadata asset;
|
||||
|
|
|
@ -800,8 +800,20 @@ inline void Texture::Read(Value& obj, Asset& r)
|
|||
}
|
||||
|
||||
namespace {
|
||||
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out)
|
||||
{
|
||||
inline void SetTextureProperties(Asset& r, Value* prop, TextureInfo& out) {
|
||||
if (r.extensionsUsed.KHR_texture_transform) {
|
||||
if (Value *extensions = FindObject(*prop, "extensions")) {
|
||||
if (Value *pKHR_texture_transform = FindObject(*extensions, "KHR_texture_transform")) {
|
||||
if (Value *array = FindArray(*pKHR_texture_transform, "offset")) {
|
||||
out.offset[0] = (*array)[0].GetFloat();
|
||||
out.offset[1] = (*array)[1].GetFloat();
|
||||
}
|
||||
ReadMember(*pKHR_texture_transform, "rotation", out.rotation);
|
||||
ReadMember(*pKHR_texture_transform, "scale", *out.scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Value* index = FindUInt(*prop, "index")) {
|
||||
out.texture = r.textures.Retrieve(index->GetUint());
|
||||
}
|
||||
|
@ -877,6 +889,9 @@ inline void Material::Read(Value& material, Asset& r)
|
|||
}
|
||||
}
|
||||
|
||||
if (r.extensionsUsed.KHR_texture_transform) {
|
||||
}
|
||||
|
||||
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
||||
}
|
||||
}
|
||||
|
@ -1463,12 +1478,10 @@ inline void Asset::ReadExtensionsUsed(Document& doc)
|
|||
}
|
||||
}
|
||||
|
||||
#define CHECK_EXT(EXT) \
|
||||
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
|
||||
|
||||
CHECK_EXT(KHR_materials_pbrSpecularGlossiness);
|
||||
CHECK_EXT(KHR_materials_unlit);
|
||||
CHECK_EXT(KHR_lights_punctual);
|
||||
CHECK_EXT(KHR_texture_transform);
|
||||
|
||||
#undef CHECK_EXT
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace glTF2
|
|||
struct Texture;
|
||||
|
||||
// Vec/matrix types, as raw float arrays
|
||||
typedef float (vec2)[2];
|
||||
typedef float (vec3)[3];
|
||||
typedef float (vec4)[4];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue