Line data Source code
1 :
2 : /* Copyright (c) 2009-2017, Stefan Eilemann <eile@equalizergraphics.com>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #ifndef EQFABRIC_FRUSTUM_H
19 : #define EQFABRIC_FRUSTUM_H
20 :
21 : #include <eq/fabric/api.h> // decl
22 : #include <eq/fabric/projection.h> // member
23 : #include <eq/fabric/wall.h> // member
24 :
25 : namespace eq
26 : {
27 : namespace fabric
28 : {
29 : /** A distributed object for frustum data. */
30 8 : class Frustum
31 : {
32 : public:
33 : /** Construct a new frustum. @version 1.0 */
34 : EQFABRIC_API Frustum();
35 :
36 : /** Destruct the frustum. @version 1.0 */
37 : EQFABRIC_API virtual ~Frustum();
38 :
39 : /** The type of the last specified frustum. @version 1.0 */
40 : enum Type
41 : {
42 : TYPE_NONE, //!< No frustum has been specified
43 : TYPE_WALL, //!< A wall description has been set last
44 : TYPE_PROJECTION //!< A projection description has been set last
45 : };
46 :
47 : /** Set the frustum using a wall description. @version 1.0 */
48 : EQFABRIC_API void setWall(const Wall& wall);
49 :
50 : /** Set the frustum using a projection description. @version 1.0 */
51 : EQFABRIC_API void setProjection(const Projection& projection);
52 :
53 : /** @return the last specified frustum as a wall. @version 1.0 */
54 2426 : const Wall& getWall() const { return _data.wall; }
55 : /** @return the last specified frustum as a projection. @version 1.0 */
56 102 : const Projection& getProjection() const { return _data.projection; }
57 : /** @return the type of the latest specified frustum. @version 1.0 */
58 9644 : Type getCurrentType() const { return _data.current; }
59 : /** Set the last specified frustum to TYPE_NONE. @version 1.0 */
60 : EQFABRIC_API void unsetFrustum();
61 :
62 : EQFABRIC_API void serialize(co::DataOStream& os); //!< @internal
63 : EQFABRIC_API void deserialize(co::DataIStream& is); //!< @internal
64 :
65 : EQFABRIC_API virtual void backup(); //!< @internal
66 : EQFABRIC_API virtual void restore(); //!< @internal
67 :
68 : protected:
69 24 : virtual void updateFrustum() {}
70 528 : virtual void notifyFrustumChanged() {}
71 : private:
72 25 : struct BackupData
73 : {
74 12344 : BackupData()
75 12344 : : current(TYPE_NONE)
76 : {
77 12344 : }
78 :
79 : /** The frustum description as a wall. */
80 : Wall wall;
81 :
82 : /** The frustum description as a projection. */
83 : Projection projection;
84 :
85 : /** The type of the last specified frustum description. */
86 : Type current;
87 : } _data, _backup;
88 : };
89 : EQFABRIC_API std::ostream& operator<<(std::ostream& os, const Frustum&);
90 : }
91 : }
92 :
93 : #endif // EQFABRIC_FRUSTUM_H
|