1 | |
---|
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 | */ |
---|
16 | |
---|
17 | #ifndef _CAMERA_H_ |
---|
18 | #define _CAMERA_H_ |
---|
19 | |
---|
20 | #include "Vector3.h" |
---|
21 | |
---|
22 | class NvCamera { |
---|
23 | |
---|
24 | Vector3 location_; //Location of the camera in the scene |
---|
25 | Vector3 target_; //Location the camera is looking at. |
---|
26 | //location and target: two points define the |
---|
27 | //line-of-sight |
---|
28 | Vector3 angle_; //rotation angles of camera along x, y, z |
---|
29 | int width_; //screen width |
---|
30 | int height_; //screen height |
---|
31 | int startX_; |
---|
32 | int startY_; |
---|
33 | |
---|
34 | public: |
---|
35 | ~NvCamera(void) { |
---|
36 | /*empty*/ |
---|
37 | } |
---|
38 | NvCamera(int startx, int starty, int w, int h, |
---|
39 | float loc_x, float loc_y, float loc_z, |
---|
40 | float target_x, float target_y, float target_z, |
---|
41 | float angle_x, float angle_y, float angle_z); |
---|
42 | |
---|
43 | //move location of camera |
---|
44 | void x(double loc_x) { |
---|
45 | location_.x = loc_x; |
---|
46 | } |
---|
47 | float x(void) { |
---|
48 | return location_.x; |
---|
49 | } |
---|
50 | void y(double loc_y) { |
---|
51 | location_.y = loc_y; |
---|
52 | } |
---|
53 | float y(void) { |
---|
54 | return location_.y; |
---|
55 | } |
---|
56 | void z(double loc_z) { |
---|
57 | location_.z = loc_z; |
---|
58 | } |
---|
59 | float z(void) { |
---|
60 | return location_.z; |
---|
61 | } |
---|
62 | |
---|
63 | void aim(double target_x, double target_y, double target_z) { |
---|
64 | target_ = Vector3(target_x, target_y, target_z); |
---|
65 | } |
---|
66 | Vector3 aim(void) { |
---|
67 | return target_; |
---|
68 | } |
---|
69 | void rotate(double angle_x, double angle_y, double angle_z) { |
---|
70 | angle_ = Vector3(angle_x, angle_y, angle_z); |
---|
71 | } |
---|
72 | void rotate(Vector3 angle) { |
---|
73 | angle_ = angle; |
---|
74 | } |
---|
75 | Vector3 rotate(void) { |
---|
76 | return angle_; |
---|
77 | } |
---|
78 | void set_screen_size(int sx, int sy, int w, int h) { |
---|
79 | width_ = w, height_ = h; |
---|
80 | startX_ = sx, startY_ = sy; |
---|
81 | } |
---|
82 | void activate(void); //make the camera setting active, this has to be |
---|
83 | //called before drawing things. |
---|
84 | }; |
---|
85 | |
---|
86 | #endif |
---|