- 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
This commit is contained in:
namespace 2007-03-27 12:42:30 +00:00
parent 2e97c6dc9f
commit 97b5fa7aa7
6 changed files with 81 additions and 12 deletions

View file

@ -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)

View file

@ -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)

View file

@ -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();
}

View file

@ -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<EntityImporter*>(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);
}

View file

@ -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));

View file

@ -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<double>& 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)