Commit ffdeae8c authored by chili's avatar chili
Browse files

some control of model position

parent 2a5d18ff
......@@ -30,17 +30,39 @@ void App::DoFrame()
wnd.Gfx().SetCamera( 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() );
// imgui windows
cam.SpawnControlWindow();
light.SpawnControlWindow();
ShowModelWindow();
// present
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()
{}
......
......@@ -16,6 +16,7 @@ public:
~App();
private:
void DoFrame();
void ShowModelWindow();
private:
ImguiManager imgui;
Window wnd;
......@@ -24,4 +25,13 @@ private:
Camera cam;
PointLight light;
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
if( ImGui::Begin( "Camera" ) )
{
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( "Phi",&phi,-89.0f,89.0f );
ImGui::Text( "Orientation" );
......
......@@ -96,6 +96,11 @@ public:
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 )
{
namespace dx = DirectX;
......@@ -171,13 +176,9 @@ public:
{
pNode->AddChild( ParseNode( *node.mChildren[i] ) );
}
return pNode;
}
void Draw( Graphics& gfx ) const
{
pRoot->Draw( gfx,DirectX::XMMatrixIdentity() );
}
private:
std::unique_ptr<Node> pRoot;
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