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

Revision 386, 1.4 KB checked in by bittner, 19 years ago (diff)

VssPreprocessor? updates - directional rays, x3dexporter updates - removed duplicated code for ray exports

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