source: GTP/trunk/Lib/Vis/Preprocessing/src/Camera.h @ 2643

Revision 2643, 2.3 KB checked in by mattausch, 17 years ago (diff)

compiling under release internal

Line 
1#ifndef __CAMERA_H
2#define __CAMERA_H
3
4#include "Vector3.h"
5#include "AxisAlignedBox3.h"
6
7
8namespace GtpVisibilityPreprocessor {
9
10class KdTree;
11class SceneGraph;
12class RayCaster;
13
14class Camera
15{
16public:
17  Vector3 mPosition;
18  Vector3 mDirection;
19  /** up vector takes into account the FOV at a unit distance from the origin */
20  Vector3 mUp;
21  /** right vector takes into account the FOV at a unit distance from the origin */
22  Vector3 mRight;
23
24  float mFovy;
25  int mWidth;
26  int mHeight;
27 
28  Camera() {
29    mWidth = 100;
30    mHeight = 100;
31    mFovy = 90.0f*(float)M_PI/180.0f;
32  }
33
34  Camera(int width, int height, float fieldOfView = 90.f) {
35    mWidth = width;
36    mHeight = height;
37    mFovy = fieldOfView*(float)M_PI/180.0f;
38  }
39 
40  void Precompute() {
41    mDirection.Normalize();
42    Vector3 side = CrossProd(Vector3(0,1,0), mDirection);
43    mUp = Normalize(CrossProd(side, mDirection));
44    mRight = Normalize(CrossProd(mDirection, mUp));
45    float k = tan(mFovy/2);
46    mUp *= k;
47    mRight *= k*mWidth/mHeight;
48  }
49
50  void SetPosition(const Vector3 &pos) {
51    mPosition = pos;
52    Precompute();
53  }
54
55  void SetDirection(const Vector3 &dir) {
56    mDirection = dir;
57    Precompute();
58  }
59
60  void LookInBox(const AxisAlignedBox3 &box)
61  {
62    mDirection = Vector3(0,0,1);
63    mPosition = box.Center();
64    Precompute();
65  }
66   
67
68  void LookAtBox(const AxisAlignedBox3 &box)
69  {
70    mDirection = box.Max() - box.Min();
71    mPosition = box.Min() - mDirection;
72    Precompute();
73  }
74 
75  bool
76  SnapImage(std::string filename,
77            KdTree *tree,
78            SceneGraph *sceneGraph
79            );
80
81  bool
82  SnapImage(std::string filename,
83            RayCaster *raycaster,
84            AxisAlignedBox3 &bbox,
85            SceneGraph *sceneGraph
86            );
87
88  bool
89  SnapImage2(std::string filename,
90             RayCaster *raycaster,
91             AxisAlignedBox3 &bbox,
92             SceneGraph *sceneGraph
93             );
94 
95  bool
96  SnapImagePacket(std::string filename,
97                  RayCaster *raycaster,
98                  AxisAlignedBox3 &bbox,
99                  SceneGraph *sceneGraph
100                  );
101
102  bool
103  SnapImagePacket2(std::string filename,
104                  RayCaster *raycaster,
105                  AxisAlignedBox3 &bbox,
106                  SceneGraph *sceneGraph
107                  );
108
109  void SetupRay(Ray &ray, const int x, const int y);
110
111  void SetupRay(SimpleRay &ray, const int x, const int y);
112};
113
114};
115
116#endif
Note: See TracBrowser for help on using the repository browser.