Background test

This commit is contained in:
2022-12-13 23:30:19 -08:00
parent 41a85a0553
commit 850f4c227d
12 changed files with 138 additions and 27 deletions

View File

@ -126,10 +126,10 @@ void RenderPipeline::renderUI(
// Clear / Bind / Update the render target.
renderTarget->bind();
renderTarget->clear(
RENDER_TARGET_CLEAR_FLAG_DEPTH |
RENDER_TARGET_CLEAR_FLAG_COLOR
);
// renderTarget->clear(
// RENDER_TARGET_CLEAR_FLAG_DEPTH |
// RENDER_TARGET_CLEAR_FLAG_COLOR
// );
this->renderManager->setRenderFlags(
RENDER_MANAGER_RENDER_FLAG_BLEND
);

View File

@ -5,6 +5,7 @@
#include "Transform.hpp"
#include "scene/SceneItem.hpp"
#include "util/mathutils.hpp"
using namespace Dawn;
@ -69,6 +70,16 @@ void Transform::lookAt(glm::vec3 pos, glm::vec3 look, glm::vec3 up) {
this->setWorldTransform(glm::lookAt(pos, look, up));
}
float_t Transform::lookAtPixelPerfect(
glm::vec3 position, glm::vec3 look, float_t viewportHeight, float_t fov
) {
float_t z = (
tanf((mathDeg2Rad(180.0f) - fov) / 2.0f) *
(viewportHeight/2.0f)
);
this->lookAt(glm::vec3(position.x, position.y, position.z + z), look);
return z;
}
glm::vec3 Transform::getLocalPosition() {
return this->localPosition;

View File

@ -60,6 +60,20 @@ namespace Dawn {
void lookAt(glm::vec3 position, glm::vec3 look);
void lookAt(glm::vec3 position, glm::vec3 look, glm::vec3 up);
/**
* Shorthand combined for lookAt and perspectivePixelPerfectDistance
* to allow you to create pixel perfect lookAt camera view matricies.
*
* @param position Position of the camera. Z is for an offset.
* @param look Position in world space this transform looks at.
* @param viewportHeight Height of the viewport.
* @param fov Field of view (in radians).
* @return The Z distance that was calculated.
*/
float_t lookAtPixelPerfect(
glm::vec3 position, glm::vec3 look, float_t viewportHeight, float_t fov
);
/**
* Returns the local position (position relative to "my parent").
* @return The 3D local position in parent-relative space.