mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-04-22 14:09:55 +08:00
Use default material as the 1st material on the array
Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
This commit is contained in:
parent
7218e40bfd
commit
02fce26c6c
@ -1,5 +1,5 @@
|
||||
{
|
||||
"obj_filename": "cornellbox_suzanne.obj",
|
||||
"commented_out_obj_filename": "cornellbox_suzanne.obj",
|
||||
"gltf_filename": "../../models/Cube/Cube.gltf",
|
||||
"scene_scale": 1.0,
|
||||
"width": 512,
|
||||
@ -20,4 +20,4 @@
|
||||
0
|
||||
],
|
||||
"dummy": 0
|
||||
}
|
||||
}
|
||||
|
@ -736,6 +736,9 @@ int main(int argc, char **argv) {
|
||||
default_material.specular[1] = 0;
|
||||
default_material.specular[2] = 0;
|
||||
|
||||
// Material pushed as first material on the list
|
||||
materials.push_back(default_material);
|
||||
|
||||
if (!gRenderConfig.obj_filename.empty()) {
|
||||
bool ret = LoadObj(gRenderConfig.obj_filename, gRenderConfig.scene_scale,
|
||||
&meshes, &materials, &textures);
|
||||
@ -744,37 +747,38 @@ int main(int argc, char **argv) {
|
||||
<< " ]" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
if (!gRenderConfig.gltf_filename.empty()) {
|
||||
std::cout << "Found gltf file : " << gRenderConfig.gltf_filename
|
||||
<< "\n";
|
||||
}
|
||||
|
||||
bool ret =
|
||||
LoadGLTF(gRenderConfig.gltf_filename, gRenderConfig.scene_scale,
|
||||
&meshes, &materials, &textures);
|
||||
if (!ret) {
|
||||
// TODO handle error
|
||||
}
|
||||
if (!gRenderConfig.gltf_filename.empty()) {
|
||||
std::cout << "Found gltf file : " << gRenderConfig.gltf_filename << "\n";
|
||||
|
||||
bool ret =
|
||||
LoadGLTF(gRenderConfig.gltf_filename, gRenderConfig.scene_scale,
|
||||
&meshes, &materials, &textures);
|
||||
if (!ret) {
|
||||
std::cerr << "Failed to load glTF file [ "
|
||||
<< gRenderConfig.gltf_filename << " ]" << std::endl;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
gAsset.materials = materials;
|
||||
gAsset.default_material = default_material;
|
||||
gAsset.textures = textures;
|
||||
gAsset.materials = materials;
|
||||
gAsset.default_material = default_material;
|
||||
gAsset.textures = textures;
|
||||
|
||||
for (size_t n = 0; n < meshes.size(); n++) {
|
||||
size_t mesh_id = gAsset.meshes.size();
|
||||
gAsset.meshes.push_back(meshes[mesh_id]);
|
||||
}
|
||||
for (size_t n = 0; n < meshes.size(); n++) {
|
||||
size_t mesh_id = gAsset.meshes.size();
|
||||
gAsset.meshes.push_back(meshes[mesh_id]);
|
||||
}
|
||||
|
||||
for (size_t n = 0; n < gAsset.meshes.size(); n++) {
|
||||
nanosg::Node<float, example::Mesh<float> > node(&gAsset.meshes[n]);
|
||||
node.SetName(meshes[n].name);
|
||||
node.SetLocalXform(
|
||||
meshes[n].pivot_xform); // Use mesh's pivot transform
|
||||
// as node's local transform.
|
||||
gNodes.push_back(node);
|
||||
for (size_t n = 0; n < gAsset.meshes.size(); n++) {
|
||||
nanosg::Node<float, example::Mesh<float> > node(&gAsset.meshes[n]);
|
||||
node.SetName(meshes[n].name);
|
||||
node.SetLocalXform(meshes[n].pivot_xform); // Use mesh's pivot transform
|
||||
// as node's local transform.
|
||||
gNodes.push_back(node);
|
||||
|
||||
gScene.AddNode(node);
|
||||
}
|
||||
gScene.AddNode(node);
|
||||
}
|
||||
|
||||
if (!gScene.Commit()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user