OrbitOrientedViewController.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 
30 #include <OgreCamera.h>
31 #include <OgreQuaternion.h>
32 #include <OgreSceneManager.h>
33 #include <OgreSceneNode.h>
34 #include <OgreVector3.h>
35 #include <OgreViewport.h>
36 
40 
41 namespace rtabmap_ros
42 {
43 
45 {
47  float yaw = yaw_property_->getFloat();
48  float pitch = pitch_property_->getFloat();
49 
50  Ogre::Matrix3 rot;
51  reference_orientation_.ToRotationMatrix(rot);
52  Ogre::Radian rollTarget, pitchTarget, yawTarget;
53  rot.ToEulerAnglesXYZ(yawTarget, pitchTarget, rollTarget);
54 
55  yaw += rollTarget.valueRadians();
56  pitch += pitchTarget.valueRadians();
57 
58  Ogre::Vector3 focal_point = focal_point_property_->getVector();
59 
60  float x = distance * cos( yaw ) * cos( pitch ) + focal_point.x;
61  float y = distance * sin( yaw ) * cos( pitch ) + focal_point.y;
62  float z = distance * sin( pitch ) + focal_point.z;
63 
64  Ogre::Vector3 pos( x, y, z );
65 
66  camera_->setPosition(pos);
67  camera_->setFixedYawAxis(true, target_scene_node_->getOrientation() * Ogre::Vector3::UNIT_Z);
68  camera_->setDirection(target_scene_node_->getOrientation() * (focal_point - pos));
69 
70  focal_shape_->setPosition( focal_point );
71 }
72 
73 }
74 
FloatProperty * distance_property_
void pitch(float angle)
FloatProperty * pitch_property_
virtual float getFloat() const
GLM_FUNC_DECL genType::value_type distance(genType const &p0, genType const &p1)
Ogre::Camera * camera_
GLM_FUNC_DECL genType cos(genType const &angle)
GLM_FUNC_DECL genType sin(genType const &angle)
VectorProperty * focal_point_property_
virtual void setPosition(const Ogre::Vector3 &position)
FloatProperty * yaw_property_
virtual Ogre::Vector3 getVector() const
PLUGINLIB_EXPORT_CLASS(rtabmap_ros::CoreWrapper, nodelet::Nodelet)
void yaw(float angle)


rtabmap_ros
Author(s): Mathieu Labbe
autogenerated on Mon Dec 14 2020 03:42:19