Announcement

Collapse
No announcement yet.

Check the pan/zoom/rotate mouse action in Viewer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Check the pan/zoom/rotate mouse action in Viewer

    Dear All,
    Please, i like to know if there is a way to check if the user is performing a 3D scene pan/zoom/rotate by mouse action in a 3D Viewer (for exampe SoWinExaminerViewer);

    i'll try to well explain my strange request; my scenario is the following:
    for example assume i have my scene graph with a translation and a cube; a timer change the translation value so i can see move the cube;
    I have also a field sensor attached to camera field (position) in order to have the POV active always on the cube (so i don'r view the cube excaping from the viewer after a while);
    in other words, the translation field changes but the cube is still (or stationary if prefer)


    i know that if i pan/rotate/zoom the scene the SoCamera fields changes, but is there another way to catch these actions?

    I hope i explained well my strange request, in other case don't hesitate to get further information.

    Regards,
    Vincenzo

  • #2
    Hi Vincenzo,
    I think I "almost" understand your scenario. :-)
    I understand that a translation is moving a cube in the scene but you also want the camera to be always looking at the cube.
    That implies: whenever the translation is changed, you make a corresponding change to the camera position. Right?

    Question 1: You said that you have a field sensor attached to the camera 'position' field to keep the POV always on the cube.
    But a field sensor attached to the position field can only detect changes made to the position field.
    Do you mean there is a field sensor attached to the translation node's translation field and the sensor's callback updates the camera position?

    Question 2: "Is there another way to catch these actions" (pan/rotate/zoom), do you mean to block/prevent these actions or just to detect these actions?
    Some related comments:
    - You can block pan/rotate/zoom from happening by switching the viewer to 'selection' mode.
    But that's probably too obvious, you certainly know that option.
    - You can detect that some sort of pan/rotate/zoom operation is happening using the viewer's addStartCallback()/addFinishCallback() methods.
    For example, if you want to pause the animation of the cube while the user adjusts the camera.

    Regards,
    Mike

    Comment


    • #3
      Dear Mike,
      thank You for Your reply and i apologize for my mistakes:
      in question 1, yes You're right!! the field sensor is attached to translation node's translation; excuse me!

      as regard as question 2, i didn't like to block viewer interactions and i try to take a look to start/finish callback: this seems the right way for me.

      Please, just another question: is there an example about start/finish camera callback in order to investigate the actions?

      I always thank You for Your precious help;

      Best regards,

      Vincenzo

      Comment


      • #4
        Originally posted by [email protected] View Post
        Please, just another question: is there an example about start/finish camera callback in order to investigate the actions?
        Hi Vincenzo,
        You probably figured it out by now. :-) I did not find a simple example using the viewer start/finish callbacks, but it's straightforward.
        Code:
        void viewerStartCB( void* data, SoWinViewer* viewer) {
          // Interaction has started
        }
        void viewerFinishCB( void* data, SoWinViewer* viewer) {
          // Interaction has ended
        }
        Code:
          viewer->addStartCallback( viewerStartCB );
          viewer->addFinishCallback( viewerFinishCB );
        The start callback is called when the viewer is in viewing mode ("hand" cursor) and the user presses a mouse button. The finish callback is called when the mouse button is released.
        Regards,
        Mike

        Comment


        • #5
          Good Morning Mike,
          thank You very much for Your suggestions, time and Help;

          Have a nice day.

          Regards,

          Vincenzo

          Comment

          Working...
          X