mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-12 02:49:02 +08:00
Keep up with loader_example.cc
Update picojson.h
This commit is contained in:
parent
2057b1ae6e
commit
f612015ac2
267
box.gltf
267
box.gltf
@ -1,267 +0,0 @@
|
||||
{
|
||||
"accessors": {
|
||||
"accessor_21": {
|
||||
"bufferView": "bufferView_29",
|
||||
"byteOffset": 0,
|
||||
"byteStride": 0,
|
||||
"componentType": 5123,
|
||||
"count": 36,
|
||||
"type": "SCALAR"
|
||||
},
|
||||
"accessor_23": {
|
||||
"bufferView": "bufferView_30",
|
||||
"byteOffset": 0,
|
||||
"byteStride": 12,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
0.5,
|
||||
0.5,
|
||||
0.5
|
||||
],
|
||||
"min": [
|
||||
-0.5,
|
||||
-0.5,
|
||||
-0.5
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
"accessor_25": {
|
||||
"bufferView": "bufferView_30",
|
||||
"byteOffset": 288,
|
||||
"byteStride": 12,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
1,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"min": [
|
||||
-1,
|
||||
-1,
|
||||
-1
|
||||
],
|
||||
"type": "VEC3"
|
||||
},
|
||||
"accessor_27": {
|
||||
"bufferView": "bufferView_30",
|
||||
"byteOffset": 576,
|
||||
"byteStride": 8,
|
||||
"componentType": 5126,
|
||||
"count": 24,
|
||||
"max": [
|
||||
1,
|
||||
1
|
||||
],
|
||||
"min": [
|
||||
0,
|
||||
0
|
||||
],
|
||||
"type": "VEC2"
|
||||
}
|
||||
},
|
||||
"animations": {},
|
||||
"asset": {
|
||||
"generator": "collada2gltf@ceec062e3d5793f2f249f53cbd843aee382ad40b",
|
||||
"premultipliedAlpha": true,
|
||||
"profile": {
|
||||
"api": "WebGL",
|
||||
"version": "1.0.2"
|
||||
},
|
||||
"version": 1
|
||||
},
|
||||
"bufferViews": {
|
||||
"bufferView_29": {
|
||||
"buffer": "box",
|
||||
"byteLength": 72,
|
||||
"byteOffset": 0,
|
||||
"target": 34963
|
||||
},
|
||||
"bufferView_30": {
|
||||
"buffer": "box",
|
||||
"byteLength": 768,
|
||||
"byteOffset": 72,
|
||||
"target": 34962
|
||||
}
|
||||
},
|
||||
"buffers": {
|
||||
"box": {
|
||||
"byteLength": 840,
|
||||
"type": "arraybuffer",
|
||||
"uri": "data:application/octet-stream;base64,AAABAAIAAwACAAEABAAFAAYABwAGAAUACAAJAAoACwAKAAkADAANAA4ADwAOAA0AEAARABIAEwASABEAFAAVABYAFwAWABUAAAAAvwAAAL8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAvwAAAL8AAAA/AAAAPwAAAL8AAAC/AAAAvwAAAL8AAAC/AAAAPwAAAD8AAAA/AAAAPwAAAL8AAAA/AAAAPwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAvwAAAD8AAAA/AAAAPwAAAD8AAAA/AAAAvwAAAD8AAAC/AAAAPwAAAD8AAAC/AAAAvwAAAL8AAAA/AAAAvwAAAD8AAAA/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAvwAAAL8AAAC/AAAAvwAAAD8AAAC/AAAAPwAAAL8AAAC/AAAAPwAAAD8AAAC/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPgAAAAAAAIA+oKqqPgAAAD8AAAAAAAAAP6Cqqj4AAIA+oKqqPgAAAACgqqo+AACAPrCqKj8AAAAAsKoqPwAAAD+gqqo+AACAPqCqqj4AAAA/sKoqPwAAgD6wqio/AABAP6Cqqj4AAAA/oKqqPgAAQD+wqio/AAAAP7CqKj8AAIA/oKqqPgAAQD+gqqo+AACAP7CqKj8AAEA/sKoqPwAAgD4AAIA/AAAAPwAAgD8AAIA+sKoqPwAAAD+wqio/"
|
||||
}
|
||||
},
|
||||
"materials": {
|
||||
"Effect-Red": {
|
||||
"name": "Red",
|
||||
"technique": "technique0",
|
||||
"values": {
|
||||
"diffuse": [
|
||||
0.8,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"shininess": 256,
|
||||
"specular": [
|
||||
0.2,
|
||||
0.2,
|
||||
0.2,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"meshes": {
|
||||
"Geometry-mesh002": {
|
||||
"name": "Mesh",
|
||||
"primitives": [
|
||||
{
|
||||
"attributes": {
|
||||
"NORMAL": "accessor_25",
|
||||
"POSITION": "accessor_23",
|
||||
"TEXCOORD_0": "accessor_27"
|
||||
},
|
||||
"indices": "accessor_21",
|
||||
"material": "Effect-Red",
|
||||
"mode": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"nodes": {
|
||||
"Geometry-mesh002Node": {
|
||||
"children": [],
|
||||
"matrix": [
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"meshes": [
|
||||
"Geometry-mesh002"
|
||||
],
|
||||
"name": "Mesh"
|
||||
},
|
||||
"node_1": {
|
||||
"children": [
|
||||
"Geometry-mesh002Node"
|
||||
],
|
||||
"matrix": [
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
-1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1
|
||||
],
|
||||
"name": "Y_UP_Transform"
|
||||
}
|
||||
},
|
||||
"programs": {
|
||||
"program_0": {
|
||||
"attributes": [
|
||||
"a_normal",
|
||||
"a_position"
|
||||
],
|
||||
"fragmentShader": "box0FS",
|
||||
"vertexShader": "box0VS"
|
||||
}
|
||||
},
|
||||
"scene": "defaultScene",
|
||||
"scenes": {
|
||||
"defaultScene": {
|
||||
"nodes": [
|
||||
"node_1"
|
||||
]
|
||||
}
|
||||
},
|
||||
"shaders": {
|
||||
"box0FS": {
|
||||
"type": 35632,
|
||||
"uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0Owp2YXJ5aW5nIHZlYzMgdl9ub3JtYWw7CnVuaWZvcm0gdmVjNCB1X2RpZmZ1c2U7CnVuaWZvcm0gdmVjNCB1X3NwZWN1bGFyOwp1bmlmb3JtIGZsb2F0IHVfc2hpbmluZXNzOwp2b2lkIG1haW4odm9pZCkgewp2ZWMzIG5vcm1hbCA9IG5vcm1hbGl6ZSh2X25vcm1hbCk7CnZlYzQgY29sb3IgPSB2ZWM0KDAuLCAwLiwgMC4sIDAuKTsKdmVjNCBkaWZmdXNlID0gdmVjNCgwLiwgMC4sIDAuLCAxLik7CnZlYzQgc3BlY3VsYXI7CmRpZmZ1c2UgPSB1X2RpZmZ1c2U7CnNwZWN1bGFyID0gdV9zcGVjdWxhcjsKZGlmZnVzZS54eXogKj0gbWF4KGRvdChub3JtYWwsdmVjMygwLiwwLiwxLikpLCAwLik7CmNvbG9yLnh5eiArPSBkaWZmdXNlLnh5ejsKY29sb3IgPSB2ZWM0KGNvbG9yLnJnYiAqIGRpZmZ1c2UuYSwgZGlmZnVzZS5hKTsKZ2xfRnJhZ0NvbG9yID0gY29sb3I7Cn0K"
|
||||
},
|
||||
"box0VS": {
|
||||
"type": 35633,
|
||||
"uri": "data:text/plain;base64,cHJlY2lzaW9uIGhpZ2hwIGZsb2F0OwphdHRyaWJ1dGUgdmVjMyBhX3Bvc2l0aW9uOwphdHRyaWJ1dGUgdmVjMyBhX25vcm1hbDsKdmFyeWluZyB2ZWMzIHZfbm9ybWFsOwp1bmlmb3JtIG1hdDMgdV9ub3JtYWxNYXRyaXg7CnVuaWZvcm0gbWF0NCB1X21vZGVsVmlld01hdHJpeDsKdW5pZm9ybSBtYXQ0IHVfcHJvamVjdGlvbk1hdHJpeDsKdm9pZCBtYWluKHZvaWQpIHsKdmVjNCBwb3MgPSB1X21vZGVsVmlld01hdHJpeCAqIHZlYzQoYV9wb3NpdGlvbiwxLjApOwp2X25vcm1hbCA9IHVfbm9ybWFsTWF0cml4ICogYV9ub3JtYWw7CmdsX1Bvc2l0aW9uID0gdV9wcm9qZWN0aW9uTWF0cml4ICogcG9zOwp9Cg=="
|
||||
}
|
||||
},
|
||||
"skins": {},
|
||||
"techniques": {
|
||||
"technique0": {
|
||||
"attributes": {
|
||||
"a_normal": "normal",
|
||||
"a_position": "position"
|
||||
},
|
||||
"parameters": {
|
||||
"diffuse": {
|
||||
"type": 35666
|
||||
},
|
||||
"modelViewMatrix": {
|
||||
"semantic": "MODELVIEW",
|
||||
"type": 35676
|
||||
},
|
||||
"normal": {
|
||||
"semantic": "NORMAL",
|
||||
"type": 35665
|
||||
},
|
||||
"normalMatrix": {
|
||||
"semantic": "MODELVIEWINVERSETRANSPOSE",
|
||||
"type": 35675
|
||||
},
|
||||
"position": {
|
||||
"semantic": "POSITION",
|
||||
"type": 35665
|
||||
},
|
||||
"projectionMatrix": {
|
||||
"semantic": "PROJECTION",
|
||||
"type": 35676
|
||||
},
|
||||
"shininess": {
|
||||
"type": 5126
|
||||
},
|
||||
"specular": {
|
||||
"type": 35666
|
||||
}
|
||||
},
|
||||
"program": "program_0",
|
||||
"states": {
|
||||
"enable": [
|
||||
2929,
|
||||
2884
|
||||
]
|
||||
},
|
||||
"uniforms": {
|
||||
"u_diffuse": "diffuse",
|
||||
"u_modelViewMatrix": "modelViewMatrix",
|
||||
"u_normalMatrix": "normalMatrix",
|
||||
"u_projectionMatrix": "projectionMatrix",
|
||||
"u_shininess": "shininess",
|
||||
"u_specular": "specular"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -62,15 +62,6 @@ static std::string PrintType(int ty) {
|
||||
return "**UNKNOWN**";
|
||||
}
|
||||
|
||||
static std::string PrintShaderType(int ty) {
|
||||
if (ty == TINYGLTF_SHADER_TYPE_VERTEX_SHADER) {
|
||||
return "VERTEX_SHADER";
|
||||
} else if (ty == TINYGLTF_SHADER_TYPE_FRAGMENT_SHADER) {
|
||||
return "FRAGMENT_SHADER";
|
||||
}
|
||||
return "**UNKNOWN**";
|
||||
}
|
||||
|
||||
static std::string PrintComponentType(int ty) {
|
||||
if (ty == TINYGLTF_COMPONENT_TYPE_BYTE) {
|
||||
return "BYTE";
|
||||
@ -93,6 +84,7 @@ static std::string PrintComponentType(int ty) {
|
||||
return "**UNKNOWN**";
|
||||
}
|
||||
|
||||
#if 0
|
||||
static std::string PrintParameterType(int ty) {
|
||||
if (ty == TINYGLTF_PARAMETER_TYPE_BYTE) {
|
||||
return "BYTE";
|
||||
@ -140,6 +132,7 @@ static std::string PrintParameterType(int ty) {
|
||||
|
||||
return "**UNKNOWN**";
|
||||
}
|
||||
#endif
|
||||
|
||||
static std::string PrintWrapMode(int mode) {
|
||||
if (mode == TINYGLTF_TEXTURE_WRAP_RPEAT) {
|
||||
@ -170,7 +163,7 @@ static std::string PrintFilterMode(int mode) {
|
||||
return "**UNKNOWN**";
|
||||
}
|
||||
|
||||
static std::string PrintFloatArray(const std::vector<double> &arr) {
|
||||
static std::string PrintIntArray(const std::vector<int> &arr) {
|
||||
if (arr.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
@ -185,7 +178,7 @@ static std::string PrintFloatArray(const std::vector<double> &arr) {
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static std::string PrintStringArray(const std::vector<std::string> &arr) {
|
||||
static std::string PrintFloatArray(const std::vector<double> &arr) {
|
||||
if (arr.size() == 0) {
|
||||
return "";
|
||||
}
|
||||
@ -244,6 +237,7 @@ static std::string PrintValue(const std::string& name, const tinygltf::Value &va
|
||||
static void DumpNode(const tinygltf::Node &node, int indent) {
|
||||
std::cout << Indent(indent) << "name : " << node.name << std::endl;
|
||||
std::cout << Indent(indent) << "camera : " << node.camera << std::endl;
|
||||
std::cout << Indent(indent) << "mesh : " << node.mesh << std::endl;
|
||||
if (!node.rotation.empty()) {
|
||||
std::cout << Indent(indent)
|
||||
<< "rotation : " << PrintFloatArray(node.rotation)
|
||||
@ -265,16 +259,13 @@ static void DumpNode(const tinygltf::Node &node, int indent) {
|
||||
}
|
||||
|
||||
std::cout << Indent(indent)
|
||||
<< "meshes : " << PrintStringArray(node.meshes) << std::endl;
|
||||
|
||||
std::cout << Indent(indent)
|
||||
<< "children : " << PrintStringArray(node.children) << std::endl;
|
||||
<< "children : " << PrintIntArray(node.children) << std::endl;
|
||||
}
|
||||
|
||||
static void DumpStringMap(const std::map<std::string, std::string> &map,
|
||||
static void DumpStringIntMap(const std::map<std::string, int> &m,
|
||||
int indent) {
|
||||
std::map<std::string, std::string>::const_iterator it(map.begin());
|
||||
std::map<std::string, std::string>::const_iterator itEnd(map.end());
|
||||
std::map<std::string, int>::const_iterator it(m.begin());
|
||||
std::map<std::string, int>::const_iterator itEnd(m.end());
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(indent) << it->first << ": " << it->second << std::endl;
|
||||
}
|
||||
@ -289,110 +280,79 @@ static void DumpPrimitive(const tinygltf::Primitive &primitive, int indent) {
|
||||
std::cout << Indent(indent)
|
||||
<< "attributes(items=" << primitive.attributes.size() << ")"
|
||||
<< std::endl;
|
||||
DumpStringMap(primitive.attributes, indent + 1);
|
||||
DumpStringIntMap(primitive.attributes, indent + 1);
|
||||
|
||||
std::cout << Indent(indent)
|
||||
<< "extras :" << std::endl
|
||||
<< PrintValue("extras", primitive.extras, indent+1) << std::endl;
|
||||
}
|
||||
|
||||
static void DumpTechniqueParameter(const tinygltf::TechniqueParameter ¶m,
|
||||
int indent) {
|
||||
std::cout << Indent(indent) << "count : " << param.count << std::endl;
|
||||
std::cout << Indent(indent) << "node : " << param.node << std::endl;
|
||||
std::cout << Indent(indent) << "semantic : " << param.semantic << std::endl;
|
||||
std::cout << Indent(indent) << "type : " << PrintParameterType(param.type)
|
||||
<< std::endl;
|
||||
std::cout << Indent(indent)
|
||||
<< "value : " << PrintParameterValue(param.value) << std::endl;
|
||||
}
|
||||
|
||||
static void Dump(const tinygltf::Scene &scene) {
|
||||
static void Dump(const tinygltf::Model &model) {
|
||||
std::cout << "=== Dump glTF ===" << std::endl;
|
||||
std::cout << "asset.generator : " << scene.asset.generator
|
||||
std::cout << "asset.copyright : " << model.asset.copyright
|
||||
<< std::endl;
|
||||
std::cout << "asset.premultipliedAlpha : " << scene.asset.premultipliedAlpha
|
||||
std::cout << "asset.generator : " << model.asset.generator
|
||||
<< std::endl;
|
||||
std::cout << "asset.version : " << scene.asset.version
|
||||
std::cout << "asset.version : " << model.asset.version
|
||||
<< std::endl;
|
||||
std::cout << "asset.profile.api : " << scene.asset.profile_api
|
||||
<< std::endl;
|
||||
std::cout << "asset.profile.version : " << scene.asset.profile_version
|
||||
std::cout << "asset.minVersion : " << model.asset.minVersion
|
||||
<< std::endl;
|
||||
std::cout << std::endl;
|
||||
|
||||
std::cout << "=== Dump scene ===" << std::endl;
|
||||
std::cout << "defaultScene: " << scene.defaultScene << std::endl;
|
||||
std::cout << "defaultScene: " << model.defaultScene << std::endl;
|
||||
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::const_iterator it(
|
||||
scene.scenes.begin());
|
||||
std::map<std::string, std::vector<std::string> >::const_iterator itEnd(
|
||||
scene.scenes.end());
|
||||
std::cout << "scenes(items=" << scene.scenes.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "nodes : [ ";
|
||||
for (size_t i = 0; i < it->second.size(); i++) {
|
||||
std::cout << it->second[i]
|
||||
<< ((i != (it->second.size() - 1)) ? ", " : "");
|
||||
}
|
||||
std::cout << " ] " << std::endl;
|
||||
std::cout << "scenes(items=" << model.scenes.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.scenes.size(); i++) {
|
||||
std::cout << Indent(1) << "scene[" << i << "] name : " << model.scenes[i].name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Mesh>::const_iterator it(
|
||||
scene.meshes.begin());
|
||||
std::map<std::string, tinygltf::Mesh>::const_iterator itEnd(
|
||||
scene.meshes.end());
|
||||
std::cout << "meshes(item=" << scene.meshes.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->second.name << std::endl;
|
||||
std::cout << "meshes(item=" << model.meshes.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.meshes.size(); i++) {
|
||||
std::cout << Indent(1) << "name : " << model.meshes[i].name << std::endl;
|
||||
std::cout << Indent(1)
|
||||
<< "primitives(items=" << it->second.primitives.size()
|
||||
<< "primitives(items=" << model.meshes[i].primitives.size()
|
||||
<< "): " << std::endl;
|
||||
|
||||
for (size_t i = 0; i < it->second.primitives.size(); i++) {
|
||||
DumpPrimitive(it->second.primitives[i], 2);
|
||||
for (size_t k = 0; k < model.meshes[i].primitives.size(); k++) {
|
||||
DumpPrimitive(model.meshes[i].primitives[k], 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Accessor>::const_iterator it(
|
||||
scene.accessors.begin());
|
||||
std::map<std::string, tinygltf::Accessor>::const_iterator itEnd(
|
||||
scene.accessors.end());
|
||||
std::cout << "accessors(items=" << scene.accessors.size() << ")"
|
||||
<< std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "bufferView : " << it->second.bufferView
|
||||
for (size_t i = 0; i < model.accessors.size(); i++) {
|
||||
const tinygltf::Accessor &accessor = model.accessors[i];
|
||||
std::cout << Indent(1) << "name : " << accessor.name << std::endl;
|
||||
std::cout << Indent(2) << "bufferView : " << accessor.bufferView
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "byteOffset : " << it->second.byteOffset
|
||||
std::cout << Indent(2) << "byteOffset : " << accessor.byteOffset
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "byteStride : " << it->second.byteStride
|
||||
std::cout << Indent(2) << "byteStride : " << accessor.byteStride
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "componentType: "
|
||||
<< PrintComponentType(it->second.componentType) << "("
|
||||
<< it->second.componentType << ")" << std::endl;
|
||||
std::cout << Indent(2) << "count : " << it->second.count
|
||||
<< PrintComponentType(accessor.componentType) << "("
|
||||
<< accessor.componentType << ")" << std::endl;
|
||||
std::cout << Indent(2) << "count : " << accessor.count
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "type : " << PrintType(it->second.type)
|
||||
std::cout << Indent(2) << "type : " << PrintType(accessor.type)
|
||||
<< std::endl;
|
||||
if (!it->second.minValues.empty()) {
|
||||
if (!accessor.minValues.empty()) {
|
||||
std::cout << Indent(2) << "min : [";
|
||||
for (size_t i = 0; i < it->second.minValues.size(); i++) {
|
||||
std::cout << it->second.minValues[i]
|
||||
<< ((i != it->second.minValues.size() - 1) ? ", " : "");
|
||||
for (size_t k = 0; k < accessor.minValues.size(); k++) {
|
||||
std::cout << accessor.minValues[k]
|
||||
<< ((i != accessor.minValues.size() - 1) ? ", " : "");
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
if (!it->second.maxValues.empty()) {
|
||||
if (!accessor.maxValues.empty()) {
|
||||
std::cout << Indent(2) << "max : [";
|
||||
for (size_t i = 0; i < it->second.maxValues.size(); i++) {
|
||||
std::cout << it->second.maxValues[i]
|
||||
<< ((i != it->second.maxValues.size() - 1) ? ", " : "");
|
||||
for (size_t k = 0; k < accessor.maxValues.size(); k++) {
|
||||
std::cout << accessor.maxValues[k]
|
||||
<< ((i != accessor.maxValues.size() - 1) ? ", " : "");
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
@ -400,113 +360,82 @@ static void Dump(const tinygltf::Scene &scene) {
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Animation>::const_iterator it(
|
||||
scene.animations.begin());
|
||||
std::map<std::string, tinygltf::Animation>::const_iterator itEnd(
|
||||
scene.animations.end());
|
||||
std::cout << "animations(items=" << scene.animations.size() << ")"
|
||||
std::cout << "animations(items=" << model.animations.size() << ")"
|
||||
<< std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
for (size_t i = 0; i < model.animations.size(); i++) {
|
||||
const tinygltf::Animation &animation = model.animations[i];
|
||||
std::cout << Indent(1) << "name : " << animation.name << std::endl;
|
||||
|
||||
std::cout << Indent(1) << "channels : [ " << std::endl;
|
||||
for (size_t i = 0; i < it->second.channels.size(); i++) {
|
||||
for (size_t j = 0; i < animation.channels.size(); i++) {
|
||||
std::cout << Indent(2)
|
||||
<< "sampler : " << it->second.channels[i].sampler
|
||||
<< "sampler : " << animation.channels[j].sampler
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "target.id : " << it->second.channels[i].target_id
|
||||
<< "target.id : " << animation.channels[j].target_node
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "target.path : " << it->second.channels[i].target_path
|
||||
<< "target.path : " << animation.channels[j].target_path
|
||||
<< std::endl;
|
||||
std::cout << ((i != (it->second.channels.size() - 1)) ? " , " : "");
|
||||
std::cout << ((i != (animation.channels.size() - 1)) ? " , " : "");
|
||||
}
|
||||
std::cout << " ]" << std::endl;
|
||||
|
||||
std::map<std::string, tinygltf::AnimationSampler>::const_iterator
|
||||
samplerIt(it->second.samplers.begin());
|
||||
std::map<std::string, tinygltf::AnimationSampler>::const_iterator
|
||||
samplerItEnd(it->second.samplers.end());
|
||||
std::cout << Indent(1) << "samplers(items=" << it->second.samplers.size()
|
||||
std::cout << Indent(1) << "samplers(items=" << animation.samplers.size()
|
||||
<< ")" << std::endl;
|
||||
for (; samplerIt != samplerItEnd; samplerIt++) {
|
||||
std::cout << Indent(1) << "name : " << samplerIt->first
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "input : " << samplerIt->second.input
|
||||
for (size_t j = 0; j < animation.samplers.size(); j++) {
|
||||
const tinygltf::AnimationSampler &sampler = animation.samplers[i];
|
||||
std::cout << Indent(2) << "input : " << sampler.input
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "interpolation : " << samplerIt->second.interpolation
|
||||
<< "interpolation : " << sampler.interpolation
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "output : " << samplerIt->second.output
|
||||
std::cout << Indent(2) << "output : " << sampler.output
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
{
|
||||
std::cout << Indent(1)
|
||||
<< "parameters(items=" << it->second.parameters.size() << ")"
|
||||
<< std::endl;
|
||||
tinygltf::ParameterMap::const_iterator p(it->second.parameters.begin());
|
||||
tinygltf::ParameterMap::const_iterator pEnd(
|
||||
it->second.parameters.end());
|
||||
for (; p != pEnd; p++) {
|
||||
std::cout << Indent(2) << p->first << ": "
|
||||
<< PrintParameterValue(p->second) << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::BufferView>::const_iterator it(
|
||||
scene.bufferViews.begin());
|
||||
std::map<std::string, tinygltf::BufferView>::const_iterator itEnd(
|
||||
scene.bufferViews.end());
|
||||
std::cout << "bufferViews(items=" << scene.bufferViews.size() << ")"
|
||||
std::cout << "bufferViews(items=" << model.bufferViews.size() << ")"
|
||||
<< std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "buffer : " << it->second.buffer
|
||||
for (size_t i = 0; i < model.bufferViews.size(); i++) {
|
||||
const tinygltf::BufferView &bufferView = model.bufferViews[i];
|
||||
std::cout << Indent(1) << "name : " << bufferView.name << std::endl;
|
||||
std::cout << Indent(2) << "buffer : " << bufferView.buffer
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "byteLength : " << it->second.byteLength
|
||||
std::cout << Indent(2) << "byteLength : " << bufferView.byteLength
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "byteOffset : " << it->second.byteOffset
|
||||
std::cout << Indent(2) << "byteOffset : " << bufferView.byteOffset
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "target : " << PrintTarget(it->second.target)
|
||||
<< "target : " << PrintTarget(bufferView.target)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Buffer>::const_iterator it(
|
||||
scene.buffers.begin());
|
||||
std::map<std::string, tinygltf::Buffer>::const_iterator itEnd(
|
||||
scene.buffers.end());
|
||||
std::cout << "buffers(items=" << scene.buffers.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "byteLength : " << it->second.data.size()
|
||||
std::cout << "buffers(items=" << model.buffers.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.buffers.size(); i++) {
|
||||
const tinygltf::Buffer &buffer = model.buffers[i];
|
||||
std::cout << Indent(1) << "name : " << buffer.name << std::endl;
|
||||
std::cout << Indent(2) << "byteLength : " << buffer.data.size()
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Material>::const_iterator it(
|
||||
scene.materials.begin());
|
||||
std::map<std::string, tinygltf::Material>::const_iterator itEnd(
|
||||
scene.materials.end());
|
||||
std::cout << "materials(items=" << scene.materials.size() << ")"
|
||||
std::cout << "materials(items=" << model.materials.size() << ")"
|
||||
<< std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(1) << "technique : " << it->second.technique
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "values(items=" << it->second.values.size()
|
||||
for (size_t i = 0; i < model.materials.size(); i++) {
|
||||
const tinygltf::Material &material = model.materials[i];
|
||||
std::cout << Indent(1) << "name : " << material.name << std::endl;
|
||||
std::cout << Indent(1) << "values(items=" << material.values.size()
|
||||
<< ")" << std::endl;
|
||||
|
||||
tinygltf::ParameterMap::const_iterator p(it->second.values.begin());
|
||||
tinygltf::ParameterMap::const_iterator pEnd(it->second.values.end());
|
||||
tinygltf::ParameterMap::const_iterator p(material.values.begin());
|
||||
tinygltf::ParameterMap::const_iterator pEnd(material.values.end());
|
||||
for (; p != pEnd; p++) {
|
||||
std::cout << Indent(2) << p->first << ": "
|
||||
<< PrintParameterValue(p->second) << std::endl;
|
||||
@ -515,179 +444,57 @@ static void Dump(const tinygltf::Scene &scene) {
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Node>::const_iterator it(
|
||||
scene.nodes.begin());
|
||||
std::map<std::string, tinygltf::Node>::const_iterator itEnd(
|
||||
scene.nodes.end());
|
||||
std::cout << "nodes(items=" << scene.nodes.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << "nodes(items=" << model.nodes.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.nodes.size(); i++) {
|
||||
const tinygltf::Node &node = model.nodes[i];
|
||||
std::cout << Indent(1) << "name : " << node.name << std::endl;
|
||||
|
||||
DumpNode(it->second, 2);
|
||||
DumpNode(node, 2);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Image>::const_iterator it(
|
||||
scene.images.begin());
|
||||
std::map<std::string, tinygltf::Image>::const_iterator itEnd(
|
||||
scene.images.end());
|
||||
std::cout << "images(items=" << scene.images.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << "images(items=" << model.images.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.images.size(); i++) {
|
||||
const tinygltf::Image &image = model.images[i];
|
||||
std::cout << Indent(1) << "name : " << image.name << std::endl;
|
||||
|
||||
std::cout << Indent(2) << "width : " << it->second.width << std::endl;
|
||||
std::cout << Indent(2) << "height : " << it->second.height
|
||||
std::cout << Indent(2) << "width : " << image.width << std::endl;
|
||||
std::cout << Indent(2) << "height : " << image.height
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "component : " << it->second.component
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "name : " << it->second.name << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Texture>::const_iterator it(
|
||||
scene.textures.begin());
|
||||
std::map<std::string, tinygltf::Texture>::const_iterator itEnd(
|
||||
scene.textures.end());
|
||||
std::cout << "textures(items=" << scene.textures.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(1) << "format : " << it->second.format
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "internalFormat : " << it->second.internalFormat
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "sampler : " << it->second.sampler
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "source : " << it->second.source
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "target : " << it->second.target
|
||||
<< std::endl;
|
||||
std::cout << Indent(1) << "type : " << it->second.type
|
||||
std::cout << Indent(2) << "component : " << image.component
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Shader>::const_iterator it(
|
||||
scene.shaders.begin());
|
||||
std::map<std::string, tinygltf::Shader>::const_iterator itEnd(
|
||||
scene.shaders.end());
|
||||
|
||||
std::cout << "shaders(items=" << scene.shaders.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name (id) : " << it->first << std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "type : " << PrintShaderType(it->second.type)
|
||||
std::cout << "textures(items=" << model.textures.size() << ")" << std::endl;
|
||||
for (size_t i = 0; i < model.textures.size(); i++) {
|
||||
const tinygltf::Texture &texture = model.textures[i];
|
||||
std::cout << Indent(1) << "sampler : " << texture.sampler
|
||||
<< std::endl;
|
||||
|
||||
std::cout << Indent(2) << "name (json) : " << it->second.name
|
||||
<< std::endl;
|
||||
|
||||
// Indent shader source nicely.
|
||||
std::string shader_source(Indent(3));
|
||||
shader_source.resize(shader_source.size() + it->second.source.size());
|
||||
|
||||
std::vector<unsigned char>::const_iterator sourceIt(
|
||||
it->second.source.begin());
|
||||
std::vector<unsigned char>::const_iterator sourceItEnd(
|
||||
it->second.source.end());
|
||||
|
||||
for (; sourceIt != sourceItEnd; ++sourceIt) {
|
||||
shader_source += static_cast<char>(*sourceIt);
|
||||
if (*sourceIt == '\n') {
|
||||
shader_source += Indent(3);
|
||||
}
|
||||
}
|
||||
std::cout << Indent(2) << "source :\n"
|
||||
<< shader_source << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Program>::const_iterator it(
|
||||
scene.programs.begin());
|
||||
std::map<std::string, tinygltf::Program>::const_iterator itEnd(
|
||||
scene.programs.end());
|
||||
|
||||
std::cout << "programs(items=" << scene.programs.size() << ")" << std::endl;
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "vertexShader : " << it->second.vertexShader
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "fragmentShader : " << it->second.fragmentShader
|
||||
<< std::endl;
|
||||
std::cout << Indent(2) << "attributes : "
|
||||
<< PrintStringArray(it->second.attributes) << std::endl;
|
||||
std::cout << Indent(2) << "name : " << it->second.name
|
||||
std::cout << Indent(1) << "source : " << texture.source
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Technique>::const_iterator it(
|
||||
scene.techniques.begin());
|
||||
std::map<std::string, tinygltf::Technique>::const_iterator itEnd(
|
||||
scene.techniques.end());
|
||||
|
||||
std::cout << "techniques(items=" << scene.techniques.size() << ")"
|
||||
<< std::endl;
|
||||
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name (id) : " << it->first << std::endl;
|
||||
std::cout << Indent(2) << "program : " << it->second.program
|
||||
<< std::endl;
|
||||
|
||||
std::cout << Indent(2) << "name (json) : " << it->second.name
|
||||
<< std::endl;
|
||||
std::cout << "samplers(items=" << model.samplers.size() << ")" << std::endl;
|
||||
|
||||
for (size_t i = 0; i < model.samplers.size(); i++) {
|
||||
const tinygltf::Sampler &sampler = model.samplers[i];
|
||||
std::cout << Indent(1) << "name (id) : " << sampler.name << std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "parameters(items=" << it->second.parameters.size() << ")"
|
||||
<< std::endl;
|
||||
|
||||
std::map<std::string, tinygltf::TechniqueParameter>::const_iterator
|
||||
paramIt(it->second.parameters.begin());
|
||||
std::map<std::string, tinygltf::TechniqueParameter>::const_iterator
|
||||
paramItEnd(it->second.parameters.end());
|
||||
|
||||
for (; paramIt != paramItEnd; ++paramIt) {
|
||||
std::cout << Indent(3) << "name : " << paramIt->first << std::endl;
|
||||
DumpTechniqueParameter(paramIt->second, 4);
|
||||
}
|
||||
|
||||
std::cout << Indent(2)
|
||||
<< "attributes(items=" << it->second.attributes.size() << ")"
|
||||
<< std::endl;
|
||||
|
||||
DumpStringMap(it->second.attributes, 3);
|
||||
|
||||
std::cout << Indent(2) << "uniforms(items=" << it->second.uniforms.size()
|
||||
<< ")" << std::endl;
|
||||
DumpStringMap(it->second.uniforms, 3);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::map<std::string, tinygltf::Sampler>::const_iterator it(
|
||||
scene.samplers.begin());
|
||||
std::map<std::string, tinygltf::Sampler>::const_iterator itEnd(
|
||||
scene.samplers.end());
|
||||
|
||||
std::cout << "samplers(items=" << scene.samplers.size() << ")" << std::endl;
|
||||
|
||||
for (; it != itEnd; it++) {
|
||||
std::cout << Indent(1) << "name (id) : " << it->first << std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "minFilter : " << PrintFilterMode(it->second.minFilter)
|
||||
<< "minFilter : " << PrintFilterMode(sampler.minFilter)
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "magFilter : " << PrintFilterMode(it->second.magFilter)
|
||||
<< "magFilter : " << PrintFilterMode(sampler.magFilter)
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "wrapS : " << PrintWrapMode(it->second.wrapS)
|
||||
<< "wrapS : " << PrintWrapMode(sampler.wrapS)
|
||||
<< std::endl;
|
||||
std::cout << Indent(2)
|
||||
<< "wrapT : " << PrintWrapMode(it->second.wrapT)
|
||||
<< "wrapT : " << PrintWrapMode(sampler.wrapT)
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
@ -699,7 +506,7 @@ int main(int argc, char **argv) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
tinygltf::Scene scene;
|
||||
tinygltf::Model model;
|
||||
tinygltf::TinyGLTFLoader loader;
|
||||
std::string err;
|
||||
std::string input_filename(argv[1]);
|
||||
@ -708,10 +515,10 @@ int main(int argc, char **argv) {
|
||||
bool ret = false;
|
||||
if (ext.compare("glb") == 0) {
|
||||
// assume binary glTF.
|
||||
ret = loader.LoadBinaryFromFile(&scene, &err, input_filename.c_str());
|
||||
ret = loader.LoadBinaryFromFile(&model, &err, input_filename.c_str());
|
||||
} else {
|
||||
// assume ascii glTF.
|
||||
ret = loader.LoadASCIIFromFile(&scene, &err, input_filename.c_str());
|
||||
ret = loader.LoadASCIIFromFile(&model, &err, input_filename.c_str());
|
||||
}
|
||||
|
||||
if (!err.empty()) {
|
||||
@ -723,7 +530,7 @@ int main(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Dump(scene);
|
||||
Dump(model);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
1911
picojson.h
1911
picojson.h
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,10 @@
|
||||
//
|
||||
// Tiny glTF loader.
|
||||
// Header-only tiny glTF 2.0 loader.
|
||||
//
|
||||
//
|
||||
// The MIT License (MIT)
|
||||
//
|
||||
// Copyright (c) 2015 - 2016 Syoyo Fujita and many contributors.
|
||||
// Copyright (c) 2015 - 2017 Syoyo Fujita, Aurélien Chatelain and many contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@ -25,13 +25,7 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
// Version:
|
||||
// - v0.9.5 Support parsing `extras` parameter.
|
||||
// - v0.9.4 Support parsing `shader`, `program` and `tecnique` thanks to
|
||||
// @lukesanantonio
|
||||
// - v0.9.3 Support binary glTF
|
||||
// - v0.9.2 Support parsing `texture`
|
||||
// - v0.9.1 Support loading glTF asset from memory
|
||||
// - v0.9.0 Initial
|
||||
// - v2.0.0 glTF 2.0!.
|
||||
//
|
||||
// Tiny glTF loader is using following third party libraries:
|
||||
//
|
||||
@ -298,21 +292,22 @@ struct AnimationChannel {
|
||||
Value extras;
|
||||
|
||||
AnimationChannel()
|
||||
: sampler(-1)
|
||||
, target_node(-1)
|
||||
{
|
||||
sampler = -1;
|
||||
target_node = -1;
|
||||
}
|
||||
};
|
||||
|
||||
struct AnimationSampler {
|
||||
int input; // required
|
||||
std::string interpolation; // in ["LINEAR", "STEP", "CATMULLROMSPLINE", "CUBICSPLINE"], default "LINEAR"
|
||||
int output; // required
|
||||
std::string interpolation; // in ["LINEAR", "STEP", "CATMULLROMSPLINE", "CUBICSPLINE"], default "LINEAR"
|
||||
|
||||
AnimationSampler()
|
||||
: input(-1)
|
||||
, output(-1)
|
||||
, interpolation("LINEAR")
|
||||
{
|
||||
input = -1;
|
||||
output = -1;
|
||||
}
|
||||
};
|
||||
|
||||
@ -346,9 +341,9 @@ struct Sampler {
|
||||
Value extras;
|
||||
|
||||
Sampler()
|
||||
: wrapS(TINYGLTF_TEXTURE_WRAP_RPEAT)
|
||||
, wrapT(TINYGLTF_TEXTURE_WRAP_RPEAT)
|
||||
{
|
||||
wrapS = TINYGLTF_TEXTURE_WRAP_RPEAT;
|
||||
wrapT = TINYGLTF_TEXTURE_WRAP_RPEAT;
|
||||
}
|
||||
};
|
||||
|
||||
@ -376,9 +371,9 @@ struct Texture {
|
||||
Value extras;
|
||||
|
||||
Texture()
|
||||
: sampler(-1)
|
||||
, source(-1)
|
||||
{
|
||||
sampler = -1;
|
||||
source =-1;
|
||||
}
|
||||
};
|
||||
|
||||
@ -482,9 +477,9 @@ typedef struct {
|
||||
class Node {
|
||||
public:
|
||||
Node()
|
||||
: skin(-1)
|
||||
, mesh(-1)
|
||||
{
|
||||
mesh = -1,
|
||||
skin = -1;
|
||||
}
|
||||
|
||||
~Node() {}
|
||||
@ -1274,7 +1269,7 @@ static bool ParseStringIntProperty(std::map<std::string, int> *ret,
|
||||
picojson::object::const_iterator dictItEnd(dict.end());
|
||||
|
||||
for (; dictIt != dictItEnd; ++dictIt) {
|
||||
if (!dictIt->second.is<int>()) {
|
||||
if (!dictIt->second.is<double>()) {
|
||||
if (required) {
|
||||
if (err) {
|
||||
(*err) += "'" + property + "' value is not an int.\n";
|
||||
@ -1841,7 +1836,7 @@ static bool ParseNode(Node *node, std::string *err, const picojson::object &o) {
|
||||
|
||||
double mesh = -1.0;
|
||||
ParseNumberProperty(&mesh, err, o, "mesh", false);
|
||||
node->mesh = mesh;
|
||||
node->mesh = int(mesh);
|
||||
|
||||
node->children.clear();
|
||||
picojson::object::const_iterator childrenObject = o.find("children");
|
||||
@ -1850,7 +1845,7 @@ static bool ParseNode(Node *node, std::string *err, const picojson::object &o) {
|
||||
const picojson::array &childrenArray =
|
||||
(childrenObject->second).get<picojson::array>();
|
||||
for (size_t i = 0; i < childrenArray.size(); i++) {
|
||||
if (!childrenArray[i].is<int>()) {
|
||||
if (!childrenArray[i].is<double>()) {
|
||||
if (err) {
|
||||
(*err) += "Invalid `children` array.\n";
|
||||
}
|
||||
@ -1918,9 +1913,9 @@ static bool ParseMaterial(Material *material, std::string *err,
|
||||
(it->second).get<picojson::object>();
|
||||
|
||||
picojson::object::const_iterator itVal(values_object.begin());
|
||||
picojson::object::const_iterator itEnd(values_object.end());
|
||||
picojson::object::const_iterator itValEnd(values_object.end());
|
||||
|
||||
for (; itVal != itEnd; itVal++) {
|
||||
for (; itVal != itValEnd; itVal++) {
|
||||
Parameter param;
|
||||
if (ParseParameterProperty(¶m, err, values_object, itVal->first,
|
||||
false)) {
|
||||
@ -1942,9 +1937,9 @@ static bool ParseMaterial(Material *material, std::string *err,
|
||||
(extIt->second).get<picojson::object>();
|
||||
|
||||
picojson::object::const_iterator itVal(values_object.begin());
|
||||
picojson::object::const_iterator itEnd(values_object.end());
|
||||
picojson::object::const_iterator itValEnd(values_object.end());
|
||||
|
||||
for (; itVal != itEnd; itVal++) {
|
||||
for (; itVal != itValEnd; itVal++) {
|
||||
Parameter param;
|
||||
if (ParseParameterProperty(¶m, err, values_object, itVal->first,
|
||||
false)) {
|
||||
@ -2323,7 +2318,7 @@ if (v.contains("scenes") && v.get("scenes").is<picojson::array>()) {
|
||||
|
||||
// 7. Parse default scenes.
|
||||
if (v.contains("scene") && v.get("scene").is<double>()) {
|
||||
const int defaultScene = v.get("scene").get<double>();
|
||||
const int defaultScene = int(v.get("scene").get<double>());
|
||||
|
||||
model->defaultScene = static_cast<int>(defaultScene);
|
||||
}
|
||||
@ -2362,7 +2357,7 @@ if (v.contains("scenes") && v.get("scenes").is<picojson::array>()) {
|
||||
|
||||
if (image.bufferView != -1) {
|
||||
// Load image from the buffer view.
|
||||
if ((size_t)image.bufferView >= model->bufferViews.size()) {
|
||||
if (size_t(image.bufferView) >= model->bufferViews.size()) {
|
||||
if (err) {
|
||||
std::stringstream ss;
|
||||
ss << "bufferView \"" << image.bufferView
|
||||
@ -2372,8 +2367,8 @@ if (v.contains("scenes") && v.get("scenes").is<picojson::array>()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const BufferView &bufferView = model->bufferViews[image.bufferView];
|
||||
const Buffer &buffer = model->buffers[bufferView.buffer];
|
||||
const BufferView &bufferView = model->bufferViews[size_t(image.bufferView)];
|
||||
const Buffer &buffer = model->buffers[size_t(bufferView.buffer)];
|
||||
|
||||
bool ret = LoadImageData(&image, err, image.width, image.height,
|
||||
&buffer.data[bufferView.byteOffset],
|
||||
|
Loading…
x
Reference in New Issue
Block a user