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 | #include <leakDetection.h> |
---|
43 | public: |
---|
44 | /** |
---|
45 | * \brief Empty constructor |
---|
46 | * |
---|
47 | * @param object_ : Pointer to the object, calling the constructor (currently not used) |
---|
48 | */ |
---|
49 | object_updater(osgVisual::visual_object* object_ ); |
---|
50 | |
---|
51 | /** |
---|
52 | * \brief Empty destructor |
---|
53 | * |
---|
54 | * @return |
---|
55 | */ |
---|
56 | virtual ~object_updater(void); |
---|
57 | |
---|
58 | /** |
---|
59 | * \brief This function is called by visual_object before rendering (preFrame). |
---|
60 | * |
---|
61 | * This updater function should be used to update the objects state like size, position, attitude etc. |
---|
62 | * |
---|
63 | * @param object_ : Pointer to the object calling this updater. |
---|
64 | */ |
---|
65 | virtual void preUpdate(osgVisual::visual_object* object_ ); |
---|
66 | |
---|
67 | /** |
---|
68 | * \brief This function is called by visual_object after rendering (postFrame). |
---|
69 | * |
---|
70 | * This updater function should be used for all actions which require the object status of that frame like HAT/HOT etc. |
---|
71 | * |
---|
72 | * @param object_ : Pointer to the object calling this updater. |
---|
73 | */ |
---|
74 | virtual void postUpdate(osgVisual::visual_object* object_); |
---|
75 | |
---|
76 | /** |
---|
77 | * \brief Returns pointer to this updater. |
---|
78 | * |
---|
79 | * This function is used for updater list management. |
---|
80 | * |
---|
81 | * @return : Pointer to this updater. |
---|
82 | */ |
---|
83 | object_updater* getPointer(){return this;}; |
---|
84 | |
---|
85 | /** |
---|
86 | * \brief This function adds an object_updater as nested updater. |
---|
87 | * |
---|
88 | * The nested Updater will be executed in pre and post traversal after this updater. |
---|
89 | * |
---|
90 | * @param updater_ |
---|
91 | */ |
---|
92 | void addUpdater( object_updater* updater_ ); |
---|
93 | |
---|
94 | protected: |
---|
95 | /** |
---|
96 | * Pointer to nested updater. |
---|
97 | */ |
---|
98 | osg::ref_ptr<object_updater> updater; |
---|
99 | |
---|
100 | }; |
---|
101 | |
---|
102 | } // END NAMESPACE |
---|