/* * Triangle.h * * Copyright (C) 2008 Matthias Schiffer * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program. If not, see . */ #ifndef ZOOMEDIT_DATA_TRIANGLE_H_ #define ZOOMEDIT_DATA_TRIANGLE_H_ #include "Vertex.h" #include "TexCoords.h" #include namespace ZoomEdit { namespace Data { class Triangle { private: xmlpp::Element *triangleNode; xmlpp::Element *vertexNodes[3]; xmlpp::Element *normalNodes[3]; xmlpp::Element *texCoordsNodes[3]; Vertex vertices[3]; Vector normals[3]; TexCoords texCoords[3]; bool visible; Glib::ustring texture; Vertex loadVertex(xmlpp::Element *node) const; Vector loadVector(xmlpp::Element *node) const; TexCoords loadTexCoords(xmlpp::Element *node) const; public: Triangle(xmlpp::Element *node); const Vertex& getVertex(unsigned int i) const {return vertices[i%3];} void setVertex(unsigned int i, Vertex v) {vertices[i%3] = v;} void setVertices(Vertex v[3]) { vertices[0] = v[0]; vertices[1] = v[1]; vertices[2] = v[2]; } const Vector& getNormal(unsigned int i) const {return normals[i%3];} void setNormal(unsigned int i, Vector n) {normals[i%3] = n;} void setNormals(Vector n[3]) { normals[0] = n[0]; normals[1] = n[1]; normals[2] = n[2]; } const TexCoords& getTexCoords(unsigned int i) const {return texCoords[i%3];} void getTexCoords(unsigned int i, TexCoords t) {texCoords[i%3] = t;} void getTexCoords(TexCoords t[3]) { texCoords[0] = t[0]; texCoords[1] = t[1]; texCoords[2] = t[2]; } bool isVisible() const {return visible;} void setVisible(bool vis) {visible = vis;} }; } } #endif /*ZOOMEDIT_DATA_TRIANGLE_H_*/