mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-11 06:09:02 +08:00
clang-format + added sparse accessor in loader_example
This commit is contained in:
parent
7e9f734d73
commit
9b321a8515
@ -228,7 +228,8 @@ static std::string PrintParameterMap(const tinygltf::ParameterMap &pmap) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static std::string PrintValue(const std::string &name,
|
static std::string PrintValue(const std::string &name,
|
||||||
const tinygltf::Value &value, const int indent, const bool tag = true) {
|
const tinygltf::Value &value, const int indent,
|
||||||
|
const bool tag = true) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|
||||||
if (value.IsObject()) {
|
if (value.IsObject()) {
|
||||||
@ -265,11 +266,10 @@ static std::string PrintValue(const std::string &name,
|
|||||||
} else if (value.IsArray()) {
|
} else if (value.IsArray()) {
|
||||||
ss << Indent(indent) << name << " [ ";
|
ss << Indent(indent) << name << " [ ";
|
||||||
for (size_t i = 0; i < value.Size(); i++) {
|
for (size_t i = 0; i < value.Size(); i++) {
|
||||||
ss << PrintValue("", value.Get(int(i)), indent + 1, /* tag */false);
|
ss << PrintValue("", value.Get(int(i)), indent + 1, /* tag */ false);
|
||||||
if (i != (value.ArrayLen()-1)) {
|
if (i != (value.ArrayLen() - 1)) {
|
||||||
ss << ", ";
|
ss << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
ss << Indent(indent) << "] ";
|
ss << Indent(indent) << "] ";
|
||||||
}
|
}
|
||||||
@ -330,12 +330,12 @@ static void DumpPrimitive(const tinygltf::Primitive &primitive, int indent) {
|
|||||||
<< PrintValue("extras", primitive.extras, indent + 1) << std::endl;
|
<< PrintValue("extras", primitive.extras, indent + 1) << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DumpExtensions(const tinygltf::ExtensionMap &extension, const int indent)
|
static void DumpExtensions(const tinygltf::ExtensionMap &extension,
|
||||||
{
|
const int indent) {
|
||||||
// TODO(syoyo): pritty print Value
|
// TODO(syoyo): pritty print Value
|
||||||
for (auto &e : extension) {
|
for (auto &e : extension) {
|
||||||
std::cout << Indent(indent) << e.first << std::endl;
|
std::cout << Indent(indent) << e.first << std::endl;
|
||||||
std::cout << PrintValue("extensions", e.second, indent+1) << std::endl;
|
std::cout << PrintValue("extensions", e.second, indent + 1) << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,6 +409,30 @@ static void Dump(const tinygltf::Model &model) {
|
|||||||
}
|
}
|
||||||
std::cout << "]" << std::endl;
|
std::cout << "]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (accessor.sparse.isSparse) {
|
||||||
|
std::cout << Indent(2) << "sparse:" << std::endl;
|
||||||
|
std::cout << Indent(3) << "count : " << accessor.sparse.count
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(3) << "indices: " << std::endl;
|
||||||
|
std::cout << Indent(4)
|
||||||
|
<< "bufferView : " << accessor.sparse.indices.bufferView
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(4)
|
||||||
|
<< "byteOffset : " << accessor.sparse.indices.byteOffset
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(4) << "componentType: "
|
||||||
|
<< PrintComponentType(accessor.sparse.indices.componentType)
|
||||||
|
<< "(" << accessor.sparse.indices.componentType << ")"
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(3) << "values : " << std::endl;
|
||||||
|
std::cout << Indent(4)
|
||||||
|
<< "bufferView : " << accessor.sparse.values.bufferView
|
||||||
|
<< std::endl;
|
||||||
|
std::cout << Indent(4)
|
||||||
|
<< "byteOffset : " << accessor.sparse.values.byteOffset
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,7 +612,8 @@ static void Dump(const tinygltf::Model &model) {
|
|||||||
|
|
||||||
// toplevel extensions
|
// toplevel extensions
|
||||||
{
|
{
|
||||||
std::cout << "extensions(items=" << model.extensions.size() << ")" << std::endl;
|
std::cout << "extensions(items=" << model.extensions.size() << ")"
|
||||||
|
<< std::endl;
|
||||||
DumpExtensions(model.extensions, 1);
|
DumpExtensions(model.extensions, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -610,18 +635,19 @@ int main(int argc, char **argv) {
|
|||||||
if (ext.compare("glb") == 0) {
|
if (ext.compare("glb") == 0) {
|
||||||
std::cout << "Reading binary glTF" << std::endl;
|
std::cout << "Reading binary glTF" << std::endl;
|
||||||
// assume binary glTF.
|
// assume binary glTF.
|
||||||
ret = gltf_ctx.LoadBinaryFromFile(&model, &err, &warn, input_filename.c_str());
|
ret = gltf_ctx.LoadBinaryFromFile(&model, &err, &warn,
|
||||||
|
input_filename.c_str());
|
||||||
} else {
|
} else {
|
||||||
std::cout << "Reading ASCII glTF" << std::endl;
|
std::cout << "Reading ASCII glTF" << std::endl;
|
||||||
// assume ascii glTF.
|
// assume ascii glTF.
|
||||||
ret = gltf_ctx.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
|
ret =
|
||||||
|
gltf_ctx.LoadASCIIFromFile(&model, &err, &warn, input_filename.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!warn.empty()) {
|
if (!warn.empty()) {
|
||||||
printf("Warn: %s\n", warn.c_str());
|
printf("Warn: %s\n", warn.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!err.empty()) {
|
if (!err.empty()) {
|
||||||
printf("Err: %s\n", err.c_str());
|
printf("Err: %s\n", err.c_str());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user