コード例 #1
0
ファイル: BrushInstance.cpp プロジェクト: chrisglass/ufoai
void BrushInstance::evaluateViewDependent (const VolumeTest& volume, const Matrix4& localToWorld) const
{
	if (m_viewChanged) {
		m_viewChanged = false;

		bool faces_visible[c_brush_maxFaces];
		{
			bool* j = faces_visible;
			ContentsFlagsValue val = m_brush.getFlags();
			if (GlobalFilterSystem().isVisible("contentflags", val.getContentFlags())) {
				for (FaceInstances::const_iterator i = m_faceInstances.begin(); i != m_faceInstances.end(); ++i, ++j) {
					const Face& face = i->getFace();
					// Check if face is filtered before adding to visibility matrix
					if (GlobalFilterSystem().isVisible("texture", face.GetShader())
							&& GlobalFilterSystem().isVisible("surfaceflags", face.GetFlags().getSurfaceFlags()))
						*j = i->intersectVolume(volume, localToWorld);
					else
						*j = false;
				}
			} else {
				*j = false;
			}
		}

		m_brush.update_wireframe(m_render_wireframe, faces_visible);
		m_brush.update_faces_wireframe(m_faceCentroidPointsCulled, faces_visible);
	}
}
コード例 #2
0
ファイル: XMLFilter.cpp プロジェクト: AresAndy/ufoai
void XMLFilter::onToggle ()
{
	// Allocate a reference, otherwise the call to GlobalFilterSystem() will crash
	GlobalFilterModuleRef ref;
	bool currentState = GlobalFilterSystem().getFilterState(_name);
	GlobalFilterSystem().setFilterState(_name, !currentState);
}
コード例 #3
0
MapPreview::MapPreview() :
	_widget(gtk_frame_new(NULL)),
	_glWidget(true),
	_filtersMenu(GlobalUIManager().createFilterMenu())
{
	// Main vbox - above is the GL widget, below is the toolbar
	GtkWidget* vbx = gtk_vbox_new(FALSE, 0);
	
	// Cast the GLWidget object to GtkWidget for further use
	GtkWidget* glWidget = _glWidget;
	gtk_box_pack_start(GTK_BOX(vbx), glWidget, TRUE, TRUE, 0);
	
	// Connect up the signals
	gtk_widget_set_events(glWidget, GDK_DESTROY | GDK_EXPOSURE_MASK | 
									GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | 
									GDK_POINTER_MOTION_MASK | GDK_SCROLL_MASK);
	g_signal_connect(G_OBJECT(glWidget), "expose-event", G_CALLBACK(onExpose), this);
	g_signal_connect(G_OBJECT(glWidget), "motion-notify-event", G_CALLBACK(onMouseMotion), this);
	g_signal_connect(G_OBJECT(glWidget), "scroll-event", G_CALLBACK(onMouseScroll), this);
	
	// The HBox containing the toolbar and the menubar
	GtkWidget* toolHBox = gtk_hbox_new(FALSE, 0);
	gtk_box_pack_end(GTK_BOX(vbx), toolHBox, FALSE, FALSE, 0);

	// Create the menu
	gtk_box_pack_start(GTK_BOX(toolHBox), _filtersMenu->getMenuBarWidget(), TRUE, TRUE, 0);

	// Pack into a frame and return
	gtk_container_add(GTK_CONTAINER(_widget), vbx);

	// Add an observer to the FilterSystem to get notified about changes
	_filterObserver = MapPreviewFilterObserverPtr(new MapPreviewFilterObserver(*this));

	GlobalFilterSystem().addObserver(_filterObserver);
}
コード例 #4
0
void MapPreview::onFiltersChanged() {
	// Sanity check
	if (_root == NULL) return;

	GlobalFilterSystem().updateSubgraph(_root);
	draw();
}
コード例 #5
0
void RenderPreview::filtersChanged()
{
    if (!getScene()->root()) return;

    GlobalFilterSystem().updateSubgraph(getScene()->root());
    queueDraw();
}
コード例 #6
0
// Set the model, this also resets the camera
void ModelPreview::setModel(const std::string& model)
{
	// If the model name is empty, release the model
	if (model.empty())
	{
		if (_modelNode)
		{
			_entity->removeChildNode(_modelNode);
		}

		_modelNode.reset();

		stopPlayback();
		return;
	}

	// Set up the scene
	if (!_entity)
	{
		getScene(); // trigger a setupscenegraph call
	}

	if (_modelNode)
	{
		_entity->removeChildNode(_modelNode);
	}

	_modelNode = GlobalModelCache().getModelNode(model);

	if (_modelNode)
	{
		_entity->addChildNode(_modelNode);

		// Trigger an initial update of the subgraph
		GlobalFilterSystem().updateSubgraph(getScene()->root());

		// Reset camera if the model has changed
		if (model != _lastModel)
		{
			// Reset preview time
			stopPlayback();

			// Reset the rotation to the default one
			_rotation = Matrix4::getRotationAboutZDegrees(45);
			_rotation = _rotation.getMultipliedBy(Matrix4::getRotation(Vector3(1,-1,0), 45));

			// Calculate camera distance so model is appropriately zoomed
			_camDist = -(_modelNode->localAABB().getRadius() * 5.0f);
		}

		_lastModel = model;
	}

	// Redraw
	queueDraw();
}
コード例 #7
0
void MapPreview::setRootNode(const scene::INodePtr& root) {
	_root = root;

	if (_root != NULL) {
		// Trigger an initial update of the subgraph
		GlobalFilterSystem().updateSubgraph(_root);

		// Calculate camera distance so map is appropriately zoomed
		_camDist = -(_root->worldAABB().getRadius() * 2.0); 
	}
}
コード例 #8
0
RenderPreview::RenderPreview(wxWindow* parent, bool enableAnimation) :
    _mainPanel(loadNamedPanel(parent, "RenderPreviewPanel")),
	_glWidget(new wxutil::GLWidget(_mainPanel, boost::bind(&RenderPreview::drawPreview, this), "RenderPreview")),
    _renderSystem(GlobalRenderSystemFactory().createRenderSystem()),
    _sceneWalker(_renderer, _volumeTest),
    _renderingInProgress(false),
    _timer(this),
    _previewWidth(0),
    _previewHeight(0),
    _filtersMenu(GlobalUIManager().createFilterMenu())
{
	Connect(wxEVT_TIMER, wxTimerEventHandler(RenderPreview::_onFrame), NULL, this);

    // Insert GL widget
	_mainPanel->GetSizer()->Prepend(_glWidget, 1, wxEXPAND);

	_glWidget->Connect(wxEVT_SIZE, wxSizeEventHandler(RenderPreview::onSizeAllocate), NULL, this);
	_glWidget->Connect(wxEVT_MOUSEWHEEL, wxMouseEventHandler(RenderPreview::onGLScroll), NULL, this);
	_glWidget->Connect(wxEVT_MOTION, wxMouseEventHandler(RenderPreview::onGLMotion), NULL, this);
	_glWidget->Connect(wxEVT_LEFT_DOWN, wxMouseEventHandler(RenderPreview::onGLMouseClick), NULL, this);
    _glWidget->Connect(wxEVT_LEFT_DCLICK, wxMouseEventHandler(RenderPreview::onGLMouseClick), NULL, this);

	wxToolBar* toolbar = findNamedObject<wxToolBar>(_mainPanel, "RenderPreviewAnimToolbar");

	_toolbarSizer = toolbar->GetContainingSizer();

	// Set up the toolbar
    if (enableAnimation)
    {
        connectToolbarSignals();
    }
    else
    {
		toolbar->Hide();
    }

	// Connect filters menu to toolbar
	wxToolBar* filterToolbar = findNamedObject<wxToolBar>(_mainPanel, "RenderPreviewFilterToolbar");

	wxMenu* filterSubmenu = _filtersMenu->getMenuWidget();

	wxToolBarToolBase* filterTool = filterToolbar->AddTool(wxID_ANY, _("Filters"), 
		wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + "iconFilter16.png"), 
		_("Filters"), wxITEM_DROPDOWN);
	filterToolbar->SetDropdownMenu(filterTool->GetId(), filterSubmenu);

	filterToolbar->Realize();

    // Get notified of filter changes
    GlobalFilterSystem().filtersChangedSignal().connect(
        sigc::mem_fun(this, &RenderPreview::filtersChanged)
    );
}
コード例 #9
0
ファイル: mainframe.cpp プロジェクト: AresAndy/ufoai
void MainFrame_Construct (void)
{
	// Tell the FilterSystem to register its commands
	GlobalFilterSystem().init();

	Commands_Register();

	GLWidget_sharedContextCreated = GlobalGL_sharedContextCreated;
	GLWidget_sharedContextDestroyed = GlobalGL_sharedContextDestroyed;

	// Broadcast the startup event
	GlobalRadiant().broadcastStartupEvent();
}
コード例 #10
0
ファイル: Map.cpp プロジェクト: Zbyl/DarkRadiant
void Map::load(const std::string& filename) {
    rMessage() << "Loading map from " << filename << "\n";

    setMapName(filename);

    // Reset all layers before loading the file
    GlobalLayerSystem().reset();
    GlobalSelectionSystem().setSelectedAll(false);

    {
        ScopeTimer timer("map load");

        m_resource = GlobalMapResourceManager().capture(_mapName);
        // greebo: Add the observer, this usually triggers a onResourceRealise() call.
        m_resource->addObserver(*this);

        // Traverse the scenegraph and find the worldspawn
        MapWorldspawnFinder finder;
        GlobalSceneGraph().root()->traverse(finder);
    }

    rMessage() << "--- LoadMapFile ---\n";
    rMessage() << _mapName << "\n";

    rMessage() << GlobalCounters().getCounter(counterBrushes).get() << " brushes\n";
    rMessage() << GlobalCounters().getCounter(counterPatches).get() << " patches\n";
    rMessage() << GlobalCounters().getCounter(counterEntities).get() << " entities\n";

    // Move the view to a start position
    gotoStartPosition();

    // Load the stored map positions from the worldspawn entity
    GlobalMapPosition().loadPositions();
    // Remove them, so that the user doesn't get bothered with them
    GlobalMapPosition().removePositions();

    // Disable the region to make sure
    GlobalRegion().disable();

    // Clear the shaderclipboard, the references are most probably invalid now
    GlobalShaderClipboard().clear();

    // Let the filtersystem update the filtered status of all instances
    GlobalFilterSystem().update();

    // Update the layer control dialog
    ui::LayerControlDialog::Instance().refresh();

    // Clear the modified flag
    setModified(false);
}
コード例 #11
0
ファイル: MapPreview.cpp プロジェクト: nbohr1more/DarkRadiant
void MapPreview::setRootNode(const scene::INodePtr& root)
{
	getScene()->setRoot(root);

	if (getScene()->root() != NULL)
	{
		// Re-associate the rendersystem, we need to propagate this info to the nodes
		associateRenderSystem();

		// Trigger an initial update of the subgraph
		GlobalFilterSystem().updateSubgraph(getScene()->root());

		// Calculate camera distance so map is appropriately zoomed
		_camDist = -(getScene()->root()->worldAABB().getRadius() * 2.0f);

		_rotation = Matrix4::getIdentity();
	}
}
コード例 #12
0
// Construct GTK widgets
void FiltersMenu::addItemsToMainMenu()
{
	// Get the menu manager
	IMenuManager& menuManager = GlobalUIManager().getMenuManager();

	// remove any items first
	removeItemsFromMainMenu();

	// Create the toplevel menu item
	menuManager.insert(MENU_INSERT_BEFORE, MENU_FILTERS_NAME, 
						ui::menuFolder, "Fi_lter", "", ""); // empty icon, empty event
	
	// Visit the filters in the FilterSystem to populate the menu
	MenuPopulatingVisitor visitor(MENU_PATH);
	GlobalFilterSystem().forEachFilter(visitor);

	menuManager.add(MENU_PATH, "_FiltersSep", menuSeparator, "", "", "");
	menuManager.add(MENU_PATH, "EditFilters", menuItem, _("Edit Filters..."), MENU_ICON, "EditFiltersDialog");
}
コード例 #13
0
	void RenderablePicoModel::render (RenderStateFlags flags) const
	{
		glEnable(GL_VERTEX_ARRAY);
		glEnable(GL_NORMAL_ARRAY);
		glEnable(GL_TEXTURE_COORD_ARRAY);
		// Render options
		if (flags & RENDER_TEXTURE_2D)
			glEnable(GL_TEXTURE_2D);
		if (flags & RENDER_SMOOTH)
			glShadeModel(GL_SMOOTH);

		// Iterate over the surfaces, calling the render function on each one
		for (SurfaceList::const_iterator i = _surfVec.begin(); i != _surfVec.end(); ++i) {
			// Get the IShader to test the shader name against the filter system
			GLTexture& tex = i->getShader()->getTexture();
			if (GlobalFilterSystem().isVisible("texture", tex.getName())) {
				// Bind the OpenGL texture and render the surface geometry
				glBindTexture(GL_TEXTURE_2D, tex.texture_number);
				i->render(flags);
			}
		}
	}
コード例 #14
0
ファイル: XMLFilter.cpp プロジェクト: AresAndy/ufoai
// The command target
void XMLFilter::toggle(bool newState)
{
	GlobalFilterSystem().setFilterState(_name, newState);
}
コード例 #15
0
MapPreview::~MapPreview() {
	GlobalFilterSystem().removeObserver(_filterObserver);
}
コード例 #16
0
ファイル: filters.cpp プロジェクト: Garux/netradiant-custom
void add_entity_filter( EntityFilter& filter, int mask, bool invert ){
	g_entityFilters.push_back( EntityFilterWrapper( filter, invert ) );
	GlobalFilterSystem().addFilter( g_entityFilters.back(), mask );
}