Go to the documentation of this file.
32 #include <OgreCamera.h>
33 #include <OgreQuaternion.h>
34 #include <OgreSceneManager.h>
35 #include <OgreSceneNode.h>
37 #include <OgreViewport.h>
53 static const float YAW_START = Ogre::Math::HALF_PI * 0.5;
55 static const float FOV_START = Ogre::Math::HALF_PI / 2.0;
88 "The center point which the camera orbits.",
this);
95 camera_->setProjectionType(Ogre::PT_PERSPECTIVE);
126 "<b>Left-Click:</b> Move X/Y. <b>Right-Click:</b>: Move Z. <b>Mouse Wheel:</b>: Zoom. ");
130 setStatus(
"<b>Left-Click:</b> Rotate. <b>Middle-Click:</b> Move X/Y. <b>Right-Click/Mouse "
131 "Wheel:</b>: Zoom. <b>Shift</b>: More options.");
140 if (event.
type == QEvent::MouseButtonPress)
145 else if (event.
type == QEvent::MouseButtonRelease)
152 diff_x =
event.x -
event.last_x;
153 diff_y =
event.y -
event.last_y;
161 pitch(-diff_y * 0.005);
167 float fovY =
camera_->getFOVy().valueRadians();
168 float fovX = 2.0f * std::atan(std::tan(fovY / 2.0
f) *
camera_->getAspectRatio());
170 int width =
camera_->getViewport()->getActualWidth();
171 int height =
camera_->getViewport()->getActualHeight();
173 move(-((
float)diff_x / (
float)width) * distance * std::tan(fovX / 2.0
f) * 2.0
f,
174 ((
float)diff_y / (
float)height) * distance * std::tan(fovY / 2.0
f) * 2.0
f, 0.0
f);
176 else if (event.
right())
182 move(0.0
f, 0.0
f, diff_y * 0.1 * (distance / 10.0
f));
188 zoom(-diff_y * 0.1 * (distance / 10.0
f));
198 int diff =
event.wheel_delta;
201 move(0, 0, -diff * 0.001 * distance);
205 zoom(diff * 0.001 * distance);
216 Ogre::Camera* source_camera = source_view->
getCamera();
217 Ogre::Vector3 position = source_camera->getPosition();
218 Ogre::Quaternion orientation = source_camera->getOrientation();
220 if (source_view->
getClassId() ==
"rviz/Orbit")
234 Ogre::Vector3 direction =
249 Ogre::Vector3 camera_position =
camera_->getPosition();
258 const Ogre::Quaternion& )
269 Ogre::Vector3 camera_z = Ogre::Vector3::UNIT_Z;
276 camera_z = -camera_z;
281 float x = distance * std::cos(
yaw) * std::cos(
pitch) + focal_point.x;
282 float y = distance * std::sin(
yaw) * std::cos(
pitch) + focal_point.y;
283 float z = distance * std::sin(
pitch) + focal_point.z;
286 Ogre::Vector3 pos(x, y, z);
291 camera_->setFOVy(Ogre::Radian(fov));
318 distance_property = 1;
320 focal_shape_->
setScale(Ogre::Vector3(fshape_size * distance_property, fshape_size * distance_property,
321 fshape_size * distance_property / 5.0));
void zoom(float amount)
Move in/out from the focal point, ie. adjust #distance_ by amount.
Ogre::Vector3 reference_position_
virtual bool getBool() const
Ogre::SceneNode * getRootNode()
Get the root scene node (pivot node) for this object.
void updateFocalShapeSize()
Calculates the focal shape size and update it's geometry.
virtual void queueRender()=0
Queues a render. Multiple calls before a render happens will only cause a single render.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
VectorProperty * focal_point_property_
The point around which the camera "orbits".
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
FloatProperty * fov_property_
The camera's vertical field of view, in radians.
static const float FOV_START
FloatProperty * distance_property_
The camera's distance from the focal point.
BoolProperty * focal_shape_fixed_size_property_
Whether the focal shape size is fixed or not.
void onTargetFrameChanged(const Ogre::Vector3 &old_reference_position, const Ogre::Quaternion &old_reference_orientation) override
Override to implement the change in properties which nullifies the change in target frame.
Property specialized to provide getter for booleans.
static const float FOCAL_SHAPE_SIZE_START
virtual Property * subProp(const QString &sub_name)
Return the first child Property with the given name, or the FailureProperty if no child has the name.
bool add(float delta)
Add the given delta to the property value.
static const float PITCH_START
void onInitialize() override
Do subclass-specific initialization. Called by ViewController::initialize after context_,...
FloatProperty * focal_shape_size_property_
The focal shape size.
virtual QVariant getValue() const
Return the value of this Property as a QVariant. If the value has never been set, an invalid QVariant...
virtual Ogre::SceneManager * getSceneManager() const =0
Returns the Ogre::SceneManager used for the main RenderPanel.
DisplayContext * context_
Property specialized to enforce floating point max/min.
void onInitialize() override
Do subclass-specific initialization.
void mimic(ViewController *source_view) override
Configure the settings of this view controller to give, as much as possible, a similar view as that g...
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
FloatProperty * pitch_property_
The camera's pitch (rotation around the x-axis), in radians.
virtual float getFloat() const
void calculatePitchYawFromPosition(const Ogre::Vector3 &position)
Calculates pitch and yaw values given a new position and the current focal point.
~OrbitViewController() override
void update(float dt, float ros_dt) override
Called at 30Hz by ViewManager::update() while this view is active. Override with code that needs to r...
virtual bool setVector(const Ogre::Vector3 &vector)
virtual void updateCamera()
static const float DISTANCE_START
An orbital camera, controlled by yaw, pitch, distance, and focal point.
FloatProperty * yaw_property_
The camera's yaw (rotation around the y-axis), in radians.
float mapAngleTo0_2Pi(float angle)
Return the input angle mapped back to the range 0 to 2*PI.
void mimic(ViewController *source_view) override
Configure the settings of this view controller to give, as much as possible, a similar view as that g...
static const bool FOCAL_SHAPE_FIXED_SIZE
void handleMouseEvent(ViewportMouseEvent &evt) override
Ogre::Camera * getCamera() const
bool setFloat(float new_value)
Float-typed "SLOT" version of setValue().
static const float PITCH_START
void update(float dt, float ros_dt) override
Called at 30Hz by ViewManager::update() while this view is active. Override with code that needs to r...
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
void setCursor(CursorType cursor_type)
static const float YAW_START
void move(float x, float y, float z)
virtual QString getClassId() const
Return the class identifier which was used to create this instance. This version just returns whateve...
virtual Ogre::Vector3 getVector() const
void lookAt(const Ogre::Vector3 &point) override
This should be implemented in each subclass to aim the camera at the given point in space (relative t...
void setStatus(const QString &message)
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
static const float YAW_START
bool add(const Ogre::Vector3 &offset)
Ogre::SceneNode * target_scene_node_
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10