Package 

Class Manipulator


  • 
    public class Manipulator
    
                        

    Helper that enables camera interaction similar to sketchfab or Google Maps. Clients notify the camera manipulator of various mouse or touch events, then periodically call its getLookAt() method so that they can adjust their camera(s). Three modes are supported: ORBIT, MAP, and FREE_FLIGHT. To construct a manipulator instance, the desired mode is passed into the create method.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public enum Manipulator.Mode
      public enum Manipulator.Fov
      public enum Manipulator.Key

      Keys used to translate the camera in FREE_FLIGHT mode.UP and DOWN dolly the camera forwards and backwards.LEFT and RIGHT strafe the camera left and right.

      public class Manipulator.Builder
    • Method Summary

      Modifier and Type Method Description
      void finalize()
      Manipulator.Mode getMode() Gets the immutable mode of the manipulator.
      void setViewport(int width, int height) Sets the viewport dimensions in terms of pixels.The manipulator uses this only in the grab and raycast methods, sincethose methods consume coordinates in viewport space.
      void getLookAt(@NonNull() @Size(min = 3) Array<float> eyePosition, @NonNull() @Size(min = 3) Array<float> targetPosition, @NonNull() @Size(min = 3) Array<float> upward) Gets the current orthonormal basis.
      void getLookAt(@NonNull() @Size(min = 3) Array<double> eyePosition, @NonNull() @Size(min = 3) Array<double> targetPosition, @NonNull() @Size(min = 3) Array<double> upward)
      Array<float> raycast(int x, int y) Given a viewport coordinate, picks a point in the ground plane.
      void grabBegin(int x, int y, boolean strafe) Starts a grabbing session (i.e.
      void grabUpdate(int x, int y) Updates a grabbing session.This must be called at least once between grabBegin / grabEnd to dirty the camera.
      void grabEnd() Ends a grabbing session.
      void keyDown(Manipulator.Key key) Keys used to translate the camera in FREE_FLIGHT mode.UP and DOWN dolly the camera forwards and backwards.LEFT and RIGHT strafe the camera left and right.UP and DOWN boom the camera upwards and downwards.
      void keyUp(Manipulator.Key key) Signals that a key is now in the up state.
      void scroll(int x, int y, float scrolldelta) In MAP and ORBIT modes, dollys the camera along the viewing direction.In FREE_FLIGHT mode, adjusts the move speed of the camera.
      void update(float deltaTime) Processes input and updates internal state.This must be called once every frame before getLookAt is valid.
      Bookmark getCurrentBookmark() Gets a handle that can be used to reset the manipulator back to its current position.
      Bookmark getHomeBookmark() Gets a handle that can be used to reset the manipulator back to its home position.
      void jumpToBookmark(Bookmark bookmark) Sets the manipulator position and orientation back to a stashed state.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setViewport

         void setViewport(int width, int height)

        Sets the viewport dimensions in terms of pixels.The manipulator uses this only in the grab and raycast methods, sincethose methods consume coordinates in viewport space.

      • raycast

        @Nullable()@Size(min = 3) Array<float> raycast(int x, int y)

        Given a viewport coordinate, picks a point in the ground plane.

      • grabBegin

         void grabBegin(int x, int y, boolean strafe)

        Starts a grabbing session (i.e. the user is dragging around in the viewport).In MAP mode, this starts a panning session.In ORBIT mode, this starts either rotating or strafing.In FREE_FLIGHT mode, this starts a nodal panning session.

        Parameters:
        x - X-coordinate for point of interest in viewport space
        y - Y-coordinate for point of interest in viewport space
        strafe - ORBIT mode only; if true, starts a translation rather than a rotation
      • grabUpdate

         void grabUpdate(int x, int y)

        Updates a grabbing session.This must be called at least once between grabBegin / grabEnd to dirty the camera.

      • grabEnd

         void grabEnd()

        Ends a grabbing session.

      • keyDown

         void keyDown(Manipulator.Key key)

        Keys used to translate the camera in FREE_FLIGHT mode.UP and DOWN dolly the camera forwards and backwards.LEFT and RIGHT strafe the camera left and right.UP and DOWN boom the camera upwards and downwards.

      • scroll

         void scroll(int x, int y, float scrolldelta)

        In MAP and ORBIT modes, dollys the camera along the viewing direction.In FREE_FLIGHT mode, adjusts the move speed of the camera.

        Parameters:
        x - X-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode
        y - Y-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode
        scrolldelta - In MAP and ORBIT modes, negative means "zoom in", positive means "zoom out"In FREE_FLIGHT mode, negative means "slower", positive means "faster"
      • update

         void update(float deltaTime)

        Processes input and updates internal state.This must be called once every frame before getLookAt is valid.

        Parameters:
        deltaTime - The amount of time, in seconds, passed since the previous call to update.
      • getCurrentBookmark

         Bookmark getCurrentBookmark()

        Gets a handle that can be used to reset the manipulator back to its current position.

      • getHomeBookmark

         Bookmark getHomeBookmark()

        Gets a handle that can be used to reset the manipulator back to its home position.see jumpToBookmark

      • jumpToBookmark

         void jumpToBookmark(Bookmark bookmark)

        Sets the manipulator position and orientation back to a stashed state.