source: osgVisual/trunk/src/object/object_updater.cpp @ 235

Last change on this file since 235 was 224, checked in by Torben Dannhauer, 14 years ago

changed updater from degreet to radian

now osgvisual uses internally rad, whiel the XML configuration file uses degree to be human readable.

File size: 4.0 KB
Line 
1/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
2 *
3 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#include <object_updater.h>
18
19using namespace osgVisual;
20
21object_updater::object_updater(osgVisual::visual_object* object_ )
22{
23        updater_lat_rad = object_->getName()+"_POS_LAT";
24        updater_lon_rad = object_->getName()+"_POS_LON";
25        updater_alt             = object_->getName()+"_POS_ALT";
26        updater_rot_x_rad = object_->getName()+"_ROT_X";
27        updater_rot_y_rad = object_->getName()+"_ROT_Y";
28        updater_rot_z_rad = object_->getName()+"_ROT_Z";
29}
30
31object_updater::~object_updater(void)
32{
33}
34
35void object_updater::preUpdate(osgVisual::visual_object* object_ )
36{
37        OSG_NOTIFY( osg::INFO ) << "preUpdate visual Object " << object_->getName() << std::endl;
38        // perform this preUpdater...
39        //For each visual_object.member,
40        //      try to search according variable in dataIO with direction TO_OBJ and copy value to visual_object.
41
42        if(!updater_lat_rad.empty())
43                object_->lat = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lat_rad, osgVisual::dataIO_slot::TO_OBJ );
44        if(!updater_lon_rad.empty())
45                object_->lon = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lon_rad, osgVisual::dataIO_slot::TO_OBJ );
46        if(!updater_alt.empty())
47                object_->alt = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_alt, osgVisual::dataIO_slot::TO_OBJ );
48        if(!updater_rot_z_rad.empty())
49                object_->azimuthAngle_psi = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_z_rad, osgVisual::dataIO_slot::TO_OBJ );
50        if(!updater_rot_y_rad.empty())
51                object_->pitchAngle_theta = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_y_rad, osgVisual::dataIO_slot::TO_OBJ );
52        if(!updater_rot_x_rad.empty())
53                object_->bankAngle_phi = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_x_rad, osgVisual::dataIO_slot::TO_OBJ );
54        if(!updater_label.empty())
55                object_->updateLabelText("default", osgVisual::visual_dataIO::getInstance()->getSlotDataAsString(updater_label, osgVisual::dataIO_slot::TO_OBJ ));
56
57        // Finally execute nested PreUpdater
58        if ( updater.valid() )
59                updater->preUpdate(object_);
60}
61
62void object_updater::postUpdate(osgVisual::visual_object* object_ )
63{
64        OSG_NOTIFY( osg::INFO ) << "postUpdate visual Object " << object_->getName() << std::endl;
65
66        // Finally execute nested PostUpdater
67        if ( updater.valid() )
68                updater->postUpdate(object_);
69}
70
71void object_updater::addUpdater( object_updater* updater_ )
72{
73        if (updater.valid())
74                updater->addUpdater( updater_ );
75        else
76                updater = updater_;
77}
78
79void object_updater::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_)
80{
81        if(lat_rad_!="")
82                updater_lat_rad = lat_rad_;
83        if(lon_rad_!="")
84                updater_lon_rad = lon_rad_;
85        if(alt_!="")
86                updater_alt = alt_;
87        if(rot_x_rad_!="")
88                updater_rot_x_rad = rot_x_rad_;
89        if(rot_y_rad_!="")
90                updater_rot_y_rad = rot_y_rad_;
91        if(rot_z_rad_!="")
92                updater_rot_z_rad = rot_z_rad_;
93
94        if(label_!="")
95                updater_label = label_;
96        else
97        {
98                updater_label = object_->getName()+"_LABEL";
99                object_->addLabel("default", " ");
100        }
101}
Note: See TracBrowser for help on using the repository browser.