void Camera::SetPerspectiveProjection( const float fov, const float aspectRatio, const float nearPlane, const float farPlane) { m_projectionMatrix = CreatePerspectiveMatrix( fov, aspectRatio, nearPlane, farPlane); }
void SetModelMatrices() { Matrix matWorld, rotMatrix, transMatrix, scaleMatrix; CreateRotationYMatrix(&rotMatrix, (timeGetTime()%2000)*(2.0f*M_PI)/2000.0f); CreateTranslationMatrix(&transMatrix, 0.0f, ytranslation, 0.0f); CreateScaleMatrix(&scaleMatrix, scaling, scaling, scaling); MultiplyMatrices(&matWorld, &rotMatrix, &transMatrix); //MultiplyMatrices(&matWorld, &matWorld, &scaleMatrix); matWorld *= scaleMatrix; Matrix finalmatrix = matWorld; Vector3 vEyePt( 0.0f, 18.0f,-20.0f ); Vector3 vLookatPt( 0.0f, 0.0f, 0.0f ); Vector3 vUpVec( 0.0f, 1.0f, 0.0f ); Matrix matView; CreateLookAtLHViewMatrix( &matView, &vEyePt, &vLookatPt, &vUpVec ); finalmatrix *= matView; Matrix matProj; CreatePerspectiveMatrix( &matProj, M_PI / 4, 1.0f, 1.0f, 100.0f ); finalmatrix *= matProj; SetTransformMatrix(&finalmatrix); }
void SetConstantMatrices() { Vector3 vCamDir = Vector3(0.0f, 0.0f, 5.0f); //Matrix mCamRot; D3DXMatrixRotationYawPitchRoll(&mCamRot, camyaw, campitch, 0.0f); Matrix mCamRot, roty, rotx; CreateRotationYMatrix(&roty, -camyaw); CreateRotationXMatrix(&rotx, -campitch); MultiplyMatrices(&mCamRot, &rotx, &roty); TransformNormal3(&vLAD, &vCamDir, &mCamRot); Vector3 vLookatPt = camerapos + vLAD; //camerapos + Vector3(0.0f, 0.0f, 5.0f); Vector3 vUpVec( 0.0f, 1.0f, 0.0f ); CreateLookAtLHViewMatrix(&matView, &camerapos, &vLookatPt, &vUpVec); //ddev->SetTransform( D3DTS_VIEW, &matView ); CreatePerspectiveMatrix( &matProj, verticalfov, (float)scrw/(float)scrh, 1.0f, farzvalue ); //ddev->SetTransform( D3DTS_PROJECTION, &matProj ); MultiplyMatrices(&vpmatrix, &matView, &matProj); CreateTranslationMatrix(&camworld, camerapos.x, camerapos.y, camerapos.z); camworld *= mCamRot; }