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


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

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


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

示例1: OnResize

void Viewport::OnResize()
{
	const uint32_t width = (m_Size.x > 0) ? m_Size.x : 64;
	const uint32_t height = (m_Size.y > 0) ? m_Size.y : 64;
	const float32_t aspectRatio =
	static_cast< float32_t >( width ) / static_cast< float32_t >( height );

	if (m_World)
	{
		Renderer* pRenderer = Renderer::GetStaticInstance();

		Renderer::ContextInitParameters ctxParams;
		ctxParams.pWindow = m_Window;
		ctxParams.displayWidth = width;
		ctxParams.displayHeight = height;
		ctxParams.bFullscreen = false;
		ctxParams.bVsync = false;

		RRenderContextPtr renderCtx = pRenderer->CreateSubContext( ctxParams );

		GraphicsScene* pGraphicsScene = GetGraphicsScene();
		GraphicsSceneView* pSceneView = pGraphicsScene->GetSceneView( m_SceneViewId );
		pSceneView->SetRenderContext( renderCtx );
		pSceneView->SetDepthStencilSurface( RenderResourceManager::GetStaticInstance().GetDepthStencilSurface() );
		pSceneView->SetAspectRatio( aspectRatio );
		pSceneView->SetViewport( 0, 0, width, height );
		pSceneView->SetClearColor( Helium::Color( 0x00505050 ) );
	}
}
开发者ID:kevindqc,项目名称:Helium,代码行数:29,代码来源:Viewport.cpp

示例2: Attach

/// @copydoc Entity::Attach()
void Camera::Attach()
{
    Base::Attach();

    // Update the scene view associated with this camera.
    if( IsValid( m_sceneViewId ) )
    {
        World* pWorld = GetWorld();
        HELIUM_ASSERT( pWorld );
        GraphicsScene* pScene = pWorld->GetGraphicsScene();
        if( pScene )
        {
            GraphicsSceneView* pSceneView = pScene->GetSceneView( m_sceneViewId );
            if( pSceneView )
            {
                Simd::Matrix44 rotationMatrix( Simd::Matrix44::INIT_ROTATION, GetRotation() );
                pSceneView->SetView(
                    GetPosition(),
                    Vector4ToVector3( rotationMatrix.GetRow( 2 ) ),
                    Vector4ToVector3( rotationMatrix.GetRow( 1 ) ) );
                pSceneView->SetHorizontalFov( m_fov );
            }
        }
    }
}
开发者ID:euler0,项目名称:Helium,代码行数:26,代码来源:Camera.cpp

示例3: 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

示例4: _tWinMain


//.........这里部分代码省略.........
	gAssetLoader->LoadObject( AssetPath( TXT( "/ExampleGames/Empty/Scenes/TestScene:TestBull_Entity" ) ), spEntityDefinition );

	DynamicDrawer& rDynamicDrawer = DynamicDrawer::GetStaticInstance();
	HELIUM_VERIFY( rDynamicDrawer.Initialize() );

	RRenderContextPtr spMainRenderContext = pRenderer->GetMainContext();
	HELIUM_ASSERT( spMainRenderContext );
	
	WorldManager& rWorldManager = WorldManager::GetStaticInstance();
	HELIUM_VERIFY( rWorldManager.Initialize() );

	// Create a world
	WorldPtr spWorld( rWorldManager.CreateWorld( spSceneDefinition ) );
	HELIUM_ASSERT( spWorld );
	HELIUM_TRACE( TraceLevels::Info, TXT( "Created world \"%s\".\n" ), *spSceneDefinition->GetPath().ToString() );

	//Slice *pRootSlice = spWorld->GetRootSlice();
	//Entity *pEntity = pRootSlice->CreateEntity(spEntityDefinition);
			
	GraphicsScene* pGraphicsScene = spWorld->GetComponents().GetFirst<GraphicsManagerComponent>()->GetGraphicsScene();
	HELIUM_ASSERT( pGraphicsScene );
	GraphicsSceneView* pMainSceneView = NULL;
	if( pGraphicsScene )
	{
		uint32_t mainSceneViewId = pGraphicsScene->AllocateSceneView();
		if( IsValid( mainSceneViewId ) )
		{
			float32_t aspectRatio =
				static_cast< float32_t >( displayWidth ) / static_cast< float32_t >( displayHeight );

			RSurface* pDepthStencilSurface = rRenderResourceManager.GetDepthStencilSurface();
			HELIUM_ASSERT( pDepthStencilSurface );

			pMainSceneView = pGraphicsScene->GetSceneView( mainSceneViewId );
			HELIUM_ASSERT( pMainSceneView );
			pMainSceneView->SetRenderContext( spMainRenderContext );
			pMainSceneView->SetDepthStencilSurface( pDepthStencilSurface );
			pMainSceneView->SetAspectRatio( aspectRatio );
			pMainSceneView->SetViewport( 0, 0, displayWidth, displayHeight );
			pMainSceneView->SetClearColor( Color( 0x00202020 ) );

			//spMainCamera->SetSceneViewId( mainSceneViewId );

#if MULTI_WINDOW
			uint32_t subSceneViewId = pGraphicsScene->AllocateSceneView();
			if( IsValid( subSceneViewId ) )
			{
				GraphicsSceneView* pSubSceneView = pGraphicsScene->GetSceneView( subSceneViewId );
				HELIUM_ASSERT( pSubSceneView );
				pSubSceneView->SetRenderContext( spSubRenderContext );
				pSubSceneView->SetDepthStencilSurface( pDepthStencilSurface );
				pSubSceneView->SetAspectRatio( aspectRatio );
				pSubSceneView->SetViewport( 0, 0, displayWidth, displayHeight );
				pSubSceneView->SetClearColor( Color( 0x00202020 ) );

				//spSubCamera->SetSceneViewId( subSceneViewId );
			}
#endif
		}
	
#if !HELIUM_RELEASE && !HELIUM_PROFILE
		BufferedDrawer& rSceneDrawer = pGraphicsScene->GetSceneBufferedDrawer();
		rSceneDrawer.DrawScreenText(
			20,
			20,
			String( TXT( "CACHING" ) ),
开发者ID:kevindqc,项目名称:Helium,代码行数:67,代码来源:TestApp.cpp

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