Revision 312,
1.3 KB
checked in by mattausch, 19 years ago
(diff) |
bsp split exporter added
|
Line | |
---|
1 | #ifndef __CAMERA_H
|
---|
2 | #define __CAMERA_H
|
---|
3 |
|
---|
4 | #include "Vector3.h"
|
---|
5 | #include "AxisAlignedBox3.h"
|
---|
6 |
|
---|
7 | class KdTree;
|
---|
8 |
|
---|
9 | class Camera
|
---|
10 | {
|
---|
11 | public:
|
---|
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 LookInBox(const AxisAlignedBox3 &box)
|
---|
45 | {
|
---|
46 | mDirection = Vector3(0,0,1);
|
---|
47 | mPosition = box.Center();
|
---|
48 | Precompute();
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | void LookAtBox(const AxisAlignedBox3 &box)
|
---|
53 | {
|
---|
54 | mDirection = box.Max() - box.Min();
|
---|
55 | mPosition = box.Min() - mDirection;
|
---|
56 | Precompute();
|
---|
57 | }
|
---|
58 |
|
---|
59 | bool
|
---|
60 | SnapImage(string filename, KdTree *tree);
|
---|
61 |
|
---|
62 | void SetupRay(Ray &ray, const int x, const int y);
|
---|
63 |
|
---|
64 | };
|
---|
65 |
|
---|
66 |
|
---|
67 | #endif
|
---|
Note: See
TracBrowser
for help on using the repository browser.