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

RevLine 
[162]1#ifndef __CAMERA_H
2#define __CAMERA_H
3
4#include "Vector3.h"
5#include "AxisAlignedBox3.h"
6
[2643]7
[860]8namespace GtpVisibilityPreprocessor {
9
[162]10class KdTree;
[492]11class SceneGraph;
[2575]12class RayCaster;
[162]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() {
[1583]29    mWidth = 100;
30    mHeight = 100;
[878]31    mFovy = 90.0f*(float)M_PI/180.0f;
[162]32  }
[2575]33
[2629]34  Camera(int width, int height, float fieldOfView = 90.f) {
[2575]35    mWidth = width;
36    mHeight = height;
[2629]37    mFovy = fieldOfView*(float)M_PI/180.0f;
[2575]38  }
[162]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
[2575]55  void SetDirection(const Vector3 &dir) {
[386]56    mDirection = dir;
57    Precompute();
58  }
59
[162]60  void LookInBox(const AxisAlignedBox3 &box)
61  {
[2575]62    mDirection = Vector3(0,0,1);
[162]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
[2575]76  SnapImage(std::string filename,
77            KdTree *tree,
78            SceneGraph *sceneGraph
79            );
[162]80
[2575]81  bool
82  SnapImage(std::string filename,
83            RayCaster *raycaster,
84            AxisAlignedBox3 &bbox,
85            SceneGraph *sceneGraph
86            );
87
88  bool
[2629]89  SnapImage2(std::string filename,
90             RayCaster *raycaster,
91             AxisAlignedBox3 &bbox,
92             SceneGraph *sceneGraph
93             );
94 
95  bool
[2575]96  SnapImagePacket(std::string filename,
97                  RayCaster *raycaster,
98                  AxisAlignedBox3 &bbox,
99                  SceneGraph *sceneGraph
100                  );
[2629]101
102  bool
103  SnapImagePacket2(std::string filename,
104                  RayCaster *raycaster,
105                  AxisAlignedBox3 &bbox,
106                  SceneGraph *sceneGraph
107                  );
108
[162]109  void SetupRay(Ray &ray, const int x, const int y);
110
[2575]111  void SetupRay(SimpleRay &ray, const int x, const int y);
[162]112};
113
[863]114};
[162]115
116#endif
Note: See TracBrowser for help on using the repository browser.