1#ifndef Magnum_Examples_ArcBallCamera_h
2#define Magnum_Examples_ArcBallCamera_h
33#include <Magnum/SceneGraph/AbstractTranslationRotation3D.h>
34#include <Magnum/SceneGraph/Camera.h>
35#include <Magnum/SceneGraph/Object.h>
36#include <Magnum/SceneGraph/Scene.h>
52 template <
class Transformation>
54 SceneGraph::Scene<Transformation> &scene,
55 const Vector3 &cameraPosition,
const Vector3 &viewCenter,
56 const Vector3 &upDir, Deg
fov,
const Vector2i &windowSize,
57 const Vector2i &viewportSize)
58 :
ArcBall{cameraPosition, viewCenter, upDir,
fov, windowSize} {
60 auto *cameraObject =
new SceneGraph::Object<Transformation>{&scene};
61 (*(
_camera =
new SceneGraph::Camera3D{*cameraObject}))
62 .setAspectRatioPolicy(SceneGraph::AspectRatioPolicy::Extend)
63 .setProjectionMatrix(Matrix4::perspectiveProjection(
64 fov, Vector2{windowSize}.aspectRatio(), 0.01f, 1000.0f))
65 .setViewport(viewportSize);
77 void reshape(
const Vector2i &windowSize,
const Vector2i &viewportSize) {
79 _camera->setViewport(viewportSize);
90 .resetTransformation()
98 void draw(SceneGraph::DrawableGroup3D &drawables) {
Arcball camera implementation integrated into the SceneGraph.
Definition ArcBallCamera.h:41
void draw(SceneGraph::DrawableGroup3D &drawables)
Draw objects using the internal scene graph camera.
Definition ArcBallCamera.h:98
void reshape(const Vector2i &windowSize, const Vector2i &viewportSize)
Update screen and viewport size after the window has been resized.
Definition ArcBallCamera.h:77
ArcBallCamera(SceneGraph::Scene< Transformation > &scene, const Vector3 &cameraPosition, const Vector3 &viewCenter, const Vector3 &upDir, Deg fov, const Vector2i &windowSize, const Vector2i &viewportSize)
Creates a new arc ball camera.
Definition ArcBallCamera.h:53
bool update()
Update the SceneGraph camera if arc ball has been changed.
Definition ArcBallCamera.h:84
SceneGraph::Camera3D & camera() const
Accessor to the raw camera object.
Definition ArcBallCamera.h:104
SceneGraph::AbstractTranslationRotation3D * _cameraObject
Definition ArcBallCamera.h:109
SceneGraph::Camera3D * _camera
Definition ArcBallCamera.h:110
Implementation of Ken Shoemake's arcball camera with smooth navigation.
Definition ArcBall.h:43
const DualQuaternion & transformation() const
Get the camera's transformation as a dual quaternion.
Definition ArcBall.h:119
void translate(const Vector2i &mousePos)
Translate the camera from the previous (screen) mouse position to the current(screen) mouse position.
Definition ArcBall.cpp:109
Vector2i _windowSize
Definition ArcBall.h:140
Deg fov() const
Field of view.
Definition ArcBall.h:101
bool updateTransformation()
Update any unfinished transformation due to lagging.
Definition ArcBall.cpp:133