Class Viewport
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
com.marginallyclever.ro3.apps.App
com.marginallyclever.ro3.apps.viewport.OpenGLPanel
com.marginallyclever.ro3.apps.viewport.Viewport
- All Implemented Interfaces:
com.jogamp.opengl.GLEventListener
,MouseListener
,MouseMotionListener
,MouseWheelListener
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
Viewport
is an OpenGLPanel
that uses a set of RenderPass
es to draw the
Registry.getScene()
from the perspective of a Registry.getActiveCamera()
.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
Nested classes/interfaces inherited from class java.awt.Component
Component.BaselineResizeBehavior
-
Field Summary
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
void
display
(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) void
dispose
(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) double
javax.vecmath.Vector3d
javax.vecmath.Point2d
double
getRayThroughPoint
(Camera camera, double x, double y) Return the ray coming through the viewport in the current projection.double
void
init
(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) void
void
void
void
void
void
void
void
reshape
(com.jogamp.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) void
Save the viewport pass state to thePreferences
.void
setOrbitChangeFactor
(double amount) void
setUserMovementScale
(double scale) Set the scale of user movement.Methods inherited from class com.marginallyclever.ro3.apps.viewport.OpenGLPanel
addGLEventListener, getFsaaSamples, isDoubleBuffered, isHardwareAccelerated, isVerticalSync, mouseEntered, mouseExited, removeGLEventListener, savePrefs, setDoubleBuffered, setFsaaSamples, setHardwareAccelerated, setVerticalSync, stopAnimationSystem
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
Methods inherited from class javax.swing.JComponent
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
renderPasses
-
-
Constructor Details
-
Viewport
public Viewport()
-
-
Method Details
-
saveRenderPassState
public void saveRenderPassState()Save the viewport pass state to thePreferences
. -
addNotify
public void addNotify()- Overrides:
addNotify
in classOpenGLPanel
-
removeNotify
public void removeNotify()- Overrides:
removeNotify
in classOpenGLPanel
-
init
public void init(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) - Specified by:
init
in interfacecom.jogamp.opengl.GLEventListener
- Overrides:
init
in classOpenGLPanel
-
dispose
public void dispose(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) - Specified by:
dispose
in interfacecom.jogamp.opengl.GLEventListener
- Overrides:
dispose
in classOpenGLPanel
-
reshape
public void reshape(com.jogamp.opengl.GLAutoDrawable glAutoDrawable, int x, int y, int width, int height) - Specified by:
reshape
in interfacecom.jogamp.opengl.GLEventListener
- Overrides:
reshape
in classOpenGLPanel
-
display
public void display(com.jogamp.opengl.GLAutoDrawable glAutoDrawable) - Specified by:
display
in interfacecom.jogamp.opengl.GLEventListener
- Overrides:
display
in classOpenGLPanel
-
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
- Overrides:
mouseClicked
in classOpenGLPanel
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classOpenGLPanel
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classOpenGLPanel
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classOpenGLPanel
-
mouseWheelMoved
- Specified by:
mouseWheelMoved
in interfaceMouseWheelListener
- Overrides:
mouseWheelMoved
in classOpenGLPanel
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classOpenGLPanel
-
getOrbitChangeFactor
public double getOrbitChangeFactor() -
setOrbitChangeFactor
public void setOrbitChangeFactor(double amount) - Parameters:
amount
- a value greater than one.
-
getRayThroughPoint
Return the ray coming through the viewport in the current projection. Remember that in OpenGL the camera -Z=forward, +X=right, +Y=up
- Parameters:
x
- the cursor position in screen coordinates [-1,1]y
- the cursor position in screen coordinates [-1,1]- Returns:
- the ray coming through the viewport in the current projection.
-
getCursorAsNormalized
public javax.vecmath.Vector3d getCursorAsNormalized()- Returns:
- the cursor position as values from -1...1.
-
getCursorPosition
public javax.vecmath.Point2d getCursorPosition() -
getAspectRatio
public double getAspectRatio() -
getUserMovementScale
public double getUserMovementScale() -
setUserMovementScale
public void setUserMovementScale(double scale) Set the scale of user movement. This is used to scale the mouse movement to the camera movement.- Parameters:
scale
- a value greater than zero.
-