mockup of utility functions
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
------------ Tyra's v2.0 roadmap to publish on GitHub ------------
|
------------ Tyra's v2.0 roadmap to publish on GitHub ------------
|
||||||
|
|
||||||
- [Renderer] utility functions
|
- [Renderer] utility functions
|
||||||
- [Renderer] drawLine()
|
|
||||||
- [Renderer] drawBBox()
|
|
||||||
- [Renderer] drawPoint()
|
|
||||||
- [Demo] Red screen on hit
|
- [Demo] Red screen on hit
|
||||||
- [Demo] Count of killed zombies
|
- [Demo] Count of killed zombies
|
||||||
- [Demo] Crosshair
|
- [Demo] Crosshair
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ using Tyra::DynamicMesh;
|
|||||||
using Tyra::DynPipOptions;
|
using Tyra::DynPipOptions;
|
||||||
using Tyra::Engine;
|
using Tyra::Engine;
|
||||||
using Tyra::Renderer;
|
using Tyra::Renderer;
|
||||||
|
using Tyra::Renderer3DUtility;
|
||||||
using Tyra::TextureRepository;
|
using Tyra::TextureRepository;
|
||||||
using Tyra::Vec4;
|
using Tyra::Vec4;
|
||||||
|
|
||||||
@@ -53,6 +54,7 @@ class Enemy {
|
|||||||
bool isFighting = false;
|
bool isFighting = false;
|
||||||
Vec4 spawnPoint;
|
Vec4 spawnPoint;
|
||||||
|
|
||||||
|
Renderer3DUtility* utility;
|
||||||
Audio* audio;
|
Audio* audio;
|
||||||
EnemyInfo info;
|
EnemyInfo info;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Demo {
|
|||||||
|
|
||||||
Enemy::Enemy(Engine* engine, const EnemyInfo& t_info) {
|
Enemy::Enemy(Engine* engine, const EnemyInfo& t_info) {
|
||||||
info = t_info;
|
info = t_info;
|
||||||
|
utility = &engine->renderer.renderer3D.utility;
|
||||||
|
|
||||||
mesh = new DynamicMesh(*info.motherMesh);
|
mesh = new DynamicMesh(*info.motherMesh);
|
||||||
|
|
||||||
@@ -96,6 +97,10 @@ void Enemy::handlePlayerShoot(const PlayerShootAction& shootAction) {
|
|||||||
|
|
||||||
auto isOnEnemy = ray.intersectBox(bbox.min(), bbox.max());
|
auto isOnEnemy = ray.intersectBox(bbox.min(), bbox.max());
|
||||||
|
|
||||||
|
utility->drawBBox(bbox);
|
||||||
|
utility->drawLine(ray.origin, ray.direction);
|
||||||
|
utility->drawPoint(*mesh->getPosition());
|
||||||
|
|
||||||
if (isOnEnemy) {
|
if (isOnEnemy) {
|
||||||
mesh->setPosition(spawnPoint);
|
mesh->setPosition(spawnPoint);
|
||||||
TYRA_LOG("Enemy hit!");
|
TYRA_LOG("Enemy hit!");
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ void GameState::update() {
|
|||||||
fpsChecker = 0;
|
fpsChecker = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
skybox->update(player->getPosition());
|
|
||||||
player->update(terrain->heightmap);
|
player->update(terrain->heightmap);
|
||||||
|
skybox->update(player->getPosition());
|
||||||
auto shootAction = player->getShootAction();
|
auto shootAction = player->getShootAction();
|
||||||
enemyManager->update(terrain->heightmap, player->getPosition(), shootAction);
|
enemyManager->update(terrain->heightmap, player->getPosition(), shootAction);
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ PlayerShootAction Player::getShootAction() const {
|
|||||||
action.isShooting = weapon.isShooting;
|
action.isShooting = weapon.isShooting;
|
||||||
|
|
||||||
if (action.isShooting) {
|
if (action.isShooting) {
|
||||||
action.ray = Ray(camera.position, camera.lookAt);
|
action.ray = Ray(camera.position, camera.lookAt.getNormalized());
|
||||||
}
|
}
|
||||||
|
|
||||||
return action;
|
return action;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "./pipeline/renderer_3d_pipeline.hpp"
|
#include "./pipeline/renderer_3d_pipeline.hpp"
|
||||||
|
#include "./renderer_3d_utility.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -19,6 +20,8 @@ class Renderer3D {
|
|||||||
Renderer3D();
|
Renderer3D();
|
||||||
~Renderer3D();
|
~Renderer3D();
|
||||||
|
|
||||||
|
Renderer3DUtility utility;
|
||||||
|
|
||||||
/** Deinitialize previous pipeline and initialize new pipeline */
|
/** Deinitialize previous pipeline and initialize new pipeline */
|
||||||
void usePipeline(Renderer3DPipeline* pipeline);
|
void usePipeline(Renderer3DPipeline* pipeline);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
# _____ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licensed under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "math/vec4.hpp"
|
||||||
|
#include "renderer/models/color.hpp"
|
||||||
|
#include "renderer/core/3d/bbox/core_bbox.hpp"
|
||||||
|
|
||||||
|
namespace Tyra {
|
||||||
|
|
||||||
|
/** Debug functions, with bad performance. */
|
||||||
|
class Renderer3DUtility {
|
||||||
|
public:
|
||||||
|
Renderer3DUtility();
|
||||||
|
~Renderer3DUtility();
|
||||||
|
|
||||||
|
void drawPoint(const Vec4& v);
|
||||||
|
void drawPoint(const Vec4& v, const float& size);
|
||||||
|
void drawPoint(const Vec4& v, const float& size, const Color& color);
|
||||||
|
|
||||||
|
void drawLine(const Vec4& from, const Vec4& to);
|
||||||
|
void drawLine(const Vec4& from, const Vec4& to, const float& size);
|
||||||
|
void drawLine(const Vec4& from, const Vec4& to, const float& size,
|
||||||
|
const Color& color);
|
||||||
|
|
||||||
|
void drawBBox(const CoreBBox& v);
|
||||||
|
void drawBBox(const CoreBBox& v, const float& size);
|
||||||
|
void drawBBox(const CoreBBox& v, const float& size, const Color& color);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Tyra
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
# _____ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licensed under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "renderer/3d/renderer_3d_utility.hpp"
|
||||||
|
|
||||||
|
namespace Tyra {
|
||||||
|
|
||||||
|
Renderer3DUtility::Renderer3DUtility() {}
|
||||||
|
|
||||||
|
Renderer3DUtility::~Renderer3DUtility() {}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawPoint(const Vec4& v) { drawPoint(v, 1.0F); }
|
||||||
|
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to) {
|
||||||
|
drawLine(from, to, 1.0F);
|
||||||
|
}
|
||||||
|
void Renderer3DUtility::drawBBox(const CoreBBox& v) { drawBBox(v, 1.0F); }
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawPoint(const Vec4& v, const float& size) {
|
||||||
|
drawPoint(v, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to,
|
||||||
|
const float& size) {
|
||||||
|
drawLine(from, to, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawBBox(const CoreBBox& v, const float& size) {
|
||||||
|
drawBBox(v, size, Color(128.0F, 0.0F, 0.0F, 128.0F));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawPoint(const Vec4& v, const float& size,
|
||||||
|
const Color& color) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawLine(const Vec4& from, const Vec4& to,
|
||||||
|
const float& size, const Color& color) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer3DUtility::drawBBox(const CoreBBox& v, const float& size,
|
||||||
|
const Color& color) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Tyra
|
||||||
Reference in New Issue
Block a user