jessey-git / fx-gltf

A C++14/C++17 header-only library for simple, efficient, and robust serialization/deserialization of glTF 2.0

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

thirdparty example addition

pdJeeves opened this issue · comments

commented

I honestly can't remember how to suggest adding it with git's interface.

This file defines data structures so that accessors can be interacted with as STL containers

E.g:
` std::vectorglm::vec3 position;

for (auto const & attrib : primitive.attributes)
{
	if(attrib.first == "POSITION")
	{
		stdAccessorVec3 position_array(document, attrib.second);
		position = std::vector<glm::vec3>(position_array.begin(), position_array.end());
	}
}`

std::array<float, 3> should work just as well as glm::vec3

When given a fx::gltf::Document &, int accessor pair it will throw an error if there is any risk of a buffer overrun when the iterator class is used in a standard way.

could stand to undergo more testing (especially with sparse structures), but works for my purposes.

stl_accessor.zip

EDIT: i realized i messed up the ampersands on the interator preinc/postinc, GCC didn't complain because the STL algorithms i was feeding it to wasn't using the one with a bad reference.