1 | #pragma once |
---|
2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2011 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 | /** |
---|
95 | * \brief This function defines the slots to use for updating the object. |
---|
96 | * |
---|
97 | * If a lot is empty, the objectname will be used with a suffix describing the channel. For details look for the implementation. |
---|
98 | * |
---|
99 | * @param object_ |
---|
100 | * @param lat_rad_ |
---|
101 | * @param lon_rad_ |
---|
102 | * @param alt_ |
---|
103 | * @param rot_x_rad_ |
---|
104 | * @param rot_y_rad_ |
---|
105 | * @param rot_z_rad_ |
---|
106 | * @param label_ |
---|
107 | */ |
---|
108 | void setUpdaterSlotNames( osgVisual::visual_object* object_, std::string lat_rad_, std::string lon_rad_, std::string alt_, std::string rot_x_rad_, std::string rot_y_rad_, std::string rot_z_rad_, std::string label_); |
---|
109 | |
---|
110 | |
---|
111 | protected: |
---|
112 | /** |
---|
113 | * Pointer to nested updater. |
---|
114 | */ |
---|
115 | osg::ref_ptr<object_updater> updater; |
---|
116 | |
---|
117 | /** |
---|
118 | * Names of the Slots the updater should use |
---|
119 | */ |
---|
120 | std::string updater_lat_rad, updater_lon_rad, updater_alt, updater_rot_x_rad, updater_rot_y_rad, updater_rot_z_rad, updater_label; |
---|
121 | |
---|
122 | }; |
---|
123 | |
---|
124 | } // END NAMESPACE |
---|