当前位置: 首页>>代码示例>>C++>>正文


C++ GraphicsScene::GetSceneViewBufferedDrawer方法代码示例

本文整理汇总了C++中GraphicsScene::GetSceneViewBufferedDrawer方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsScene::GetSceneViewBufferedDrawer方法的具体用法?C++ GraphicsScene::GetSceneViewBufferedDrawer怎么用?C++ GraphicsScene::GetSceneViewBufferedDrawer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphicsScene的用法示例。


在下文中一共展示了GraphicsScene::GetSceneViewBufferedDrawer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Draw

void Viewport::Draw()
{
	SCENE_GRAPH_RENDER_SCOPE_TIMER( ("") );

	uint64_t start = Helium::TimerGetClock();

	if (!m_World)
	{
		return;
	}

	Camera& camera = m_Cameras[m_CameraMode];

	GraphicsScene* pGraphicsScene = GetGraphicsScene();
	GraphicsSceneView* pSceneView = pGraphicsScene->GetSceneView( m_SceneViewId );
	BufferedDrawer* pDrawer = pGraphicsScene->GetSceneViewBufferedDrawer( m_SceneViewId );

	DrawArgs args;

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup Viewport and Projection") );

		Vector3 pos;
		camera.GetPosition( pos );

		const Matrix4& invView = camera.GetInverseView();

		pSceneView->SetView(
			Simd::Vector3( &pos.x ),
			-Simd::Vector3( &invView.z.x ),
			Simd::Vector3( &invView.y.x ) );

		pSceneView->SetHorizontalFov( Camera::FieldOfView * static_cast< float32_t >(HELIUM_RAD_TO_DEG) );
	}

	if (m_GridVisible)
	{
		m_GlobalPrimitives[GlobalPrimitives::StandardGrid]->Draw( pDrawer, &args );
	}

#ifdef VIEWPORT_REFACTOR
	// this seems like a bad place to do this
	if (m_Tool)
	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Tool Evaluate") );
		m_Tool->Evaluate();
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Clear and Reset Scene") );

		device->BeginScene();
		device->SetRenderTarget( 0, m_DeviceManager.GetBackBuffer() );
		device->SetDepthStencilSurface( m_DeviceManager.GetDepthBuffer() );
		device->Clear(NULL, NULL, D3DCLEAR_TARGET | D3DCLEAR_STENCIL | D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB(255, 80, 80, 80), 1.0f, 0);
		device->SetTransform(D3DTS_WORLD, (D3DMATRIX*)&Matrix4::Identity);

		m_ResourceTracker->ResetState();
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup Viewport and Projection") );

		device->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)&m_Cameras[m_CameraMode].SetProjection(m_Size.x, m_Size.y));
		device->SetTransform(D3DTS_VIEW, (D3DMATRIX*)&m_Cameras[m_CameraMode].GetViewport());
	}

	{
		SCENE_GRAPH_RENDER_SCOPE_TIMER( ("Setup RenderState (culling, lighting, and fill") );

		device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
		device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

		if (m_Cameras[m_CameraMode].IsBackFaceCulling())
		{
			device->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
		}
		else
		{
			device->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
		}

		device->SetRenderState(D3DRS_LIGHTING, TRUE);
		device->SetRenderState(D3DRS_COLORVERTEX, FALSE);
		device->SetRenderState(D3DRS_AMBIENTMATERIALSOURCE, D3DMCS_MATERIAL);
		device->SetRenderState(D3DRS_DIFFUSEMATERIALSOURCE, D3DMCS_MATERIAL);
		device->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);

		device->SetRenderState(D3DRS_ZENABLE, TRUE);
		device->SetRenderState(D3DRS_NORMALIZENORMALS, TRUE);
		device->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);

		device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
		device->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);

		device->SetPixelShader( NULL );
		device->SetVertexShader( NULL );

		D3DLIGHT9 light;    
//.........这里部分代码省略.........
开发者ID:kevindqc,项目名称:Helium,代码行数:101,代码来源:Viewport.cpp

示例2: Draw

void Viewport::Draw()
{
	HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "" );

	uint64_t start = Timer::GetTickCount();

	if (!m_World)
	{
		return;
	}

	Camera& camera = m_Cameras[m_CameraMode];

	GraphicsScene* pGraphicsScene = GetGraphicsScene();
	GraphicsSceneView* pSceneView = pGraphicsScene->GetSceneView( m_SceneViewId );
	BufferedDrawer* pDrawer = pGraphicsScene->GetSceneViewBufferedDrawer( m_SceneViewId );

	{
		HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Setup Viewport and Projection" );

		pSceneView->SetViewAndProjectionMatrices(
			Simd::Matrix44( const_cast<Matrix4&>( camera.GetView() ).GetArray1d() ),
			Simd::Matrix44( const_cast<Matrix4&>( camera.GetProjection() ).GetArray1d() )
		);
	}

	pGraphicsScene->SetActiveSceneView( m_SceneViewId );
	pGraphicsScene->Update( m_World.Get() );
	pGraphicsScene->SetActiveSceneView( Invalid< uint32_t >() );

	if (m_GridVisible)
	{
		m_GlobalPrimitives[GlobalPrimitives::StandardGrid]->Draw( pDrawer );
	}

	// this seems like a bad place to do this
	if (m_Tool)
	{
		HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Tool Evaluate" );
		m_Tool->Evaluate();
	}

	{
		HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "PreRender" );

		if (m_GridVisible)
		{
			m_GlobalPrimitives[GlobalPrimitives::StandardGrid]->Draw( pDrawer );
		}
	}

	{
		HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Render" );

		{
			HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Render Setup" );
			m_RenderVisitor.Reset( this, pDrawer );
		}

		{
			HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Render Walk" );
			m_Render.Raise( &m_RenderVisitor );
		}

		if (m_Tool)
		{
			HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "Render Tool" );
			m_Tool->Draw( pDrawer );
		}
	}

	{
		HELIUM_EDITOR_SCENE_RENDER_SCOPE_TIMER( "PostRender" );

		//device->Clear(NULL, NULL, D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

		if (m_AxesVisible)
		{
			static_cast<Editor::PrimitiveAxes*>(m_GlobalPrimitives[GlobalPrimitives::ViewportAxes])->DrawViewport( pDrawer, &m_Cameras[m_CameraMode] );
		}

		if (m_Tool)
		{
			m_Tool->Draw( pDrawer );
		}

#if  VIEWPORT_REFACTOR
		if ( m_Focused )
		{
			unsigned w = 3;
			unsigned x = m_Size.x;
			unsigned y = m_Size.y;

			uint32_t color = D3DCOLOR_ARGB(255, 200, 200, 200);

			std::vector< TransformedColored > vertices;

			//   <--
			//  | \  ^
			//  v  \ |
//.........这里部分代码省略.........
开发者ID:HeliumProject,项目名称:Helium,代码行数:101,代码来源:Viewport.cpp


注:本文中的GraphicsScene::GetSceneViewBufferedDrawer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。