34 enum class ValueType { number = 0, charstring, character, MARKER };
37 ValueType valueType = ValueType::charstring;
39 std::shared_ptr<Token> next;
45 std::string name =
"";
49 Vec3 translation =
Vec3(0.0f, 0.0f, 0.0f);
53 std::vector<uint32_t> children;
58 uint32_t inverseBindMatrices = 0;
59 std::vector<uint32_t> joints;
60 uint32_t skeleton = 0;
61 bool foundSkeleton =
false;
64 struct AnimationSampler {
66 std::string interpolation;
70 struct ChannelTarget {
75 struct AnimationChannel {
82 std::vector<AnimationChannel> channels;
83 std::vector<AnimationSampler> samplers;
86 const uint32_t CHUNK_TYPE_JSON = 0x4E4F534A;
87 const uint32_t CHUNK_TYPE_BIN = 0x004E4942;
89 std::shared_ptr<Token> jsonRootToken;
90 std::vector<char> binBuffer;
96 std::vector<std::shared_ptr<Token>> token_queues;
98 std::shared_ptr<Token> getToken(
const std::string&,
size_t);
100 void lexJson(
const std::vector<char>&, uint32_t);
101 std::shared_ptr<Token> createToken(ValueType,
const std::string&);
102 void parseJson(std::shared_ptr<Token>);
103 std::vector<std::shared_ptr<Token>> getTokens(uint32_t);
105 void printToken(
const std::shared_ptr<Token>& token);
107 std::shared_ptr<Token> getToken(
const std::string& name);
109 std::vector<std::shared_ptr<Token>> getChildTokens(
const std::shared_ptr<Token>& token);
111 std::shared_ptr<Token> getChildToken(
const std::shared_ptr<GlbFile::Token>& token,
const std::string& name);
113 std::vector<char> getBufferByView(
const size_t index);
115 std::vector<char> getBufferByAccessor(
const size_t index,
int& componentType);
117 std::vector<char> getBufferByAccessor(
const size_t index);
119 bool existNode(
const uint32_t index);
121 Node getNode(
const uint32_t index);
123 bool existNode(
const std::string& name);
125 Node getNode(
const std::string& name);
127 bool existParentNode(
const uint32_t index);
129 Node getParentNode(
const uint32_t index);
131 bool existNodeForMesh(
const uint32_t meshIndex);
133 Node getNodeForMesh(
const uint32_t meshIndex);
135 bool existSkin(
const uint32_t index);
137 Skin getSkin(
const uint32_t index);
139 bool existSkin(
const std::string& name);
141 Skin getSkin(
const std::string& name);
143 bool existAnimation(
const uint32_t index);
145 Animation getAnimation(
const uint32_t index);
147 Animation getAnimation(
const std::string& name);
153 void operator=(
GlbFile const&) =
delete;
155 void operator=(
GlbFile&&) =
delete;
163 explicit GlbFile(
const std::string& fileLocation);
183 void load(
Model& model,
const std::string& meshName =
"")
override;
195 void addAnimation(std::vector<Model::Animation>& animations, uint32_t animationIdx,
const Animation& animation,
196 const AnimationChannel& channel,
Model& model);