This repository has been archived on 2025-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
neofx-zoomedit/src/Data/Triangle.h
neoraider 7db6adf7e9 zoomedit:
* TexCoords saves number of used coordinates now.
* All data classes save changes in the XML tree now.
2008-04-10 22:47:04 +00:00

86 lines
2.4 KiB
C++

/*
* Triangle.h
*
* Copyright (C) 2008 Matthias Schiffer <matthias@gamezock.de>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef ZOOMEDIT_DATA_TRIANGLE_H_
#define ZOOMEDIT_DATA_TRIANGLE_H_
#include "Vertex.h"
#include "TexCoords.h"
#include <libxml++/nodes/element.h>
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, const Vertex &v);
void setVertices(Vertex *v) {
for(int i = 0; i < 3; ++i)
setVertex(i, v[i]);
}
const Vector& getNormal(unsigned int i) const {return normals[i%3];}
void setNormal(unsigned int i, const Vector &n);
void setNormals(Vector *n) {
for(int i = 0; i < 3; ++i)
setNormal(i, n[i]);
}
const TexCoords& getTexCoords(unsigned int i) const {return texCoords[i%3];}
void setTexCoords(unsigned int i, const TexCoords &t);
void setTexCoords(TexCoords *t) {
for(int i = 0; i < 3; ++i)
setTexCoords(i, t[i]);
}
bool isVisible() const {return visible;}
void setVisible(bool vis) {
visible = vis;
triangleNode->set_attribute("visible", vis ? "true" : "false");
}
};
}
}
#endif /*ZOOMEDIT_DATA_TRIANGLE_H_*/