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

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

ray casting issue partially solved

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