camera adjustments

This commit is contained in:
lightling 2022-04-09 21:04:28 -04:00
parent 0517fe07dd
commit e65a111f1f
Signed by: lightling
GPG key ID: 016F11E0AA296B67
3 changed files with 8 additions and 6 deletions

View file

@ -3,7 +3,7 @@
using namespace DirectX;
Camera::Camera(float _x, float _y, float _z, float _aspect, float _fov, float _near, float _far)
Camera::Camera(float _x, float _y, float _z, float _aspect, float _fov, float _near, float _far, float _moveSpeed)
{
transform.SetPosition(_x, _y, _z);
@ -11,6 +11,7 @@ Camera::Camera(float _x, float _y, float _z, float _aspect, float _fov, float _n
fovYRadians = XMConvertToRadians(_fov);
clipNear = _near;
clipFar = _far;
moveSpeed = _moveSpeed;
UpdateViewMatrix();
UpdateProjectionMatrix();
@ -100,8 +101,8 @@ void Camera::ReadInput(float _dt)
if (input.KeyDown(VK_SHIFT)) modify *= 2.0f;
if (input.KeyDown(VK_CONTROL)) modify /= 2.0f;
transform.TranslateRelative(moveLat * _dt * modify, 0, moveLong * _dt * modify);
transform.TranslateAbsolute(0, moveVert * _dt * modify, 0);
transform.TranslateRelative(moveLat * _dt * modify * moveSpeed, 0, moveLong * _dt * modify * moveSpeed);
transform.TranslateAbsolute(0, moveVert * _dt * modify * moveSpeed, 0);
if (input.MouseLeftDown())
{

View file

@ -6,7 +6,7 @@
class Camera
{
public:
Camera(float _x, float _y, float _z, float _aspect, float _fov, float _near, float _far);
Camera(float _x, float _y, float _z, float _aspect, float _fov, float _near, float _far, float _moveSpeed);
~Camera();
void Update(float _dt);
@ -23,6 +23,7 @@ public:
void SetFarClip(float _far);
private:
float moveSpeed;
float aspect;
float fovYRadians;
float clipNear;

View file

@ -34,7 +34,7 @@ Game::Game(HINSTANCE hInstance)
CreateConsoleWindow(500, 120, 32, 120);
printf("Console window created successfully. Feel free to printf() here.\n");
#endif
camera = std::make_shared<Camera>(0.0f, 0.0f, -20.0f, (float)width / height, 60, 0.01f, 1000.0f);
camera = std::make_shared<Camera>(0.0f, 0.0f, -10.0f, (float)width / height, 60, 0.01f, 1000.0f, 5.0f);
}
// --------------------------------------------------------
@ -226,7 +226,7 @@ void Game::CreateBasicGeometry()
for (int i = 0; i < entities.size(); ++i)
{
entities[i]->GetTransform()->SetPosition((-(int)(entities.size() / 2) + i) * 5, 0, 0);
entities[i]->GetTransform()->SetPosition((-(int)(entities.size() / 2) + i + 0.5f) * 2.5f, 0, 0);
}
skybox = std::make_shared<Sky>(