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

Last change on this file since 211 was 210, checked in by Torben Dannhauer, 14 years ago
File size: 3.8 KB
RevLine 
[31]1/* -*-c++-*- osgVisual - Copyright (C) 2009-2010 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}
24
25object_updater::~object_updater(void)
26{
27}
28
29void object_updater::preUpdate(osgVisual::visual_object* object_ )
30{
31        OSG_NOTIFY( osg::INFO ) << "preUpdate visual Object " << object_->getName() << std::endl;
32        // perform this preUpdater...
33        //For each visual_object.member,
34        //      try to search according variable in dataIO with direction TO_OBJ and copy value to visual_object.
35
36       
[209]37        object_->lat = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lat, osgVisual::dataIO_slot::TO_OBJ ));
38        object_->lon = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_lon, osgVisual::dataIO_slot::TO_OBJ ));
39        object_->alt = osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_alt, osgVisual::dataIO_slot::TO_OBJ );
40        object_->azimuthAngle_psi = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_z, osgVisual::dataIO_slot::TO_OBJ ));
41        object_->pitchAngle_theta = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_y, osgVisual::dataIO_slot::TO_OBJ ));
42        object_->bankAngle_phi = osg::DegreesToRadians(osgVisual::visual_dataIO::getInstance()->getSlotDataAsDouble(updater_rot_x, osgVisual::dataIO_slot::TO_OBJ ));
[210]43        object_->updateLabelText("autoupdated", osgVisual::visual_dataIO::getInstance()->getSlotDataAsString(updater_label, osgVisual::dataIO_slot::TO_OBJ ));
[31]44
45        // Finally execute nested PreUpdater
46        if ( updater.valid() )
47                updater->preUpdate(object_);
48}
49
50void object_updater::postUpdate(osgVisual::visual_object* object_ )
51{
52        OSG_NOTIFY( osg::INFO ) << "postUpdate visual Object " << object_->getName() << std::endl;
53
54        // Finally execute nested PostUpdater
55        if ( updater.valid() )
56                updater->postUpdate(object_);
57}
58
59void object_updater::addUpdater( object_updater* updater_ )
60{
61        if (updater.valid())
62                updater->addUpdater( updater_ );
63        else
64                updater = updater_;
[209]65}
66
67void object_updater::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_)
68{
69        if(lat_!="")
70                updater_lat = lat_;
71        else
72                updater_lat = object_->getName()+"_POS_LAT";
73
74        if(lon_!="")
75                updater_lon = lon_;
76        else
77                updater_lon = object_->getName()+"_POS_LON";
78
79        if(alt_!="")
80                updater_alt = alt_;
81        else
82                updater_alt = object_->getName()+"_POS_ALT";
83
84        if(rot_x_!="")
85                updater_rot_x = rot_x_;
86        else
87                updater_rot_x = object_->getName()+"_ROT_X";
88
89        if(rot_y_!="")
90                updater_rot_y = rot_y_;
91        else
92                updater_rot_y = object_->getName()+"_ROT_Y";
93
94        if(rot_z_!="")
95                updater_rot_z = rot_z_;
96        else
97                updater_rot_z = object_->getName()+"_ROT_Z";
98
99        if(label_!="")
100                updater_label = label_;
101        else
[210]102        {
[209]103                updater_label = object_->getName()+"_LABEL";
[210]104                object_->addLabel("autoupdated", " ");
105        }
[31]106}
Note: See TracBrowser for help on using the repository browser.