From a7651ab0a376d498b2174f8e6541a0d55b960fff Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Sun, 5 Apr 2015 09:40:32 +0200 Subject: [PATCH] fixed invisible elements in Shader move depending on direction --- Weave/Graphix/GLM.h | 3 ++- Weave/Graphix/Scene.cpp | 4 ++-- Weave/Graphix/ViewPort.cpp | 4 ++++ Weave/Graphix/ViewPort.h | 1 + shader/lightingTexture_FS.hlsl | 2 +- 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Weave/Graphix/GLM.h b/Weave/Graphix/GLM.h index c556038..1bbaacf 100644 --- a/Weave/Graphix/GLM.h +++ b/Weave/Graphix/GLM.h @@ -2,7 +2,8 @@ #include "glm\glm.hpp" #include "glm\gtx\transform.hpp" -#include +#include "glm\gtc\type_ptr.hpp"" +#include "glm\gtx\rotate_vector.hpp" using glm::vec3; using glm::mat4; diff --git a/Weave/Graphix/Scene.cpp b/Weave/Graphix/Scene.cpp index 19c2d34..0fa52c9 100644 --- a/Weave/Graphix/Scene.cpp +++ b/Weave/Graphix/Scene.cpp @@ -85,9 +85,9 @@ void Scene::update(float deltaT) //int reset = Events::getAction2(); if (move_x) - lookat->move(0.03f *move_x * vec3(1.f, 0.f, 0.f)); + lookat->move(0.03f *move_x * viewPort->rotateDirection(vec3(-1.f, 0.f, 0.f))); if (move_y) - lookat->move(0.03f *move_y * vec3(0.f, 0.f, 1.f)); + lookat->move(0.03f *move_y * viewPort->rotateDirection(vec3(0.f, 0.f, -1.f))); // XYAchse um den Player viewPort->rotateView(.3f*Events::getViewX(), .3f*Events::getViewY()); diff --git a/Weave/Graphix/ViewPort.cpp b/Weave/Graphix/ViewPort.cpp index ab0bcd7..212f9c4 100644 --- a/Weave/Graphix/ViewPort.cpp +++ b/Weave/Graphix/ViewPort.cpp @@ -64,6 +64,10 @@ void ViewPort::rotateView(float angle_x, float angle_y){ } +vec3 ViewPort::rotateDirection(const vec3 & direction) const{ + return glm::rotateY(direction,- view_angle_x / 50); +} + unsigned int ViewPort::getXPos() const { return xpos; diff --git a/Weave/Graphix/ViewPort.h b/Weave/Graphix/ViewPort.h index cf6e108..fdb0a4e 100644 --- a/Weave/Graphix/ViewPort.h +++ b/Weave/Graphix/ViewPort.h @@ -17,6 +17,7 @@ public: void bindView(Shader* shader, vec3 lookat) const; void rotateView(float angle_x, float angle_y); + vec3 rotateDirection(const vec3 & direction) const; unsigned int getXPos() const; unsigned int getYPos() const; diff --git a/shader/lightingTexture_FS.hlsl b/shader/lightingTexture_FS.hlsl index daaa655..9b56637 100644 --- a/shader/lightingTexture_FS.hlsl +++ b/shader/lightingTexture_FS.hlsl @@ -10,7 +10,7 @@ uniform sampler2D ColorTexture; void main() { - if (visNormal < 0) + if (visNormal < -0.2) { discard; } -- 2.47.3