Line data Source code
1 :
2 : /* Copyright (c) 2009-2015, Stefan Eilemann <eile@equalizergraphics.com>
3 : * Cedric Stalder <cedric.stalder@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 EQSERVER_OBSERVER_H
20 : #define EQSERVER_OBSERVER_H
21 :
22 : #include <eq/server/api.h>
23 : #include "types.h"
24 :
25 : #include <eq/fabric/observer.h> // base class
26 : #include <eq/fabric/eye.h> // enum
27 : #include <lunchbox/bitOperation.h> // function getIndexOfLastBit
28 :
29 : #include <string>
30 :
31 : namespace eq
32 : {
33 : namespace server
34 : {
35 : /** The observer. @sa eq::Observer */
36 : class Observer : public fabric::Observer< Config, Observer >
37 : {
38 : public:
39 : /** Construct a new Observer. */
40 : EQSERVER_API explicit Observer( Config* parent );
41 :
42 : /** Destruct this observer. */
43 : virtual ~Observer();
44 :
45 : /** @name Data Access */
46 : //@{
47 : /** @return the Server of this observer. @version 1.0 */
48 : ServerPtr getServer();
49 :
50 : /** @return the position of an eye in world-space coordinates. */
51 0 : const fabric::Vector3f& getEyeWorld( const fabric::Eye eye ) const
52 0 : { return _eyeWorld[ lunchbox::getIndexOfLastBit( eye ) ]; }
53 :
54 : /** @return the inverse of the current head matrix. */
55 0 : const fabric::Matrix4f& getInverseHeadMatrix() const
56 0 : { return _inverseHeadMatrix; }
57 :
58 : /** @return true if this observer should be deleted. */
59 4 : bool needsDelete() const { return _state == STATE_DELETE; }
60 : //@}
61 :
62 : /**
63 : * @name Operations
64 : */
65 : //@{
66 : /** Initialize the observer parameters. */
67 : void init();
68 :
69 : /** Schedule deletion of this observer. */
70 : void postDelete();
71 : //@}
72 :
73 : void addView( View* view ); //!< @internal
74 : void removeView( View* view ); //!< @internal
75 :
76 : protected:
77 : virtual void setDirty( const uint64_t bits ); //!< @internal
78 :
79 : /** @sa Object::deserialize */
80 : virtual void deserialize( co::DataIStream& is,
81 : const uint64_t dirtyBits );
82 :
83 : private:
84 : /** Cached inverse head matrix. */
85 : fabric::Matrix4f _inverseHeadMatrix;
86 :
87 : /** The eye positions in world space. */
88 : fabric::Vector3f _eyeWorld[ eq::fabric::NUM_EYES ];
89 :
90 : /** Views tracked by this observer. */
91 : Views _views;
92 :
93 : enum State
94 : {
95 : STATE_ACTIVE = 0, // next: DELETE
96 : STATE_DELETE, // next: destructor
97 : }
98 : _state;
99 :
100 : struct Private;
101 : Private* _private; // placeholder for binary-compatible changes
102 :
103 : void _updateEyes();
104 : void _updateViews();
105 : };
106 : }
107 : }
108 : #endif // EQSERVER_OBSERVER_H
|