Commit 13abbb1e authored by chili's avatar chili
Browse files

use camera/view matrix

parent 98fa77f0
......@@ -11,6 +11,8 @@
#include "GDIPlusManager.h"
#include "imgui/imgui.h"
namespace dx = DirectX;
GDIPlusManager gdipm;
App::App()
......@@ -74,7 +76,8 @@ App::App()
drawables.reserve( nDrawables );
std::generate_n( std::back_inserter( drawables ),nDrawables,Factory{ wnd.Gfx() } );
wnd.Gfx().SetProjection( DirectX::XMMatrixPerspectiveLH( 1.0f,3.0f / 4.0f,0.5f,40.0f ) );
wnd.Gfx().SetProjection( dx::XMMatrixPerspectiveLH( 1.0f,3.0f / 4.0f,0.5f,40.0f ) );
wnd.Gfx().SetCamera( dx::XMMatrixTranslation( 0.0f,0.0f,20.0f ) );
}
void App::DoFrame()
......
......@@ -106,6 +106,5 @@ DirectX::XMMATRIX Box::GetTransformXM() const noexcept
return dx::XMLoadFloat3x3( &mt ) *
dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) *
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
}
......@@ -170,6 +170,16 @@ DirectX::XMMATRIX Graphics::GetProjection() const noexcept
return projection;
}
void Graphics::SetCamera( DirectX::FXMMATRIX cam ) noexcept
{
camera = cam;
}
DirectX::XMMATRIX Graphics::GetCamera() const noexcept
{
return camera;
}
void Graphics::EnableImgui() noexcept
{
imguiEnabled = true;
......
......@@ -60,12 +60,15 @@ public:
void DrawIndexed( UINT count ) noexcept(!IS_DEBUG);
void SetProjection( DirectX::FXMMATRIX proj ) noexcept;
DirectX::XMMATRIX GetProjection() const noexcept;
void SetCamera( DirectX::FXMMATRIX cam ) noexcept;
DirectX::XMMATRIX GetCamera() const noexcept;
void EnableImgui() noexcept;
void DisableImgui() noexcept;
bool IsImguiEnabled() const noexcept;
private:
bool imguiEnabled = true;
DirectX::XMMATRIX projection;
DirectX::XMMATRIX camera;
bool imguiEnabled = true;
#ifndef NDEBUG
DxgiInfoManager infoManager;
#endif
......
......@@ -98,6 +98,5 @@ DirectX::XMMATRIX Melon::GetTransformXM() const noexcept
namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) *
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
}
......@@ -90,6 +90,5 @@ DirectX::XMMATRIX Pyramid::GetTransformXM() const noexcept
namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) *
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
}
......@@ -90,6 +90,5 @@ DirectX::XMMATRIX Sheet::GetTransformXM() const noexcept
namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) *
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
}
......@@ -83,6 +83,5 @@ DirectX::XMMATRIX SkinnedBox::GetTransformXM() const noexcept
namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) *
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
}
......@@ -14,7 +14,9 @@ void TransformCbuf::Bind( Graphics& gfx ) noexcept
{
pVcbuf->Update( gfx,
DirectX::XMMatrixTranspose(
parent.GetTransformXM() * gfx.GetProjection()
parent.GetTransformXM() *
gfx.GetCamera() *
gfx.GetProjection()
)
);
pVcbuf->Bind( gfx );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment