Commit 90bd4507 authored by Administrator's avatar Administrator
Browse files

added camera

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