summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2008-04-11 00:47:04 +0200
committerneoraider <devnull@localhost>2008-04-11 00:47:04 +0200
commit7db6adf7e9e178c83f0278124a3d6c786134b014 (patch)
tree26f975f9391def4b2a14289699fb9d245b65ac52 /src
parent84780a8c1d9801e6a2c9f14dd0c17f362ccf7a57 (diff)
downloadzoomedit-7db6adf7e9e178c83f0278124a3d6c786134b014.tar
zoomedit-7db6adf7e9e178c83f0278124a3d6c786134b014.zip
zoomedit:
* TexCoords saves number of used coordinates now. * All data classes save changes in the XML tree now.
Diffstat (limited to 'src')
-rw-r--r--src/Data/Gate.h22
-rw-r--r--src/Data/Info.cpp1
-rw-r--r--src/Data/Info.h19
-rw-r--r--src/Data/Makefile.in2
-rw-r--r--src/Data/Room.h13
-rw-r--r--src/Data/TexCoords.h7
-rw-r--r--src/Data/Texture.h18
-rw-r--r--src/Data/Triangle.cpp74
-rw-r--r--src/Data/Triangle.h29
-rw-r--r--src/Gui/Makefile.in2
-rw-r--r--src/Makefile.in2
11 files changed, 167 insertions, 22 deletions
diff --git a/src/Data/Gate.h b/src/Data/Gate.h
index 9aa539a..91acbce 100644
--- a/src/Data/Gate.h
+++ b/src/Data/Gate.h
@@ -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);
+ }
};
}
diff --git a/src/Data/Info.cpp b/src/Data/Info.cpp
index bb384b6..28b85db 100644
--- a/src/Data/Info.cpp
+++ b/src/Data/Info.cpp
@@ -18,7 +18,6 @@
*/
#include "Info.h"
-#include <libxml++/nodes/textnode.h>
namespace ZoomEdit {
namespace Data {
diff --git a/src/Data/Info.h b/src/Data/Info.h
index bc51855..1678b81 100644
--- a/src/Data/Info.h
+++ b/src/Data/Info.h
@@ -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);
+ }
};
}
diff --git a/src/Data/Makefile.in b/src/Data/Makefile.in
index 7b7ff9b..2e1f63f 100644
--- a/src/Data/Makefile.in
+++ b/src/Data/Makefile.in
@@ -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@
diff --git a/src/Data/Room.h b/src/Data/Room.h
index f01b051..efd67cb 100644
--- a/src/Data/Room.h
+++ b/src/Data/Room.h
@@ -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);
+ }
};
}
diff --git a/src/Data/TexCoords.h b/src/Data/TexCoords.h
index 679c41c..06f8b59 100644
--- a/src/Data/TexCoords.h
+++ b/src/Data/TexCoords.h
@@ -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;}
diff --git a/src/Data/Texture.h b/src/Data/Texture.h
index b6a605a..e0cea59 100644
--- a/src/Data/Texture.h
+++ b/src/Data/Texture.h
@@ -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);
+ }
};
}
diff --git a/src/Data/Triangle.cpp b/src/Data/Triangle.cpp
index 8966b09..d334c12 100644
--- a/src/Data/Triangle.cpp
+++ b/src/Data/Triangle.cpp
@@ -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");
+}
+
}
}
diff --git a/src/Data/Triangle.h b/src/Data/Triangle.h
index f668289..3a235ce 100644
--- a/src/Data/Triangle.h
+++ b/src/Data/Triangle.h
@@ -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");
+ }
};
}
diff --git a/src/Gui/Makefile.in b/src/Gui/Makefile.in
index 461bad8..30619a3 100644
--- a/src/Gui/Makefile.in
+++ b/src/Gui/Makefile.in
@@ -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@
diff --git a/src/Makefile.in b/src/Makefile.in
index d19ad3e..793286b 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -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@