From f030154fe727e25a2afe1f78b3998c2d2dba95e4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 18 Aug 2009 09:24:15 +0000 Subject: astyle cleanup, corrects not loading of material textures --- src/model/asefile.cc | 86 ++++++++++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'src/model/asefile.cc') diff --git a/src/model/asefile.cc b/src/model/asefile.cc index 6010947..3bf0d59 100644 --- a/src/model/asefile.cc +++ b/src/model/asefile.cc @@ -23,7 +23,7 @@ ASEFile::ASEFile(std::string const &name) asefile_ifs.open(asefile_name); - for (int i=0; i < 3; i++) { + for (int i = 0; i < 3; i++) { ase_minbbox[i] = MAX_BOUNDS; ase_maxbbox[i] = -MAX_BOUNDS; } @@ -33,17 +33,17 @@ ASEFile::ASEFile(std::string const &name) ASEFile::~ASEFile() { for (VertexList::iterator it = ase_tvertexlist.begin(); it != ase_tvertexlist.end(); it++) { - delete (*it).second; + delete(*it).second; } ase_tvertexlist.clear(); for (VertexList::iterator it = ase_vertexlist.begin(); it != ase_vertexlist.end(); it++) { - delete (*it).second; + delete(*it).second; } ase_vertexlist.clear(); for (FaceList::iterator it = ase_facelist.begin(); it != ase_facelist.end(); it++) { - delete (*it).second; + delete(*it).second; } ase_facelist.clear(); @@ -60,7 +60,7 @@ bool ASEFile::read_header(std::istream &is) char data[1024]; memset(data, 0, sizeof(data)); - if (!is.getline(data, sizeof(data) -1 )) { + if (!is.getline(data, sizeof(data) - 1)) { return false; } @@ -82,7 +82,7 @@ bool ASEFile::read_mesh_vertex_list(std::istream &is) char data[1024]; memset(data, 0, sizeof(data)); - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string firstword; @@ -93,7 +93,7 @@ bool ASEFile::read_mesh_vertex_list(std::istream &is) return true; - } else if ( firstword.compare("*MESH_VERTEX") == 0) { + } else if (firstword.compare("*MESH_VERTEX") == 0) { size_t index; float x, y, z; if (line >> index >> x >> y >> z) { @@ -123,7 +123,7 @@ bool ASEFile::read_mesh_face_list(std::istream &is) char data[1024]; memset(data, 0, sizeof(data)); - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string word; @@ -133,22 +133,22 @@ bool ASEFile::read_mesh_face_list(std::istream &is) //con_debug << " " << count << " mesh faces" << std::endl; return true; - } else if ( word.compare("*MESH_FACE") == 0) { + } else if (word.compare("*MESH_FACE") == 0) { std::string facestr; size_t a, b, c; - if ( (line >> facestr) && - (line >> word) && (line >> a) && - (line >> word) && (line >> b) && - (line >> word) && (line >> c)) { + if ((line >> facestr) && + (line >> word) && (line >> a) && + (line >> word) && (line >> b) && + (line >> word) && (line >> c)) { if (facestr.size() && facestr[facestr.size()-1] == ':') { - facestr.erase(facestr.size()-1); + facestr.erase(facestr.size() - 1); } size_t index; std::istringstream faceindexstr(facestr); faceindexstr >> index; - + Triangle *triangle = new Triangle(*ase_vertexlist[a], *ase_vertexlist[b], *ase_vertexlist[c]); ase_facelist[index] = triangle; } @@ -171,7 +171,7 @@ bool ASEFile::read_mesh_normals(std::istream &is) float x, y, z; FaceList::iterator it; - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string firstword; @@ -181,7 +181,7 @@ bool ASEFile::read_mesh_normals(std::istream &is) //con_debug << " " << count << " face normals" << std::endl; return true; - } else if ( firstword.compare("*MESH_FACENORMAL") == 0) { + } else if (firstword.compare("*MESH_FACENORMAL") == 0) { if (line >> index >> x >> y >> z) { it = ase_facelist.find(index); if (it != ase_facelist.end()) { @@ -194,10 +194,10 @@ bool ASEFile::read_mesh_normals(std::istream &is) } else { it = ase_facelist.end(); } - } else if ( firstword.compare("*MESH_VERTEXNORMAL") == 0) { + } else if (firstword.compare("*MESH_VERTEXNORMAL") == 0) { + + if ((it != ase_facelist.end()) && (line >> index >> x >> y >> z)) { - if ( (it != ase_facelist.end()) && (line >> index >> x >> y >> z)) { - if (vertindex == 0) { (*it).second->n0().assign(x, y, z); } else if (vertindex == 1) { @@ -220,7 +220,7 @@ bool ASEFile::read_mesh_tvertex_list(std::istream &is) char data[1024]; memset(data, 0, sizeof(data)); - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string firstword; @@ -230,7 +230,7 @@ bool ASEFile::read_mesh_tvertex_list(std::istream &is) //con_debug << " " << count << " texture vertices" << std::endl; return true; - } else if ( firstword.compare("*MESH_TVERT") == 0) { + } else if (firstword.compare("*MESH_TVERT") == 0) { size_t index; float x, y, z; if (line >> index >> x >> y >> z) { @@ -246,12 +246,12 @@ bool ASEFile::read_mesh_tvertex_list(std::istream &is) bool ASEFile::read_mesh_tface_list(std::istream &is) { -size_t count = 0; + size_t count = 0; char data[1024]; memset(data, 0, sizeof(data)); - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string firstword; @@ -261,7 +261,7 @@ size_t count = 0; //con_debug << " " << count << " face texture coordinates" << std::endl; return true; - } else if ( firstword.compare("*MESH_TFACE") == 0) { + } else if (firstword.compare("*MESH_TFACE") == 0) { size_t index, a, b, c; if (line >> index >> a >> b >> c) { Triangle *triangle = ase_facelist[index]; @@ -292,38 +292,38 @@ bool ASEFile::read_mesh(std::istream &is) ase_vertexlist.clear(); - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string word; line >> word; - if ((level == 1 ) && (word.compare("*MESH_VERTEX_LIST") == 0)) { + if ((level == 1) && (word.compare("*MESH_VERTEX_LIST") == 0)) { if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " *MESH_VERTEX_LIST" << std::endl; read_mesh_vertex_list(is); } - } else if ((level == 1 ) && (word.compare("*MESH_FACE_LIST") == 0)) { + } else if ((level == 1) && (word.compare("*MESH_FACE_LIST") == 0)) { if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " *MESH_FACE_LIST" << std::endl; read_mesh_face_list(is); } - } else if ((level == 1 ) && (word.compare("*MESH_NORMALS") == 0)) { + } else if ((level == 1) && (word.compare("*MESH_NORMALS") == 0)) { if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " *MESH_NORMALS" << std::endl; read_mesh_normals(is); } - } else if ((level == 1 ) && (word.compare("*MESH_TVERTLIST") == 0)) { - if ((line >> word) && (word.compare("{") == 0)) { + } else if ((level == 1) && (word.compare("*MESH_TVERTLIST") == 0)) { + if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " *MESH_TVERTLIST" << std::endl; read_mesh_tvertex_list(is); } - } else if ((level == 1 ) && (word.compare("*MESH_TFACELIST") == 0)) { - if ((line >> word) && (word.compare("{") == 0)) { + } else if ((level == 1) && (word.compare("*MESH_TFACELIST") == 0)) { + if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " *MESH_TFACELIST" << std::endl; read_mesh_tface_list(is); } @@ -352,13 +352,13 @@ bool ASEFile::read_geom(std::istream &is) memset(data, 0, sizeof(data)); int level = 1; - while (is.getline(data, sizeof(data) -1 )) { + while (is.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string word; line >> word; - if ((level == 1 ) && (word.compare("*MESH") == 0)) { + if ((level == 1) && (word.compare("*MESH") == 0)) { if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " " << "*MESH" << std::endl; read_mesh(is); @@ -391,13 +391,13 @@ bool ASEFile::read() char data[1024]; memset(data, 0, sizeof(data)); - while (asefile_ifs.getline(data, sizeof(data) -1 )) { + while (asefile_ifs.getline(data, sizeof(data) - 1)) { std::istringstream line(data); std::string word; line >> word; - - if (word.compare("*GEOMOBJECT") == 0) { + + if (word.compare("*GEOMOBJECT") == 0) { if ((line >> word) && (word.compare("{") == 0)) { //con_debug << " " << name() << " " << "*GEOMOBJECT" << std::endl; @@ -429,9 +429,9 @@ Model * ASEFile::load(const std::string &name) // default material Material *material = Material::find(name); if (!material) { - material = new Material(name); + material = new Material(name); Material::add(material); - material->set_flags(Material::Texture); + //material->set_flags(Material::Texture); material->set_texture(material->name()); } @@ -449,7 +449,7 @@ Model * ASEFile::load(const std::string &name) // caculate bounding box model->model_minbbox = (asefile.ase_minbbox - center) * scale; - model->model_maxbbox = (asefile.ase_maxbbox - center) * scale; + model->model_maxbbox = (asefile.ase_maxbbox - center) * scale; model->set_radius(model->model_maxbbox.length()); model->set_origin(center * scale); @@ -460,14 +460,14 @@ Model * ASEFile::load(const std::string &name) fragment->add_vertex((triangle->v0() - center) * scale , triangle->n0(), triangle->t0(), false); fragment->add_vertex((triangle->v1() - center) * scale , triangle->n1(), triangle->t1(), false); fragment->add_vertex((triangle->v2() - center) * scale , triangle->n2(), triangle->t2(), false); - + model->model_tris_count++; } model->add_group(group); con_debug << " " << asefile.name() << " " << asefile.ase_vertexlist.size() << " vertices " << - model->model_tris_detail_count << "/" << model->model_tris_count << " detail/tris" << std::endl; + model->model_tris_detail_count << "/" << model->model_tris_count << " detail/tris" << std::endl; return model; } -- cgit v1.2.3