From 1d518a54914531d7a4fab3a6835b75de85bd7bc7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Wed, 9 Jul 2014 19:18:31 +0000 Subject: Initial support for multi-layered materials, requires shaders files in the new format. --- src/model/objfile.cc | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) (limited to 'src/model/objfile.cc') diff --git a/src/model/objfile.cc b/src/model/objfile.cc index 489da2c..e4cec92 100644 --- a/src/model/objfile.cc +++ b/src/model/objfile.cc @@ -93,7 +93,7 @@ bool OBJFile::read() std::string materialname; material = 0; - if(line >> materialname) { + if (line >> materialname) { for(MaterialList::iterator it = obj_materiallist.begin(); it != obj_materiallist.end(); ++it) { if( (*it).second->name() == materialname) { material = (*it).second; @@ -102,18 +102,9 @@ bool OBJFile::read() } } - if(!material) { - material = Material::find(materialname); - - if(material) - obj_materiallist[obj_materiallist.size()] = material; - else { - material = new Material(materialname); - Material::add(material); - material->set_texture(materialname); - - obj_materiallist[obj_materiallist.size()] = material; - } + if (!material) { + material = Material::load(materialname); + obj_materiallist[obj_materiallist.size()] = material; current_m = obj_materiallist.size()-1; } } @@ -121,7 +112,7 @@ bool OBJFile::read() con_warn << objfile_name << " invalid material definition at line " << index_line << std::endl; - } else if( word.compare("v") == 0) { /* new wertex */ + } else if (word.compare("v") == 0) { /* new wertex */ float x, y, z; line >> x >> y >> z; @@ -129,14 +120,14 @@ bool OBJFile::read() obj_vertexlist[obj_vertexlist.size()] = v; obj_box.expand(*v * SCALE); - } else if( word.compare("vt") == 0) { /* wertex texture coordinate */ + } else if (word.compare("vt") == 0) { /* wertex texture coordinate */ float u, v; line >> u >> v; math::Vector2f *uv = new math::Vector2f(u, v); obj_uvlist[obj_uvlist.size()] = uv; - } else if( word.compare("vn") == 0) { /* wertex wormal */ + } else if (word.compare("vn") == 0) { /* wertex wormal */ float x, y, z; line >> x >> y >> z; @@ -145,7 +136,7 @@ bool OBJFile::read() obj_normallist[obj_normalcount] = nm; obj_normalcount++; - } else if( word.compare("f") == 0) { /* face/polygon */ + } else if (word.compare("f") == 0) { /* face/polygon */ size_t v[4]; size_t uv[4]; size_t vn[4]; -- cgit v1.2.3