Package boofcv.gui.mesh
Class MeshViewerPanel
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
boofcv.gui.mesh.MeshViewerPanel
- All Implemented Interfaces:
ImageObserver,KeyEventDispatcher,MenuContainer,Serializable,Accessible,VerbosePrint
Displays a rendered mesh in 3D and provides mouse and keyboard controls for moving the camera. Each shape in the
mesh can be assigned a single color. By default this colorization will be based on the normal angle, but the user
can provide custom colors. Two styles of control are provided by default orbit and
first person, again the user can provide others easily.
To ensure smooth updates a double buffer is used and rendering is done in a separate thread. All rendering is done in software and can't use a GPU. The rendering thread will automatically stop and stop depending on the lifecycle of this panel.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JPanel
JPanel.AccessibleJPanelNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionintHow big the help button appears to bestatic final StringName given to the default approach that colorizes based on normal anglebooleanIf the help button existsFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.MeshViewerPanel(VertexMesh mesh) Convenience constructor that callssetMesh(VertexMesh, boolean)and the default constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidEach time this is called it will change the colorizer being used, if more than one has been specifiedbooleanProvides keyboard commands that adjust how and what data is displayedintvoidvoidPerform clean up when this component is no longer being usedvoidRequests that a new image is rendered.voidsetActiveControl(String name) Changes the active camera controlvoidsetHorizontalFov(double degrees) Changes the camera's horizontal field-of-view.voidsetMesh(VertexMesh mesh, boolean copy) Sets the mesh which will be rendered.voidsetRenderBackgroundColor(int rgba) Color of background when renderingvoidsetSurfaceColor(String name, RenderMesh.SurfaceColor colorizer) Let's ou specify the RGB color for each vertex in the mesh.voidsetVerbose(@Nullable PrintStream out, @Nullable Set<String> configuration) voidsetVertexColors(String name, int[] vertexColors) It will colorize each surface using the color of the vertexesvoidOpens a window which provides help about keys and let's the user modify control settingsvoidSend a request that the rendering threadMethods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUIMethods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, 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
-
COLOR_NORMAL
Name given to the default approach that colorizes based on normal angle- See Also:
-
buttonSize
public int buttonSizeHow big the help button appears to be -
helpButtonFont
-
helpButtonActive
public boolean helpButtonActiveIf the help button exists
-
-
Constructor Details
-
MeshViewerPanel
Convenience constructor that callssetMesh(VertexMesh, boolean)and the default constructor.- Parameters:
mesh- That mesh which is to be viewed. A reference is saved internally.
-
MeshViewerPanel
public MeshViewerPanel()Default constructor. Configures the GUI and adds in default controls and colorizations.
-
-
Method Details
-
setActiveControl
Changes the active camera control -
removeNotify
public void removeNotify()Perform clean up when this component is no longer being used- Overrides:
removeNotifyin classJComponent
-
shutdownRenderThread
public void shutdownRenderThread()Send a request that the rendering thread -
setMesh
Sets the mesh which will be rendered.- Parameters:
copy- If true then a copy of the mesh will be made and saved. If false then a reference will be saved. You should create a copy if this mesh is going to be modified.
-
setSurfaceColor
Let's ou specify the RGB color for each vertex in the mesh.- Parameters:
name- Name given to this colorization approach
-
setVertexColors
It will colorize each surface using the color of the vertexes- Parameters:
name- Name given to this colorization approach
-
requestRender
public void requestRender()Requests that a new image is rendered. Typically this is done when a configuration has changed. It will render when the rendering thread has a chance. -
setHorizontalFov
public void setHorizontalFov(double degrees) Changes the camera's horizontal field-of-view.- Parameters:
degrees- FOV in degrees
-
cycleColorizer
public void cycleColorizer()Each time this is called it will change the colorizer being used, if more than one has been specified -
paintComponent
- Overrides:
paintComponentin classJComponent
-
showHelpWindow
public void showHelpWindow()Opens a window which provides help about keys and let's the user modify control settings -
setVerbose
public void setVerbose(@Nullable @Nullable PrintStream out, @Nullable @Nullable Set<String> configuration) - Specified by:
setVerbosein interfaceVerbosePrint
-
setRenderBackgroundColor
public void setRenderBackgroundColor(int rgba) Color of background when rendering -
getRenderBackgroundColor
public int getRenderBackgroundColor() -
dispatchKeyEvent
Provides keyboard commands that adjust how and what data is displayed- Specified by:
dispatchKeyEventin interfaceKeyEventDispatcher
-