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

use camera/view matrix

parent 98fa77f0
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "GDIPlusManager.h" #include "GDIPlusManager.h"
#include "imgui/imgui.h" #include "imgui/imgui.h"
namespace dx = DirectX;
GDIPlusManager gdipm; GDIPlusManager gdipm;
App::App() App::App()
...@@ -74,7 +76,8 @@ App::App() ...@@ -74,7 +76,8 @@ App::App()
drawables.reserve( nDrawables ); drawables.reserve( nDrawables );
std::generate_n( std::back_inserter( drawables ),nDrawables,Factory{ wnd.Gfx() } ); 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() void App::DoFrame()
......
...@@ -106,6 +106,5 @@ DirectX::XMMATRIX Box::GetTransformXM() const noexcept ...@@ -106,6 +106,5 @@ DirectX::XMMATRIX Box::GetTransformXM() const noexcept
return dx::XMLoadFloat3x3( &mt ) * return dx::XMLoadFloat3x3( &mt ) *
dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) * dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) * dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) * dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
} }
...@@ -170,6 +170,16 @@ DirectX::XMMATRIX Graphics::GetProjection() const noexcept ...@@ -170,6 +170,16 @@ DirectX::XMMATRIX Graphics::GetProjection() const noexcept
return projection; return projection;
} }
void Graphics::SetCamera( DirectX::FXMMATRIX cam ) noexcept
{
camera = cam;
}
DirectX::XMMATRIX Graphics::GetCamera() const noexcept
{
return camera;
}
void Graphics::EnableImgui() noexcept void Graphics::EnableImgui() noexcept
{ {
imguiEnabled = true; imguiEnabled = true;
......
...@@ -60,12 +60,15 @@ public: ...@@ -60,12 +60,15 @@ public:
void DrawIndexed( UINT count ) noexcept(!IS_DEBUG); void DrawIndexed( UINT count ) noexcept(!IS_DEBUG);
void SetProjection( DirectX::FXMMATRIX proj ) noexcept; void SetProjection( DirectX::FXMMATRIX proj ) noexcept;
DirectX::XMMATRIX GetProjection() const noexcept; DirectX::XMMATRIX GetProjection() const noexcept;
void SetCamera( DirectX::FXMMATRIX cam ) noexcept;
DirectX::XMMATRIX GetCamera() const noexcept;
void EnableImgui() noexcept; void EnableImgui() noexcept;
void DisableImgui() noexcept; void DisableImgui() noexcept;
bool IsImguiEnabled() const noexcept; bool IsImguiEnabled() const noexcept;
private: private:
bool imguiEnabled = true;
DirectX::XMMATRIX projection; DirectX::XMMATRIX projection;
DirectX::XMMATRIX camera;
bool imguiEnabled = true;
#ifndef NDEBUG #ifndef NDEBUG
DxgiInfoManager infoManager; DxgiInfoManager infoManager;
#endif #endif
......
...@@ -98,6 +98,5 @@ DirectX::XMMATRIX Melon::GetTransformXM() const noexcept ...@@ -98,6 +98,5 @@ DirectX::XMMATRIX Melon::GetTransformXM() const noexcept
namespace dx = DirectX; namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) * return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) * dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) * dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
} }
...@@ -90,6 +90,5 @@ DirectX::XMMATRIX Pyramid::GetTransformXM() const noexcept ...@@ -90,6 +90,5 @@ DirectX::XMMATRIX Pyramid::GetTransformXM() const noexcept
namespace dx = DirectX; namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) * return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) * dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) * dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
} }
...@@ -90,6 +90,5 @@ DirectX::XMMATRIX Sheet::GetTransformXM() const noexcept ...@@ -90,6 +90,5 @@ DirectX::XMMATRIX Sheet::GetTransformXM() const noexcept
namespace dx = DirectX; namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) * return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) * dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) * dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
} }
...@@ -83,6 +83,5 @@ DirectX::XMMATRIX SkinnedBox::GetTransformXM() const noexcept ...@@ -83,6 +83,5 @@ DirectX::XMMATRIX SkinnedBox::GetTransformXM() const noexcept
namespace dx = DirectX; namespace dx = DirectX;
return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) * return dx::XMMatrixRotationRollPitchYaw( pitch,yaw,roll ) *
dx::XMMatrixTranslation( r,0.0f,0.0f ) * dx::XMMatrixTranslation( r,0.0f,0.0f ) *
dx::XMMatrixRotationRollPitchYaw( theta,phi,chi ) * dx::XMMatrixRotationRollPitchYaw( theta,phi,chi );
dx::XMMatrixTranslation( 0.0f,0.0f,20.0f );
} }
...@@ -14,7 +14,9 @@ void TransformCbuf::Bind( Graphics& gfx ) noexcept ...@@ -14,7 +14,9 @@ void TransformCbuf::Bind( Graphics& gfx ) noexcept
{ {
pVcbuf->Update( gfx, pVcbuf->Update( gfx,
DirectX::XMMatrixTranspose( DirectX::XMMatrixTranspose(
parent.GetTransformXM() * gfx.GetProjection() parent.GetTransformXM() *
gfx.GetCamera() *
gfx.GetProjection()
) )
); );
pVcbuf->Bind( gfx ); 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