Skip to main content
gamedev.net
🔒 Locked

Cubic mapping??

Started by 00702000744 Apr 12, 2002 at 7:51 PM 0 replies 250+ views
Original Post
00702000744
00702000744
I have got a snippet of code here from Microsoft sample program of cubic mapping. It looks too confusing to me. One major thing is that it sets different view and projection matrices when rendering the cube maps, why do they need to do that? Isn''t that true every model shares the same view and projection matrices? can any one explain the code to me in a little bit more detail? I will be very gratful for any help!!! HRESULT CMyD3DApplication::RenderSceneIntoEnvMap() { HRESULT hr; // Set the projection matrix for a field of view of 90 degrees D3DXMATRIX matProj; D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI * 0.5f, 1.0f, 0.5f, 1000.0f ); // Get the current view matrix, to concat it with the cubemap view vectors D3DXMATRIX matViewDir( m_matView ); matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f; // Render the six cube faces into the environment map if( m_pCubeMap ) hr = m_pRenderToEnvMap->BeginCube( m_pCubeMap ); else hr = m_pRenderToEnvMap->BeginSphere( m_pSphereMap ); if(FAILED(hr)) return hr; for( UINT i = 0; i < 6; i++ ) { m_pRenderToEnvMap->Face( (D3DCUBEMAP_FACES) i ); // Set the view transform for this cubemap surface D3DXMATRIX matView; matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES) i ); D3DXMatrixMultiply( &matView, &matViewDir, &matView ); // Render the scene (except for the teapot) RenderScene( &matView, &matProj, FALSE ); } m_pRenderToEnvMap->End(); return S_OK; }
Moe
Moe
Basically, (as far as I know) it changes the perspective 6 times - one for each rendering to texture. When you are doing cubic environment mapping you are basically taking 6 pictures of the surroundings (top, bottom, front, back, left, right - not necessarily in that order) and apply those 6 pictures to the object.

Moe''s Site

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.