Revision 469,
1.4 KB
checked in by mattausch, 19 years ago
(diff) |
updated view cells, view cell manager. changed rendersimulator
|
Rev | Line | |
---|
[162] | 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;
|
---|
[469] | 26 | mFovy = 60.0f*(float)M_PI/180.0f;
|
---|
[162] | 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 |
|
---|
[386] | 44 | void SetDirection(const Vector3 &dir) {
|
---|
| 45 | mDirection = dir;
|
---|
| 46 | Precompute();
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[162] | 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.