Пример #1
0
	//----------
	void Scene::drawOutlines() {
		ofShader & outlineShader(shader("outlineIndex"));
		outlineShader.begin();
		outlineShader.setUniform1i("elementHover", this->elementUnderCursor);
		outlineShader.setUniform1i("nodeSelection", this->nodeSelected);
		outlineShader.setUniform1i("nodeHover", this->nodeUnderCursor);
		outlineShader.setUniformTexture("texIndex", indexBuffer, 2);
		outlineShader.setUniform1i("elementCount", this->elements.size());
		outlineShader.setUniform1f("indexScaling", GRABSCENE_INDEX_SCALE);
		drawFullscreen(indexBuffer);
		outlineShader.end();
	}
Пример #2
0
	//----------
	void Scene::drawNodesAndElements() {
		////
		//nodes
		node_iterator itN;
		for (itN = this->nodes.begin(); itN != this->nodes.end(); itN++) {
			(*itN)->draw();
		}
		//
		////
		
		
		////
		//elements
		const_element_iterator itE;
		for (itE = elements.begin(); itE != elements.end(); itE++) {
			if (!(**itE).onTop())
				(**itE).draw();
		}
		//onTop
		if (frameBuffer.getWidth() != ofGetWidth() || frameBuffer.getHeight() != ofGetHeight()) {
			frameBuffer.allocate(ofGetWidth(), ofGetHeight(), GL_RGBA, 4);
		}
		//
		////
		
		this->camera->updateCursorWorld();
		
		////
		//onTop elements
		frameBuffer.bind();
		ofClear(0,0,0,0);
		for (itE = elements.begin(); itE != elements.end(); itE++) {
			if ((**itE).onTop())
				(**itE).draw();
		}
		frameBuffer.unbind();
		glColor4f(1.0f, 1.0f, 1.0f, 0.8f);
		shader("constant").begin();
		shader("constant").setUniformTexture("tex", frameBuffer, 0);
		drawFullscreen(frameBuffer);
		shader("constant").end();
		//
		////
	}
Пример #3
0
void GraphicsDevice::executeRenderPass( RenderPass p_pass, 
									    BufferBase* p_cbuf/*=NULL*/, 
										vector<BufferBase*>* p_instancesLists/*=NULL*/, 
										vector<Mesh*>* p_meshList/*=NULL*/)
{
	switch(p_pass)
	{	
	case RenderPass::P_BASEPASS:
		if (p_instancesLists != NULL && p_cbuf != NULL)
		{
			m_deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
			setBlendState(BlendState::NORMAL);
			setRasterizerStateSettings(RasterizerState::DEFAULT, true);
			setRenderTarget(RT_MRT);
			p_cbuf->apply();
			setShader(SI_MESHBASESHADER);
			unsigned int instancesListSize = (unsigned int)p_instancesLists->size();
			// fallback if no mesh list has been supplied
			if (p_meshList == NULL)
				p_meshList = &m_meshFallbackBoxList;
			unsigned int meshListSize = (unsigned int)p_meshList->size();
			// for each mesh as defined by the instance list
			for (unsigned int i = 0; i < instancesListSize; i++)
			{
				// Fetch the mesh, fall back to fallback meshes
				// if not enough meshes have been defined
				Mesh* mesh = NULL;
				if (i < meshListSize)
					mesh = (*p_meshList)[i];
				else
					mesh = m_meshFallbackBoxList[0];
				//for each copy of a mesh
				// issue a render using the instance buffer in the 
				// instanceslist for that index
				BufferBase* instances = (*p_instancesLists)[i];
				if (instances != NULL && mesh!=NULL)
				{
					drawInstancedIndexedMesh(mesh,
						instances->getElementCount(),
						instances->getElementSize(),
						instances->getBufferPointer());
				}
			}
		}
		break;
	case RenderPass::P_COMPOSEPASS:
		m_deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
		setBlendState(BlendState::NORMAL);
		setRasterizerStateSettings(RasterizerState::DEFAULT,false);
		setRenderTarget(RT_BACKBUFFER_NODEPTHSTENCIL);
		setShader(SI_COMPOSESHADER);
		drawFullscreen();
		break;
	case RenderPass::P_BOUNDINGBOX_WIREFRAMEPASS:
		if (p_instancesLists != NULL && p_cbuf != NULL)
		{
			m_deviceContext->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_LINELIST);
			setBlendState(BlendState::ADDITIVE);
			setRasterizerStateSettings(RasterizerState::WIREFRAME, false);
			setRenderTarget(RT_BACKBUFFER_NODEPTHSTENCIL);
			p_cbuf->apply();
			setShader(SI_WIREFRAMESHADER);
			// loop through all instance lists in the vector
			// not really necessary as it will almost always be of size 1 here
			// for simple bounding boxes
			for (int i = 0; i < p_instancesLists->size(); i++)
			{
				BufferBase* instances = (*p_instancesLists)[i];
				if (instances != NULL)
				{
					drawInstancedLineOBB(instances->getElementCount(),
						instances->getElementSize(),
						instances->getBufferPointer());
				}
			}
		}

		break;
	}
}