mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
Do stuff
This commit is contained in:
parent
6bf12dc95b
commit
b5c7750649
@ -48,6 +48,8 @@ namespace engine {
|
|||||||
Input* m_input;
|
Input* m_input;
|
||||||
ResourceManager* m_res;
|
ResourceManager* m_res;
|
||||||
SceneRoot* m_scene;
|
SceneRoot* m_scene;
|
||||||
|
|
||||||
|
bool m_enableFrameLimiter = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
|
#include <glm/ext/matrix_clip_space.hpp>
|
||||||
|
|
||||||
namespace engine::components {
|
namespace engine::components {
|
||||||
|
|
||||||
glm::vec4 Camera::s_clearColor{-999.0f, -999.0f, -999.0f, -999.0f};
|
glm::vec4 Camera::s_clearColor{-999.0f, -999.0f, -999.0f, -999.0f};
|
||||||
@ -76,7 +78,11 @@ void Camera::usePerspective(float fovDeg)
|
|||||||
float fovRad = glm::radians(fovDeg);
|
float fovRad = glm::radians(fovDeg);
|
||||||
|
|
||||||
glm::vec2 viewportDim = getViewportSize();
|
glm::vec2 viewportDim = getViewportSize();
|
||||||
m_projMatrix = glm::perspectiveFovRH_ZO(fovRad, viewportDim.x, viewportDim.y, NEAR, FAR);
|
float aspect = viewportDim.x / viewportDim.y;
|
||||||
|
|
||||||
|
float fovY = fovRad / aspect;
|
||||||
|
|
||||||
|
m_projMatrix = glm::perspectiveZO(fovY, aspect, NEAR, FAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Camera::useOrtho()
|
void Camera::useOrtho()
|
||||||
|
@ -55,6 +55,8 @@ namespace engine {
|
|||||||
auto beginFrame = std::chrono::steady_clock::now();
|
auto beginFrame = std::chrono::steady_clock::now();
|
||||||
auto endFrame = beginFrame + FRAMETIME_LIMIT;
|
auto endFrame = beginFrame + FRAMETIME_LIMIT;
|
||||||
|
|
||||||
|
//m_enableFrameLimiter = false;
|
||||||
|
|
||||||
// single-threaded game loop
|
// single-threaded game loop
|
||||||
while (m_win->isRunning()) {
|
while (m_win->isRunning()) {
|
||||||
|
|
||||||
@ -83,7 +85,9 @@ namespace engine {
|
|||||||
m_win->getInputAndEvents();
|
m_win->getInputAndEvents();
|
||||||
|
|
||||||
/* fps limiter */
|
/* fps limiter */
|
||||||
|
if (m_enableFrameLimiter) {
|
||||||
std::this_thread::sleep_until(endFrame);
|
std::this_thread::sleep_until(endFrame);
|
||||||
|
}
|
||||||
beginFrame = endFrame;
|
beginFrame = endFrame;
|
||||||
endFrame = beginFrame + FRAMETIME_LIMIT;
|
endFrame = beginFrame + FRAMETIME_LIMIT;
|
||||||
|
|
||||||
|
BIN
test/res/models/lego/lego.dae
(Stored with Git LFS)
Normal file
BIN
test/res/models/lego/lego.dae
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
test/res/models/lego/lego_ville.png
Normal file
BIN
test/res/models/lego/lego_ville.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 664 KiB |
BIN
test/res/models/pyramid/pyramid.dae
(Stored with Git LFS)
BIN
test/res/models/pyramid/pyramid.dae
(Stored with Git LFS)
Binary file not shown.
@ -49,6 +49,7 @@ void CameraController::onUpdate(glm::mat4 t)
|
|||||||
isJumping = false;
|
isJumping = false;
|
||||||
dy = 0.0f;
|
dy = 0.0f;
|
||||||
parent.transform.position.y = standingHeight;
|
parent.transform.position.y = standingHeight;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +85,16 @@ void CameraController::onUpdate(glm::mat4 t)
|
|||||||
parent.transform.position += (d2xRotated + d2zRotated) * dt;
|
parent.transform.position += (d2xRotated + d2zRotated) * dt;
|
||||||
parent.transform.position.y += dy * dt;
|
parent.transform.position.y += dy * dt;
|
||||||
|
|
||||||
|
constexpr float MAX_DISTANCE_FROM_ORIGIN = 1000.0f;
|
||||||
|
|
||||||
|
if (glm::length(parent.transform.position) > MAX_DISTANCE_FROM_ORIGIN) {
|
||||||
|
parent.transform.position = { 0.0f, standingHeight, 0.0f };
|
||||||
|
dy = 0.0f;
|
||||||
|
isJumping = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ROTATION STUFF */
|
||||||
|
|
||||||
// pitch quaternion
|
// pitch quaternion
|
||||||
const float halfPitch = m_pitch / 2.0f;
|
const float halfPitch = m_pitch / 2.0f;
|
||||||
glm::quat pitchQuat{};
|
glm::quat pitchQuat{};
|
||||||
|
@ -14,11 +14,11 @@ private:
|
|||||||
float m_yaw = 0.0f;
|
float m_yaw = 0.0f;
|
||||||
float m_pitch = 0.0f;
|
float m_pitch = 0.0f;
|
||||||
|
|
||||||
float walk_speed = 4.0f;
|
const float walk_speed = 4.0f;
|
||||||
|
|
||||||
bool isJumping = false;
|
bool isJumping = false;
|
||||||
float dy = 0.0f;
|
float dy = 0.0f;
|
||||||
float standingHeight = 0.0f;
|
float standingHeight = 0.0f;
|
||||||
float thrust = 25.0f;
|
const float thrust = 25.0f;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -30,8 +30,6 @@ void playGame()
|
|||||||
// configure window
|
// configure window
|
||||||
app.window()->setRelativeMouseMode(true);
|
app.window()->setRelativeMouseMode(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// input config
|
// input config
|
||||||
|
|
||||||
// game buttons
|
// game buttons
|
||||||
@ -56,20 +54,21 @@ void playGame()
|
|||||||
constexpr float EYE_LEVEL = (HEIGHT_INCHES - 4.5f) * 25.4f / 1000.0f;
|
constexpr float EYE_LEVEL = (HEIGHT_INCHES - 4.5f) * 25.4f / 1000.0f;
|
||||||
cam->transform.position = { 0.0f, EYE_LEVEL, 0.0f };
|
cam->transform.position = { 0.0f, EYE_LEVEL, 0.0f };
|
||||||
auto camCamera = cam->createComponent<engine::components::Camera>();
|
auto camCamera = cam->createComponent<engine::components::Camera>();
|
||||||
camCamera->usePerspective(70.0f);
|
camCamera->usePerspective(130.0f);
|
||||||
cam->createComponent<CameraController>();
|
cam->createComponent<CameraController>();
|
||||||
//cam->createComponent<engine::components::Renderer>()->m_mesh = genSphereMesh(0.2f, 20);
|
cam->createComponent<engine::components::Renderer>()->m_mesh = genSphereMesh(0.2f, 20);
|
||||||
//cam->getComponent<engine::components::Renderer>()->setTexture("textures/cobble_stone.png");
|
cam->getComponent<engine::components::Renderer>()->setTexture("textures/cobble_stone.png");
|
||||||
|
|
||||||
|
/*
|
||||||
auto gun = cam->createChild("gun");
|
auto gun = cam->createChild("gun");
|
||||||
gun->transform.position = glm::vec3{ 0.2f, -0.1f, -0.15f };
|
gun->transform.position = glm::vec3{ 0.2f, -0.1f, -0.15f };
|
||||||
gun->transform.rotation = glm::angleAxis(glm::pi<float>(), glm::vec3{ 0.0f, 1.0f, 0.0f });
|
gun->transform.rotation = glm::angleAxis(glm::pi<float>(), glm::vec3{ 0.0f, 1.0f, 0.0f });
|
||||||
float GUN_SCALE = 9.0f / 560.0f;
|
float GUN_SCALE = 9.0f / 560.0f;
|
||||||
GUN_SCALE *= 1.0f;
|
|
||||||
gun->transform.scale *= GUN_SCALE;
|
gun->transform.scale *= GUN_SCALE;
|
||||||
auto gunRenderer = gun->createComponent<engine::components::Renderer>();
|
auto gunRenderer = gun->createComponent<engine::components::Renderer>();
|
||||||
gunRenderer->setMesh("meshes/gun.mesh");
|
gunRenderer->setMesh("meshes/gun.mesh");
|
||||||
gunRenderer->setTexture("textures/gun.png");
|
gunRenderer->setTexture("textures/gun.png");
|
||||||
|
*/
|
||||||
|
|
||||||
// FLOOR
|
// FLOOR
|
||||||
|
|
||||||
@ -138,12 +137,14 @@ void playGame()
|
|||||||
// boundary
|
// boundary
|
||||||
auto bounds = app.scene()->createChild("bounds");
|
auto bounds = app.scene()->createChild("bounds");
|
||||||
auto boundsRen = bounds->createComponent<engine::components::Renderer>();
|
auto boundsRen = bounds->createComponent<engine::components::Renderer>();
|
||||||
boundsRen->m_mesh = genSphereMesh(100.0f, 100, true);
|
boundsRen->m_mesh = genSphereMesh(100.0f, 36, true);
|
||||||
boundsRen->setTexture("textures/metal.jpg");
|
boundsRen->setTexture("textures/metal.jpg");
|
||||||
|
|
||||||
auto myModel = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/pyramid/pyramid.dae").string());
|
auto myModel = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/pyramid/pyramid.dae").string());
|
||||||
|
myModel->transform.position = { -5.0f, 2.0f, 7.0f };
|
||||||
|
|
||||||
auto myRoom = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/room/room.dae").string());
|
auto myRoom = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/room/room.dae").string());
|
||||||
|
myRoom->transform.position = { 9.0f, 0.1f, 3.0f };
|
||||||
|
|
||||||
auto astronaut = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/astronaut/astronaut.dae").string());
|
auto astronaut = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/astronaut/astronaut.dae").string());
|
||||||
astronaut->transform.position.z += 5.0f;
|
astronaut->transform.position.z += 5.0f;
|
||||||
@ -152,6 +153,10 @@ void playGame()
|
|||||||
auto plane = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/plane/plane.dae").string());
|
auto plane = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/plane/plane.dae").string());
|
||||||
plane->transform.position = { -30.0f, 2.0f, 10.0f };
|
plane->transform.position = { -30.0f, 2.0f, 10.0f };
|
||||||
|
|
||||||
|
auto lego = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/lego/lego.dae").string());
|
||||||
|
lego->transform.position = { 30.0f, -2.0f, 30.0f };
|
||||||
|
lego->transform.scale = { 0.1f, 0.1f, 0.1f };
|
||||||
|
|
||||||
// END TESTING
|
// END TESTING
|
||||||
|
|
||||||
app.scene()->printTree();
|
app.scene()->printTree();
|
||||||
|
Loading…
Reference in New Issue
Block a user