void WavesApp::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::PI/* 90度视角 */, GetAspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&m_projMaxtrix, P); }
void Pass::draw() { initDraw(); if (useDefaultWVP) { XMFLOAT4X4 view = camera->getViewMatrix(); XMMATRIX camView = XMLoadFloat4x4(&view); XMMATRIX camProjection = XMMatrixPerspectiveFovLH(0.4f * 3.14f, (float)width / height, 1.0f, 1000.0f); XMMATRIX w = XMLoadFloat4x4(&world); XMMATRIX WVP = XMMatrixTranspose(w * camView * camProjection); cbPerObject cbPerObj; cbPerObj.WVP = WVP; cbPerObj.normalTransform = w; cbPerObj.eyePosition = camera->position; Constant *wvp = new Constant(&cbPerObj, sizeof(cbPerObj), 0); wvp->setConstantForVS(device, context); } else { XMMATRIX w = XMLoadFloat4x4(&world); XMMATRIX WVP = XMMatrixTranspose(w); MatrixBuffer buffer; buffer.matrix = WVP; Constant *wvp = new Constant(&buffer, sizeof(buffer), 0); wvp->setConstantForVS(device, context); } model->draw(device, context, vertexShader->buffer); }
void CubeObject::UpdateConstantBuffer() { //行列の定義 Mat4x4 World, View, Proj; //ワールド行列の決定 World.affineTransformation( m_Scale, //スケーリング Vec3(0, 0, 0), //回転の中心(重心) m_Qt, //回転角度 m_Pos //位置 ); //転置する World.transpose(); //ビュー行列の決定 View = XMMatrixLookAtLH(Vec3(0, 2.0, -5.0f), Vec3(0, 0, 0), Vec3(0, 1.0f, 0)); //転置する View.transpose(); //射影行列の決定 float w = static_cast<float>(App::GetApp()->GetGameWidth()); float h = static_cast<float>(App::GetApp()->GetGameHeight()); Proj = XMMatrixPerspectiveFovLH(XM_PIDIV4, w / h, 1.0f, 100.0f); //転置する Proj.transpose(); m_StaticConstantBuffer.World = World; m_StaticConstantBuffer.View = View; m_StaticConstantBuffer.Projection = Proj; m_StaticConstantBuffer.Emissive = Col4(0, 0, 0, 0); //更新 memcpy(m_pConstantBuffer, reinterpret_cast<void**>(&m_StaticConstantBuffer), sizeof(m_StaticConstantBuffer)); }
bool processClass::initialize(int width, int height, ID3D11Device *device) { HRESULT hr; m_width = width; m_height = height; camPosition = XMVectorSet(0.0f, 7.0f, -10.0f, 0.0f); camTarget = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f); camUp = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); //Set the View matrix camView = XMMatrixLookAtLH(camPosition, camTarget, camUp); camProjection = XMMatrixPerspectiveFovLH(0.4f*XM_PI, (float)width / height, 1.0f, 1000.0f); ortho = XMMatrixOrthographicLH((float)width, (float)height, 0.1f, 1000.0f); D3D11_BUFFER_DESC cbbd; ZeroMemory(&cbbd, sizeof(D3D11_BUFFER_DESC)); cbbd.Usage = D3D11_USAGE_DEFAULT; cbbd.ByteWidth = sizeof(cbPerObject); cbbd.BindFlags = D3D11_BIND_CONSTANT_BUFFER; cbbd.CPUAccessFlags = 0; cbbd.MiscFlags = 0; hr = device->CreateBuffer(&cbbd, NULL, &cbPerObjectBuffer); return true; }
void RenderSystem::init_camera() { //Viewport Infomation D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(D3D11_VIEWPORT)); vp.TopLeftX = 0; vp.TopLeftY = 0; vp.Width = static_cast<FLOAT>(m_ScreenWidth); vp.Height = static_cast<FLOAT>(m_ScreenHeight); m_pD3D11DeviceContext->RSSetViewports(1, &vp); //MVP Matrix XMVECTOR camPos = XMVectorSet(0.0f, 0.0f, -5.0f, 0.0f); XMVECTOR camTarget = XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f); XMVECTOR camUp = XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f); XMMATRIX View = XMMatrixLookAtLH(camPos, camTarget, camUp); XMMATRIX Proj = XMMatrixPerspectiveFovLH(0.4f*3.14f, GetAspect(), 1.0f, 1000.0f); XMMATRIX Model = XMMatrixRotationY(60.0f); XMStoreFloat4x4(&m_Matrix.model, XMMatrixTranspose(Model) ); XMStoreFloat4x4(&m_Matrix.view, XMMatrixTranspose(View) ); XMStoreFloat4x4(&m_Matrix.proj, XMMatrixTranspose(Proj) ); }
void TextureDemo::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH(0.25f * MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
void D3DCamera::Init(int screenWidth, int screenHeight, ID3D11DeviceContext* devCon, XMVECTOR position, XMVECTOR rotation) { // Setup the viewport m_viewport.Width = (float)screenWidth; m_viewport.Height = (float)screenHeight; m_viewport.MinDepth = 0.0f; m_viewport.MaxDepth = 1.0f; m_viewport.TopLeftX = 0.0f; m_viewport.TopLeftY = 0.0f; m_position = position; m_rotation = rotation; devCon->RSSetViewports(1, &m_viewport); // Set up fov to 90° m_fieldOfView = PI/4.0f; //get Apsect ratio m_screenAspect = (float)screenWidth / (float)screenHeight; //Set the projection matrix m_projectionMatrix = XMMatrixPerspectiveFovLH(m_fieldOfView, m_screenAspect, SCREEN_NEAR, SCREEN_DEPTH); //OrthoMatrix m_orthoMatrix = XMMatrixOrthographicLH((float)screenWidth, (float)screenHeight, SCREEN_NEAR, SCREEN_DEPTH); }
XMFLOAT4X4 Camera::GetProjection() { // Initialize the projection matrix XMStoreFloat4x4(&_projection, XMMatrixPerspectiveFovLH(XM_PIDIV2, _windowWidth / _windowHeight, _nearDepth, _farDepth)); return _projection; }
//! Constructor. Camera::Camera() { // Set the sensitivity and speed SetLookSensitivity(2.0f); SetMovementSpeed(0.6f); SetLocked(false); // Default position and target mPosition = XMFLOAT3(-30, 60, 0); mTarget = XMFLOAT3(0.0f, 0.0f, 0.0f); mUp = XMFLOAT3(0.0f, 1.0f, 0.0f); // Weird up vector // Calculate the new direction. UpdatePitchYaw(); // Build the projection matrix XMMATRIX proj = XMMatrixPerspectiveFovLH(XM_PI * 0.25, (float)GlobalApp::GetClientWidth()/(float)GlobalApp::GetClientHeight(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, proj); UpdateViewMatrix(); // Build the camera frustum. mFrustum.ConstructFromProjection(GetProjectionMatrix()); //XNA::ComputeFrustumFromProjection(&mFrustum, &XMLoadFloat4x4(&GetProjectionMatrix())); }
void LightSkull::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH(0.25f * MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); }
bool Renderer::initialize( const char *scenefile, HWND * hWnd, int width, int height, float z_far, int msaa, bool fullscreen ) { // setup DirectX controls if ( !dxManager.initialize( hWnd, width, height, msaa, fullscreen ) ) return false; XMMATRIX m; camera.GetTransform( m ); dxManager.setViewMatrix( m ); XMMATRIX proj = XMMatrixPerspectiveFovLH( .4f * CoreLib::Basic::Math::Pi, (float) width / height, 1.f, z_far ); dxManager.setProjMatrix( proj ); BoundingFrustum::CreateFromMatrix( camera_frustum, proj ); this->z_far = z_far; // Load the scene file if ( scenefile != NULL ) { if ( !scene.LoadFromFile( scenefile ) ) return false; } if ( !scene.initializeD3D( dxManager ) ) return false; spriteBatch.reset( new SpriteBatch( dxManager.pD3DDeviceContext ) ); spriteFont.reset( new SpriteFont( dxManager.pD3DDevice, L"Calibri.spritefont" ) ); time = CoreLib::Diagnostics::PerformanceCounter::Start( ); return true; }
//-------------------------------------------------------------------------------------- // Create any D3D11 resources that depend on the back buffer //-------------------------------------------------------------------------------------- HRESULT CALLBACK OnD3D11ResizedSwapChain( ID3D11Device* pd3dDevice, IDXGISwapChain* pSwapChain, const DXGI_SURFACE_DESC* pBackBufferSurfaceDesc, void* pUserContext ) { HRESULT hr; V_RETURN( g_DialogResourceManager.OnD3D11ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) ); V_RETURN( g_SettingsDlg.OnD3D11ResizedSwapChain( pd3dDevice, pBackBufferSurfaceDesc ) ); FLOAT fAspect = (FLOAT)pBackBufferSurfaceDesc->Width / (FLOAT)pBackBufferSurfaceDesc->Height; // Setup the camera's projection parameters XMMATRIX matProjection = XMMatrixPerspectiveFovLH( XM_PIDIV4, fAspect, 0.001f, 100.0f ); XMStoreFloat4x4A( &g_matProjection, matProjection ); g_pTerrainView->GetCamera()->SetProjParams( XM_PIDIV4, fAspect, 0.01f, 1000.0f ); g_HUD.SetLocation( pBackBufferSurfaceDesc->Width - 170, 0 ); g_HUD.SetSize( 170, 170 ); INT UIWidth = 250; INT UIHeight = 110; g_SampleUI.SetLocation( pBackBufferSurfaceDesc->Width - UIWidth, pBackBufferSurfaceDesc->Height - UIHeight ); g_SampleUI.SetSize( UIWidth, UIHeight ); g_HalfClientWidthPixels = (FLOAT)pBackBufferSurfaceDesc->Width * 0.5f; g_HalfClientHeightPixels = (FLOAT)pBackBufferSurfaceDesc->Height * 0.5f; ResidencySampleRender::ResizeRenderView( pBackBufferSurfaceDesc->Width, pBackBufferSurfaceDesc->Height ); return S_OK; }
void InitDirect3DApp::OnResize() { D3DApp::OnResize(); XMMATRIX newProjMtx = XMMatrixPerspectiveFovLH(0.25f * PI, AspectRatio(), 1.0f, 1000.0f); projMtx = newProjMtx; }
void Box::OnResize() { D3DApp::OnResize(); m_proj = XMMatrixPerspectiveFovLH((float)0.25f*XM_PI, AspectRatio(), 1.0f, 1000.0f); }
bool LightLx::GenerateProjectionMatrix() { XMMATRIX projection = XMMatrixPerspectiveFovLH(XM_PIDIV2, 1.0f, 0.1f, 1000.0f); XMStoreFloat4x4(&m_projectionMatrix, projection); return true; }
void RenderSystem::CheckPick() { float tempDist; float closestDist = FLT_MAX; int hitIndex; float pickedDist = 0; XMMATRIX Proj = XMMatrixPerspectiveFovLH(0.4f*3.14f, GetAspect(), 1.0f, 1000.0f); d3dPicking.PickRayVector(m_Camera.GetMouseX(), m_Camera.GetMouseY(), XMLoadFloat4x4(&m_Camera.GetViewMatrix()), Proj); //Check if picking the object and mark it for (int i = 0; i < 20; i++) { if (bottleHit[i] == 0) //No need to check bottles already hit { tempDist = d3dPicking.Pick(bottleModel[i]); if (tempDist < closestDist) { closestDist = tempDist; hitIndex = i; } } } //We pick a object, and set the closest one be the target object if (closestDist < FLT_MAX) { bottleHit[hitIndex] = 1; pickedDist = closestDist; ++score; } }
void CameraComponent::SetLens(float p_FovY, float p_Width, float p_Height, float p_Znear, float p_Zfar, float p_TopX, float p_TopY) { m_FovY = p_FovY; m_Aspect = (p_Width/p_Height); m_NearZ = p_Znear; m_FarZ = p_Zfar; m_NearWindowHeight = 2.0f * m_NearZ * tanf(0.5f*m_FovY); m_FarWindowHeight = 2.0f * m_FarZ * tanf(0.5f*m_FovY); //mProj = XMMatrixPerspectiveFovLH(mFovY,mAspect,mNearZ,mFarZ); //if we had tha matrixes in 4x4 float instead XMMATRIX t_Projection = XMMatrixPerspectiveFovLH(m_FovY, m_Aspect, m_NearZ, m_FarZ); XMStoreFloat4x4(&m_Proj, t_Projection); m_Viewport->Height = p_Height; m_Viewport->Width = p_Width; m_Viewport->MaxDepth = 1; m_Viewport->MinDepth = 0; m_Viewport->TopLeftX = p_TopX; m_Viewport->TopLeftY = p_TopY; }
void RenderSystem::init_camera() { //Viewport Infomation D3D11_VIEWPORT vp; ZeroMemory(&vp, sizeof(D3D11_VIEWPORT)); vp.TopLeftX = 0; vp.TopLeftY = 0; vp.MinDepth = 0.0f; vp.MaxDepth = 1.0f; vp.Width = m_ScreenWidth; vp.Height = m_ScreenHeight; m_pD3D11DeviceContext->RSSetViewports(1, &vp); //MVP Matrix XMVECTOR camPos = XMVectorSet(0.0f, 5.0f, -8.0f, 0.0f); XMVECTOR camTarget = XMVectorSet( 0.0f, 0.0f, 0.0f, 0.0f ); XMVECTOR camUp = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f ); XMMATRIX View = XMMatrixLookAtLH( camPos, camTarget, camUp ); XMMATRIX Model = XMMatrixIdentity(); XMMATRIX Proj = XMMatrixPerspectiveFovLH(0.4f*3.14f, GetAspect(), 1.0f, 1000.0f); XMStoreFloat4x4(&m_Proj, XMMatrixTranspose(Proj)); XMStoreFloat4x4(&m_Model, XMMatrixTranspose(Model) ); XMStoreFloat4x4(&m_View, XMMatrixTranspose(View) ); }
void CrateApp::OnResize() { D3DApp::OnResize(); XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); }
// レンダリング HRESULT Render( void ) { // 画面クリア XMFLOAT4 v4Color = XMFLOAT4( 0.0f, 0.0f, 0.0f, 1.0f ); g_pImmediateContext->ClearRenderTargetView( g_pRTV, ( float * )&v4Color ); // *** Zバッファクリア *** g_pImmediateContext->ClearDepthStencilView( g_pDepthStencilView, D3D11_CLEAR_DEPTH, 1.0f, 0 ); // サンプラセット g_pImmediateContext->PSSetSamplers( 0, 1, &g_pSamplerState ); // 描画設定 UINT nStrides = sizeof( CUSTOMVERTEX ); UINT nOffsets = 0; g_pImmediateContext->IASetVertexBuffers( 0, 1, &g_pVertexBuffer, &nStrides, &nOffsets ); g_pImmediateContext->IASetIndexBuffer( g_pIndexBuffer, DXGI_FORMAT_R16_UINT, 0 ); g_pImmediateContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST ); g_pImmediateContext->IASetInputLayout( g_pInputLayout ); // シェーダ設定 g_pImmediateContext->VSSetShader( g_pVertexShader, NULL, 0 ); g_pImmediateContext->VSSetConstantBuffers( 0, 1, &g_pCBNeverChanges ); g_pImmediateContext->PSSetShader( g_pPixelShader, NULL, 0 ); g_pImmediateContext->PSSetConstantBuffers( 0, 1, &g_pCBNeverChanges ); // 変換行列 CBNeverChanges cbNeverChanges; XMMATRIX mWorld; XMMATRIX mView; XMMATRIX mProjection; XMMATRIX mViewProjection; // Initialize the view matrix XMVECTOR Eye = XMVectorSet( Player_1.v3Pos.x, Player_1.v3Pos.y + 3.0f, Player_1.v3Pos.z - 5.0f, 0.0f ); XMVECTOR At = XMVectorSet( 0.0f, 0.0f, 0.0f, 0.0f ); XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f ); mView = XMMatrixLookAtLH( Eye, At, Up ); // Initialize the projection matrix mProjection = XMMatrixPerspectiveFovLH( XM_PIDIV4, VIEW_WIDTH / ( FLOAT )VIEW_HEIGHT, 0.01f, 100.0f ); mViewProjection = mView * mProjection; // 描画 g_pImmediateContext->OMSetDepthStencilState( g_pDSDepthState, 1 ); g_pImmediateContext->RSSetState( g_pRS_Cull_CW ); // カリングあり // 地面 g_pImmediateContext->OMSetBlendState( NULL, NULL, 0xFFFFFFFF ); g_mmGround.v4AddColor = XMFLOAT4( 0.0f, 0.0f, 0.0f, 1.0f ); DrawMyModel( &g_mmGround, &mViewProjection ); // ビルボード g_pImmediateContext->RSSetState( g_pRS ); // カリングなし g_pImmediateContext->OMSetBlendState( g_pbsAddBlend, NULL, 0xFFFFFFFF ); // 加算ブレンド DrawMyModel( &g_mmBillboard, &mViewProjection ); return S_OK; }
//--------------------------------------------------------------------- Frustum::Frustum(Util::real nearCilp, Util::real farClip, Util::real width, Util::real height) : mNearClip(nearCilp), mFarClip(farClip) { mAspect = width / height; XMStoreFloat4x4(&mProjMatrix, XMMatrixPerspectiveFovLH(XM_PI / 2.0, mAspect, mNearClip, mFarClip)); }
void CameraComponent::update() { Transform transf = m_pOwnerGameObject->getTransform(); XMFLOAT3 position = transf.getPosition(); m_View=XMMatrixLookAtLH(XMLoadFloat3(&position),XMLoadFloat3(&m_LookAt),XMLoadFloat3(&m_Up)); m_Projection=XMMatrixPerspectiveFovLH(m_FOV,m_AspectRatio,m_Near,m_Far); }
void ShadowLight::CreateProjectionMatrix(float screenDepth, float screenNear) { //Field of view and screen aspect for square light float fov = (float)XM_PI / 2.0f; float screenAspect = 1.0f; projectionMatrix = XMMatrixPerspectiveFovLH(fov, screenAspect, screenNear, screenDepth); }
void BoxApp::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); }
void intiData(){ people = loadPUBModel("resources/456.BINARY",m_pd3dDevice,m_pImmediateContext); // Initialize the world matrix m_World = XMMatrixIdentity(); // Initialize the view matrix XMVECTOR Eye = XMVectorSet( 0, 1.1, -2.0, 0.0f ); XMVECTOR At = XMVectorSet( 0.0f, 1.1, 0.0f, 0.0f ); XMVECTOR Up = XMVectorSet( 0.0f, 1.0f, 0.0f, 0.0f ); m_View = XMMatrixLookAtLH( Eye, At, Up ); // Initialize the projection matrix m_Projection = XMMatrixPerspectiveFovLH( XM_PIDIV4, getWindowWidth() / (FLOAT)getWindowHeight(), 0.01f, 1000.0f ); m_Projection = XMMatrixOrthographicLH(4,4*getWindowHeight()/(FLOAT)getWindowWidth(),0,100); bone_shader =new ShaderProgram(m_pd3dDevice); bone_shader->setLayout(CUSTOM_LAYOUT_PUB,CUSTOM_LAYOUT_PUB_NUM); bone_shader->requestConstantBuffer(192,0); bone_shader->requestConstantBuffer(sizeof(XMMATRIX)*BONE_MAX_NUM,1); bone_shader->loadShader(L"FX/boneAnime.fx"); people->useShader(bone_shader); Sampler* samp=new Sampler(m_pd3dDevice); samp->createSampleState(D3D11_FILTER_MIN_MAG_MIP_LINEAR,D3D11_TEXTURE_ADDRESS_WRAP,-1); samp->useSamplerAt(m_pImmediateContext,0); // MyLuaManager::getInstance()->registerFun(ConsleGlue); /***********************************************************************/ view_shader= new ShaderProgram(m_pd3dDevice); view_shader->setLayout(CUSTOM_LAYOUT_PU,CUSTOM_LAYOUT_PU_NUM); view_shader->requestConstantBuffer(192,0); view_shader->loadShader(L"FX/Tutorial04.fx"); quard=new ImageView(m_pd3dDevice); quard->setBorder(getWindowWidth(),getWindowHeight()); quard->setSize(200,150); quard->setShader(view_shader); backTarget=RenderTarget::generateRenderTarget(m_pd3dDevice,getWindowWidth(),getWindowHeight()); quard->setTexture(*backTarget->getShaderResource()); /**********************************************************************/ setDrawMode(Triangle); /*********************************************************************/ controller=new ObjectController(m_pd3dDevice); controller->addObject(quard); }
void D3DRenderer::OnResize(UINT newHeight, UINT newWidth) { mWindowHeight = newHeight; mWindowWidth = newWidth; //Release old COM interfaces. ReleaseCOM(mDepthStencilBuffer); ReleaseCOM(mDepthStencilView); ReleaseCOM(mRenderTargetView); //Resize the buffers to the new sizes and rebind them to the pipeline through //the RenderTargetView. HR(mSwapChain->ResizeBuffers(1, mWindowWidth, mWindowHeight, DXGI_FORMAT_R8G8B8A8_UNORM, 0)); ID3D11Texture2D* backBuffer; HR(mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), reinterpret_cast<void**>(&backBuffer))); HR(md3dDevice->CreateRenderTargetView(backBuffer, 0, &mRenderTargetView)); ReleaseCOM(backBuffer); //Description for the Depth Stencil buffer D3D11_TEXTURE2D_DESC depthStencilDesc; //Defining the buffer depthStencilDesc.Height = mWindowHeight; depthStencilDesc.Width = mWindowWidth; depthStencilDesc.MipLevels = 1; depthStencilDesc.ArraySize = 1; depthStencilDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT; //The MSAA settings for the depthStencilDesc MUST match the SwapChain. depthStencilDesc.SampleDesc.Count = 1; depthStencilDesc.SampleDesc.Quality = 0; //Other options depthStencilDesc.Usage = D3D11_USAGE_DEFAULT; depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL; depthStencilDesc.CPUAccessFlags = 0; depthStencilDesc.MiscFlags = 0; //Actually create the DepthStencilView md3dDevice->CreateTexture2D(&depthStencilDesc, 0, &mDepthStencilBuffer); md3dDevice->CreateDepthStencilView(mDepthStencilBuffer, 0, &mDepthStencilView); //Bind the Render target and DepthStencilView to the pipline mDeviceContext->OMSetRenderTargets(1, &mRenderTargetView, mDepthStencilView); mScreenViewport.TopLeftX = 0.0f; mScreenViewport.TopLeftY = 0.0f; mScreenViewport.Width = static_cast<float>(newWidth); mScreenViewport.Height = static_cast<float>(newHeight); mScreenViewport.MinDepth = 0.0f; mScreenViewport.MaxDepth = 1.0f; mDeviceContext->RSSetViewports(1, &mScreenViewport); mProjMatrix = XMMatrixPerspectiveFovLH(0.25f*3.14f, newWidth/newHeight, 1.0f, 1000.0f); }
void Camera::onResize(float aspectRatio) { // Update our projection matrix since the window size changed XMMATRIX P = XMMatrixPerspectiveFovLH( 0.25f * 3.1415926535f, // Field of View Angle aspectRatio, // Aspect ratio 0.1f, // Near clip plane distance 100.0f); // Far clip plane distance XMStoreFloat4x4(&projectionMatrix, XMMatrixTranspose(P)); // Transpose for HLSL! }
void SwapChain::SetMatrixPerspective() { float Aspect = (float)m_nWidth / (float)m_nHeight; m_projectMat = XMMatrixPerspectiveFovLH(XM_PI / 4.0f, Aspect, 1.0f, 20000.f); XMVECTOR v0 = XMVectorSet(0.0f, 0.0f, -10.0f, 1.0f); XMVECTOR v1 = XMVectorSet(0.0f, 0.0f, 0.0f, 1.0f); XMVECTOR v2 = XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f); m_viewMat = XMMatrixLookAtLH(v0, v1, v2); m_WorldMat = XMMatrixIdentity(); }
void Camera::SetFOV(float fov) { if (fov > 0.0f) { _fov = XMConvertToRadians(fov); } _projection = XMMatrixPerspectiveFovLH(_fov, _viewport.Width / _viewport.Height, _farClip, _nearClip); Transform.Moved = true; }
void Assignment5::OnResize() { D3DApp::OnResize(); // The window resized, so update the aspect ratio and recompute the projection matrix. XMMATRIX P = XMMatrixPerspectiveFovLH(0.25f*MathHelper::Pi, AspectRatio(), 1.0f, 1000.0f); XMStoreFloat4x4(&mProj, P); m_Phone.resizeScreen(XMFLOAT2(static_cast<float>(mClientWidth), static_cast<float>(mClientHeight)), md3dDevice); }