Skip to content

Add Turntable camera controller example#354

Merged
robertosfield merged 3 commits intovsg-dev:masterfrom
nolankramer:master
Jun 16, 2025
Merged

Add Turntable camera controller example#354
robertosfield merged 3 commits intovsg-dev:masterfrom
nolankramer:master

Conversation

@nolankramer
Copy link
Contributor

Sorry for the really late contribution here - it totally got shelved due to conflicting priorities with my own projects and life things.

Currently untested in vsgExamples (but I've tested the controller in my own private project and it works well).

If I get the time I can try to test in a Linux environment at-least. Although it might be awhile until I get a free moment.

@robertosfield
Copy link
Collaborator

Thanks for the example. I've merged as a turntable branch:

https://github.com/vsg-dev/vsgExamples/tree/turntable

It builds under Linux without any errors. It runs but I have only been able to translate and zoom in/out, the rotation side isn't working for me yet. I won't have time to investigate right as I lots of other work that needs attending.

@nolankramer
Copy link
Contributor Author

Found the issue, was using abs() but meant std::abs() when checking rotation angle. Tested as working on Fedora 42.

@robertosfield robertosfield merged commit 2688593 into vsg-dev:master Jun 16, 2025
@robertosfield
Copy link
Collaborator

Sorry for the slow review of this PR, I have been super busy. I have merged this PR but it still needs some further work.

I have just checked the PR as a branch and it runs, but I'm perplexed by the way it works. When I run:

vsgturntable models/teapot.vsgt
~~~

The up down movement with the left mouse button rotates the view around the models X axis in a natural way, but when I move left and right the scene rolls around the models Y axis.  The later feels really odd.  I was expecting the scene to rotate around the models Z axis, like it was placed on the record turntable.

Is the behavior how you meant it?

----

There is also the following compile warnings, I can easily fix this myself but mention them in case they are hint of something that was intended to be implemented but not yet completed.

~~~ sh
/home/robert/dev/vsgExamples/examples/app/vsgturntablecamera/Turntable.cpp: In member function ‘virtual void Turntable::apply(vsg::MoveEvent&)’:
/home/robert/dev/vsgExamples/examples/app/vsgturntablecamera/Turntable.cpp:161:16: warning: variable ‘prev_ttc’ set but not used [-Wunused-but-set-variable]
  161 |     vsg::dvec3 prev_ttc = ttc(*_previousPointerEvent);
      |                ^~~~~~~~
/home/robert/dev/vsgExamples/examples/app/vsgturntablecamera/Turntable.cpp:165:12: warning: variable ‘control_ttc’ set but not used [-Wunused-but-set-variable]
  165 | vsg::dvec3 control_ttc = new_ttc;
      |            ^~~~~~~~~~~
/home/robert/dev/vsgExamples/examples/app/vsgturntablecamera/Turntable.cpp: In member function ‘virtual void Turntable::apply(vsg::FrameEvent&)’:
/home/robert/dev/vsgExamples/examples/app/vsgturntablecamera/Turntable.cpp:403:20: warning: unused variable ‘distanceFromCenter’ [-Wunused-variable]
  403 |             double distanceFromCenter = vsg::length(_lookAt->eye - _lookAt->center);
      |                    ^~~~~~~~~~~~~~~~~~
~~~

@robertosfield
Copy link
Collaborator

I have fixed the warnings, changed the horizontal mouse movement to rotate around the Z axis (the VSG's default model up direction) and changed the Turntable header extension to .h to be consistent with the rest of the VSG.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants