-
public class ManipulatorHelper 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 enumManipulator.Modepublic enumManipulator.Fovpublic enumManipulator.KeyKeys 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 classManipulator.Builder
-
Method Summary
Modifier and Type Method Description voidfinalize()Manipulator.ModegetMode()Gets the immutable mode of the manipulator. voidsetViewport(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. voidgetLookAt(@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. voidgetLookAt(@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. voidgrabBegin(int x, int y, boolean strafe)Starts a grabbing session (i.e. voidgrabUpdate(int x, int y)Updates a grabbing session.This must be called at least once between grabBegin / grabEnd to dirty the camera. voidgrabEnd()Ends a grabbing session. voidkeyDown(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. voidkeyUp(Manipulator.Key key)Signals that a key is now in the up state. voidscroll(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. voidupdate(float deltaTime)Processes input and updates internal state.This must be called once every frame before getLookAt is valid. BookmarkgetCurrentBookmark()Gets a handle that can be used to reset the manipulator back to its current position. BookmarkgetHomeBookmark()Gets a handle that can be used to reset the manipulator back to its home position. voidjumpToBookmark(Bookmark bookmark)Sets the manipulator position and orientation back to a stashed state. -
-
Method Detail
-
finalize
void finalize()
-
getMode
Manipulator.Mode getMode()
Gets the immutable mode of the manipulator.
-
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.
-
getLookAt
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. This is usually called once per frame.
-
getLookAt
void getLookAt(@NonNull() @Size(min = 3) Array<double> eyePosition, @NonNull() @Size(min = 3) Array<double> targetPosition, @NonNull() @Size(min = 3) Array<double> upward)
-
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 spacey- Y-coordinate for point of interest in viewport spacestrafe- 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.
-
keyUp
void keyUp(Manipulator.Key key)
Signals that a key is now in the up state.
-
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 modey- Y-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT modescrolldelta- 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.
-
-
-
-