source: nanovis/branches/1.1/Camera.h @ 4906

Last change on this file since 4906 was 4904, checked in by ldelgass, 9 years ago

Merge serveral changes from trunk. Does not include threading, world space
changes, etc.

  • 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 * Copyright (c) 2004-2013  HUBzero Foundation, LLC
4 *
5 *  Authors:
6 *    Wei Qiao <qiaow@purdue.edu>
7 */
8#ifndef NV_CAMERA_H
9#define NV_CAMERA_H
10
11#include <vrmath/Matrix4x4d.h>
12#include <vrmath/Vector3f.h>
13
14#include "config.h"
15
16namespace nv {
17
18class Camera
19{
20public:
21    enum AxisDirection {
22        X_POS = 1,
23        Y_POS = 2,
24        Z_POS = 3,
25        X_NEG = -1,
26        Y_NEG = -2,
27        Z_NEG = -3
28    };
29
30    Camera(int x, int y, int width, int height);
31
32    ~Camera()
33    {}
34
35    void setUpdir(AxisDirection dir)
36    {
37        setUpDirMatrix(dir);
38    }
39
40    AxisDirection getUpdir()
41    {
42        return _updir;
43    }
44
45    void setPosition(const vrmath::Vector3f& pos)
46    {
47        _position = pos;
48    }
49
50    const vrmath::Vector3f& getPosition() const
51    {
52        return _position;
53    }
54
55    void x(float loc_x)
56    {
57        _position.x = loc_x;
58    }
59
60    float x() const
61    {
62        return _position.x;
63    }
64
65    void y(float loc_y)
66    {
67        _position.y = loc_y;
68    }
69
70    float y() const
71    {
72        return _position.y;
73    }
74
75    void z(float loc_z)
76    {
77        _position.z = loc_z;
78    }
79
80    float z() const
81    {
82        return _position.z;
83    }
84
85    void orient(double *quat);
86
87    void orient(float angleX, float angleY, float angleZ);
88
89    void setFov(float fov)
90    {
91        _fov = fov;
92    }
93
94    float getFov() const
95    {
96        return _fov;
97    }
98
99    void reset(const vrmath::Vector3f& bboxMin,
100               const vrmath::Vector3f& bboxMax,
101               bool resetOrientation = false);
102
103    void resetClippingRange(const vrmath::Vector3f& bboxMin,
104                            const vrmath::Vector3f& bboxMax);
105
106    void setViewport(int x, int y, int width, int height)
107    {
108        _viewport[0] = x;
109        _viewport[1] = y;
110        _viewport[2] = width;
111        _viewport[3] = height;
112    }
113
114    /**
115     * \brief Make the camera setting active, this has to be
116     * called before drawing things
117     */
118    void initialize();
119
120    void print() const;
121
122    void getProjectionMatrix(vrmath::Matrix4x4d& mat);
123
124    const vrmath::Matrix4x4d& getUpDirMatrix() const;
125
126private:
127    void setClippingRange(float near, float far)
128    {
129        _near = near;
130        _far = far;
131    }
132
133    void setUpDirMatrix(AxisDirection dir);
134
135    AxisDirection _updir;
136
137    /// Position of the camera in the scene
138    vrmath::Vector3f _position;
139
140    /// Model transform for z-up scene
141    vrmath::Matrix4x4d _updirMatrix;
142    /// Camera orientation
143    vrmath::Matrix4x4d _rotationMatrix;
144
145    /// Field of view (vertical angle in degrees)
146    float _fov;
147    /// Near, far z clipping
148    float _near, _far;
149
150    // x, y, width, height
151    int _viewport[4];
152};
153
154}
155
156#endif
Note: See TracBrowser for help on using the repository browser.