zoomedit:
* TexCoords saves number of used coordinates now. * All data classes save changes in the XML tree now.
This commit is contained in:
parent
84780a8c1d
commit
7db6adf7e9
15 changed files with 433 additions and 742 deletions
|
@ -35,6 +35,28 @@ class Gate {
|
|||
|
||||
public:
|
||||
Gate(xmlpp::Element *node);
|
||||
|
||||
const std::list<Triangle>& getTriangles() {
|
||||
return triangles;
|
||||
}
|
||||
|
||||
const Glib::ustring& getRoom1() const {
|
||||
return room1;
|
||||
}
|
||||
|
||||
void setRoom1(const Glib::ustring &room) {
|
||||
room1 = room;
|
||||
gateNode->set_attribute("room1", room);
|
||||
}
|
||||
|
||||
const Glib::ustring& getRoom2() const {
|
||||
return room2;
|
||||
}
|
||||
|
||||
void setRoom2(const Glib::ustring &room) {
|
||||
room2 = room;
|
||||
gateNode->set_attribute("room2", room);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
|
||||
#include "Info.h"
|
||||
#include <libxml++/nodes/textnode.h>
|
||||
|
||||
namespace ZoomEdit {
|
||||
namespace Data {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define ZOOMEDIT_DATA_INFO_H_
|
||||
|
||||
#include <libxml++/nodes/element.h>
|
||||
#include <libxml++/nodes/textnode.h>
|
||||
|
||||
namespace ZoomEdit {
|
||||
namespace Data {
|
||||
|
@ -35,6 +36,24 @@ class Info {
|
|||
|
||||
public:
|
||||
Info(xmlpp::Element *node);
|
||||
|
||||
const Glib::ustring& getName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
void setName(const Glib::ustring &n) {
|
||||
name = n;
|
||||
nameNode->get_child_text()->set_content(n);
|
||||
}
|
||||
|
||||
const Glib::ustring& getDescription() const {
|
||||
return desc;
|
||||
}
|
||||
|
||||
void setDescription(const Glib::ustring &d) {
|
||||
desc = d;
|
||||
descNode->get_child_text()->set_content(d);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -84,7 +84,6 @@ CXXFLAGS = @CXXFLAGS@
|
|||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
|
@ -110,7 +109,6 @@ LTLIBOBJS = @LTLIBOBJS@
|
|||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
|
|
|
@ -35,6 +35,19 @@ class Room {
|
|||
|
||||
public:
|
||||
Room(xmlpp::Element *node);
|
||||
|
||||
const std::list<Triangle>& getTriangles() {
|
||||
return triangles;
|
||||
}
|
||||
|
||||
const Glib::ustring& getId() const {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(const Glib::ustring &nid) {
|
||||
id = nid;
|
||||
roomNode->set_attribute("id", nid);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -25,10 +25,15 @@ namespace Data {
|
|||
|
||||
class TexCoords {
|
||||
private:
|
||||
unsigned int coordCount;
|
||||
float s, t, r, q;
|
||||
|
||||
public:
|
||||
TexCoords(float s0 = 0, float t0 = 0, float r0 = 0, float q0 = 0) : s(s0), t(t0), r(r0), q(q0) {}
|
||||
TexCoords(unsigned int c = 2, float s0 = 0, float t0 = 0, float r0 = 0, float q0 = 0)
|
||||
: coordCount(c), s(s0), t(t0), r(r0), q(q0) {}
|
||||
|
||||
unsigned int getCoordCount() const {return coordCount;}
|
||||
void setCoordCount(unsigned int c) {coordCount = c;}
|
||||
|
||||
float getS() const {return s;}
|
||||
void setS(float s0) {s = s0;}
|
||||
|
|
|
@ -33,6 +33,24 @@ class Texture {
|
|||
|
||||
public:
|
||||
Texture(xmlpp::Element *node);
|
||||
|
||||
const Glib::ustring& getId() const {
|
||||
return id;
|
||||
}
|
||||
|
||||
void setId(const Glib::ustring &nid) {
|
||||
id = nid;
|
||||
texNode->set_attribute("id", nid);
|
||||
}
|
||||
|
||||
const Glib::ustring& getName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
void setName(const Glib::ustring &nname) {
|
||||
name = nname;
|
||||
texNode->set_attribute("name", nname);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -44,12 +44,28 @@ Vector Triangle::loadVector(xmlpp::Element *node) const {
|
|||
}
|
||||
|
||||
TexCoords Triangle::loadTexCoords(xmlpp::Element *node) const {
|
||||
TexCoords t;
|
||||
TexCoords t(1);
|
||||
xmlpp::Attribute *attr;
|
||||
|
||||
t.setS(std::atof(node->get_attribute_value("s").c_str()));
|
||||
t.setT(std::atof(node->get_attribute_value("t").c_str()));
|
||||
t.setR(std::atof(node->get_attribute_value("r").c_str()));
|
||||
t.setQ(std::atof(node->get_attribute_value("q").c_str()));
|
||||
|
||||
attr = node->get_attribute("t");
|
||||
if(attr) {
|
||||
t.setT(std::atof(attr->get_value().c_str()));
|
||||
t.setCoordCount(2);
|
||||
}
|
||||
|
||||
attr = node->get_attribute("r");
|
||||
if(attr) {
|
||||
t.setR(std::atof(attr->get_value().c_str()));
|
||||
t.setCoordCount(3);
|
||||
}
|
||||
|
||||
attr = node->get_attribute("q");
|
||||
if(attr) {
|
||||
t.setQ(std::atof(attr->get_value().c_str()));
|
||||
t.setCoordCount(4);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
@ -83,6 +99,9 @@ Triangle::Triangle(xmlpp::Element *node) : triangleNode(node) {
|
|||
if(e->get_name() == "vertex") {
|
||||
vertexNodes[++i] = e;
|
||||
vertices[i] = loadVertex(e);
|
||||
|
||||
normalNodes[i] = NULL;
|
||||
texCoordsNodes[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,5 +109,52 @@ Triangle::Triangle(xmlpp::Element *node) : triangleNode(node) {
|
|||
texture = node->get_attribute_value("texture");
|
||||
}
|
||||
|
||||
void Triangle::setVertex(unsigned int i, const Vertex &v) {
|
||||
vertices[i] = v;
|
||||
|
||||
vertexNodes[i]->set_attribute("x", Glib::ustring::format(v.getX()));
|
||||
vertexNodes[i]->set_attribute("y", Glib::ustring::format(v.getY()));
|
||||
vertexNodes[i]->set_attribute("z", Glib::ustring::format(v.getZ()));
|
||||
}
|
||||
|
||||
void Triangle::setNormal(unsigned int i, const Vector &n) {
|
||||
normals[i] = n;
|
||||
|
||||
if(!normalNodes[i])
|
||||
normalNodes[i] = triangleNode->add_child(static_cast<xmlpp::Node*>(vertexNodes[i]), "normal");
|
||||
|
||||
normalNodes[i]->set_attribute("x", Glib::ustring::format(n.getX()));
|
||||
normalNodes[i]->set_attribute("y", Glib::ustring::format(n.getY()));
|
||||
normalNodes[i]->set_attribute("z", Glib::ustring::format(n.getZ()));
|
||||
}
|
||||
|
||||
void Triangle::setTexCoords(unsigned int i, const TexCoords &t) {
|
||||
texCoords[i] = t;
|
||||
|
||||
if(!texCoordsNodes[i]) {
|
||||
if(normalNodes[i])
|
||||
texCoordsNodes[i] = triangleNode->add_child(static_cast<xmlpp::Node*>(normalNodes[i]), "texcoords");
|
||||
else
|
||||
texCoordsNodes[i] = triangleNode->add_child(static_cast<xmlpp::Node*>(vertexNodes[i]), "texcoords");
|
||||
}
|
||||
|
||||
texCoordsNodes[i]->set_attribute("s", Glib::ustring::format(t.getS()));
|
||||
|
||||
if(t.getCoordCount() >= 2)
|
||||
texCoordsNodes[i]->set_attribute("t", Glib::ustring::format(t.getT()));
|
||||
else
|
||||
texCoordsNodes[i]->remove_attribute("t");
|
||||
|
||||
if(t.getCoordCount() >= 3)
|
||||
texCoordsNodes[i]->set_attribute("r", Glib::ustring::format(t.getR()));
|
||||
else
|
||||
texCoordsNodes[i]->remove_attribute("r");
|
||||
|
||||
if(t.getCoordCount() >= 4)
|
||||
texCoordsNodes[i]->set_attribute("q", Glib::ustring::format(t.getQ()));
|
||||
else
|
||||
texCoordsNodes[i]->remove_attribute("q");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,25 +50,34 @@ class Triangle {
|
|||
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];
|
||||
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, Vector n) {normals[i%3] = n;}
|
||||
void setNormals(Vector n[3]) {
|
||||
normals[0] = n[0]; normals[1] = n[1]; normals[2] = n[2];
|
||||
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 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];
|
||||
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;}
|
||||
void setVisible(bool vis) {
|
||||
visible = vis;
|
||||
triangleNode->set_attribute("visible", vis ? "true" : "false");
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -81,7 +81,6 @@ CXXFLAGS = @CXXFLAGS@
|
|||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
|
@ -107,7 +106,6 @@ LTLIBOBJS = @LTLIBOBJS@
|
|||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
|
|
|
@ -99,7 +99,6 @@ CXXFLAGS = @CXXFLAGS@
|
|||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
DSYMUTIL = @DSYMUTIL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
|
@ -125,7 +124,6 @@ LTLIBOBJS = @LTLIBOBJS@
|
|||
MAINT = @MAINT@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKDIR_P = @MKDIR_P@
|
||||
NMEDIT = @NMEDIT@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
|
|
Reference in a new issue