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
f61cdfde
Commit
f61cdfde
authored
Apr 22, 2019
by
chili
Browse files
create a nice base for our test objects
parent
3bff8c88
Changes
5
Hide whitespace changes
Inline
Side-by-side
hw3d/Box.cpp
View file @
f61cdfde
...
@@ -13,16 +13,7 @@ Box::Box( Graphics& gfx,
...
@@ -13,16 +13,7 @@ Box::Box( Graphics& gfx,
std
::
uniform_real_distribution
<
float
>&
bdist
,
std
::
uniform_real_distribution
<
float
>&
bdist
,
DirectX
::
XMFLOAT3
material
)
DirectX
::
XMFLOAT3
material
)
:
:
r
(
rdist
(
rng
)
),
TestObject
(
gfx
,
rng
,
adist
,
ddist
,
odist
,
rdist
)
droll
(
ddist
(
rng
)
),
dpitch
(
ddist
(
rng
)
),
dyaw
(
ddist
(
rng
)
),
dphi
(
odist
(
rng
)
),
dtheta
(
odist
(
rng
)
),
dchi
(
odist
(
rng
)
),
chi
(
adist
(
rng
)
),
theta
(
adist
(
rng
)
),
phi
(
adist
(
rng
)
)
{
{
namespace
dx
=
DirectX
;
namespace
dx
=
DirectX
;
...
@@ -79,21 +70,8 @@ Box::Box( Graphics& gfx,
...
@@ -79,21 +70,8 @@ Box::Box( Graphics& gfx,
);
);
}
}
void
Box
::
Update
(
float
dt
)
noexcept
{
roll
+=
droll
*
dt
;
pitch
+=
dpitch
*
dt
;
yaw
+=
dyaw
*
dt
;
theta
+=
dtheta
*
dt
;
phi
+=
dphi
*
dt
;
chi
+=
dchi
*
dt
;
}
DirectX
::
XMMATRIX
Box
::
GetTransformXM
()
const
noexcept
DirectX
::
XMMATRIX
Box
::
GetTransformXM
()
const
noexcept
{
{
namespace
dx
=
DirectX
;
namespace
dx
=
DirectX
;
return
dx
::
XMLoadFloat3x3
(
&
mt
)
*
return
dx
::
XMLoadFloat3x3
(
&
mt
)
*
TestObject
::
GetTransformXM
();
dx
::
XMMatrixRotationRollPitchYaw
(
pitch
,
yaw
,
roll
)
*
dx
::
XMMatrixTranslation
(
r
,
0.0
f
,
0.0
f
)
*
dx
::
XMMatrixRotationRollPitchYaw
(
theta
,
phi
,
chi
);
}
}
hw3d/Box.h
View file @
f61cdfde
#pragma once
#pragma once
#include "
DrawableBase
.h"
#include "
TestObject
.h"
class
Box
:
public
DrawableBase
<
Box
>
class
Box
:
public
TestObject
<
Box
>
{
{
public:
public:
Box
(
Graphics
&
gfx
,
std
::
mt19937
&
rng
,
Box
(
Graphics
&
gfx
,
std
::
mt19937
&
rng
,
...
@@ -11,24 +11,8 @@ public:
...
@@ -11,24 +11,8 @@ public:
std
::
uniform_real_distribution
<
float
>&
rdist
,
std
::
uniform_real_distribution
<
float
>&
rdist
,
std
::
uniform_real_distribution
<
float
>&
bdist
,
std
::
uniform_real_distribution
<
float
>&
bdist
,
DirectX
::
XMFLOAT3
material
);
DirectX
::
XMFLOAT3
material
);
void
Update
(
float
dt
)
noexcept
override
;
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
override
;
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
override
;
private:
private:
// positional
float
r
;
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
float
theta
;
float
phi
;
float
chi
;
// speed (delta/s)
float
droll
;
float
dpitch
;
float
dyaw
;
float
dtheta
;
float
dphi
;
float
dchi
;
// model transform
// model transform
DirectX
::
XMFLOAT3X3
mt
;
DirectX
::
XMFLOAT3X3
mt
;
};
};
\ No newline at end of file
hw3d/TestObject.h
0 → 100644
View file @
f61cdfde
#pragma once
#include "DrawableBase.h"
template
<
class
T
>
class
TestObject
:
public
DrawableBase
<
T
>
{
public:
TestObject
(
Graphics
&
gfx
,
std
::
mt19937
&
rng
,
std
::
uniform_real_distribution
<
float
>&
adist
,
std
::
uniform_real_distribution
<
float
>&
ddist
,
std
::
uniform_real_distribution
<
float
>&
odist
,
std
::
uniform_real_distribution
<
float
>&
rdist
)
:
r
(
rdist
(
rng
)
),
droll
(
ddist
(
rng
)
),
dpitch
(
ddist
(
rng
)
),
dyaw
(
ddist
(
rng
)
),
dphi
(
odist
(
rng
)
),
dtheta
(
odist
(
rng
)
),
dchi
(
odist
(
rng
)
),
chi
(
adist
(
rng
)
),
theta
(
adist
(
rng
)
),
phi
(
adist
(
rng
)
)
{}
void
Update
(
float
dt
)
noexcept
{
roll
+=
droll
*
dt
;
pitch
+=
dpitch
*
dt
;
yaw
+=
dyaw
*
dt
;
theta
+=
dtheta
*
dt
;
phi
+=
dphi
*
dt
;
chi
+=
dchi
*
dt
;
}
DirectX
::
XMMATRIX
GetTransformXM
()
const
noexcept
{
namespace
dx
=
DirectX
;
return
dx
::
XMMatrixRotationRollPitchYaw
(
pitch
,
yaw
,
roll
)
*
dx
::
XMMatrixTranslation
(
r
,
0.0
f
,
0.0
f
)
*
dx
::
XMMatrixRotationRollPitchYaw
(
theta
,
phi
,
chi
);
}
private:
// positional
float
r
;
float
roll
=
0.0
f
;
float
pitch
=
0.0
f
;
float
yaw
=
0.0
f
;
float
theta
;
float
phi
;
float
chi
;
// speed (delta/s)
float
droll
;
float
dpitch
;
float
dyaw
;
float
dtheta
;
float
dphi
;
float
dchi
;
};
hw3d/hw3d.vcxproj
View file @
f61cdfde
...
@@ -176,6 +176,7 @@
...
@@ -176,6 +176,7 @@
<ClCompile
Include=
"Sampler.cpp"
/>
<ClCompile
Include=
"Sampler.cpp"
/>
<ClCompile
Include=
"SkinnedBox.cpp"
/>
<ClCompile
Include=
"SkinnedBox.cpp"
/>
<ClCompile
Include=
"Surface.cpp"
/>
<ClCompile
Include=
"Surface.cpp"
/>
<ClCompile
Include=
"TestObject.h"
/>
<ClCompile
Include=
"Texture.cpp"
/>
<ClCompile
Include=
"Texture.cpp"
/>
<ClCompile
Include=
"Topology.cpp"
/>
<ClCompile
Include=
"Topology.cpp"
/>
<ClCompile
Include=
"TransformCbuf.cpp"
/>
<ClCompile
Include=
"TransformCbuf.cpp"
/>
...
...
hw3d/hw3d.vcxproj.filters
View file @
f61cdfde
...
@@ -153,6 +153,9 @@
...
@@ -153,6 +153,9 @@
<ClCompile
Include=
"PointLight.cpp"
>
<ClCompile
Include=
"PointLight.cpp"
>
<Filter>
Source Files
</Filter>
<Filter>
Source Files
</Filter>
</ClCompile>
</ClCompile>
<ClCompile
Include=
"TestObject.h"
>
<Filter>
Header Files\Drawable
</Filter>
</ClCompile>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<ClInclude
Include=
"WindowsMessageMap.h"
>
<ClInclude
Include=
"WindowsMessageMap.h"
>
...
...
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