source: trunk/VUT/GtpVisibilityPreprocessor/src/Camera.h @ 492

Revision 492, 1.5 KB checked in by bittner, 18 years ago (diff)

Large merge - viewcells seem not functional now

Line 
1#ifndef __CAMERA_H
2#define __CAMERA_H
3
4#include "Vector3.h"
5#include "AxisAlignedBox3.h"
6
7class KdTree;
8class SceneGraph;
9
10class Camera
11{
12public:
13  Vector3 mPosition;
14  Vector3 mDirection;
15  /** up vector takes into account the FOV at a unit distance from the origin */
16  Vector3 mUp;
17  /** right vector takes into account the FOV at a unit distance from the origin */
18  Vector3 mRight;
19
20  float mFovy;
21  int mWidth;
22  int mHeight;
23 
24  Camera() {
25    mWidth = 1400;
26    mHeight = 1000;
27    mFovy = 60.0f*(float)M_PI/180.0f;
28  }
29 
30  void Precompute() {
31    mDirection.Normalize();
32    Vector3 side = CrossProd(Vector3(0,1,0), mDirection);
33    mUp = Normalize(CrossProd(side, mDirection));
34    mRight = Normalize(CrossProd(mDirection, mUp));
35    float k = tan(mFovy/2);
36    mUp *= k;
37    mRight *= k*mWidth/mHeight;
38  }
39
40  void SetPosition(const Vector3 &pos) {
41    mPosition = pos;
42    Precompute();
43  }
44
45        void SetDirection(const Vector3 &dir) {
46    mDirection = dir;
47    Precompute();
48  }
49
50  void LookInBox(const AxisAlignedBox3 &box)
51  {
52    mDirection = Vector3(0,0,1);
53    mPosition = box.Center();
54    Precompute();
55  }
56   
57
58  void LookAtBox(const AxisAlignedBox3 &box)
59  {
60    mDirection = box.Max() - box.Min();
61    mPosition = box.Min() - mDirection;
62    Precompute();
63  }
64 
65  bool
66  SnapImage(string filename,
67                        KdTree *tree,
68                        SceneGraph *sceneGraph
69                        );
70
71  void SetupRay(Ray &ray, const int x, const int y);
72
73};
74
75
76#endif
Note: See TracBrowser for help on using the repository browser.