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.
 
 
 

109 lines
2.9 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://www.wtfpl.net/ for more details.
  9. //
  10. //
  11. // The Camera class
  12. // ----------------
  13. //
  14. #if !defined __CAMERA_H__
  15. #define __CAMERA_H__
  16. #include "worldentity.h"
  17. namespace lol
  18. {
  19. class Camera : public WorldEntity
  20. {
  21. public:
  22. Camera();
  23. ~Camera();
  24. char const *GetName() { return "<camera>"; }
  25. //View functions
  26. void SetView(mat4 const &view);
  27. void SetView(vec3 eye, vec3 target, vec3 up);
  28. void SetView(vec3 pos, vec3 rot);
  29. void SetView(vec3 pos, quat rot);
  30. mat4 GetView() const;
  31. //Projections functions
  32. //private:
  33. void SetProjection(mat4 const &proj);
  34. public:
  35. void SetProjection(float fov, float near, float far);
  36. void SetProjection(float fov, float near, float far, float screen_size, float screen_ratio);
  37. mat4 GetProjection() const;
  38. //Projections manipulation functions
  39. void SetFov(float fov);
  40. void SetScreenInfos(float screen_size);
  41. void SetScreenInfos(float screen_size, float screen_ratio);
  42. void SetDrawInfos(float far);
  43. void SetDrawInfos(float near, float far);
  44. void SetScreenScale(vec2 scale);
  45. void UseShift(bool should_shift);
  46. void UseTarget(bool use_target);
  47. float GetFov() const { return m_fov; }
  48. float GetScreenSize() const { return m_screen_size; }
  49. float GetScreenRatio() const { return m_screen_ratio; }
  50. float GetNear() const { return m_near; }
  51. float GetFar() const { return m_far; }
  52. vec2 GetScreenScale() const { return m_screen_scale; }
  53. bool IsShifted() const { return m_is_shifted; }
  54. bool IsTargeting() const { return (m_target_distance != .0f); }
  55. //camera manipulation Functions
  56. void SetPosition(vec3 pos, bool keep_target=false);
  57. void SetTarget(vec3 target, vec3 up);
  58. void SetRotation(vec3 rot);
  59. void SetRotation(quat rot);
  60. vec3 GetPosition() const;
  61. vec3 GetTarget() const;
  62. vec3 GetUp() const;
  63. vec3 GetRotationEuler() const;
  64. quat GetRotation() const;
  65. //Convenience functions
  66. float GetFrustumHeightAtDistance(float distance, float fov) const;
  67. float GetFOVForHeightAndDistance(float distance, float height) const;
  68. protected:
  69. virtual void TickGame(float seconds);
  70. virtual void TickDraw(float seconds);
  71. //private:
  72. public:
  73. //Work datas
  74. mat4 m_view_matrix;
  75. mat4 m_proj_matrix;
  76. //Datas used to create above matrix
  77. float m_target_distance;
  78. float m_fov;
  79. float m_screen_size;
  80. float m_screen_ratio;
  81. float m_near;
  82. float m_far;
  83. vec2 m_screen_scale;
  84. bool m_is_shifted;
  85. bool m_fix_up;
  86. };
  87. } /* namespace lol */
  88. #endif /* __CAMERA_H__ */