Skip to content

Add ArcBallCamera example - #75

Closed
ttnghia wants to merge 12 commits into
mosra:masterfrom
ttnghia:arcball-camera
Closed

ttnghia wants to merge 12 commits into
mosra:masterfrom
ttnghia:arcball-camera

Conversation

@ttnghia

@ttnghia ttnghia commented Jan 28, 2020 •

Copy link
Copy Markdown
Contributor

Here is the arcball camera example :)

image

Brief Usage:

By mouse:

  • Left mouse: rotation
  • Right mouse: translation
  • Middle mouse: zooming

Keyboard shortcuts:

  • 'R': reset view
  • 'L': toggle lagging (smooth navigation)
  • '+'/'-': zooming
  • Up/Down/Left/Right: translation

Enjoy.

@ttnghia
ttnghia force-pushed the arcball-camera branch 2 times, most recently from 2b11368 to 85cad80 Compare January 29, 2020 17:45

@mosra mosra left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is great!

I went a bit more in detail on this, because I think this isn't too far from becoming a builtin feature -- especially when we relax the dependency on SceneGraph a bit :)

Comment thread src/arcball-camera/ArcBall.cpp Outdated
Comment thread src/arcball-camera/ArcBall.cpp Outdated
Comment thread src/arcball-camera/ArcBall.cpp Outdated
Comment thread src/arcball-camera/ArcBall.cpp Outdated
Comment thread src/arcball-camera/ArcBall.h Outdated
Comment thread src/arcball-camera/ArcBallCameraExample.cpp Outdated
Comment thread src/arcball-camera/ArcBallCameraExample.cpp
Comment thread src/arcball-camera/ArcBallCameraExample.cpp Outdated
Comment thread src/arcball-camera/ArcBall.h Outdated
Comment thread src/arcball-camera/ArcBall.cpp Outdated
@mosra mosra added this to the 2020.0a milestone Jan 29, 2020
@ttnghia

ttnghia commented Jan 29, 2020 •

Copy link
Copy Markdown
Contributor Author

I would prefer to create just one ArcBallCamera object and nothing else, instead of having 3 objects:

ArcBall* _arcball { nullptr };
Object3D*             _cameraObject { nullptr };
SceneGraph::Camera3D* _camera { nullptr };

By doing so, the last 2 objects will be private members of the ArcBall class. How do you think?

@mosra

mosra commented Jan 29, 2020

Copy link
Copy Markdown
Owner

Okay, maybe I'm diverging from simplicity of the example a bit too much already, but (to repeat myself) I'd like to have this easy to integrate for people who don't use / want to use the scenegraph.

What about an ArcBall class, containing the algorithmic implementation, and SceneGraphArcBall, being a convenience all-in-one thing containing the camera+object inside? It still feels a bit too rigid for me, as it breaks composability, but as a convenience API why not.

Or if you're fine with the templated update() above, let's do just that, as it's less code overall :)

@ttnghia

ttnghia commented Jan 29, 2020

Copy link
Copy Markdown
Contributor Author

Hah, two-classes sounds good to me. We can have both of them, ArcBall will implement the update(cameraObj) function above, and ArcBallCamera will have an ArcBall object and 2 scene graph camera objects inside as private members.
I'm going to make that. The second class will just be a short header.

@ttnghia

ttnghia commented Jan 29, 2020

Copy link
Copy Markdown
Contributor Author

Done!

@mosra mosra left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have time and want to make the merging easier on my side, could you:

  • add a PNG 800x600 screenshot to doc/arcball-camera.png, without window borders please
  • add a doc/arcball-camera.dox doc page, showing the screenshot, listing key controls and having links to all source files? Similarly to what's in e.g. doc/fluidsimulation2d.dox, doesn't need to be perfect, just putting most of the relevant content there :)
  • mention the new WITH_ option in doc/building-examples.dox
  • and enable the new WITH_ option in package/ci/ in all *.bat and *.sh files, except the vulkan, android, emscripten and ios ones, so I can see if it builds correctly on most platforms?

This will help me a lot, thanks much! 🙏

Comment thread src/arcball-camera/ArcBallCameraExample.cpp Outdated
Comment thread src/arcball-camera/CMakeLists.txt Outdated
Comment thread src/arcball-camera/ArcBallCamera.h Outdated
Comment thread src/arcball-camera/ArcBallCamera.h Outdated
Comment thread src/arcball-camera/ArcBall.h Outdated
Comment thread src/arcball-camera/ArcBall.h Outdated
@mosra

mosra commented Feb 4, 2020

Copy link
Copy Markdown
Owner

Merged as 49a1bbe, thanks a lot! Especially thanks for the docs+CI push, that saved me quite some time. Docs now online here: https://doc.magnum.graphics/magnum/examples-arcball.html

As I mentioned on Gitter, I made the ArcBall class internals use dual quats and as a result ArcBallCamera is independent of used scenegraph transformation implementation. It needed an update on magnum's side to allow this (mosra/magnum@c25b19d), so be sure to pull it before going further :)

@mosra mosra closed this Feb 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants