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

Last change on this file since 209 was 209, checked in by Torben Dannhauer, 13 years ago
File size: 3.9 KB
Line 
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       
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 ));
43
44        //object_->setCameraOffsetTranslation(0.0, -150.0, 50.0);       // Trans: (rechts davon, longitudinal, vertikal)
45        object_->setCameraOffsetTranslation( 150.0, 0.0, 30.0);
46        object_->setCameraOffsetRotation( osg::DegreesToRadians(0.0), osg::DegreesToRadians(-15.0), osg::DegreesToRadians(-90.0) );
47       
48std::string updater_label;
49
50        // Finally execute nested PreUpdater
51        if ( updater.valid() )
52                updater->preUpdate(object_);
53}
54
55void object_updater::postUpdate(osgVisual::visual_object* object_ )
56{
57        OSG_NOTIFY( osg::INFO ) << "postUpdate visual Object " << object_->getName() << std::endl;
58
59        // Finally execute nested PostUpdater
60        if ( updater.valid() )
61                updater->postUpdate(object_);
62}
63
64void object_updater::addUpdater( object_updater* updater_ )
65{
66        if (updater.valid())
67                updater->addUpdater( updater_ );
68        else
69                updater = updater_;
70}
71
72void 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_)
73{
74        if(lat_!="")
75                updater_lat = lat_;
76        else
77                updater_lat = object_->getName()+"_POS_LAT";
78
79        if(lon_!="")
80                updater_lon = lon_;
81        else
82                updater_lon = object_->getName()+"_POS_LON";
83
84        if(alt_!="")
85                updater_alt = alt_;
86        else
87                updater_alt = object_->getName()+"_POS_ALT";
88
89        if(rot_x_!="")
90                updater_rot_x = rot_x_;
91        else
92                updater_rot_x = object_->getName()+"_ROT_X";
93
94        if(rot_y_!="")
95                updater_rot_y = rot_y_;
96        else
97                updater_rot_y = object_->getName()+"_ROT_Y";
98
99        if(rot_z_!="")
100                updater_rot_z = rot_z_;
101        else
102                updater_rot_z = object_->getName()+"_ROT_Z";
103
104        if(label_!="")
105                updater_label = label_;
106        else
107                updater_label = object_->getName()+"_LABEL";
108}
Note: See TracBrowser for help on using the repository browser.