Replies: 7 comments 3 replies
-
The vsg::UIEvent base class that all the event types subclass has a handled flag to specify whether an event handler has dealt with the event and subsequent event handlers should take this into account on judging whether to handle the event themselves: https://github.com/vsg-dev/VulkanSceneGraph/blob/master/include/vsg/ui/UIEvent.h#L36 The vsg::Trackball class both sets and honours the handled flag so if the first trackball handles it then subsequent ones won't handle it. If your custom event handler doesn't intend to avoid other classes from processing the events then you could just not set the handled flag. Alternatively you could subclass from vsg::Trackball and override/customize it's behaviour, possible mix it with the OrienterTrackball you have. You could event nest another event handler within an outer one and pass the events on to the nested class and manage the handled flags at the time that suits you usage case. |
Beta Was this translation helpful? Give feedback.
-
So I changed my architecture so that the orientation trackball takes the model trackball as a parameter, and it succesfully delegates all events to it. But I still fail to match to align the view matrices of the orientation camera and the model camera. At construction I tried to make them match by setting the orientation camera as follows: // Setup the orientation camera based on the model camera
auto lookAt = vsg::LookAt::create();
lookAt->set(modelCamera->viewMatrix->transform());
setViewpoint(lookAt); But this did not align them! However the interaction affects both cameras, but not fully. E.g. sometimes I'm left with the model camera continuing rotating while the orientation camera has stopped. What am I missing? My complete example can be found here: https://gist.github.com/dov/8a03c01d610203dbca23be1b6d394013 |
Beta Was this translation helpful? Give feedback.
-
I don't know what functionality you are attempting to implement, all I know is how you've gone about trying to achieve the functionality. Without knowing the end point and reasons behind what you are trying to implement I can't provide any advice on how you should be implementing it, and how to resolve what issues might be remaining. The best I can say it's combine two trackball classes is not something I've come across other users attempting with the OSG or VSG, it might what you are trying to do is reasonable, or might be that you've just heading off on the wrong track. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your comments, Robert. Sorry for not being clearer. What I wanted to do is to show a "gizmo" in the corner of the vsg view which shows the current camera orientation. For an example of such a gizmo see the following screenshot from Blender: After playing around some more with my example, I realized that using two trackballs is indeed unnecessary. Instead in my latest effort I subclassed Here is the graph that I have created. The green arrow represents the normal camera that the trackball controls. The blue arrow is the additional camera that is created by the Does this approach make sense? Do you have another idea of how to create an orientation gizmo? |
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation. This is why high level intros are really helpful. The way I would tackle a compass/axis insert view like you describe is that set up the insert View as you describe but assign it's own vsg::Camera and it's own vsg::ViewMatrix and vsg::ProjectMatrix instances. For vsg::ViewMatrix on the insert view I would subclass from vsg::ViewMatrix and override the transform method to implement the tracking on the main view's vsg::Camera's own ViewMartrix. The vsg::RelativeViewMatrix subclass from vsg::ViewMatrix is the closest to what type of ViewMatrix you'll want. Instead of adding a relative transform like this class does you'll want to track the rotation component of the main ViewMartrix. The vsg::decompose function can be used to convert a vsg::dmat4 into it's component parts include the rotation. With this approach you can have your insert view track any main view setting as it's just coupled to the view matrix not the trackball implementation, so if you change how you set the main view's camera view matrix it'll just work with no needed changed. |
Beta Was this translation helpful? Give feedback.
-
Thanks Robert! It works! |
Beta Was this translation helpful? Give feedback.
-
Great to hear you got it working. I was hoping that a vsgExample might be possible this as it's something that other useful will be curious about. So if you can clean it up it'll be much appreciated :-) |
Beta Was this translation helpful? Give feedback.
-
I'm trying to implement a "Orienter Gizmo", that should show the xyz axis orientation in the corner of the viewport. My plan was to create a
OrienterTrackball
connected to an "orienter camera". TheOrienterTrackball
inheritsvsg::Trackball
but blocks the zoom and pan functions. That part worked fine and I can rotate my axes. But when trying to add the model trackball to the scene, I discovered that when I try to add a second event handler after adding the event handler for the orienter trackball, then those events are not processed. Here is the relevant code.How can I add events both to my (model) trackball and to my orienter trackball?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions