Announcement

Collapse
No announcement yet.

Camera Help

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

  • Camera Help

    I am using the SwSimpleViewer and my intention is to replace having to use PICK_MODE and VIEW_MODE separately so I have set up Mouse Events and I need them to do specific events.

    What I want to be able to do is replicate camera movement in PICK_MODE, so I have the scroll wheel zooming the camera properly but now I need to do the rest.
    I need clicking and holding the scroll wheel to pan, and clicking and holding the right mouse button to rotate around. I am looking in the source code and cannot find exactly how it works in VIEW_MODE.

    I am using Java btw, I notice a lot of examples use C++ and it is pretty difficult to convert it in this particular case.

    If you have the process already written that I can use that would be wonderful.

    This also brings another issue up. I want to remove the right click popup from coming up on mouse down so I can make my own. When I use viewer.getPopup.setEnabled(false) all it does is make the options in the right click menu unusable. If there is a way to remove that in SwSimpleViewer that would be very useful as well.

    Thanks.

  • #2
    Here is my code btw. It is written in Scala:

    private class MouseEventCB extends SoEventCallbackCB {
    override def invoke(eventCB: SoEventCallback) = {
    val event = eventCB.getEvent.asInstanceOf[SoMouseButtonEvent]

    if(event.getState == SoButtonEvent.States.DOWN) {
    event.getButton match {
    case SoMouseButtonEvent.Buttons.BUTTON1 => println("left")
    case SoMouseButtonEvent.Buttons.BUTTON2 => println("scroll")
    case SoMouseButtonEvent.Buttons.BUTTON3 => println("right")
    case _ =>
    }

    buttonPressed = true

    }
    if (event.getState == SoButtonEvent.States.UP && buttonPressed.==(true)) {

    event.getButton match {
    case SoMouseButtonEvent.Buttons.BUTTON1 => println("left release")
    case SoMouseButtonEvent.Buttons.BUTTON2 => println("scroll release")
    case SoMouseButtonEvent.Buttons.BUTTON3 => println("right release")
    case _ =>
    }
    buttonPressed = false
    }
    }
    }

    Comment


    • #3
      Re: Camera Help

      Originally posted by ZachSMS View Post
      I am using the SwSimpleViewer and my intention is to replace having to use PICK_MODE and VIEW_MODE separately so I have set up Mouse Events and I need them to do specific events.

      What I want to be able to do is replicate camera movement in PICK_MODE, so I have the scroll wheel zooming the camera properly but now I need to do the rest.
      I need clicking and holding the scroll wheel to pan, and clicking and holding the right mouse button to rotate around. I am looking in the source code and cannot find exactly how it works in VIEW_MODE.
      Hi,
      You're on the right track with the code you posted! The basic camera manipulation algorithms that SwSimpleViewer (aka the Examiner viewer) uses are provided for application use in a utility class called SoCameraInteractor. If you want to see which methods are called for which events to emulate the standard Examiner viewer, take a look at (in the Java SDK):
      $OIVHOME/examples/sources/inventor/gui/viewercomponents/SceneExaminer.java

      The SceneExaminer class is part of a larger example that shows how to completely replace SwSimpleViewer using the "viewerComponents" classes. But you can use SceneExaminer as a model to "fill in the blanks" in the event handling code you've already started and that should work with SwSimpleViewer.

      Comment


      • #4
        Thanks! I got it to work!

        Comment

        Working...
        X