Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve zooming/rotating/moving #5

Closed
6 tasks done
hannobraun opened this issue Nov 21, 2021 · 5 comments
Closed
6 tasks done

Improve zooming/rotating/moving #5

hannobraun opened this issue Nov 21, 2021 · 5 comments
Labels
type: feature New features and improvements to existing features

Comments

@hannobraun
Copy link
Owner

hannobraun commented Nov 21, 2021

The current input code doesn't work great. Rotating the model works fine, but zooming and moving are basically unusable, unless the model happens to fall into the right size range. Plus, the current zooming code is a bit of a failed experiment.

Furthermore, this kind of thing is a pain point in all of the open source CAD applications I've tried. Quite often, you want to see a feature you modeled up close, but maneuvering the camera where you need it is borderline impossible.

I've come up with the following concept, that I'd like to try out.

Basic ideas:

  • The camera is stationary. You're moving the model.
  • Zooming/rotating/moving are all influenced by where the mouse pointer touches the model when the operation begins. I'll call that the focus point from here on.

Zooming:

  • There is no 1:1 relation between mouse wheel or touch pad input and changes in zoom. Instead, zoom speed is dependent on input frequency.
  • If you turn the mouse wheel once, you get slow movement for a short time. Turn it faster, you get much faster movement. Not sure what the function mapping from frequency to speed should be, but maybe it shouldn't be linear. Something that allows precise control at low speeds, but also very high speeds.
  • The speed zooming in is limited by the distance to the focus point. Speed zooming out is not limited.

Moving:

  • Moving only takes place, if there is a focus point. If the mouse pointer doesn't point to the model, it isn't moved.
  • The focus point stays directly under the mouse pointer, regardless of zoom level.

Rotating:

  • The center of the rotation is always the focus point. This won't matter much when looking at the model from afar. But it will allow for very precise inspection of features up close, as you won't accidentally turn your point of interest far away while zoomed in.

Thoughts on implementation:

  • To find the focus point, we can shoot a ray from the camera and make an intersection test.
  • Could be a ray-triangle intersection, as we already have triangulation anyway, and don't need perfect accuracy for this.
@hannobraun hannobraun added the type: feature New features and improvements to existing features label Nov 21, 2021
@hannobraun
Copy link
Owner Author

Worked a bit on the zooming behavior. Turned the lists in the original comment into checklists, to track progress.

@hannobraun
Copy link
Owner Author

I implemented the computation of the focus point (well, mostly, but it works well enough for now) and used that to implement the desired rotation behavior.

@hannobraun
Copy link
Owner Author

Movement is implemented. Doesn't work perfectly, probably due to #18.

@hannobraun
Copy link
Owner Author

Zooming speed is limited when zooming in. The only thing left now is turning the camera towards the focus point when zooming.

@hannobraun
Copy link
Owner Author

I've opened #20 and have taken the respective item off the list. This is the last item here that wasn't implemented yet.

I'm closing this issue now. The new features don't work great yet, but it's good enough for now, and I'm kinda tired of working on this. I need to do something else for a bit, so I'm declaring victory here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New features and improvements to existing features
Projects
None yet
Development

No branches or pull requests

1 participant