]> git.leopard-lacewing.eu Git - cgue_weave.git/commitdiff
added PI in GLM
authorPeter Schaefer <schaeferpm@gmail.com>
Tue, 14 Apr 2015 12:54:24 +0000 (14:54 +0200)
committerPeter Schaefer <schaeferpm@gmail.com>
Tue, 14 Apr 2015 12:54:24 +0000 (14:54 +0200)
capped Player movements (fix in all directions)
switched to radiant
fixed move undepending on deltaT
fixed CULL_FACE + visNormals (shader)

Weave/Events.cpp
Weave/Game.cpp
Weave/Graphix/GLM.h
Weave/Graphix/Graphix.cpp
Weave/Graphix/Scene.cpp
Weave/Graphix/ViewPort.cpp
shader/basicTexture_VS.hlsl
shader/lightingTexture_FS.hlsl

index fe6d5627a5a9d33922d5741da6c1535564d09373..00d076cef3d043207757b32c24099de2f09b1d27 100644 (file)
@@ -3,6 +3,8 @@
 
 #include "Graphix\Graphix.h"
 
+#include "Graphix\GLM.h"
+
 #include <iostream>
 using std::cout;
 using std::endl;
@@ -205,6 +207,7 @@ void Events::axis(int& axis, int keyUP, int keyDOWN)
        {
                axis = 0;
        }
+       axis = sign(axis);
 }
 
 int Events::getViewX()
index 625d768ba544885ef563c23c25e0d65e9ff5b74f..be0a8ef0c843b7cd878dc4742b218febf710bda5 100644 (file)
@@ -82,12 +82,12 @@ Game::Game() : playing(true)
        //      //cout << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << ((float)(rand() % (size*steps * 2)) / steps - size) << endl;
        //}
        //ein Gegner
-//     tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "duck.dae", "model_duck.png"));
+       tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "duck.dae", "model_duck.png"));
        //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(-1.f, 2.f, -2.f)), "../models/box/box.dae", "../Textures/sky_withstars.png"));
        //tmp_Scene->addObject(new SceneObject(shader1, translate(vec3(1.f, 3.f, -2.f)), "../models/cow/cow.dae", "../models/cow/texture.jpg"));
 
        // load LVL
-       tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "level_test.dae", "model_duck.png"));
+       //tmp_Scene->addObject(new SceneObject(shader1, glm::mat4(1.0f), "level_test.dae", "model_duck.png"));
 
        //import("level_test.dae", tmp_Scene, shader1);
 
index 94e6895135a16283f9460552c472af224b13f7b5..a334115d468bc26352474229d901d82139c0a0e5 100644 (file)
@@ -21,5 +21,12 @@ using glm::value_ptr;
 
 using glm::sign;
 
+#define M_PI        3.14159265358979323846264338327950288   /* pi */
+#define M_PI_2      1.57079632679489661923132169163975144   /* pi/2 */
+#define M_PI_4      0.785398163397448309615660845819875721  /* pi/4 */
+#define M_1_PI      0.318309886183790671537767526745028724  /* 1/pi */
+#define M_2_PI      0.636619772367581343075535053490057448  /* 2/pi */
+#define M_D_R       57.2957795131                                                      /* 180/pi */
+
 
 float VektorAbs(const vec3& vek);
index 1c3c1499eb9f5ee03ffa37246e7ba1bf6ae6fa1d..b3b2d871342a32823fa4183457783a383379d0cf 100644 (file)
@@ -65,7 +65,7 @@ void Graphix::init()
        glEnable(GL_COLOR_MATERIAL);
        glEnable(GL_LIGHTING);
        glEnable(GL_LIGHT0);
-       //glEnable(GL_CULL_FACE);
+       glEnable(GL_CULL_FACE);
        glShadeModel(GL_SMOOTH);
 
        //glEnable(GL_BLEND);
index 836913e070a563a5acbb484e093606c592ec9077..c6eff2cdf05af3ec27201daa9014b11551ba3b61 100644 (file)
@@ -79,16 +79,20 @@ void Scene::update(float deltaT)
        //int shoot = Events::getAction1();
        //int reset = Events::getAction2();
 
-       if (move_x)
-               lookat->move(0.03f *move_x * viewPort->rotateDirection(vec3(-1.f, 0.f, 0.f)));
-       if (move_y)
-               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());
+       viewPort->rotateView(0.005f*Events::getViewX(), 0.002f*Events::getViewY());
        //int view_x = Events::getViewX();
        //int view_y = Events::getViewY();
 
+       if (move_x){
+               //TODO vorwärts schneller gehen nach einer sekunde
+               lookat->move(3.f * deltaT *move_x * viewPort->rotateDirection(vec3(-1.f, 0.f, 0.f)));
+       }
+       if (move_y)
+               lookat->move(3.f *move_y * deltaT * viewPort->rotateDirection(vec3(0.f, 0.f, -1.f)));
+
+
+
        //if ( view_x || view_y)
        //{
        //      //TODO Limit Rotation
index 75c315b6b8be17bcf6f42e3ffa348fc040f45f7e..3aab0ff9893f5203825cda871ea0c728a3353fd7 100644 (file)
@@ -5,8 +5,8 @@
 
 #include "Shader.h"
 
-#define VIEW_TOP_LIM 60.f
-#define VIEW_BOT_LIM -30.f
+#define VIEW_TOP_LIM 0.8f
+#define VIEW_BOT_LIM -0.3f
 
 
 ViewPort::ViewPort(unsigned int _x, unsigned int _y, unsigned int _width, unsigned int _height, float fovy, float zNear, float zFar) :
@@ -60,14 +60,14 @@ void ViewPort::rotateView(float angle_x, float angle_y){
                        view_angle_y = VIEW_BOT_LIM;
 
                //keine Ahnung warum hier noch durch 50 geteilt werden muss, sonst ists aber irgend wie falsch
-               view = translate(vec3(0.f, 0.f, -view_dist))*rotate(view_angle_y / 50, vec3(1.f, 0.f, 0.f))*rotate(view_angle_x / 50, vec3(0.f, 1.f, 0.f));
+               view = translate(vec3(0.f, 0.f, -view_dist))*rotate(view_angle_y *(float)M_PI_4, vec3(1.f, 0.f, 0.f))*rotate(view_angle_x * (float)M_PI_4, vec3(0.f, 1.f, 0.f));
 
        }
 
 }
 
 vec3 ViewPort::rotateDirection(const vec3 & direction) const{
-       return glm::rotateY(direction,- view_angle_x / 50);
+       return glm::rotateY(direction, -view_angle_x * (float)M_PI_4);
 }
 
 unsigned int ViewPort::getXPos() const
index 0b5bc86d0954efca2f8812813086942dc965b71d..3b2d055de95783637954ea14d1bed4b4c8f1aced 100644 (file)
@@ -31,7 +31,7 @@ void main()
 
        gl_Position = projection * view * world_position;
        worldNormal = (model * inv * vec4(normal, 0.0f)).xyz;
-       visNormal = (view * vec4(worldNormal, 0.0f)).z;
+//     visNormal = (view * vec4(worldNormal, 0.0f)).z;
 
 
        SpecularCosPoint1 = clamp(dot(vec3(0.0f, 0.0f, -1.0f), normalize((projection * view * vec4(reflect(-PointLightPosition1, worldNormal), 0.0f)).xyz)), 0, 1);
index 9b566376cc7f930a883315bd23639606cc5834f4..e36e62799375f0fb279ef71cc7832278b637ccf2 100644 (file)
@@ -10,11 +10,11 @@ uniform sampler2D ColorTexture;
  
 void main()
 {
-       if (visNormal < -0.2)
-       {
-               discard;
-       }
-       float specularConst = 5.0f;
+       //if (visNormal < -0.2)
+       //{
+       //      discard;
+       //}
+       float specularConst = 3.0f;
        vec3 normal = normalize(worldNormal);
        vec4 uvColor = texture(ColorTexture, fUVs);