Small OpenGL based c++ rendering library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glcamera.h 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* libsegl - Sebas Extended GL Library
  2. * Collection of Opengl/3D-Math helpers
  3. *
  4. * Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
  5. * http://www.seba-geek.de
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __GLCAMERA_H
  23. #define __GLCAMERA_H
  24. #include <iostream>
  25. #include <SDL.h>
  26. #include <SDL_opengl.h>
  27. #include "rotationsmatrix.h"
  28. #include "emath_opengl.h"
  29. #include "punkt3d.h"
  30. namespace segl {
  31. class GLCamera {
  32. private:
  33. Punkt3D std_dir;
  34. Punkt3D std_norm;
  35. Punkt3D pos;
  36. Punkt3D norm;
  37. Punkt3D dir; // normalisiert
  38. float rotx;
  39. float roty;
  40. bool doupdate;
  41. float mpersec;
  42. float apersec;
  43. Rotationsmatrix rotmatX;
  44. Rotationsmatrix rotmatY;
  45. void updateVectors();
  46. public:
  47. GLCamera();
  48. // GLCamera(Punkt3d
  49. void setCamera();
  50. void setPosDirNorm(Punkt3D p, Punkt3D D, Punkt3D n);
  51. // Std Move
  52. void moveForward(float sec);
  53. void moveBackward(float sec);
  54. void moveLeft(float sec);
  55. void moveRight(float sec);
  56. void rotateLeft(float sec);
  57. void rotateRight(float sec);
  58. void rotateUp(float sec);
  59. void rotateDown(float sec);
  60. void handleKeys(float sec);
  61. float getXrot();
  62. float getYrot();
  63. void print();
  64. void renderCoord();
  65. Punkt3D getPos();
  66. ~GLCamera();
  67. };
  68. } // namespace segl {
  69. #endif