1 | /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ |
---|
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(float loc_x) { |
---|
45 | location_.x = loc_x; |
---|
46 | } |
---|
47 | float x(void) { |
---|
48 | return location_.x; |
---|
49 | } |
---|
50 | void y(float loc_y) { |
---|
51 | location_.y = loc_y; |
---|
52 | } |
---|
53 | float y(void) { |
---|
54 | return location_.y; |
---|
55 | } |
---|
56 | void z(float loc_z) { |
---|
57 | location_.z = loc_z; |
---|
58 | } |
---|
59 | float z(void) { |
---|
60 | return location_.z; |
---|
61 | } |
---|
62 | |
---|
63 | //move location of target |
---|
64 | void xAim(float x) { |
---|
65 | target_.x = x; |
---|
66 | } |
---|
67 | float xAim(void) { |
---|
68 | return target_.x; |
---|
69 | } |
---|
70 | void yAim(float y) { |
---|
71 | target_.y = y; |
---|
72 | } |
---|
73 | float yAim(void) { |
---|
74 | return target_.y; |
---|
75 | } |
---|
76 | void zAim(float z) { |
---|
77 | target_.z = z; |
---|
78 | } |
---|
79 | float zAim(void) { |
---|
80 | return target_.z; |
---|
81 | } |
---|
82 | |
---|
83 | void rotate(float angle_x, float angle_y, float angle_z) { |
---|
84 | angle_ = Vector3(angle_x, angle_y, angle_z); |
---|
85 | } |
---|
86 | void rotate(Vector3 angle) { |
---|
87 | angle_ = angle; |
---|
88 | } |
---|
89 | Vector3 rotate(void) { |
---|
90 | return angle_; |
---|
91 | } |
---|
92 | void set_screen_size(int sx, int sy, int w, int h) { |
---|
93 | width_ = w, height_ = h; |
---|
94 | startX_ = sx, startY_ = sy; |
---|
95 | } |
---|
96 | void initialize(void); //make the camera setting active, this has to be |
---|
97 | //called before drawing things. |
---|
98 | }; |
---|
99 | |
---|
100 | #endif |
---|