Ejemplo n.º 1
0
void MapExporter::finishScene()
{
	addOriginToChildPrimitives(_root);

	// Re-evaluate all brushes, to update the Winding calculations
	recalculateBrushWindings();
}
Ejemplo n.º 2
0
void Map::importSelected(std::istream& in)
{
    BasicContainerPtr root(new BasicContainer);

    // Instantiate the default import filter
    class MapImportFilter :
        public IMapImportFilter
    {
    private:
        scene::INodePtr _root;
    public:
        MapImportFilter(const scene::INodePtr& root) :
            _root(root)
        {}

        bool addEntity(const scene::INodePtr& entityNode)
        {
            _root->addChildNode(entityNode);
            return true;
        }

        bool addPrimitiveToEntity(const scene::INodePtr& primitive, const scene::INodePtr& entity)
        {
            if (Node_getEntity(entity)->isContainer())
            {
                entity->addChildNode(primitive);
                return true;
            }
            else
            {
                return false;
            }
        }
    } importFilter(root);

    MapFormatPtr format = getFormat();

    IMapReaderPtr reader = format->getMapReader(importFilter);

    try
    {
        // Start parsing
        reader->readFromStream(in);

        // Prepare child primitives
        addOriginToChildPrimitives(root);

        // Adjust all new names to fit into the existing map namespace,
        // this routine will be changing a lot of names in the importNamespace
        INamespacePtr nspace = getRoot()->getNamespace();
        if (nspace)
        {
            // Prepare all names, but do not import them into the namesace. This
            // will happen during the MergeMap call.
            nspace->ensureNoConflicts(root);
        }

        MergeMap(root);
    }
    catch (IMapReader::FailureException& e)
    {
        gtkutil::MessageBox::ShowError(
            (boost::format(_("Failure reading map from clipboard:\n%s")) % e.what()).str(),
            GlobalMainFrame().getTopLevelWindow());

        // Clear out the root node, otherwise we end up with half a map
        scene::NodeRemover remover;
        root->traverse(remover);
    }
}
Ejemplo n.º 3
0
void MapExporter::finishScene()
{
	addOriginToChildPrimitives(_root);
}