diff --git a/demo/demo.cpp b/demo/demo.cpp index 6581d9e..efa21ca 100644 --- a/demo/demo.cpp +++ b/demo/demo.cpp @@ -15,7 +15,7 @@ const ofbx::Object* g_selected_object = nullptr; template void catProperty(char(&out)[N], const ofbx::IElementProperty& prop) { - char tmp[128]; + char tmp[127]; switch (prop.getType()) { case ofbx::IElementProperty::DOUBLE: sprintf_s(tmp, "%f", prop.getValue().toDouble()); break; @@ -30,7 +30,7 @@ void catProperty(char(&out)[N], const ofbx::IElementProperty& prop) void gui(const ofbx::IElement& parent) { for (const ofbx::IElement* element = parent.getFirstChild(); element; element = element->getSibling()) { auto id = element->getID(); - char label[128]; + char label[1024]; id.toString(label); strcat_s(label, " ("); ofbx::IElementProperty* prop = element->getFirstProperty(); diff --git a/src/ofbx.cpp b/src/ofbx.cpp index b160cf2..f14444e 100644 --- a/src/ofbx.cpp +++ b/src/ofbx.cpp @@ -80,6 +80,7 @@ struct Allocator { struct Video { + IElementProperty* base64_property = nullptr; DataView filename; DataView content; DataView media; @@ -1957,6 +1958,10 @@ struct Scene : IScene return m_videos[index].is_base_64; } + const IElementProperty* getEmbeddedBase64Data(int index) const override { + return m_videos[index].base64_property; + } + DataView getEmbeddedFilename(int index) const override { return m_videos[index].filename; } @@ -2256,16 +2261,6 @@ void parseVideo(Scene& scene, const Element& element, Allocator& allocator) if (!content_element->first_property) return; const Property* content_property = content_element->first_property; if (content_element->first_property->getType() != IElementProperty::BINARY) { - /* - if this happens in text format: - Content: , - "iVBORw0KGgoA... - this is not a proper solution, but keep doing this until it become an issue - */ - if (content_element->first_property->getType() != IElementProperty::NONE) return; - if (!content_element->first_property->next) return; - if (content_element->first_property->next->getType() != IElementProperty::STRING) return; - content_property = content_element->first_property->next; is_base64 = true; } @@ -2276,7 +2271,8 @@ void parseVideo(Scene& scene, const Element& element, Allocator& allocator) Video video; video.is_base_64 = is_base64; - video.content = content_property->value; + video.base64_property = is_base64 ? content_element->first_property->next : nullptr; + video.content = is_base64 ? DataView{} : content_element->first_property->value; video.filename = filename_element->first_property->value; video.media = element.first_property->next->value; scene.m_videos.push_back(video); diff --git a/src/ofbx.h b/src/ofbx.h index 4b61598..ae97a03 100644 --- a/src/ofbx.h +++ b/src/ofbx.h @@ -737,6 +737,8 @@ struct IScene virtual DataView getEmbeddedData(int index) const = 0; virtual DataView getEmbeddedFilename(int index) const = 0; virtual bool isEmbeddedBase64(int index) const = 0; + // data are encoded in returned property and all ->next properties + virtual const IElementProperty* getEmbeddedBase64Data(int index) const = 0; // Scene Misc virtual const TakeInfo* getTakeInfo(const char* name) const = 0;