Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
ffdeae8c
Commit
ffdeae8c
authored
May 16, 2019
by
chili
Browse files
some control of model position
parent
2a5d18ff
Changes
4
Hide whitespace changes
Inline
Side-by-side
hw3d/App.cpp
View file @
ffdeae8c
...
...
@@ -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.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Pitch"
,
&
pos
.
pitch
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Yaw"
,
&
pos
.
yaw
,
-
180.0
f
,
180.0
f
);
ImGui
::
Text
(
"Position"
);
ImGui
::
SliderFloat
(
"X"
,
&
pos
.
x
,
-
20.0
f
,
20.0
f
);
ImGui
::
SliderFloat
(
"Y"
,
&
pos
.
y
,
-
20.0
f
,
20.0
f
);
ImGui
::
SliderFloat
(
"Z"
,
&
pos
.
z
,
-
20.0
f
,
20.0
f
);
}
ImGui
::
End
();
}
App
::~
App
()
{}
...
...
hw3d/App.h
View file @
ffdeae8c
...
...
@@ -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.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
float
x
=
0.0
f
;
float
y
=
0.0
f
;
float
z
=
0.0
f
;
}
pos
;
};
\ No newline at end of file
hw3d/Camera.cpp
View file @
ffdeae8c
...
...
@@ -22,7 +22,7 @@ void Camera::SpawnControlWindow() noexcept
if
(
ImGui
::
Begin
(
"Camera"
)
)
{
ImGui
::
Text
(
"Position"
);
ImGui
::
SliderFloat
(
"R"
,
&
r
,
0.
0
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderFloat
(
"R"
,
&
r
,
0.
2
f
,
80.0
f
,
"%.1f"
);
ImGui
::
SliderAngle
(
"Theta"
,
&
theta
,
-
180.0
f
,
180.0
f
);
ImGui
::
SliderAngle
(
"Phi"
,
&
phi
,
-
89.0
f
,
89.0
f
);
ImGui
::
Text
(
"Orientation"
);
...
...
hw3d/Model.h
View file @
ffdeae8c
...
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment