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

Revision 2575, 2.0 KB checked in by bittner, 17 years ago (diff)

big merge: preparation for havran ray caster, check if everything works

RevLine 
[162]1#ifndef __CAMERA_H
2#define __CAMERA_H
3
4#include "Vector3.h"
5#include "AxisAlignedBox3.h"
6
[860]7namespace GtpVisibilityPreprocessor {
8
[162]9class KdTree;
[492]10class SceneGraph;
[2575]11class RayCaster;
[162]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() {
[1583]28    mWidth = 100;
29    mHeight = 100;
[878]30    mFovy = 90.0f*(float)M_PI/180.0f;
[162]31  }
[2575]32
33  Camera(int width, int height) {
34    mWidth = width;
35    mHeight = height;
36    mFovy = 90.0f*(float)M_PI/180.0f;
37  }
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
89  SnapImagePacket(std::string filename,
90                  RayCaster *raycaster,
91                  AxisAlignedBox3 &bbox,
92                  SceneGraph *sceneGraph
93                  );
94 
[162]95  void SetupRay(Ray &ray, const int x, const int y);
96
[2575]97  void SetupRay(SimpleRay &ray, const int x, const int y);
[162]98};
99
[863]100};
[162]101
102#endif
Note: See TracBrowser for help on using the repository browser.