Actually have matrixed cubes working
This commit is contained in:
@ -67,6 +67,18 @@ float_t Camera::getAspect() {
|
||||
return target->getWidth() / target->getHeight();
|
||||
}
|
||||
|
||||
glm::vec3 Camera::getRayDirectionFromScreenSpace(glm::vec2 screenSpace) {
|
||||
glm::vec4 clipCoords(screenSpace.x, -screenSpace.y, -1.0f, 1.0f);
|
||||
glm::mat4 inverseProjectionMatrix = glm::inverse(this->projection);
|
||||
glm::vec4 eyeCoords = inverseProjectionMatrix * clipCoords;
|
||||
eyeCoords = glm::vec4(eyeCoords.x, eyeCoords.y, -1.0f, 0.0f);
|
||||
|
||||
glm::mat4 inverseViewMatrix = glm::inverse(transform->getWorldTransform());
|
||||
glm::vec4 t = inverseViewMatrix * eyeCoords;
|
||||
|
||||
return glm::normalize(glm::vec3(t.x, t.y, t.z));
|
||||
}
|
||||
|
||||
void Camera::onStart() {
|
||||
this->updateProjection();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include "scene/SceneItemComponent.hpp"
|
||||
#include "display/RenderTarget.hpp"
|
||||
#include "scene/Scene.hpp"
|
||||
#include "physics/3d/Ray3D.hpp"
|
||||
|
||||
namespace Dawn {
|
||||
enum CameraType {
|
||||
@ -79,6 +80,18 @@ namespace Dawn {
|
||||
*/
|
||||
float_t getAspect();
|
||||
|
||||
/**
|
||||
* Creates the directional vector for a given point on the screen space
|
||||
* coordinates provided. This is useful if you want to, say, cast a ray
|
||||
* based on a position on the screen. The directional vector is normalized
|
||||
* between -1 and 1 where -1 is the near clipping plane, and 1 is the
|
||||
* far clipping plane.
|
||||
*
|
||||
* @param screenSpace Screen space vector (-1,-1 to 1,1) on the screen.
|
||||
* @return The vector for the direction to cast from.
|
||||
*/
|
||||
glm::vec3 getRayDirectionFromScreenSpace(glm::vec2 screenSpace);
|
||||
|
||||
/**
|
||||
* Event triggered by the scene item when the item is added to the scene.
|
||||
*/
|
||||
|
@ -29,7 +29,7 @@ struct ShaderPassItem SceneDebugLine::createShaderItem(
|
||||
auto i = *lineIndex;
|
||||
item.mesh = mesh;
|
||||
item.drawMode = MESH_DRAW_MODE_LINES;
|
||||
item.renderFlags = RENDER_MANAGER_RENDER_FLAG_BLEND | RENDER_MANAGER_RENDER_FLAG_DEPTH_TEST;
|
||||
item.renderFlags = 0x00;
|
||||
item.start = i * SCENE_DEBUG_LINE_INDICE_COUNT;
|
||||
item.count = SCENE_DEBUG_LINE_INDICE_COUNT;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
#define SCENE_DEBUG_LINE_VERTICE_COUNT 2
|
||||
#define SCENE_DEBUG_LINE_INDICE_COUNT 2
|
||||
#define SCENE_DEBUG_LINE_PRIORITY 1
|
||||
#define SCENE_DEBUG_LINE_PRIORITY 100
|
||||
|
||||
namespace Dawn {
|
||||
class SimpleTexturedShader;
|
||||
|
Reference in New Issue
Block a user