void Game::fnRender(HWND hWnd)
{
D3DXVECTOR3 vecEyePoint; // The eye point
D3DXVECTOR3 vecLookatPoint; // The camera look-at target
D3DXVECTOR3 vecUp; // The current world's up
D3DXMATRIX matRotationX; // The matrix that rotates around the x-axis
D3DXMATRIX matRotationY; // The matrix that rotates around the y-axis
D3DXMATRIX matRotation; // The matrix that rotates around the x and y-axis
D3DXMATRIX matWorld; // The world transformation matrix
D3DXMATRIX matView; // The view transformation matrix
int nTexture;
int nVertex;
int nWheel;
fnCheckKeyboard(hWnd);
fnCheckMouse(hWnd);
vecEyePoint = D3DXVECTOR3(g_fPosX, g_fPosY, g_fPosZ);
vecLookatPoint = D3DXVECTOR3(g_fPosX, g_fPosY, g_fPosZ + 0.1f);
vecUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
D3DXMatrixLookAtLH(&matView, &vecEyePoint, &vecLookatPoint, &vecUp);
D3DXMatrixRotationX(&matRotationX, D3DXToRadian(g_fAngleX));
D3DXMatrixRotationY(&matRotationY, D3DXToRadian(g_fAngleY));
D3DXMatrixMultiply(&matRotation, &matRotationY, &matRotationX);
D3DXMatrixMultiply(&matView, &matView, &matRotation);
// Clear the back buffer to a black color
g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
// Begin the scene
g_pd3dDevice->BeginScene();
// Skybox
D3DXMatrixScaling(&matWorld, 100.0f, 100.0f, 100.0f);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
D3DXMATRIX matViewSkybox(matView);
matViewSkybox._41 = matViewSkybox._42 = matViewSkybox._43 = 0.0f;
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matViewSkybox);
// Set Texture-Addressing to clamp
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP);
// Use default LOD and LOD Bias
g_pd3dDevice->SetTextureStageState(0, D3DTSS_MAXMIPLEVEL, 0);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_MIPMAPLODBIAS, 0);
for (nTexture = nVertex = 0; nTexture <= 5; nTexture++, nVertex += 4)
{
if (!g_bWireframe)
{
g_pd3dDevice->SetTexture(0, g_pTexture[nTexture]);
}
g_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, nVertex, 2);
}
g_pd3dDevice->SetTextureStageState(0, D3DTSS_MAXMIPLEVEL, g_dwLOD);
g_pd3dDevice->SetTextureStageState(0, D3DTSS_MIPMAPLODBIAS, *((LPDWORD)(&g_fLODBias)));
//my mesh
/*D3DXMatrixScaling(&matWorld, 10.0f, 10.0f, 10.0f);
D3DXMatrixTranslation(&matWorld, 3.0f, 1.7f, 0.0f);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
g_pd3dDevice->SetTransform(D3DTS_VIEW, &matView);*/
m_mesh->Render();
......
......
// End the scene
g_pd3dDevice->EndScene();
// Present the back buffer contents to the display
g_pd3dDevice->Present(NULL, NULL, NULL, NULL);
}


Reply With Quote
