Go to the documentation of this file.
33 #include <OgreCamera.h>
34 #include <OgreSceneManager.h>
35 #include <OgreSceneNode.h>
37 #include <OgreQuaternion.h>
38 #include <OgreViewport.h>
45 #define MIN_DISTANCE 0.01
88 yaw_ = fmod(
yaw_, Ogre::Math::TWO_PI);
105 return global_focal_point;
116 Ogre::Vector3 pos(x, y, z);
120 Ogre::Vector3 vec = pos - global_focal_point;
121 pos =
relative_node_->getOrientation() * vec + global_focal_point;
127 camera_->lookAt(global_focal_point);
161 return camera_->getOrientation();
174 yaw_ = std::acos(val);
178 if (direction.dotProduct(Ogre::Vector3::NEGATIVE_UNIT_Z) < 0)
189 Ogre::Vector3 direction = orientation * (Ogre::Vector3::NEGATIVE_UNIT_Z *
distance_);
199 Ogre::Vector3 position =
camera_->getPosition();
200 Ogre::Quaternion orientation(w, x, y, z);
202 Ogre::Vector3 direction = orientation * (Ogre::Vector3::NEGATIVE_UNIT_Z *
distance_);
231 Ogre::Quaternion orientation =
camera_->getOrientation();
235 orientation =
relative_node_->getOrientation().Inverse() * orientation;
245 Ogre::Vector3 pos(x, y, z);
255 Ogre::Vector3 focal_point = point;
256 Ogre::Vector3 camera_position =
camera_->getPosition();
263 focal_point = rel_orient.Inverse() * (focal_point - rel_pos);
264 camera_position = rel_orient.Inverse() * (camera_position - rel_pos);
267 distance_ = focal_point.distance(camera_position);
276 pitch(-diff_y * 0.005);
281 float fovY =
camera_->getFOVy().valueRadians();
282 float fovX = 2.0f * std::atan(std::tan(fovY / 2.0
f) *
camera_->getAspectRatio());
284 int width =
camera_->getViewport()->getActualWidth();
285 int height =
camera_->getViewport()->getActualHeight();
287 move(-((
float)diff_x / (
float)width) *
distance_ * std::tan(fovX / 2.0
f) * 2.0
f,
288 ((
float)diff_y / (
float)height) *
distance_ * std::tan(fovY / 2.0
f) * 2.0
f, 0.0
f);
347 std::istringstream iss(str);
366 std::ostringstream oss;
float yaw_
The camera's yaw (rotation around the y-axis), in radians.
Ogre::SceneNode * getRootNode()
Get the root scene node (pivot node) for this object.
Ogre::Quaternion getOrientation() override
Get the orientation of this camera.
void mouseRightDown(int x, int y) override
void mouseMiddleDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a middle mouse button drag.
void setColor(float r, float g, float b, float a) override
Set the color of the object. Values are in the range [0, 1].
void mouseLeftDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a left mouse button drag.
TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
void normalizeYaw()
Normalizes the camera's yaw in the range [0, 2*pi)
void setOrientation(float x, float y, float z, float w) override
Set the orientation of the camera from a quaternion.
Ogre::Camera * camera_
Ogre camera associated with this camera object.
void lookAt(const Ogre::Vector3 &point) override
Point the camera at the specified point.
Ogre::SceneNode * relative_node_
Ogre::Vector3 getGlobalFocalPoint()
void setPosition(float x, float y, float z) override
Set the position of the camera.
static const float PITCH_START
Generic interface for a camera.
void setFocalPoint(const Ogre::Vector3 &focal_point)
Set the focal point of the camera. Keeps the pitch/yaw/distance the same.
void move(float x, float y, float z) override
Move the camera relative to its orientation.
Ogre::Vector3 getPosition() override
Get the position of this camera.
void zoom(float amount)
Move in/out from the focal point, ie. adjust distance_ by amount.
void pitch(float angle) override
Pitch the camera.
static const float PITCH_LIMIT_HIGH
void calculatePitchYawFromPosition(const Ogre::Vector3 &position)
Calculates pitch and yaw values given a new position and the current focal point.
void scrollWheel(int diff, bool ctrl, bool alt, bool shift) override
Handle a scrollwheel change.
virtual Ogre::Quaternion getOrientation()=0
Get the orientation of this camera.
static const float PITCH_LIMIT_LOW
void mouseRightUp(int x, int y) override
Shape * focal_point_object_
void update() override
Calculates the camera's position and orientation from the yaw, pitch, distance and focal point.
float pitch_
The camera's pitch (rotation around the x-axis), in radians.
void mouseMiddleDown(int x, int y) override
void yaw(float angle) override
Yaw the camera.
TFSIMD_FORCE_INLINE tfScalar length(const Quaternion &q)
void roll(float angle) override
Roll the camera.
float distance_
The camera's distance from the focal point.
OrbitCamera(Ogre::SceneManager *scene_manager)
void mouseMiddleUp(int x, int y) override
void setScale(const Ogre::Vector3 &scale) override
Set the scale of the object. Always relative to the identity orientation of the object.
Ogre::Vector3 focal_point_
The camera's focal point.
std::string toString() override
Returns a string representation of the camera's configuration.
static const float YAW_START
virtual Ogre::Vector3 getPosition()=0
Get the position of this camera.
void mouseRightDrag(int diff_x, int diff_y, bool ctrl, bool alt, bool shift) override
Handle a right mouse button drag.
void setPosition(const Ogre::Vector3 &position) override
Set the position of this object.
void mouseLeftDown(int x, int y) override
void fromString(const std::string &str) override
Loads the camera's configure from the supplied string (generated through toString())
void normalizePitch()
Normalizes the camera's pitch, preventing it from reaching vertical (or turning upside down)
void mouseLeftUp(int x, int y) override
void setFrom(CameraBase *camera) override
Set the position/orientation of this camera from another camera.
rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Aug 2 2024 08:43:10