Use default material as the 1st material on the array

Signed-off by: Arthur Brainville (Ybalrid) <ybalrid@ybalrid.info>
This commit is contained in:
Arthur Brainville (Ybalrid) 2018-02-20 14:25:46 +01:00 committed by Arthur Brainville
parent 7218e40bfd
commit 02fce26c6c
No known key found for this signature in database
GPG Key ID: BC05C4812A06BCF3
2 changed files with 31 additions and 27 deletions

View File

@ -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,

View File

@ -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,15 +747,18 @@ int main(int argc, char **argv) {
<< " ]" << std::endl;
return -1;
}
}
if (!gRenderConfig.gltf_filename.empty()) {
std::cout << "Found gltf file : " << gRenderConfig.gltf_filename
<< "\n";
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
std::cerr << "Failed to load glTF file [ "
<< gRenderConfig.gltf_filename << " ]" << std::endl;
return -1;
}
}
@ -768,14 +774,12 @@ int main(int argc, char **argv) {
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
node.SetLocalXform(meshes[n].pivot_xform); // Use mesh's pivot transform
// as node's local transform.
gNodes.push_back(node);
gScene.AddNode(node);
}
}
if (!gScene.Commit()) {
std::cerr << "Failed to commit the scene." << std::endl;