From 97b5fa7aa79f3e0d5c859a9adf0c1fac3b094937 Mon Sep 17 00:00:00 2001 From: namespace Date: Tue, 27 Mar 2007 12:42:30 +0000 Subject: [PATCH] - Fix: Added missing xml-writer pop-calls - Ported mapxml plugin to Doom3 - mapxml now exports brushes with its vertices git-svn-id: svn://svn.icculus.org/gtkradiant/GtkRadiant/trunk@159 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- CHANGES | 6 +++++ libs/xml/xmlwriter.h | 2 ++ plugins/mapxml/plugin.cpp | 29 +++++++++++++++++++----- plugins/mapxml/xmlparse.cpp | 10 ++++----- plugins/mapxml/xmlwrite.cpp | 2 +- radiant/brushxml.h | 44 +++++++++++++++++++++++++++++++++++++ 6 files changed, 81 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index 6f87cf82..ef1dcbb6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,12 @@ This is the changelog for developers, != changelog for the end user that we distribute with the binaries. (see changelog) +27/03/2007 +namespace +- Fix: Added missing xml-writer pop-calls +- Ported mapxml plugin to Doom3 +- mapxml now exports brushes with its vertices + 19/03/2007 namespace - Fix: Selection is now deleted when creating a patch out of it (aumüller / namespace) diff --git a/libs/xml/xmlwriter.h b/libs/xml/xmlwriter.h index d387f320..85e49d45 100644 --- a/libs/xml/xmlwriter.h +++ b/libs/xml/xmlwriter.h @@ -159,6 +159,7 @@ public: { m_ostream.write('/'); m_ostream.write('>'); + m_elements.pop_back(); } else { @@ -166,6 +167,7 @@ public: m_ostream.write('/'); write_string(name); m_ostream.write('>'); + m_elements.pop_back(); } } std::size_t write(const char* data, std::size_t length) diff --git a/plugins/mapxml/plugin.cpp b/plugins/mapxml/plugin.cpp index 6bb09be8..5d62f1ac 100644 --- a/plugins/mapxml/plugin.cpp +++ b/plugins/mapxml/plugin.cpp @@ -37,29 +37,43 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA class MapXMLDependencies : public GlobalRadiantModuleRef, public GlobalBrushModuleRef, - public GlobalPatchModuleRef, public GlobalFiletypesModuleRef, public GlobalEntityClassManagerModuleRef, public GlobalSceneGraphModuleRef { + PatchModuleRef m_patchDef2Doom3Module; + PatchModuleRef m_patchDoom3Module; public: MapXMLDependencies() : GlobalBrushModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("brushtypes")), - GlobalPatchModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("patchtypes")), - GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")) + GlobalEntityClassManagerModuleRef(GlobalRadiant().getRequiredGameDescriptionKeyValue("entityclass")), + m_patchDef2Doom3Module("def2doom3"), + m_patchDoom3Module("doom3") { } + BrushCreator& getBrushDoom3() + { + return GlobalBrushModule::getTable(); + } + PatchCreator& getPatchDoom3() + { + return *m_patchDoom3Module.getTable(); + } + PatchCreator& getPatchDef2Doom3() + { + return *m_patchDef2Doom3Module.getTable(); + } }; class MapXMLAPI : public TypeSystemRef, public MapFormat { public: typedef MapFormat Type; - STRING_CONSTANT(Name, "xmlq3"); + STRING_CONSTANT(Name, "xmldoom3"); MapXMLAPI() { - GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("xml quake3 maps", "*.xmap")); + GlobalFiletypesModule::getTable().addType(Type::Name(), Name(), filetype_t("xml doom3 maps", "*.xmap")); } MapFormat* getTable() { @@ -84,7 +98,10 @@ MapXMLModule g_MapXMLModule; extern "C" void RADIANT_DLLEXPORT Radiant_RegisterModules(ModuleServer& server) { - initialiseModule(server); + GlobalErrorStream::instance().setOutputStream(server.getErrorStream()); + GlobalOutputStream::instance().setOutputStream(server.getOutputStream()); + GlobalDebugMessageHandler::instance().setHandler(server.getDebugMessageHandler()); + GlobalModuleServer::instance().set(server); g_MapXMLModule.selfRegister(); } diff --git a/plugins/mapxml/xmlparse.cpp b/plugins/mapxml/xmlparse.cpp index 751b99e0..8893f9ec 100644 --- a/plugins/mapxml/xmlparse.cpp +++ b/plugins/mapxml/xmlparse.cpp @@ -208,7 +208,7 @@ public: } }; -class MapQ3Importer : public TreeXMLImporter +class MapDoom3Importer : public TreeXMLImporter { scene::Node& m_root; char m_child[sizeof(EntityImporter)]; @@ -219,17 +219,17 @@ class MapQ3Importer : public TreeXMLImporter return *reinterpret_cast(m_child); } public: - MapQ3Importer(scene::Node& root, EntityCreator& entityTable) : m_root(root), m_entityTable(entityTable) + MapDoom3Importer(scene::Node& root, EntityCreator& entityTable) : m_root(root), m_entityTable(entityTable) { } void pushElement(const XMLElement& element) { - ASSERT_MESSAGE(string_equal(element.name(), "mapq3"), PARSE_ERROR); + ASSERT_MESSAGE(string_equal(element.name(), "mapdoom3"), PARSE_ERROR); constructor(getEntity(), makeReference(m_root), makeReference(m_entityTable)); } void popElement(const char* name) { - ASSERT_MESSAGE(string_equal(name, "mapq3"), PARSE_ERROR); + ASSERT_MESSAGE(string_equal(name, "mapdoom3"), PARSE_ERROR); destructor(getEntity()); } std::size_t write(const char* data, std::size_t length) @@ -271,7 +271,7 @@ void Map_Read(scene::Node& root, TextInputStream& in, EntityCreator& entityTable { XMLStreamParser parser(in); - MapQ3Importer importer(root, entityTable); + MapDoom3Importer importer(root, entityTable); TreeXMLImporterStack stack(importer); parser.exportXML(stack); } diff --git a/plugins/mapxml/xmlwrite.cpp b/plugins/mapxml/xmlwrite.cpp index f0564b25..6e24f7cf 100644 --- a/plugins/mapxml/xmlwrite.cpp +++ b/plugins/mapxml/xmlwrite.cpp @@ -80,7 +80,7 @@ void Map_Write(scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& XMLStreamWriter writer(out); writer.write("\n", 1); { - StaticElement element("mapq3"); + StaticElement element("mapdoom3"); writer.pushElement(element); traverse(root, write_all(writer)); diff --git a/radiant/brushxml.h b/radiant/brushxml.h index 0a4fdcca..9ec4dc50 100644 --- a/radiant/brushxml.h +++ b/radiant/brushxml.h @@ -250,6 +250,49 @@ inline void FacePlane_exportXML(const FacePlane& facePlane, XMLImporter& importe importer.popElement(element.name()); } +inline void FacePolygon_exportXML(const Winding& w, const BasicVector3& normal, XMLImporter& importer) +{ + DynamicElement element("polygon"); + + char tmp[32]; + + sprintf(tmp, "%f", normal.x()); + element.insertAttribute("nx", tmp); + + sprintf(tmp, "%f", normal.y()); + element.insertAttribute("ny", tmp); + + sprintf(tmp, "%f", normal.z()); + element.insertAttribute("nz", tmp); + + importer.pushElement(element); + + for(unsigned int i = 0; i < w.numpoints; ++i) + { + StaticElement c("vertex"); + + sprintf(tmp, "%f", w.points[i].vertex.x()); + c.insertAttribute("x", tmp); + + sprintf(tmp, "%f", w.points[i].vertex.y()); + c.insertAttribute("y", tmp); + + sprintf(tmp, "%f", w.points[i].vertex.z()); + c.insertAttribute("z", tmp); + + sprintf(tmp, "%f", w.points[i].texcoord.x()); + c.insertAttribute("s", tmp); + + sprintf(tmp, "%f", w.points[i].texcoord.y()); + c.insertAttribute("t", tmp); + + importer.pushElement(c); + importer.popElement(c.name()); + } + + importer.popElement(element.name()); +} + class FaceXMLExporter { const Face& m_face; @@ -269,6 +312,7 @@ public: importer.popElement(element.name()); } + FacePolygon_exportXML(m_face.getWinding(), m_face.getPlane().plane3().normal(), importer); FacePlane_exportXML(m_face.getPlane(), importer); if(!bAlternateTexdef) -- 2.39.2