Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
3dcamera.hpp
1 //////////////////////////////
2 //
3 // File: lxs/coregraphics/3dcamera.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Nov 27 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_R3DCAMERA__
15 #define __LXS_R3DCAMERA__
16 #include "lxs/coregraphics/renderable.hpp"
17 namespace LxS
18 {
19  namespace CoreGraphics
20  {
21  class Renderable;
22  //! dynamic 3D camera object for setting camera perspectives in 3D space and convenient maniputation of it (compare: GLCamera being lower level object)
23  class R3DCamera:public Renderable
24  {
25  friend class Map;
26  // angle
27  float angle_y, angle_x, t_angle_y, t_angle_x,
28  // position
29  x, y, z, t_x, t_y, t_z;
30  float av_y,av_x, v_y,v_x, v_z;//, velocity;
31 
32  public:
33  //! \brief Set position in XYZ coordinate system
34  //! \param x x coordinate (width)
35  //! \param y y coordinate (height)
36  //! \param z z coordinate (depth)
37  void SetPosition(float x,float y,float z);
38  //! \brief set angle at which target is viewed
39  void SetRotation(float x,float y);
40 
41  //! relative rotation around x axis
42  void RotateX(float x) {angle_x+=x;t_angle_x=angle_x;}
43  //! relative rotation around y axis
44  void RotateY(float y) {angle_y+=y;t_angle_y=angle_y;}
45  //! return current camera position
46  float GetPositionX() { return x;}
47  //! return current camera position
48  float GetPositionY() { return y;}
49  //! return current camera position
50  float GetPositionZ() { return z;}
51 
52  //! set target position; camera will pan to a position; velocity is auto-adjusted
53  void SetTargetPosition(float x,float y,float z);
54  //! set camera to rotate around focal point; angular velocity is auto-adjusted
55  void SetTargetRotation(float x,float y);
56  //! set up default variables
57  virtual void Initialize(); // load and set up some resources
58  //! animate camera movement
59  virtual void Animate(float dt);
60  virtual void Render(Rendermode mode);
61  //! it is to fulfill gameobject API. actually no resources are allocated, so no resources to free
62  virtual void UnloadResources();
63  //! get angle at which target is viewed
64  float GetRotationY() {return angle_y;}
65  //! get angle at which target is viewed
66  float GetRotationX() {return angle_x;}
67 
68  //! Finish movement. (after setting target position by default camera
69  //! will slowly start moving to achieve that position; by issuing this command
70  //! one can move camera to target position immediately
71  void SetPositionTarget() {x=t_x; y=t_y; z=t_z;}
72 
73  unsigned long GetTexelsCount() { return 0;}
74  unsigned long GetFacesCount() { return 0;}
75 
76  };
77  }
78 }
79 #endif