mirror of
https://github.com/bailwillharr/engine.git
synced 2024-09-21 04:51:18 +00:00
disable most of the engine for for rewrite
This commit is contained in:
parent
cc705fde85
commit
fd6c99ea12
@ -12,74 +12,24 @@ project(engine LANGUAGES CXX
|
|||||||
set(SRC_FILES
|
set(SRC_FILES
|
||||||
"src/engine.cpp"
|
"src/engine.cpp"
|
||||||
"src/window.cpp"
|
"src/window.cpp"
|
||||||
"src/input.cpp" #TODO make input_manager
|
"src/input.cpp"
|
||||||
|
|
||||||
"src/object.cpp"
|
|
||||||
"src/sceneroot.cpp"
|
|
||||||
|
|
||||||
"src/components/component.cpp"
|
|
||||||
# TODO move functionality into "Object" class
|
|
||||||
"src/components/camera.cpp"
|
|
||||||
"src/components/mesh_renderer.cpp"
|
|
||||||
"src/components/text_ui_renderer.cpp"
|
|
||||||
"src/components/custom.cpp"
|
|
||||||
|
|
||||||
"src/resources/resource.cpp"
|
|
||||||
"src/resources/mesh.cpp"
|
|
||||||
"src/resources/shader.cpp"
|
|
||||||
"src/resources/texture.cpp"
|
|
||||||
"src/resources/font.cpp"
|
|
||||||
|
|
||||||
"src/util/model_loader.cpp"
|
|
||||||
"src/util/files.cpp"
|
|
||||||
|
|
||||||
"src/resource_manager.cpp"
|
|
||||||
|
|
||||||
"src/gfx_device_vulkan.cpp"
|
"src/gfx_device_vulkan.cpp"
|
||||||
"src/gfx_device_null.cpp"
|
"src/util/files.cpp"
|
||||||
"src/gfx_device_opengl45.cpp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(INCLUDE_FILES
|
set(INCLUDE_FILES
|
||||||
|
|
||||||
"include/engine_api.h"
|
"include/engine_api.h"
|
||||||
|
|
||||||
"include/engine.hpp"
|
"include/engine.hpp"
|
||||||
|
|
||||||
"include/util.hpp"
|
"include/util.hpp"
|
||||||
|
|
||||||
"include/log.hpp"
|
"include/log.hpp"
|
||||||
|
"include/logger.hpp"
|
||||||
"include/window.hpp"
|
"include/window.hpp"
|
||||||
|
|
||||||
"include/inputs/keyboard.hpp"
|
"include/inputs/keyboard.hpp"
|
||||||
"include/inputs/mouse.hpp"
|
"include/inputs/mouse.hpp"
|
||||||
|
|
||||||
"include/input.hpp"
|
"include/input.hpp"
|
||||||
|
|
||||||
"include/transform.hpp"
|
|
||||||
"include/object.hpp"
|
|
||||||
"include/sceneroot.hpp"
|
|
||||||
|
|
||||||
"include/components/component.hpp"
|
|
||||||
"include/components/camera.hpp"
|
|
||||||
"include/components/mesh_renderer.hpp"
|
|
||||||
"include/components/text_ui_renderer.hpp"
|
|
||||||
"include/components/custom.hpp"
|
|
||||||
|
|
||||||
"include/resources/resource.hpp"
|
|
||||||
"include/resources/mesh.hpp"
|
|
||||||
"include/resources/shader.hpp"
|
|
||||||
"include/resources/texture.hpp"
|
|
||||||
"include/resources/font.hpp"
|
|
||||||
|
|
||||||
"include/util/model_loader.hpp"
|
|
||||||
"include/util/files.hpp"
|
|
||||||
|
|
||||||
"include/resource_manager.hpp"
|
|
||||||
|
|
||||||
"include/gfx.hpp"
|
"include/gfx.hpp"
|
||||||
"include/gfx_device.hpp"
|
"include/gfx_device.hpp"
|
||||||
|
"include/util/files.hpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC
|
add_library(${PROJECT_NAME} STATIC
|
||||||
|
@ -1,16 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
class Window;
|
class Window;
|
||||||
|
class GFXDevice;
|
||||||
class Input;
|
class Input;
|
||||||
class ResourceManager;
|
|
||||||
class SceneRoot;
|
|
||||||
|
|
||||||
class Application {
|
class Application {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application(const char* appName, const char* appVersion);
|
Application(const char* appName, const char* appVersion);
|
||||||
|
|
||||||
@ -21,35 +17,15 @@ namespace engine {
|
|||||||
|
|
||||||
void gameLoop();
|
void gameLoop();
|
||||||
|
|
||||||
Window* window()
|
Window* window() { return m_win; }
|
||||||
{
|
GFXDevice* gfx() { return m_gfx; }
|
||||||
return m_win;
|
Input* input() { return m_input; }
|
||||||
}
|
|
||||||
|
|
||||||
Input* input()
|
|
||||||
{
|
|
||||||
return m_input;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceManager* resources()
|
|
||||||
{
|
|
||||||
return m_res;
|
|
||||||
}
|
|
||||||
|
|
||||||
SceneRoot* scene()
|
|
||||||
{
|
|
||||||
return m_scene;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Window* m_win;
|
Window* m_win;
|
||||||
|
GFXDevice* m_gfx;
|
||||||
Input* m_input;
|
Input* m_input;
|
||||||
ResourceManager* m_res;
|
|
||||||
SceneRoot* m_scene;
|
|
||||||
|
|
||||||
bool m_enableFrameLimiter = true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ namespace engine {
|
|||||||
class ENGINE_API GFXDevice {
|
class ENGINE_API GFXDevice {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, bool vsync);
|
GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, bool vsync = false);
|
||||||
|
|
||||||
GFXDevice(const GFXDevice&) = delete;
|
GFXDevice(const GFXDevice&) = delete;
|
||||||
GFXDevice& operator=(const GFXDevice&) = delete;
|
GFXDevice& operator=(const GFXDevice&) = delete;
|
||||||
@ -49,6 +49,4 @@ namespace engine {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GFXDevice* gfxdev;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
#include <spdlog/sinks/stdout_color_sinks.h>
|
#include <spdlog/sinks/stdout_color_sinks.h>
|
||||||
#include <spdlog/sinks/basic_file_sink.h>
|
#include <spdlog/sinks/basic_file_sink.h>
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
// To be executed in the target application, NOT engine.dll
|
// To be executed in the target application, NOT engine.dll
|
||||||
|
@ -29,18 +29,12 @@ namespace engine {
|
|||||||
class CustomComponent;
|
class CustomComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GameIO {
|
|
||||||
Window* win;
|
|
||||||
Input* input;
|
|
||||||
ResourceManager* resMan;
|
|
||||||
};
|
|
||||||
|
|
||||||
// This object lives until it is deleted by its parent(s) or finally when the "Scene" is destroyed.
|
// This object lives until it is deleted by its parent(s) or finally when the "Scene" is destroyed.
|
||||||
// Therefore it is safe to return raw pointers
|
// Therefore it is safe to return raw pointers
|
||||||
class ENGINE_API Object {
|
class ENGINE_API Object {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Object(std::string name, Object* parent, SceneRoot& root, struct GameIO things);
|
Object(std::string name, Object* parent, SceneRoot& root);
|
||||||
Object(const Object&) = delete;
|
Object(const Object&) = delete;
|
||||||
Object& operator=(const Object&) = delete;
|
Object& operator=(const Object&) = delete;
|
||||||
~Object();
|
~Object();
|
||||||
|
@ -5,15 +5,12 @@
|
|||||||
#include "inputs/keyboard.hpp"
|
#include "inputs/keyboard.hpp"
|
||||||
#include "inputs/mouse.hpp"
|
#include "inputs/mouse.hpp"
|
||||||
|
|
||||||
#pragma warning (push, 0)
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#pragma warning (pop)
|
|
||||||
|
|
||||||
#include <glm/vec2.hpp>
|
#include <glm/vec2.hpp>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
ENGINE_API extern const uint64_t BILLION;
|
ENGINE_API extern const uint64_t BILLION;
|
||||||
|
|
||||||
|
@ -3,11 +3,8 @@
|
|||||||
#include "log.hpp"
|
#include "log.hpp"
|
||||||
|
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
#include "input.hpp"
|
|
||||||
#include "resource_manager.hpp"
|
|
||||||
#include "sceneroot.hpp"
|
|
||||||
|
|
||||||
#include "gfx_device.hpp"
|
#include "gfx_device.hpp"
|
||||||
|
#include "input.hpp"
|
||||||
|
|
||||||
// To allow the FPS-limiter to put the thread to sleep
|
// To allow the FPS-limiter to put the thread to sleep
|
||||||
#include <thread>
|
#include <thread>
|
||||||
@ -17,28 +14,14 @@ namespace engine {
|
|||||||
Application::Application(const char* appName, const char* appVersion)
|
Application::Application(const char* appName, const char* appVersion)
|
||||||
{
|
{
|
||||||
m_win = new Window(appName, true, true);
|
m_win = new Window(appName, true, true);
|
||||||
|
m_gfx = new GFXDevice(appName, appVersion, m_win->getHandle());
|
||||||
gfxdev = new GFXDevice(appName, appVersion, m_win->getHandle(), false);
|
|
||||||
|
|
||||||
m_input = new Input(*m_win);
|
m_input = new Input(*m_win);
|
||||||
m_res = new ResourceManager();
|
|
||||||
|
|
||||||
GameIO things{
|
|
||||||
m_win,
|
|
||||||
m_input,
|
|
||||||
m_res
|
|
||||||
};
|
|
||||||
m_scene = new SceneRoot(things);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
{
|
{
|
||||||
delete m_scene;
|
|
||||||
delete m_res;
|
|
||||||
delete m_input;
|
delete m_input;
|
||||||
|
delete m_gfx;
|
||||||
delete gfxdev;
|
|
||||||
|
|
||||||
delete m_win;
|
delete m_win;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,29 +34,25 @@ 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()) {
|
||||||
|
|
||||||
m_scene->updateStuff();
|
/* logic */
|
||||||
|
|
||||||
/* draw */
|
/* draw */
|
||||||
gfxdev->renderFrame();
|
m_gfx->renderFrame();
|
||||||
|
|
||||||
/* poll events */
|
/* poll events */
|
||||||
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gfxdev->waitIdle();
|
m_gfx->waitIdle();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
|
|
||||||
namespace engine {
|
namespace engine {
|
||||||
|
|
||||||
// EXTERNED GLOBAL VARIABLE
|
|
||||||
GFXDevice* gfxdev = nullptr;
|
|
||||||
|
|
||||||
static constexpr uint32_t FRAMES_IN_FLIGHT = 2; // This improved FPS by 5x! (on Intel IGPU)
|
static constexpr uint32_t FRAMES_IN_FLIGHT = 2; // This improved FPS by 5x! (on Intel IGPU)
|
||||||
|
|
||||||
static constexpr size_t PUSH_CONSTANT_MAX_SIZE = 128; // bytes
|
static constexpr size_t PUSH_CONSTANT_MAX_SIZE = 128; // bytes
|
||||||
@ -1027,10 +1024,6 @@ namespace engine {
|
|||||||
|
|
||||||
GFXDevice::GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, bool vsync)
|
GFXDevice::GFXDevice(const char* appName, const char* appVersion, SDL_Window* window, bool vsync)
|
||||||
{
|
{
|
||||||
if (gfxdev != nullptr) {
|
|
||||||
throw std::runtime_error("There can only be one graphics device");
|
|
||||||
}
|
|
||||||
gfxdev = this;
|
|
||||||
|
|
||||||
pimpl = std::make_unique<Impl>();
|
pimpl = std::make_unique<Impl>();
|
||||||
|
|
||||||
|
@ -15,9 +15,6 @@ namespace engine {
|
|||||||
// init SDL
|
// init SDL
|
||||||
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
|
||||||
const std::string errMsg("Unable to initialise SDL: " + std::string(SDL_GetError()));
|
const std::string errMsg("Unable to initialise SDL: " + std::string(SDL_GetError()));
|
||||||
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "SDL error", errMsg.c_str(), NULL) != 0) {
|
|
||||||
std::cerr << errMsg << "\nAre you in a graphical environment?\n";
|
|
||||||
}
|
|
||||||
throw std::runtime_error(errMsg);
|
throw std::runtime_error(errMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,15 +9,8 @@ project(enginetest LANGUAGES CXX
|
|||||||
set(GAME_SOURCES
|
set(GAME_SOURCES
|
||||||
|
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
|
||||||
src/game.cpp
|
src/game.cpp
|
||||||
src/game.hpp
|
src/game.hpp
|
||||||
src/meshgen.cpp
|
|
||||||
src/meshgen.hpp
|
|
||||||
src/terrain.cpp
|
|
||||||
src/terrain.hpp
|
|
||||||
src/camera_controller.cpp
|
|
||||||
src/camera_controller.hpp
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,29 +1,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "engine.hpp"
|
#include "engine.hpp"
|
||||||
|
|
||||||
#include "window.hpp"
|
#include "window.hpp"
|
||||||
#include "input.hpp"
|
|
||||||
#include "sceneroot.hpp"
|
|
||||||
|
|
||||||
#include "components/camera.hpp"
|
|
||||||
#include "components/mesh_renderer.hpp"
|
|
||||||
#include "components/text_ui_renderer.hpp"
|
|
||||||
|
|
||||||
#include "resource_manager.hpp"
|
|
||||||
#include "resources/texture.hpp"
|
|
||||||
#include "resources/font.hpp"
|
|
||||||
|
|
||||||
#include "util/model_loader.hpp"
|
|
||||||
|
|
||||||
#include "camera_controller.hpp"
|
|
||||||
#include "meshgen.hpp"
|
|
||||||
|
|
||||||
#include <glm/gtc/quaternion.hpp>
|
|
||||||
|
|
||||||
#include <log.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
void playGame()
|
void playGame()
|
||||||
{
|
{
|
||||||
@ -32,136 +10,5 @@ void playGame()
|
|||||||
// configure window
|
// configure window
|
||||||
app.window()->setRelativeMouseMode(true);
|
app.window()->setRelativeMouseMode(true);
|
||||||
|
|
||||||
// input config
|
|
||||||
|
|
||||||
// game buttons
|
|
||||||
app.input()->addInputButton("fire", engine::inputs::MouseButton::M_LEFT);
|
|
||||||
app.input()->addInputButton("aim", engine::inputs::MouseButton::M_RIGHT);
|
|
||||||
app.input()->addInputButton("jump", engine::inputs::Key::SPACE);
|
|
||||||
app.input()->addInputButton("sneak", engine::inputs::Key::LSHIFT);
|
|
||||||
// game movement
|
|
||||||
app.input()->addInputButtonAsAxis("movex", engine::inputs::Key::D, engine::inputs::Key::A);
|
|
||||||
app.input()->addInputButtonAsAxis("movey", engine::inputs::Key::W, engine::inputs::Key::S);
|
|
||||||
// looking around
|
|
||||||
app.input()->addInputAxis("lookx", engine::inputs::MouseAxis::X);
|
|
||||||
app.input()->addInputAxis("looky", engine::inputs::MouseAxis::Y);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// create the scene
|
|
||||||
|
|
||||||
auto cam = app.scene()->createChild("cam");
|
|
||||||
constexpr float HEIGHT_INCHES = 6.0f * 12.0f;
|
|
||||||
// eye level is about 4 1/2 inches below height
|
|
||||||
constexpr float EYE_LEVEL = (HEIGHT_INCHES - 4.5f) * 25.4f / 1000.0f;
|
|
||||||
cam->transform.position = { 0.0f, EYE_LEVEL, 0.0f };
|
|
||||||
auto camCamera = cam->createComponent<engine::components::Camera>();
|
|
||||||
camCamera->usePerspective(130.0f);
|
|
||||||
cam->createComponent<CameraController>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
auto gun = cam->createChild("gun");
|
|
||||||
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 });
|
|
||||||
float GUN_SCALE = 9.0f / 560.0f;
|
|
||||||
gun->transform.scale *= GUN_SCALE;
|
|
||||||
auto gunRenderer = gun->createComponent<engine::components::Renderer>();
|
|
||||||
gunRenderer->setMesh("meshes/gun.mesh");
|
|
||||||
gunRenderer->setTexture("textures/gun.png");
|
|
||||||
*/
|
|
||||||
|
|
||||||
// FLOOR
|
|
||||||
constexpr float GRASS_DENSITY = 128.0f * 20.0f;
|
|
||||||
auto floor = app.scene()->createChild("floor");
|
|
||||||
auto floorRenderer = floor->createComponent<engine::components::Renderer>();
|
|
||||||
floor->transform.position = glm::vec3{ 0.0f, 0.0f, 0.0f };
|
|
||||||
floorRenderer->setTexture("textures/grass.jpg");
|
|
||||||
floorRenderer->m_mesh = std::make_unique<engine::resources::Mesh>(std::vector<Vertex>{
|
|
||||||
{ { -16.0f, 0.0f, 16.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, GRASS_DENSITY } },
|
|
||||||
{ { 16.0f, 0.0f, -16.0f }, { 0.0f, 1.0f, 0.0f }, { GRASS_DENSITY, 0.0f } },
|
|
||||||
{ { -16.0f, 0.0f, -16.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.0f } },
|
|
||||||
{ { 16.0f, 0.0f, 16.0f }, { 0.0f, 1.0f, 0.0f }, { GRASS_DENSITY, GRASS_DENSITY } },
|
|
||||||
{ { 16.0f, 0.0f, -16.0f }, { 0.0f, 1.0f, 0.0f }, { GRASS_DENSITY, 0.0f } },
|
|
||||||
{ { -16.0f, 0.0f, 16.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, GRASS_DENSITY } }
|
|
||||||
});
|
|
||||||
floor->transform.scale = { 100.0f, 1.0f, 100.0f };
|
|
||||||
|
|
||||||
auto cube = app.scene()->createChild("cube");
|
|
||||||
auto cubeRen = cube->createComponent<engine::components::Renderer>();
|
|
||||||
cubeRen->setMesh("meshes/cube.mesh");
|
|
||||||
cube->transform.position = glm::vec3{ -5.0f, 1.0f, 0.0f };
|
|
||||||
class Spin : public engine::components::CustomComponent {
|
|
||||||
public:
|
|
||||||
Spin(engine::Object* parent) : CustomComponent(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
void onUpdate(glm::mat4 t) override
|
|
||||||
{
|
|
||||||
m_yaw += win.dt();
|
|
||||||
m_yaw = glm::mod(m_yaw, glm::two_pi<float>());
|
|
||||||
const float halfYaw = m_yaw / 2.0f;
|
|
||||||
glm::quat yawQuat{};
|
|
||||||
yawQuat.x = 0.0f;
|
|
||||||
yawQuat.y = glm::sin(halfYaw);
|
|
||||||
yawQuat.z = 0.0f;
|
|
||||||
yawQuat.w = glm::cos(halfYaw);
|
|
||||||
parent.transform.rotation = yawQuat;
|
|
||||||
|
|
||||||
constexpr float halfPitch = -glm::half_pi<float>() / 2.0f;
|
|
||||||
glm::quat pitchQuat{};
|
|
||||||
pitchQuat.x = glm::sin(halfPitch);
|
|
||||||
pitchQuat.y = 0.0f;
|
|
||||||
pitchQuat.z = 0.0f;
|
|
||||||
pitchQuat.w = glm::cos(halfPitch);
|
|
||||||
parent.transform.rotation *= pitchQuat;
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
float m_yaw = 0.0f;
|
|
||||||
};
|
|
||||||
cube->createComponent<Spin>();
|
|
||||||
|
|
||||||
// boundary
|
|
||||||
auto bounds = app.scene()->createChild("bounds");
|
|
||||||
auto boundsRen = bounds->createComponent<engine::components::Renderer>();
|
|
||||||
boundsRen->m_mesh = genSphereMesh(100.0f, 36, true);
|
|
||||||
boundsRen->setTexture("textures/metal.jpg");
|
|
||||||
|
|
||||||
auto message = app.scene()->createChild("message");
|
|
||||||
message->transform.position = { -1.0f, 0.95f, 0.0f };
|
|
||||||
message->transform.scale *= 0.5f;
|
|
||||||
auto messageUI = message->createComponent<engine::components::UI>();
|
|
||||||
class FPSTextUpdater : public engine::components::CustomComponent {
|
|
||||||
engine::components::UI* textUI = nullptr;
|
|
||||||
public:
|
|
||||||
FPSTextUpdater(engine::Object* parent) : CustomComponent(parent)
|
|
||||||
{
|
|
||||||
textUI = parent->getComponent<engine::components::UI>();
|
|
||||||
}
|
|
||||||
void onUpdate(glm::mat4 t) override
|
|
||||||
{
|
|
||||||
textUI->m_text = std::to_string(parent.win.dt() * 1000.0f) + " ms";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
message->createComponent<FPSTextUpdater>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
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());
|
|
||||||
myRoom->transform.position = { 9.0f, 0.1f, 3.0f };
|
|
||||||
*/
|
|
||||||
auto astronaut = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/astronaut/astronaut.dae").string());
|
|
||||||
astronaut->transform.position.z += 5.0f;
|
|
||||||
astronaut->createComponent<Spin>();
|
|
||||||
|
|
||||||
/*
|
|
||||||
auto lego = engine::util::loadAssimpMeshFromFile(app.scene(), app.resources()->getFilePath("models/lego/lego.dae").string());
|
|
||||||
lego->transform.position = { -30.0f, -33.0f, -30.0f };
|
|
||||||
*/
|
|
||||||
|
|
||||||
app.scene()->printTree();
|
|
||||||
|
|
||||||
app.gameLoop();
|
app.gameLoop();
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "game.hpp"
|
#include "game.hpp"
|
||||||
|
|
||||||
#include "logger.hpp"
|
#include "logger.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user