void CameraHandler::GetCameraData(FbxNode* pNode, CameraExporter* outCamera)
{
	for (int j = 0; j < pNode->GetChildCount(); j++)
		GetCameraData(pNode->GetChild(j), outCamera);

	if (pNode->GetCamera())
	{
		std::cout << pNode->GetName() << std::endl;
		ProcessCameraData(pNode->GetCamera(), outCamera);
	}
}
Example #2
0
//--------------------------------------------------------------------------------------
// RenderGrass
//--------------------------------------------------------------------------------------
void RenderGrass( ID3D10Device* pd3dDevice )
{
    D3DXMATRIX mWorld;
    D3DXMatrixIdentity( &mWorld );

    D3DXVECTOR3 vEye;
    D3DXVECTOR3 vDir;
    D3DXMATRIX mCamWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
    GetCameraData( &mCamWorld, &mView, &mProj, &vEye, &vDir );
    D3DXMATRIX mWVP = mCamWorld * mView * mProj;

    // set vb streams
    ID3D10Buffer* pBuffers[1];
    pBuffers[0] = g_pGrassDataVB10;
    UINT strides[1];
    strides[0] = sizeof( D3DXVECTOR3 );
    UINT offsets[1] = {0};
    pd3dDevice->IASetVertexBuffers( 1, 1, pBuffers, strides, offsets );

    SetNumVisibleGrassTiles( g_NumGrassTiles );

    // set effect variables
    g_pmWorldViewProj->SetMatrix( ( float* )&mWVP );
    g_pfWorldScale->SetFloat( g_fWorldScale );
    g_pfHeightScale->SetFloat( g_fHeightScale );
    D3DXVECTOR4 vEye4( vEye, 1 );
    g_pvEyePt->SetFloatVector( ( float* )&vEye4 );
    g_pfFadeStart->SetFloat( g_fFadeStart );
    g_pfFadeEnd->SetFloat( g_fFadeEnd );

    g_ptxDiffuse->SetResource( g_pGrassTexRV );
    g_ptxHeight->SetResource( g_pHeightTexRV );
    g_ptxMask->SetResource( g_pMaskTexRV );
    g_ptxShadeNormals->SetResource( g_pShadeNormalTexRV );

    ID3D10EffectTechnique* pTechnique = g_pRenderGrass;

    pd3dDevice->IASetInputLayout( g_pGrassDecl10 );

    D3D10_TECHNIQUE_DESC techDesc;
    pTechnique->GetDesc( &techDesc );

    for( UINT p = 0; p < techDesc.Passes; p++ )
    {
        pTechnique->GetPassByIndex( p )->Apply( 0 );

        g_Terrain.RenderGrass( &vDir, g_NumGrassTiles );
    }

    pBuffers[0] = NULL;
    pd3dDevice->IASetVertexBuffers( 1, 1, pBuffers, strides, offsets );
}
Example #3
0
//--------------------------------------------------------------------------------------
// RenderTerrain
//--------------------------------------------------------------------------------------
void RenderTerrain( ID3D10Device* pd3dDevice )
{
    D3DXMATRIX mWorld;
    D3DXMatrixIdentity( &mWorld );

    D3DXVECTOR3 vEye;
    D3DXVECTOR3 vDir;
    D3DXMATRIX mCamWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
    GetCameraData( &mCamWorld, &mView, &mProj, &vEye, &vDir );
    D3DXMATRIX mWVP = mCamWorld * mView * mProj;

    pd3dDevice->IASetInputLayout( g_pBasicDecl10 );

    g_pmWorldViewProj->SetMatrix( ( float* )&mWVP );
    g_pmWorld->SetMatrix( ( float* )&mWorld );

    g_ptxNormal->SetResource( g_pNormalTexRV );
    g_ptxDirt->SetResource( g_pDirtTexRV );
    g_ptxGrass->SetResource( g_pGroundGrassTexRV );
    g_ptxMask->SetResource( g_pMaskTexRV );

    if( !g_bShowTiles )
    {
        D3DXVECTOR4 color( 1,1,1,1 );
        g_pvColor->SetFloatVector( ( float* )&color );
    }

    pd3dDevice->IASetIndexBuffer( g_Terrain.GetTerrainIB10(), DXGI_FORMAT_R16_UINT, 0 );

    D3D10_TECHNIQUE_DESC techDesc;
    g_pRenderTerrain->GetDesc( &techDesc );

    for( UINT p = 0; p < techDesc.Passes; ++p )
    {
        // Render front to back
        UINT NumTiles = g_VisibleTileArray.GetSize();
        SetNumVisibleTiles( NumTiles );
        for( UINT i = 0; i < NumTiles; i++ )
        {
            TERRAIN_TILE* pTile = g_Terrain.GetTile( g_VisibleTileArray.GetAt( i ) );

            if( g_bShowTiles )
            {
                g_pvColor->SetFloatVector( ( float* )&pTile->Color );
            }
            g_pRenderTerrain->GetPassByIndex( p )->Apply( 0 );

            g_Terrain.RenderTile( pTile );
        }
    }
}
Example #4
0
//--------------------------------------------------------------------------------------
// RenderSky
//--------------------------------------------------------------------------------------
void RenderSky( ID3D10Device* pd3dDevice )
{
    D3DXMATRIX mWorld;
    D3DXVECTOR3 vEye;
    D3DXVECTOR3 vDir;
    D3DXMATRIX mCamWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;

    D3DXMatrixRotationY( &mWorld, -D3DX_PI / 2.5f );
    GetCameraData( &mCamWorld, &mView, &mProj, &vEye, &vDir );
    mView._41 = mView._42 = mView._43 = 0.0f;
    D3DXMATRIX mWVP = mWorld * mCamWorld * mView * mProj;

    g_pmWorldViewProj->SetMatrix( ( float* )&mWVP );
    g_pmWorld->SetMatrix( ( float* )&mWorld );

    pd3dDevice->IASetInputLayout( g_pBasicDecl10 );
    g_SkyMesh.Render( pd3dDevice, g_pRenderSky, g_ptxDiffuse );
}
Example #5
0
//--------------------------------------------------------------------------------------
// RenderBalls
//--------------------------------------------------------------------------------------
void RenderBalls( ID3D10Device* pd3dDevice )
{
    D3DXMATRIX mWorld;
    D3DXMatrixIdentity( &mWorld );

    D3DXVECTOR3 vEye;
    D3DXVECTOR3 vDir;
    D3DXMATRIX mCamWorld;
    D3DXMATRIX mView;
    D3DXMATRIX mProj;
    GetCameraData( &mCamWorld, &mView, &mProj, &vEye, &vDir );
    D3DXMATRIX mWVP = mCamWorld * mView * mProj;

    g_pmWorldViewProj->SetMatrix( ( float* )&mWVP );
    g_pmWorld->SetMatrix( ( float* )&mWorld );

    pd3dDevice->IASetInputLayout( g_pBallDecl10 );

    ID3D10EffectTechnique* pTechnique = g_pRenderBall;
	
    // set vb streams
    ID3D10Buffer* pBuffers[2];
    pBuffers[0] = g_BallMesh.GetVB10( 0, 0 );
    pBuffers[1] = g_pStreamDataVB10;
    UINT strides[2];
    strides[0] = g_BallMesh.GetVertexStride( 0, 0 );
    strides[1] = sizeof( D3DXVECTOR3 );
    UINT offsets[2] = {0,0};
    pd3dDevice->IASetVertexBuffers( 0, 2, pBuffers, strides, offsets );

    SetNumVisibleBalls( g_NumVisibleBalls );

    // Set our index buffer as well
    pd3dDevice->IASetIndexBuffer( g_BallMesh.GetIB10( 0 ), g_BallMesh.GetIBFormat10( 0 ), 0 );

    SDKMESH_SUBSET* pSubset = NULL;
    D3D10_PRIMITIVE_TOPOLOGY PrimType;
    D3D10_TECHNIQUE_DESC techDesc;
    pTechnique->GetDesc( &techDesc );

    for( UINT p = 0; p < techDesc.Passes; ++p )
    {
        for( UINT subset = 0; subset < g_BallMesh.GetNumSubsets( 0 ); subset++ )
        {
            pSubset = g_BallMesh.GetSubset( 0, subset );

            PrimType = g_BallMesh.GetPrimitiveType10( ( SDKMESH_PRIMITIVE_TYPE )pSubset->PrimitiveType );
            pd3dDevice->IASetPrimitiveTopology( PrimType );

            pTechnique->GetPassByIndex( p )->Apply( 0 );

            UINT IndexCount = ( UINT )pSubset->IndexCount;
            UINT IndexStart = ( UINT )pSubset->IndexStart;
            UINT VertexStart = ( UINT )pSubset->VertexStart;
            //UINT VertexCount = (UINT)pSubset->VertexCount;

            pd3dDevice->DrawIndexedInstanced( IndexCount, g_NumVisibleBalls, IndexStart, VertexStart, 0 );
        }
    }

    pBuffers[0] = NULL;
    pBuffers[1] = NULL;
    pd3dDevice->IASetVertexBuffers( 0, 2, pBuffers, strides, offsets );
}