Jump to content
  • Advertisement
Sign in to follow this  
Keisni

A question about cube map

This topic is 4127 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This is function copyed from "Special effects game programming with directx" chapter 23 : 3D Water HRESULT CMyD3DApplication::CubeMapRender() { // Set the projection matrix for a field of view of 90 degrees D3DXMATRIX matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 0.5f, 100.0f ); m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj ); // Get the current view matrix, to concat it with the cubemap view vectors D3DXMATRIX matViewDir = m_Camera.GetViewMatrix(); matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f; D3DXPLANE plane; plane.a = plane.b = plane.c = plane.d = 0.0f; D3DXMATRIX matFlip; D3DXMatrixReflect(&matFlip, &plane); D3DXMatrixMultiply(&matViewDir, &matFlip, &matViewDir); // Store the current backbuffer and zbuffer LPDIRECT3DSURFACE8 pBackBuffer, pZBuffer; m_pd3dDevice->GetRenderTarget( &pBackBuffer ); m_pd3dDevice->GetDepthStencilSurface( &pZBuffer ); // Render to the six faces of the cube map for( DWORD i=0; i<6; i++ ) { // Set the view transform for this cubemap surface D3DXMATRIX matView; matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES)i ); D3DXMatrixMultiply( &matView, &matViewDir, &matView ); m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView ); // Set the rendertarget to the i'th cubemap surface LPDIRECT3DSURFACE8 pCubeMapFace; m_pCubeMap->GetCubeMapSurface( (D3DCUBEMAP_FACES)i, 0, &pCubeMapFace ); m_pd3dDevice->SetRenderTarget( pCubeMapFace, m_pCubeFaceZBuffer); pCubeMapFace->Release(); m_pd3dDevice->BeginScene(); m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xffffffff, 1.0f, 0L ); CoreRender( FALSE, matView ); m_pd3dDevice->EndScene(); } m_pd3dDevice->SetTransform( D3DTS_VIEW, &m_Camera.GetViewMatrix()); // Change the rendertarget back to the main backbuffer m_pd3dDevice->SetRenderTarget( pBackBuffer, pZBuffer ); pBackBuffer->Release(); pZBuffer->Release(); return S_OK; } For each cube face, three matrices are concatenated to produce a proper view matrix. The purpose of the first matrix is to reflect the scene about the ground plane. But I just can`t understand the plane used in the code : all of the 4 factors are 0. I know that a, b, c forms the plane normal, but if they are all 0, what the plane is?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!