From c883f50f90d6f0fcfa3bee94e974ede149c35ca6 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 24 Dec 2009 20:38:40 +0100 Subject: Refactored TriangleRecord --- src/Level.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/Level.cpp') diff --git a/src/Level.cpp b/src/Level.cpp index 2867ab9..9b2aa78 100644 --- a/src/Level.cpp +++ b/src/Level.cpp @@ -53,14 +53,14 @@ boost::shared_ptr Level::loadLevel(const std::string &filename) { } for(std::list::iterator room = level->rooms.begin(); room != level->rooms.end(); ++room) { - for(std::list::iterator wall = room->walls.begin(); wall != room->walls.end(); ++wall) { - boost::shared_ptr wallData = boost::dynamic_pointer_cast(wall->data); + for(std::list::iterator wall = room->walls.begin(); wall != room->walls.end(); ++wall) { + boost::shared_ptr wallData = boost::dynamic_pointer_cast(wall->getData()); if(!wallData->texture.empty()) { std::map::iterator texture = level->textures.find(wallData->texture); if(texture != level->textures.end()) - wall->triangle.setTexture(texture->second); + wall->getTriangle().setTexture(texture->second); } } } @@ -149,11 +149,11 @@ void Level::loadTextures(xmlNodePtr texturesNode) { } } -BSPTree::TriangleRecord Level::loadWall(xmlNodePtr wallNode) { +TriangleRecord Level::loadWall(xmlNodePtr wallNode) { boost::shared_ptr wallData(new WallData); - BSPTree::TriangleRecord wall; - wall.data = wallData; + TriangleRecord wall; + wall.setData(wallData); xmlChar *data = xmlGetProp(wallNode, (xmlChar*)"texture"); @@ -172,39 +172,39 @@ BSPTree::TriangleRecord Level::loadWall(xmlNodePtr wallNode) { if(++vertexNum > 2) break; - wall.triangle.setVertex(vertexNum, loadVector(node)); + wall.getTriangle().setVertex(vertexNum, loadVector(node)); } else if(!xmlStrcmp(node->name, (xmlChar*)"normal")) { if(vertexNum < 0) continue; - wall.triangle.setNormal(vertexNum, loadVector(node)); + wall.getTriangle().setNormal(vertexNum, loadVector(node)); } else if(!xmlStrcmp(node->name, (xmlChar*)"texcoords")) { if(vertexNum < 0) continue; data = xmlGetProp(node, (xmlChar*)"s"); if(data) { - wall.triangle.getTexCoords(vertexNum)[0] = atof((char*)data); + wall.getTriangle().getTexCoords(vertexNum)[0] = atof((char*)data); xmlFree(data); } data = xmlGetProp(node, (xmlChar*)"t"); if(data) { - wall.triangle.getTexCoords(vertexNum)[1] = atof((char*)data); + wall.getTriangle().getTexCoords(vertexNum)[1] = atof((char*)data); xmlFree(data); } } } - vmml::vec3f normal = wall.triangle.computeNormal(); + vmml::vec3f normal = wall.getTriangle().computeNormal(); if(normal.squared_length() > 0) { normal.normalize(); for(int i = 0; i < 3; ++i) { - if(wall.triangle.getNormal(i).squared_length() == 0) - wall.triangle.setNormal(i, normal); + if(wall.getTriangle().getNormal(i).squared_length() == 0) + wall.getTriangle().setNormal(i, normal); } } -- cgit v1.2.3