Example #1
0
	void Polygon2f::DrawRecursive(Polygon2f* poly, float Z, float color)
	{
		DisplayPolygons(poly->containedHoles, Z, color, color, 0, 1);
		color *= 0.5;
		DisplayPolygons(poly->containedSolids, Z, 0, color, 0, 1);
		for(list<Polygon2f*>::iterator pIt =poly->containedSolids.begin(); pIt!=poly->containedSolids.end(); pIt++)
		{
			DrawRecursive(*pIt, Z, color);
		}
	}
Example #2
0
		void SceneRendererD3D::render () {
			nvutil::smart_cast<RenderTargetD3D>( m_renderTarget)->clearRenderTargetView ();
			nvutil::smart_cast<RenderTargetD3D>( m_renderTarget)->clearDepthStencilView ();
			unsigned int width = 0;
			unsigned int height= 0;
			nvutil::smart_cast<RenderTargetD3D>( m_renderTarget)->getSize (width,height);

			GetNV3DBase().SetTargets (  nvutil::smart_cast<RenderTargetD3D>( m_renderTarget)->GetRenderTargetView(),
				nvutil::smart_cast<RenderTargetD3D>( m_renderTarget)->GetDepthStencilView(),
				float(width),
				float(height));
			GetNV3DBase().SetDefaultShaders ();								
			nvsg::NodeSharedPtr root = nvsg::SceneReadLock (m_scene)->getRootNode ();
			nvmath::Mat44f m(true);
			DrawRecursive (root,m);
		}
Example #3
0
		//  void setViewState () { }
		void SceneRendererD3D::DrawRecursive (nvsg::NodeSharedPtr node,nvmath::Mat44f &mat)
		{
			nvsg::Group::ChildrenConstIterator it ;
			nvsg::GroupSharedPtr group ;
			nvsg::GeoNodeSharedPtr geop;
			nvsg::GeoNode::DrawableConstIterator dit;
			nvsg::GeoNode::StateSetConstIterator ssit;
			nvsg::DrawableSharedPtr drawable;
			nvmath::Mat44f matt2 ;
			nvmath::Trafo tr ;
			switch (nvsg::NodeReadLock (node)->getObjectCode() )
			{
			case nvsg::OC_GROUP:
				group = nvutil::smart_cast<nvsg::GroupHandle>  (node);
				it = nvsg::GroupReadLock (group)->beginChildren ();
				while (it != nvsg::GroupReadLock (group)->endChildren())
				{
					nvsg::NodeSharedPtr childNode = *it;
					DrawRecursive (childNode,mat);
					++it;
				}
				break;
			case nvsg::OC_TRANSFORM:
				group = nvutil::smart_cast<nvsg::TransformHandle>  (node);
				tr= nvsg::TransformReadLock (group)->getTrafo();
				matt2=tr.getMatrix();
				it = nvsg::TransformReadLock (group)->beginChildren ();
				while (it != nvsg::TransformReadLock (group)->endChildren())
				{
					nvsg::NodeSharedPtr childNode = *it;
					DrawRecursive (childNode,mat*matt2);
					++it;
				}
				break;
			case nvsg::OC_GEONODE:
				geop = nvutil::smart_cast<nvsg::GeoNodeHandle>(node);
				ssit = nvsg::GeoNodeReadLock (geop)->beginStateSets();
				while(ssit != nvsg::GeoNodeReadLock (geop)->endStateSets())
				{
					dit = nvsg::GeoNodeReadLock (geop)->beginDrawables (ssit);
					while (dit !=  nvsg::GeoNodeReadLock (geop)->endDrawables (ssit))
					{
						// move this to a draw callback..

						drawable = *dit;
						nvsg::D3DDalHostSharedPtr dalhost;
						ID3D11Buffer *vertexBuffer =0 ;
						ID3D11Buffer *indexBuffer = 0;

						nvsg::VertexAttributeSetSharedPtr vas= nvsg::PrimitiveReadLock (drawable)->getVertexAttributeSet();
						dalhost = nvsg::VertexAttributeSetReadLock(vas)->getDALHost();
						nvsg::D3DVertexBufferData *vbdata;
						nvsg::D3DDalHostReadLock (dalhost)->getDeviceAbstractionLinkData(0,vbdata,nvsg::D3DVertexBufferData::test_func);
						vertexBuffer = vbdata->GetBuffer();//m_d3dBuffer;


						nvsg::IndexSetSharedPtr isptr= nvsg::PrimitiveReadLock (drawable)->getIndexSet();//getVertexAttributeSet();
						dalhost = nvsg::IndexSetWriteLock(isptr)->getDALHost();
						nvsg::D3DVertexBufferData *ibdata;
						nvsg::D3DDalHostReadLock (dalhost)->getDeviceAbstractionLinkData(0,ibdata,nvsg::D3DVertexBufferData::test_func);
						indexBuffer = ibdata->GetBuffer();
						GetNV3DBase().SetModelMatrix (mat);
						GetNV3DBase().DrawBuffer ( indexBuffer, &vertexBuffer,ibdata->GetCount(),ibdata->GetFormat());
						++dit;
					}
					++ssit;
				}

				break;
			case nvsg::OC_DRAWABLE:
				break;
			case nvsg::OC_STATESET:
				break;
			default:
				break;
			};
		}