www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit da80887bee39f533d4ad24052fff158546947570
parent 4e0853e54f41ca32cc27a861cb6f7cb025ea6227
Author: Yoann <yoann.b87@voila.fr>
Date:   Mon, 28 Nov 2011 19:07:00 +0100

Dernière correction sur la camera et nettoyage du code.

Diffstat:
Mview.cpp | 21++++++++-------------
Mview.hh | 12++++--------
2 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/view.cpp b/view.cpp @@ -1,9 +1,7 @@ #include "all_includes.hh" -View::View(Chose* root) : root(root), cameraCenter(500,-500,100), cameraDist(300), xSight(0), ySight(0), zSight(0), xAngle(0), yAngle(0), moveDist(10) { - xSight = cameraCenter.x + 20; - ySight = cameraCenter.y; - zSight = cameraCenter.z; +View::View(Chose* root) : root(root), cameraCenter(500,-500,100), xAngle(0), yAngle(0), moveDist(40) { + cameraSight = cameraCenter + Vertex::fromSpherical(100, yAngle, xAngle); initWindow(); mainLoop(); } @@ -86,14 +84,11 @@ void View::displayAxes() { void View::renderScene() { glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - //gluLookAt(1024,512,1356,1024,512,0,0,1,0); - //glClearColor(1,1,1,1); // pour un fond blanc glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) ; - Vertex sight; - sight = cameraCenter + Vertex::fromSpherical(100, yAngle, xAngle); - gluLookAt(cameraCenter.x,cameraCenter.y,cameraCenter.z, sight.x, sight.y, sight.z,0,0,1); + cameraSight = cameraCenter + Vertex::fromSpherical(100, yAngle, xAngle); + gluLookAt(cameraCenter.x,cameraCenter.y,cameraCenter.z, cameraSight.x, cameraSight.y, cameraSight.z,0,0,1); displayAxes(); glBegin(GL_TRIANGLES); @@ -117,10 +112,10 @@ void View::mainLoop() { case SDL_KEYDOWN: switch(event.key.keysym.sym) { case SDLK_DOWN: - cameraCenter = cameraCenter + Vertex::fromSpherical(100, yAngle, xAngle); + cameraCenter = cameraCenter - Vertex::fromSpherical(moveDist, yAngle, xAngle); break; case SDLK_UP: - cameraCenter = cameraCenter - Vertex::fromSpherical(100, yAngle, xAngle); + cameraCenter = cameraCenter + Vertex::fromSpherical(moveDist, yAngle, xAngle); break; default: break; @@ -128,8 +123,8 @@ void View::mainLoop() { break; case SDL_MOUSEMOTION: - xAngle = (event.motion.x - (windowWidth/2))*340/windowWidth; - yAngle = (event.motion.y - (windowHeight/2))*340/windowHeight; + xAngle = 90 - (event.motion.x - (windowWidth/2))*340/windowWidth; + yAngle = 90 + (event.motion.y - (windowHeight/2))*340/windowHeight; break; default: diff --git a/view.hh b/view.hh @@ -10,24 +10,20 @@ // Prendre en compte tous les évènements X en attente avant de relancer le rendu. class View { -private: + private: Chose* root; static const int windowWidth = 1024; static const int windowHeight = 768; Vertex cameraCenter; - - int cameraDist; - - int xSight; - int ySight; - int zSight; + Vertex cameraSight; float xAngle; float yAngle; int moveDist; -public: + + public: View(Chose* root); void initWindow(); void mainLoop();