[2798] | 1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
[953] | 2 | /* |
---|
| 3 | * ---------------------------------------------------------------------- |
---|
| 4 | * NvCamera.h : NvCamera class |
---|
| 5 | * |
---|
| 6 | * ====================================================================== |
---|
| 7 | * AUTHOR: Wei Qiao <qiaow@purdue.edu> |
---|
| 8 | * Purdue Rendering and Perceptualization Lab (PURPL) |
---|
| 9 | * |
---|
| 10 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
| 11 | * |
---|
| 12 | * See the file "license.terms" for information on usage and |
---|
| 13 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 14 | * ====================================================================== |
---|
| 15 | */ |
---|
[2836] | 16 | #ifndef CAMERA_H |
---|
| 17 | #define CAMERA_H |
---|
[953] | 18 | |
---|
| 19 | #include "Vector3.h" |
---|
| 20 | |
---|
[2836] | 21 | class NvCamera |
---|
| 22 | { |
---|
[1215] | 23 | public: |
---|
[953] | 24 | NvCamera(int startx, int starty, int w, int h, |
---|
[1215] | 25 | float loc_x, float loc_y, float loc_z, |
---|
| 26 | float target_x, float target_y, float target_z, |
---|
| 27 | float angle_x, float angle_y, float angle_z); |
---|
| 28 | |
---|
[2836] | 29 | ~NvCamera() |
---|
| 30 | {} |
---|
| 31 | |
---|
| 32 | |
---|
[1215] | 33 | //move location of camera |
---|
[2836] | 34 | void x(float loc_x) |
---|
| 35 | { |
---|
| 36 | _location.x = loc_x; |
---|
[1215] | 37 | } |
---|
[2836] | 38 | |
---|
| 39 | float x() const |
---|
| 40 | { |
---|
| 41 | return _location.x; |
---|
[1215] | 42 | } |
---|
[2836] | 43 | |
---|
| 44 | void y(float loc_y) |
---|
| 45 | { |
---|
| 46 | _location.y = loc_y; |
---|
[1215] | 47 | } |
---|
[2836] | 48 | |
---|
| 49 | float y() const |
---|
| 50 | { |
---|
| 51 | return _location.y; |
---|
[1215] | 52 | } |
---|
[2836] | 53 | |
---|
| 54 | void z(float loc_z) |
---|
| 55 | { |
---|
| 56 | _location.z = loc_z; |
---|
[1215] | 57 | } |
---|
[2836] | 58 | |
---|
| 59 | float z() const |
---|
| 60 | { |
---|
| 61 | return _location.z; |
---|
[1215] | 62 | } |
---|
| 63 | |
---|
[1236] | 64 | //move location of target |
---|
[2836] | 65 | void xAim(float x) |
---|
| 66 | { |
---|
| 67 | _target.x = x; |
---|
[1215] | 68 | } |
---|
[2836] | 69 | |
---|
| 70 | float xAim() const |
---|
| 71 | { |
---|
| 72 | return _target.x; |
---|
[1215] | 73 | } |
---|
[2836] | 74 | |
---|
| 75 | void yAim(float y) |
---|
| 76 | { |
---|
| 77 | _target.y = y; |
---|
[1236] | 78 | } |
---|
[2836] | 79 | |
---|
| 80 | float yAim() const |
---|
| 81 | { |
---|
| 82 | return _target.y; |
---|
[1236] | 83 | } |
---|
[2836] | 84 | |
---|
| 85 | void zAim(float z) |
---|
| 86 | { |
---|
| 87 | _target.z = z; |
---|
[1236] | 88 | } |
---|
[2836] | 89 | |
---|
| 90 | float zAim() const |
---|
| 91 | { |
---|
| 92 | return _target.z; |
---|
[1236] | 93 | } |
---|
| 94 | |
---|
[2836] | 95 | void rotate(float angle_x, float angle_y, float angle_z) |
---|
| 96 | { |
---|
| 97 | _angle = Vector3(angle_x, angle_y, angle_z); |
---|
[1215] | 98 | } |
---|
[2836] | 99 | |
---|
| 100 | void rotate(const Vector3& angle) |
---|
| 101 | { |
---|
| 102 | _angle = angle; |
---|
[1215] | 103 | } |
---|
[2836] | 104 | |
---|
| 105 | Vector3 rotate() const |
---|
| 106 | { |
---|
| 107 | return _angle; |
---|
[1215] | 108 | } |
---|
[2836] | 109 | |
---|
| 110 | void set_screen_size(int sx, int sy, int w, int h) |
---|
| 111 | { |
---|
| 112 | _width = w; |
---|
| 113 | _height = h; |
---|
| 114 | _startX = sx; |
---|
| 115 | _startY = sy; |
---|
[1215] | 116 | } |
---|
[2836] | 117 | |
---|
| 118 | //make the camera setting active, this has to be |
---|
| 119 | //called before drawing things |
---|
| 120 | void initialize(); |
---|
| 121 | |
---|
| 122 | private: |
---|
| 123 | Vector3 _location; //Location of the camera in the scene |
---|
| 124 | Vector3 _target; //Location the camera is looking at. |
---|
| 125 | //location and target: two points define the |
---|
| 126 | //line-of-sight |
---|
| 127 | Vector3 _angle; //rotation angles of camera along x, y, z |
---|
| 128 | int _width; //screen width |
---|
| 129 | int _height; //screen height |
---|
| 130 | int _startX; |
---|
| 131 | int _startY; |
---|
[953] | 132 | }; |
---|
| 133 | |
---|
| 134 | #endif |
---|