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
PracticeDx
Commits
90bd4507
Commit
90bd4507
authored
Mar 16, 2023
by
Administrator
Browse files
added camera
parent
b9789a92
Changes
4
Show whitespace changes
Inline
Side-by-side
PracticeDx/Box.cpp
View file @
90bd4507
...
...
@@ -10,6 +10,7 @@
#include "Topology.h"
#include "TransformCBuf.h"
#include "Graphics.h"
#include <DirectXMath.h>
Box
::
Box
(
Graphics
&
gfx
,
float
position
[][
3
],
float
color
[][
3
],
Logger
&
logger
)
{
...
...
@@ -128,8 +129,8 @@ void Box::Update(float dt) noexcept
phi += dphi * dt;
chi += dchi * dt;*/
dx
=
dt
;
//
dy = dt;
//
dz = dt;
dy
=
dt
;
dz
=
dt
;
}
DirectX
::
XMMATRIX
Box
::
GetTransformXM
()
const
noexcept
...
...
@@ -138,7 +139,16 @@ DirectX::XMMATRIX Box::GetTransformXM() const noexcept
DirectX::XMMatrixTranslation(r, 0.0f, 0.0f) *
DirectX::XMMatrixRotationRollPitchYaw(theta, phi, chi) *
DirectX::XMMatrixTranslation(0.0f, 0.0f, 20.0f);*/
using
namespace
DirectX
;
XMVECTOR
upDirection
,
eyePosition
,
focusPosition
;
// Setup the vector that points upwards.
upDirection
=
XMVectorSet
(
0.0
f
,
1.0
f
,
0.0
f
,
1.0
f
);
focusPosition
=
XMVectorZero
();
eyePosition
=
XMVectorSet
(
5.0
f
,
5.0
f
,
-
5.0
f
,
1.0
f
);
return
DirectX
::
XMMatrixTranslation
(
0.0
f
,
0.0
f
,
4.0
f
)
*
DirectX
::
XMMatrix
Translation
(
dx
,
dy
,
dz
);
DirectX
::
XMMatrixTranslation
(
dx
,
dy
,
dz
)
*
DirectX
::
XMMatrix
LookAtLH
(
eyePosition
,
focusPosition
,
upDirection
);
}
\ No newline at end of file
PracticeDx/Logger.cpp
View file @
90bd4507
...
...
@@ -24,6 +24,8 @@ void Logger::start()
void
Logger
::
PutLog
(
std
::
string
module
,
std
::
string
text
)
{
if
(
debugFlag
)
{
// Get current system time
auto
now
=
std
::
chrono
::
system_clock
::
now
();
...
...
@@ -38,6 +40,7 @@ void Logger::PutLog(std::string module, std::string text)
std
::
strftime
(
timestamp
,
sizeof
(
timestamp
),
"%Y-%m-%d %H:%M:%S"
,
now_tm
);
fs
<<
"["
<<
timestamp
<<
"]: "
<<
"["
<<
module
<<
"] "
<<
text
<<
endl
;
}
};
void
Logger
::
end
()
...
...
PracticeDx/Logger.h
View file @
90bd4507
...
...
@@ -19,4 +19,5 @@ public:
private:
std
::
string
loggerFile
;
std
::
fstream
fs
;
bool
debugFlag
=
false
;
};
\ No newline at end of file
PracticeDx/WinMain.cpp
View file @
90bd4507
...
...
@@ -734,8 +734,8 @@ int WINAPI WinMain(HINSTANCE hInstance,
};
Box
box
(
gfx
,
boxPos
,
boxCol
,
logger
);
long
seed
=
0
;
seed
=
seed
%
10000
;
double
seed
=
0
;
seed
=
int
(
seed
)
%
10000
;
// enter the main loop:
...
...
@@ -765,16 +765,18 @@ int WINAPI WinMain(HINSTANCE hInstance,
gfx
.
RendorFrame
();
seed
++
;
auto
dt
=
sin
(
seed
/
1000
);
auto
dt
=
sin
(
seed
/
2000
);
logger
.
PutLog
(
"seed"
,
std
::
to_string
(
seed
));
logger
.
PutLog
(
"dt"
,
std
::
to_string
(
dt
));
box
.
Update
(
dt
);
//logger.PutLog("box.update", std::to_string(dt));
box
.
ExecuteBind
(
gfx
,
logger
);
box
.
Draw
(
gfx
,
logger
);
//tri.Update(dt);
tri
.
ExecuteBind
(
gfx
,
logger
);
tri
.
Draw
(
gfx
,
logger
);
//tri.ExecuteBind(gfx, logger);
//tri.Draw(gfx, logger);
gfx
.
EndFrame
();
}
}
...
...
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