Line data Source code
1 :
2 : /* Copyright (c) 2006-2017, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Daniel Nachbaur <danielnachbaur@gmail.com>
4 : *
5 : * This library is free software; you can redistribute it and/or modify it under
6 : * the terms of the GNU Lesser General Public License version 2.1 as published
7 : * by the Free Software Foundation.
8 : *
9 : * This library is distributed in the hope that it will be useful, but WITHOUT
10 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 : * details.
13 : *
14 : * You should have received a copy of the GNU Lesser General Public License
15 : * along with this library; if not, write to the Free Software Foundation, Inc.,
16 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 : */
18 :
19 : #ifndef EQFABRIC_WALL_H
20 : #define EQFABRIC_WALL_H
21 :
22 : #include <eq/fabric/api.h>
23 : #include <eq/fabric/types.h>
24 : #include <eq/fabric/vmmlib.h>
25 : #include <iostream>
26 :
27 : namespace eq
28 : {
29 : namespace fabric
30 : {
31 : /**
32 : * A wall defining a view frustum.
33 : *
34 : * The three points describe the bottom left, bottom right and top left
35 : * coordinate of the wall in real-world coordinates (meters).
36 : */
37 1623 : class Wall
38 : {
39 : public:
40 : /** Construct a new wall description. */
41 : EQFABRIC_API Wall();
42 :
43 : /** Construct a new wall description with default values. */
44 : EQFABRIC_API Wall(const Vector3f& bottomLeft, const Vector3f& bottomRight,
45 : const Vector3f& topLeft);
46 :
47 : /**
48 : * Resize the wall horizontally.
49 : *
50 : * @param ratio the amount by which the wall is grown or shrunk.
51 : * @version 1.0
52 : */
53 : EQFABRIC_API void resizeHorizontal(const float ratio);
54 :
55 : /**
56 : * Resize the wall vertically.
57 : *
58 : * @param ratio the amount by which the wall is grown or shrunk.
59 : * @version 1.0
60 : */
61 : EQFABRIC_API void resizeVertical(const float ratio);
62 :
63 : /**
64 : * Resize the wall on the left side.
65 : *
66 : * @param ratio the amount by which the wall is grown or shrunk.
67 : * @version 1.0
68 : */
69 : EQFABRIC_API void resizeLeft(const float ratio);
70 :
71 : /**
72 : * Resize the wall on the right side.
73 : *
74 : * @param ratio the amount by which the wall is grown or shrunk.
75 : * @version 1.0
76 : */
77 : EQFABRIC_API void resizeRight(const float ratio);
78 :
79 : /**
80 : * Resize the wall on the top side.
81 : *
82 : * @param ratio the amount by which the wall is grown or shrunk.
83 : * @version 1.0
84 : */
85 : EQFABRIC_API void resizeTop(const float ratio);
86 :
87 : /**
88 : * Resize the wall on the bottom side.
89 : *
90 : * @param ratio the amount by which the wall is grown or shrunk.
91 : * @version 1.0
92 : */
93 : EQFABRIC_API void resizeBottom(const float ratio);
94 :
95 : /**
96 : * Resize the wall horizontally to match the given aspect ratio.
97 : *
98 : * @param aspectRatio the destination aspect ratio.
99 : * @version 1.1.2
100 : */
101 : EQFABRIC_API void resizeHorizontalToAR(const float aspectRatio);
102 :
103 : /**
104 : * Resize the wall by the given ratio as observed from the eye position.
105 : *
106 : * Each wall corner is moved by ratio along the vector eye -> wall
107 : * corner.
108 : *
109 : * @param eye the observer position
110 : * @param ratio the relative ratio to the current position
111 : * @version 1.1
112 : */
113 : EQFABRIC_API void moveFocus(const Vector3f& eye, const float ratio);
114 :
115 : /**
116 : * Compute the sub-frustum for a 2D area on the full wall.
117 : * @version 1.0
118 : */
119 : EQFABRIC_API void apply(const Viewport& viewport);
120 :
121 : /**
122 : * Move each wall corner by the given ratio.
123 : * @version 1.3.1
124 : */
125 : EQFABRIC_API void scale(const float ratio);
126 :
127 : /**
128 : * Set the wall parameters from a projection description.
129 : * @version 1.0
130 : */
131 : EQFABRIC_API Wall& operator=(const Projection& projection);
132 :
133 : /**
134 : * Set the wall parameters from an inverse projection matrix.
135 : * @version 1.5.2
136 : */
137 : EQFABRIC_API Wall& operator=(const Matrix4f& xfm);
138 :
139 : /** @return the width of the wall. @version 1.0 */
140 1 : float getWidth() const { return (bottomRight - bottomLeft).length(); }
141 : /** @return the height of the wall. @version 1.0 */
142 1 : float getHeight() const { return (topLeft - bottomLeft).length(); }
143 : /** @return true if the two walls are identical. @version 1.0 */
144 : EQFABRIC_API bool operator==(const Wall& rhs) const;
145 :
146 : /** @return true if the two walls are not identical. @version 1.0 */
147 : EQFABRIC_API bool operator!=(const Wall& rhs) const;
148 :
149 : /** @return the horizontal vector. @version 1.1 */
150 0 : Vector3f getU() const { return bottomRight - bottomLeft; }
151 : /** @return the vertical vector. @version 1.1 */
152 0 : Vector3f getV() const { return topLeft - bottomLeft; }
153 : /** @return the perpendicular vector. @version 1.1 */
154 0 : Vector3f getW() const { return vmml::cross(getU(), getV()); }
155 : Vector3f bottomLeft; //!< The bottom-left corner
156 : Vector3f bottomRight; //!< The bottom-right corner
157 : Vector3f topLeft; //!< The top-left corner
158 :
159 : /** The reference system type of the wall. */
160 : enum Type
161 : {
162 : TYPE_FIXED, //!< A fixed mounted projection wall
163 : TYPE_HMD //!< A wall fixed to the observer (head-mounted display)
164 : };
165 : Type type; //!< The wall type
166 : };
167 :
168 : EQFABRIC_API std::ostream& operator<<(std::ostream&, const Wall&);
169 : EQFABRIC_API std::ostream& operator<<(std::ostream&, const Wall::Type&);
170 : }
171 : }
172 :
173 : #endif // EQFABRIC_WALL_H
|