source: trunk/packages/vizservers/nanovis/NvCamera.h @ 2877

Last change on this file since 2877 was 2877, checked in by ldelgass, 13 years ago

Some minor refactoring, also add some more fine grained config.h defines
(e.g. replace NV40 define with feature defines). Add tests for some required
OpenGL extensions (should always check for extensions or base version before
calling entry points from the extension). Also, clamp diffuse and specular
values on input and warn when they are out of range.

  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
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#ifndef CAMERA_H
17#define CAMERA_H
18
19#include <vrmath/vrMatrix4x4f.h>
20
21#include "config.h"
22#include "Vector3.h"
23
24class NvCamera
25{
26public:
27    NvCamera(int startx, int starty, int w, int h,
28             float loc_x, float loc_y, float loc_z,
29             float target_x, float target_y, float target_z,
30             float angle_x, float angle_y, float angle_z);
31
32    ~NvCamera()
33    {}
34
35    //move location of camera
36    void x(float loc_x)
37    {
38        _location.x = loc_x;
39    }
40
41    float x() const
42    {
43        return _location.x;
44    }
45
46    void y(float loc_y)
47    {
48        _location.y = loc_y;
49    }
50
51    float y() const
52    {
53        return _location.y;
54    }
55
56    void z(float loc_z)
57    {
58        _location.z = loc_z;
59    }
60
61    float z() const
62    {
63        return _location.z;
64    }
65
66    //move location of target
67    void xAim(float x)
68    {
69        _target.x = x;
70    }
71
72    float xAim() const
73    {
74        return _target.x;
75    }
76
77    void yAim(float y)
78    {
79        _target.y = y;
80    }
81
82    float yAim() const
83    {
84        return _target.y;
85    }
86
87    void zAim(float z)
88    {
89        _target.z = z;
90    }
91
92    float zAim() const
93    {
94        return _target.z;
95    }
96
97    void rotate(double *quat);
98
99    void rotate(float angle_x, float angle_y, float angle_z);
100
101    void rotate(const Vector3& angle);
102
103    Vector3 rotate() const
104    {
105        return _angle;
106    }
107
108    void set_screen_size(int sx, int sy, int w, int h)
109    {
110        _width = w;
111        _height = h;
112        _startX = sx;
113        _startY = sy;
114    }
115
116    /**
117     * \brief Make the camera setting active, this has to be
118     * called before drawing things
119     */
120    void initialize();
121
122private:
123    /// Location of the camera in the scene
124    Vector3 _location;
125    /**
126     * \brief Location the camera is looking at
127     *
128     * Location and target: two points define the line-of-sight
129     */
130    Vector3 _target;
131    /// rotation angles of camera along x, y, z
132    Vector3 _angle;
133
134    vrMatrix4x4f _cameraMatrix;
135
136    /// screen width
137    int _width;
138    /// screen height
139    int _height;
140    int _startX;
141    int _startY;
142};
143
144#endif
Note: See TracBrowser for help on using the repository browser.