VirtualRangeSensor.cpp
Go to the documentation of this file.
00001 /* 
00002  * Copyright (c) 2013 University of Jaume-I.
00003  * All rights reserved. This program and the accompanying materials
00004  * are made available under the terms of the GNU Public License v3.0
00005  * which accompanies this distribution, and is available at
00006  * http://www.gnu.org/licenses/gpl.html
00007  * 
00008  * Contributors:
00009  *     Mario Prats
00010  *     Javier Perez
00011  */
00012 
00013 #include <uwsim/VirtualRangeSensor.h>
00014 #include <uwsim/UWSimUtils.h>
00015 #include <iostream>
00016 
00017 VirtualRangeSensor::VirtualRangeSensor()
00018 {
00019 }
00020 
00021 VirtualRangeSensor::VirtualRangeSensor(std::string name, osg::Node *root, osg::Node *trackNode, double range,
00022                                        bool visible)
00023 {
00024   init(name, root, trackNode, range, visible);
00025 }
00026 
00027 void VirtualRangeSensor::init(std::string name, osg::Node *root, osg::Node *trackNode, double range, bool visible)
00028 {
00029   this->name = name;
00030   this->root = root;
00031 
00032   this->trackNode = trackNode;
00033   //Add a switchable frame geometry on the sensor frame
00034   osg::ref_ptr < osg::Node > axis = UWSimGeometry::createSwitchableFrame();
00035   this->trackNode->asGroup()->addChild(axis);
00036 
00037   this->range = range;
00038   this->visible = visible;
00039 
00040   //make this virtual ray track the node
00041   node_tracker = new IntersectorUpdateCallback(range, visible, root);
00042   trackNode->setUpdateCallback(node_tracker);
00043   trackNode->asGroup()->addChild(node_tracker->geode);
00044 }
00045 


uwsim
Author(s): Mario Prats
autogenerated on Mon Oct 6 2014 08:24:07