Exemplo n.º 1
0
void ModelExporter::processNodes()
{
	AABB bounds = calculateModelBounds();

	if (_centerObjects)
	{
		// Depending on the center point, we need to use the object bounds
		// or just the translation towards the user-defined origin, ignoring bounds
		_centerTransform = _useOriginAsCenter ?
			Matrix4::getTranslation(-_origin) :
			Matrix4::getTranslation(-bounds.origin);
	}

	for (const scene::INodePtr& node : _nodes)
	{
		if (Node_isModel(node))
		{
			model::ModelNodePtr modelNode = Node_getModel(node);

			// Push the geometry into the exporter
			model::IModel& model = modelNode->getIModel();

			Matrix4 exportTransform = node->localToWorld().getPremultipliedBy(_centerTransform);

			for (int s = 0; s < model.getSurfaceCount(); ++s)
			{
				const model::IModelSurface& surface = model.getSurface(s);

				if (isExportableMaterial(surface.getActiveMaterial()))
				{
					_exporter->addSurface(surface, exportTransform);
				}
			}
		}
		else if (Node_isBrush(node))
		{
			processBrush(node);
		}
		else if (Node_isPatch(node))
		{
			processPatch(node);
		}
		else if (_exportLightsAsObjects && Node_getLightNode(node))
		{
			processLight(node);
		}
	}
}
Exemplo n.º 2
0
AABB ModelExporter::calculateModelBounds()
{
	AABB bounds;

	for (const scene::INodePtr& node : _nodes)
	{
		// Only consider the node types supported by processNodes()
		if (!Node_isModel(node) && !Node_isBrush(node) && !Node_isPatch(node))
		{
			continue;
		}

		bounds.includeAABB(node->worldAABB());
	}

	return bounds;
}
Exemplo n.º 3
0
		bool pre( scene::Node& node ) const {
			scene::Path path( NodeReference( GlobalSceneGraph().root() ) );
			path.push( NodeReference( *m_entity->QER_Entity ) );
			path.push( NodeReference( node ) );
			scene::Instance* instance = GlobalSceneGraph().find( path );
			ASSERT_MESSAGE( instance != 0, "" );

			if ( Node_isPatch( node ) ) {
				DPatch* loadPatch = m_entity->NewPatch();
				loadPatch->LoadFromPatch( *instance );
			}
			else if ( Node_isBrush( node ) ) {
				DBrush* loadBrush = m_entity->NewBrush( m_count++ );
				loadBrush->LoadFromBrush( *instance, true );
			}
			return false;
		}
Exemplo n.º 4
0
	// Checks if the given SceneNode structure is a PatchNode
	static bool isPatch(const ScriptSceneNode& node) {
		return Node_isPatch(node);
	}
Exemplo n.º 5
0
	ScriptPatchNode(const scene::INodePtr& node) :
		ScriptSceneNode((node != NULL && Node_isPatch(node)) ? node : scene::INodePtr())
	{}
Exemplo n.º 6
0
void visit( scene::Instance& instance ) const {
	if ( Node_isPatch( instance.path().top() ) ) {
		m_functor( instance );
	}
}