# A question about cube map

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

## 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 on other sites
I'm as stumped as you. Maybe it has some special meaning in D3D? A zero normal is an undefined plane as far as I know...

##### Share on other sites
I would use an SDK sample instead. The code for rendering a cubemap should not need a relfection matrix.

Try the HDR cubemap sample.

1. 1
2. 2
3. 3
Rutin
14
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633674
• Total Posts
3013275
×