[32] | 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 | { |
---|
[88] | 42 | #include <leakDetection.h> |
---|
[32] | 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 | |
---|
[209] | 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 lat_ |
---|
| 100 | * @param lon_ |
---|
| 101 | * @param alt_ |
---|
| 102 | * @param rot_x_ |
---|
| 103 | * @param rot_y_ |
---|
| 104 | * @param rot_z_ |
---|
| 105 | * @param label_ |
---|
| 106 | */ |
---|
| 107 | void setUpdaterSlotNames( osgVisual::visual_object* object_, std::string lat_, std::string lon_, std::string alt_, std::string rot_x_, std::string rot_y_, std::string rot_z_, std::string label_); |
---|
| 108 | |
---|
| 109 | |
---|
[32] | 110 | protected: |
---|
| 111 | /** |
---|
| 112 | * Pointer to nested updater. |
---|
| 113 | */ |
---|
| 114 | osg::ref_ptr<object_updater> updater; |
---|
| 115 | |
---|
[209] | 116 | /** |
---|
| 117 | * Names of the Slots the updater should use |
---|
| 118 | */ |
---|
| 119 | std::string updater_lat, updater_lon, updater_alt, updater_rot_x, updater_rot_y, updater_rot_z, updater_label; |
---|
| 120 | |
---|
[32] | 121 | }; |
---|
| 122 | |
---|
| 123 | } // END NAMESPACE |
---|