1 | #pragma once |
---|
2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
3 | * |
---|
4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
6 | * (at your option) any later version. The full license is in LICENSE file |
---|
7 | * included with this distribution, and on the openscenegraph.org website. |
---|
8 | * |
---|
9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
10 | * You have to aquire licenses for all used proprietary modules. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * OpenSceneGraph Public License for more details. |
---|
16 | */ |
---|
17 | |
---|
18 | #include <osg/Node> |
---|
19 | #include <osg/Notify> |
---|
20 | #include <visual_object.h> |
---|
21 | |
---|
22 | namespace osgVisual |
---|
23 | { |
---|
24 | class visual_object; // Forward declaration |
---|
25 | |
---|
26 | |
---|
27 | /** |
---|
28 | * \brief This class is the base class for visual_object updater. |
---|
29 | * |
---|
30 | * This base implementation updates the object position with the slotnames |
---|
31 | * object_->getName()+"_POS_LAT", object_->getName()+"_POS_LON", object_->getName()+"_POS_ALT", |
---|
32 | * object_->getName()+"_ROT_X", object_->getName()+"_ROT_Y", object_->getName()+"_ROT_Z", |
---|
33 | * |
---|
34 | * To implement custom updaters, please derive from this class and overwrite the functions preUpdate(..) and postUpdate(..). |
---|
35 | * Take care to call nested preUpdater and postUpdater to allow updater chains. |
---|
36 | * |
---|
37 | * @author Torben Dannhauer |
---|
38 | * @date Apr 2010 |
---|
39 | */ |
---|
40 | class object_updater : public osg::Node |
---|
41 | { |
---|
42 | public: |
---|
43 | /** |
---|
44 | * \brief Empty constructor |
---|
45 | * |
---|
46 | * @param object_ : Pointer to the object, calling the constructor (currently not used) |
---|
47 | */ |
---|
48 | object_updater(osgVisual::visual_object* object_ ); |
---|
49 | |
---|
50 | /** |
---|
51 | * \brief Empty destructor |
---|
52 | * |
---|
53 | * @return |
---|
54 | */ |
---|
55 | virtual ~object_updater(void); |
---|
56 | |
---|
57 | /** |
---|
58 | * \brief This function is called by visual_object before rendering (preFrame). |
---|
59 | * |
---|
60 | * This updater function should be used to update the objects state like size, position, attitude etc. |
---|
61 | * |
---|
62 | * @param object_ : Pointer to the object calling this updater. |
---|
63 | */ |
---|
64 | virtual void preUpdate(osgVisual::visual_object* object_ ); |
---|
65 | |
---|
66 | /** |
---|
67 | * \brief This function is called by visual_object after rendering (postFrame). |
---|
68 | * |
---|
69 | * This updater function should be used for all actions which require the object status of that frame like HAT/HOT etc. |
---|
70 | * |
---|
71 | * @param object_ : Pointer to the object calling this updater. |
---|
72 | */ |
---|
73 | virtual void postUpdate(osgVisual::visual_object* object_); |
---|
74 | |
---|
75 | /** |
---|
76 | * \brief Returns pointer to this updater. |
---|
77 | * |
---|
78 | * This function is used for updater list management. |
---|
79 | * |
---|
80 | * @return : Pointer to this updater. |
---|
81 | */ |
---|
82 | object_updater* getPointer(){return this;}; |
---|
83 | |
---|
84 | /** |
---|
85 | * \brief This function adds an object_updater as nested updater. |
---|
86 | * |
---|
87 | * The nested Updater will be executed in pre and post traversal after this updater. |
---|
88 | * |
---|
89 | * @param updater_ |
---|
90 | */ |
---|
91 | void addUpdater( object_updater* updater_ ); |
---|
92 | |
---|
93 | protected: |
---|
94 | /** |
---|
95 | * Pointer to nested updater. |
---|
96 | */ |
---|
97 | osg::ref_ptr<object_updater> updater; |
---|
98 | |
---|
99 | }; |
---|
100 | |
---|
101 | } // END NAMESPACE |
---|