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

added camera

parent b9789a92
......@@ -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.0f, 1.0f, 0.0f, 1.0f);
focusPosition = XMVectorZero();
eyePosition = XMVectorSet(5.0f, 5.0f, -5.0f, 1.0f);
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,20 +24,23 @@ void Logger::start()
void Logger::PutLog(std::string module, std::string text)
{
// Get current system time
auto now = std::chrono::system_clock::now();
if (debugFlag)
{
// Get current system time
auto now = std::chrono::system_clock::now();
// Convert system time to time_t (seconds since Jan 1, 1970)
std::time_t now_time = std::chrono::system_clock::to_time_t(now);
// Convert system time to time_t (seconds since Jan 1, 1970)
std::time_t now_time = std::chrono::system_clock::to_time_t(now);
// Convert time_t to struct tm (broken down time)
std::tm* now_tm = std::localtime(&now_time);
// Convert time_t to struct tm (broken down time)
std::tm* now_tm = std::localtime(&now_time);
// Format timestamp string manually
char timestamp[20];
std::strftime(timestamp, sizeof(timestamp), "%Y-%m-%d %H:%M:%S", now_tm);
// Format timestamp string manually
char timestamp[20];
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()
......
......@@ -19,4 +19,5 @@ public:
private:
std::string loggerFile;
std::fstream fs;
bool debugFlag = false;
};
\ No newline at end of file
......@@ -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();
}
}
......
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