Commit ffdeae8c authored by chili's avatar chili
Browse files

some control of model position

parent 2a5d18ff
...@@ -30,17 +30,39 @@ void App::DoFrame() ...@@ -30,17 +30,39 @@ void App::DoFrame()
wnd.Gfx().SetCamera( cam.GetMatrix() ); wnd.Gfx().SetCamera( cam.GetMatrix() );
light.Bind( wnd.Gfx(),cam.GetMatrix() ); light.Bind( wnd.Gfx(),cam.GetMatrix() );
nano.Draw( wnd.Gfx() ); const auto transform = dx::XMMatrixRotationRollPitchYaw( pos.roll,pos.pitch,pos.yaw ) *
dx::XMMatrixTranslation( pos.x,pos.y,pos.z );
nano.Draw( wnd.Gfx(),transform );
light.Draw( wnd.Gfx() ); light.Draw( wnd.Gfx() );
// imgui windows // imgui windows
cam.SpawnControlWindow(); cam.SpawnControlWindow();
light.SpawnControlWindow(); light.SpawnControlWindow();
ShowModelWindow();
// present // present
wnd.Gfx().EndFrame(); wnd.Gfx().EndFrame();
} }
void App::ShowModelWindow()
{
if( ImGui::Begin( "Model" ) )
{
using namespace std::string_literals;
ImGui::Text( "Orientation" );
ImGui::SliderAngle( "Roll",&pos.roll,-180.0f,180.0f );
ImGui::SliderAngle( "Pitch",&pos.pitch,-180.0f,180.0f );
ImGui::SliderAngle( "Yaw",&pos.yaw,-180.0f,180.0f );
ImGui::Text( "Position" );
ImGui::SliderFloat( "X",&pos.x,-20.0f,20.0f );
ImGui::SliderFloat( "Y",&pos.y,-20.0f,20.0f );
ImGui::SliderFloat( "Z",&pos.z,-20.0f,20.0f );
}
ImGui::End();
}
App::~App() App::~App()
{} {}
......
...@@ -16,6 +16,7 @@ public: ...@@ -16,6 +16,7 @@ public:
~App(); ~App();
private: private:
void DoFrame(); void DoFrame();
void ShowModelWindow();
private: private:
ImguiManager imgui; ImguiManager imgui;
Window wnd; Window wnd;
...@@ -24,4 +25,13 @@ private: ...@@ -24,4 +25,13 @@ private:
Camera cam; Camera cam;
PointLight light; PointLight light;
Model nano{ wnd.Gfx(),"Models\\nanosuit.obj" }; Model nano{ wnd.Gfx(),"Models\\nanosuit.obj" };
struct
{
float roll = 0.0f;
float pitch = 0.0f;
float yaw = 0.0f;
float x = 0.0f;
float y = 0.0f;
float z = 0.0f;
} pos;
}; };
\ No newline at end of file
...@@ -22,7 +22,7 @@ void Camera::SpawnControlWindow() noexcept ...@@ -22,7 +22,7 @@ void Camera::SpawnControlWindow() noexcept
if( ImGui::Begin( "Camera" ) ) if( ImGui::Begin( "Camera" ) )
{ {
ImGui::Text( "Position" ); ImGui::Text( "Position" );
ImGui::SliderFloat( "R",&r,0.0f,80.0f,"%.1f" ); ImGui::SliderFloat( "R",&r,0.2f,80.0f,"%.1f" );
ImGui::SliderAngle( "Theta",&theta,-180.0f,180.0f ); ImGui::SliderAngle( "Theta",&theta,-180.0f,180.0f );
ImGui::SliderAngle( "Phi",&phi,-89.0f,89.0f ); ImGui::SliderAngle( "Phi",&phi,-89.0f,89.0f );
ImGui::Text( "Orientation" ); ImGui::Text( "Orientation" );
......
...@@ -96,6 +96,11 @@ public: ...@@ -96,6 +96,11 @@ public:
pRoot = ParseNode( *pScene->mRootNode ); pRoot = ParseNode( *pScene->mRootNode );
} }
void Draw( Graphics& gfx,DirectX::FXMMATRIX transform ) const
{
pRoot->Draw( gfx,transform );
}
private:
static std::unique_ptr<Mesh> ParseMesh( Graphics& gfx,const aiMesh& mesh ) static std::unique_ptr<Mesh> ParseMesh( Graphics& gfx,const aiMesh& mesh )
{ {
namespace dx = DirectX; namespace dx = DirectX;
...@@ -174,10 +179,6 @@ public: ...@@ -174,10 +179,6 @@ public:
return pNode; return pNode;
} }
void Draw( Graphics& gfx ) const
{
pRoot->Draw( gfx,DirectX::XMMatrixIdentity() );
}
private: private:
std::unique_ptr<Node> pRoot; std::unique_ptr<Node> pRoot;
std::vector<std::unique_ptr<Mesh>> meshPtrs; std::vector<std::unique_ptr<Mesh>> meshPtrs;
......
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