Class Scene
- java.lang.Object
-
- com.jogamp.graph.ui.Scene
-
- All Implemented Interfaces:
Container,GLEventListener,EventListener
public final class Scene extends Object implements Container, GLEventListener
GraphUI SceneGraphUI is GPU based and resolution independent.
GraphUI is intended to become an immediate- and retained-mode API.
To utilize a Scene instance directly as a
GLEventListener, user needs tosetClearParams(float[], int). Otherwise user may just call providedGLEventListenerfrom within their own workflow -GLEventListener.init(GLAutoDrawable)-GLEventListener.reshape(GLAutoDrawable, int, int, int, int)-GLEventListener.display(GLAutoDrawable)-GLEventListener.dispose(GLAutoDrawable)setPMVMatrixSetup(PMVMatrixSetup)maybe used to provide a customPMVMatrix4fsetup.- See Also:
Shape
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classScene.DefaultPMVMatrixSetupDefault implementation ofScene.PMVMatrixSetup, implementingScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)as follows:GLMatrixFunc.GL_PROJECTIONMatrix Identity PerspectiveScene.DefaultPMVMatrixSetup.getAngle()withScene.DefaultPMVMatrixSetup.getZNear()andScene.DefaultPMVMatrixSetup.getZFar()Translated to givenScene.DefaultPMVMatrixSetup.getSceneDist()GLMatrixFunc.GL_MODELVIEWMatrix identitystatic interfaceScene.PMVMatrixSetupInterface providinga methodto setupPMVMatrix4f'sGLMatrixFunc.GL_PROJECTIONandGLMatrixFunc.GL_MODELVIEW.
-
Field Summary
Fields Modifier and Type Field Description static floatDEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALEDefault Z precision scale, i.e.static floatDEFAULT_ACTIVE_ZOFFSET_SCALEDefault Z precision scale, i.e.static floatDEFAULT_ANGLEDefault projection angle in radians is PI/4, i.e.static floatDEFAULT_SCENE_DISTDefault scene distance on z-axis to projection is -1/5f.static floatDEFAULT_Z16_EPSILONDefault Z precision on 16-bit depth buffer usingDEFAULT_SCENE_DISTz-position andDEFAULT_ZNEAR.static floatDEFAULT_ZFARDefault projection z-far value is 7000.0f.static floatDEFAULT_ZNEARDefault projection z-near value is 0.10000000149011612f.
-
Constructor Summary
Constructors Constructor Description Scene()Create a new scene with an internally createdRegionRenderer, a graph AA sample-count 4 and usingDefaultPMVMatrixSetup().Scene(int sampleCount)Create a new scene with an internally createdRegionRenderer, usingDefaultPMVMatrixSetup().Scene(RegionRenderer renderer)Create a new scene taking ownership of the given RegionRenderer, usingDefaultPMVMatrixSetup().
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDisposeAction(GLRunnable action)Add a user one-timeGLRunnabledisposal action to an internal list, all invoked at where the list is cleared afterwards similar to all shapes.voidaddGLEventListener(GLEventListener listener)voidaddShape(Shape s)Adds aShape.voidaddShapes(Collection<? extends Shape> shapes)voidattachGLAutoDrawable(GLAutoDrawable drawable)voidattachInputListenerTo(GLWindow window)booleancontains(Shape s)voiddetachGLAutoDrawable(GLAutoDrawable drawable)voiddetachInputListenerFrom(GLWindow window)voiddisplay(GLAutoDrawable drawable)Called by the drawable to initiate OpenGL rendering by the client.voiddispose(GLAutoDrawable drawable)intgetAAQuality()ReturnsRegionRenderer.getAAQuality().ShapegetActiveShape()floatgetActiveShapeZOffsetScale()Returns the activeShapeZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.floatgetActiveTopLevelZOffsetScale()Returns the generaltop-level widgetZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.com.jogamp.math.geom.AABBoxgetBounds()Describing the scene's object model-dimensions of the plane at scene-distance covering the visible viewport rectangle.com.jogamp.math.geom.AABBoxgetBounds(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)ReturnsAABBoxdimension of givenShapefrom this container's perspective, i.e.float[]getClearColor()Returns theglClearColor(..)arguments, seesetClearParams(float[], int).intgetClearMask()Returns theglClear(..)mask, seesetClearParams(float[], int).intgetHeight()Returns thegetViewport()'s height, set after initialreshape(GLAutoDrawable, int, int, int, int).com.jogamp.math.util.PMVMatrix4fgetMatrix()Borrow the currentPMVMatrix4f.Scene.PMVMatrixSetupgetPMVMatrixSetup()Return the default orsetPMVMatrixSetup(PMVMatrixSetup)Scene.PMVMatrixSetup.List<Shape>getRenderedShapes()Returnsadded shapeswhich are rendered and sorted by z-axis in ascending order toward z-near.RegionRenderergetRenderer()Returns the associated RegionRendererintgetSampleCount()ReturnsRegionRenderer.getSampleCount().intgetScreenshotCount()Return the number ofnextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String)calls.ShapegetShapeByID(int id)ShapegetShapeByIdx(int id)ShapegetShapeByName(String name)intgetShapeCount()Returns number ofShapes, seeContainer.getShapes().List<Shape>getShapes()static StringgetStatusText(FPSCounter fpsCounter)Return a formatted status string containing avg fps and avg frame duration.StringgetStatusText(GLAutoDrawable glad, int renderModes, float dpi)Return a formatted status string containing avg fps and avg frame duration.com.jogamp.math.RectigetViewport()Borrows the current int[4] viewport w/o copying.com.jogamp.math.RectigetViewport(com.jogamp.math.Recti target)Copies the current int[4] viewport in given target and returns it for chaining.intgetWidth()Returns thegetViewport()'s width, set after initialreshape(GLAutoDrawable, int, int, int, int).floatgetZEpsilon(int zBits)Return Z precision on using currentgetPMVMatrixSetup()'sScene.PMVMatrixSetup.getSceneDist()z-position andScene.PMVMatrixSetup.getZNear().static floatgetZEpsilon(int zBits, Scene.PMVMatrixSetup setup)Return Z precision on usingScene.PMVMatrixSetup.getSceneDist()z-position andScene.PMVMatrixSetup.getZNear().voidinit(GLAutoDrawable drawable)Called by the drawable immediately after the OpenGL context is initialized.booleaninvoke(boolean wait, GLRunnable glRunnable)Enqueues a one-shotGLRunnable, which will be executed within the nextGLAutoDrawable.display()call if thisScenehas been added as aGLEventListenerandinit(GLAutoDrawable)has been called.booleanisCullingEnabled()Return whetherProject-Modelview (PMv) frustum cullingorGroup's Modelview (Mv) frustum clippingis enabled for this container.booleanisOutside(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)Returns whether the givenShapeis completely outside of this container.booleanisOutside2(com.jogamp.math.Matrix4f mvCont, Shape shape, com.jogamp.math.util.PMVMatrix4f pmvShape)Returns whether the givenShapeis completely outside of this container.booleanisPMvCullingEnabled()Return whetherProject-Modelview (PMv) frustum cullingis enabled for this container.voidmarkShapesDirty()voidmarkStatesDirty()FilenextScreenshotFile(String dir, String prefix, int renderModes, GLCapabilitiesImmutable caps, String contentDetail)Return the unique next technical screenshot PNGFileinstance as follows:ShapepickShape(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Ray ray, int glWinX, int glWinY, com.jogamp.math.Vec3f objPos, Shape.Visitor1 visitor)voidpickShapeGL(int glWinX, int glWinY, com.jogamp.math.Vec3f objPos, Shape[] shape, Runnable runnable)Attempt to pick aShapeusing the OpenGL false color rendering.voidreleaseActiveShape()voidremoveAllShapes(GL2ES2 gl)Removes all given shapes and destroys them, convenient call forremoveAllShapes(GL2ES2, RegionRenderer).voidremoveAllShapes(GL2ES2 gl, RegionRenderer renderer)Removes all contained shapes withShape.destroy(GL2ES2, RegionRenderer).voidremoveGLEventListener(GLEventListener listener)ShaperemoveShape(Shape s)Removes given shape, w/oShape.destroy(GL2ES2, RegionRenderer).booleanremoveShape(GL2ES2 gl, RegionRenderer renderer, Shape s)Removes given shape withShape.destroy(GL2ES2, RegionRenderer), if contained.booleanremoveShape(GL2ES2 gl, Shape s)Removes given shape and destroy it, if contained - convenient call forremoveShape(GL2ES2, RegionRenderer, Shape).voidremoveShapes(GL2ES2 gl, RegionRenderer renderer, Collection<? extends Shape> shapes)Removes all given shapes withShape.destroy(GL2ES2, RegionRenderer).voidremoveShapes(GL2ES2 gl, Collection<? extends Shape> shapes)Removes all given shapes and destroys them, convenient call forremoveShape(GL2ES2, RegionRenderer, Shape)voidremoveShapes(Collection<? extends Shape> shapes)Removes all given shapes, w/oShape.destroy(GL2ES2, RegionRenderer).voidreshape(GLAutoDrawable drawable, int x, int y, int width, int height)Reshape scene using#setupMatrix(PMVMatrix4f, int, int, int, int)usingScene.PMVMatrixSetup.voidscreenshot(boolean wait, File file)Write current read drawable (screen) to a file onon the display call.voidscreenshot(GL gl, File file)Write current read drawable (screen) to a file.intsetAAQuality(int v)voidsetActiveShapeZOffsetScale(float v)Sets the activeShapeZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.voidsetActiveTopLevelZOffsetScale(float v)Sets the generaltop-level widgetZ-Offset scale, defaults toDEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE.voidsetClearParams(float[] clearColor, int clearMask)Sets the clear parameter forglClearColor(..)andglClear(..)to be issued atdisplay(GLAutoDrawable).voidsetPMvCullingEnabled(boolean v)Enable or disableProject-Modelview (PMv) frustumculling perShapefor this container.voidsetPMVMatrixSetup(Scene.PMVMatrixSetup setup)Set a customScene.PMVMatrixSetup.intsetSampleCount(int v)voidsetSharpness(float sharpness)voidsetupMatrix(com.jogamp.math.util.PMVMatrix4f pmv)SetupPMVMatrix4fGLMatrixFunc.GL_PROJECTIONandGLMatrixFunc.GL_MODELVIEWusing implicitgetViewport()surface dimension by callinggetPMVMatrixSetup()'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti).voidsetupMatrix(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Recti viewport)SetupPMVMatrix4fGLMatrixFunc.GL_PROJECTIONandGLMatrixFunc.GL_MODELVIEWby callinggetPMVMatrixSetup()'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti).voidsurfaceToPlaneSize(com.jogamp.math.Recti viewport, float zNear, float zFar, float objOrthoDist, com.jogamp.math.Vec2f objSceneSize)Map given window surface-size to object coordinates relative to this scene using the give projection parameters.voidsurfaceToPlaneSize(com.jogamp.math.Recti viewport, com.jogamp.math.Vec2f objSceneSize)Map given window surface-size to object coordinates relative to this scene using the defaultScene.PMVMatrixSetup, i.e.voidwaitUntilDisplayed()Blocks until firstdisplay(GLAutoDrawable)has completed after construction or {@link #dispose(GLAutoDrawable).static voidwinToPlaneCoord(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Recti viewport, float zNear, float zFar, float winX, float winY, float objOrthoZ, com.jogamp.math.Vec3f objPos)voidwinToShapeCoord(Shape shape, int glWinX, int glWinY, com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Vec3f objPos, Runnable runnable)CallingShape#winToObjCoord(Scene, int, int, float[]), retrieving its Shape object position.
-
-
-
Field Detail
-
DEFAULT_SCENE_DIST
public static final float DEFAULT_SCENE_DIST
Default scene distance on z-axis to projection is -1/5f.- See Also:
- Constant Field Values
-
DEFAULT_ANGLE
public static final float DEFAULT_ANGLE
Default projection angle in radians is PI/4, i.e. 45.0 degrees.- See Also:
- Constant Field Values
-
DEFAULT_ZNEAR
public static final float DEFAULT_ZNEAR
Default projection z-near value is 0.10000000149011612f.- See Also:
- Constant Field Values
-
DEFAULT_ZFAR
public static final float DEFAULT_ZFAR
Default projection z-far value is 7000.0f.- See Also:
- Constant Field Values
-
DEFAULT_Z16_EPSILON
public static final float DEFAULT_Z16_EPSILON
Default Z precision on 16-bit depth buffer usingDEFAULT_SCENE_DISTz-position andDEFAULT_ZNEAR. Value is6.1033297E-6.
-
DEFAULT_ACTIVE_ZOFFSET_SCALE
public static final float DEFAULT_ACTIVE_ZOFFSET_SCALE
Default Z precision scale, i.e. multiple ofDEFAULT_Z16_EPSILONforsetActiveShapeZOffsetScale(float). Value is 10.0f.- See Also:
- Constant Field Values
-
DEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE
public static final float DEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE
Default Z precision scale, i.e. multiple ofDEFAULT_Z16_EPSILONforsetActiveTopLevelZOffsetScale(float). Value is 100.0f.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Scene
public Scene()
Create a new scene with an internally createdRegionRenderer, a graph AA sample-count 4 and usingDefaultPMVMatrixSetup().
-
Scene
public Scene(int sampleCount)
Create a new scene with an internally createdRegionRenderer, usingDefaultPMVMatrixSetup().- Parameters:
sampleCount- sample count for Graph Region AArender-modes:Region.VBAA_RENDERING_BITorRegion.MSAA_RENDERING_BIT, clipped to [Region.MIN_AA_SAMPLE_COUNT..Region.MAX_AA_SAMPLE_COUNT]- See Also:
Scene(RegionRenderer),setSampleCount(int),setAAQuality(int)
-
Scene
public Scene(RegionRenderer renderer)
Create a new scene taking ownership of the given RegionRenderer, usingDefaultPMVMatrixSetup().- Parameters:
renderer-RegionRendererto be owned- See Also:
setSampleCount(int),setAAQuality(int)
-
-
Method Detail
-
getZEpsilon
public static float getZEpsilon(int zBits, Scene.PMVMatrixSetup setup)Return Z precision on usingScene.PMVMatrixSetup.getSceneDist()z-position andScene.PMVMatrixSetup.getZNear().- Parameters:
zBits- depth buffer bit-depth, minimum 16-bitsetup-Scene.PMVMatrixSetupfor scene-distance as z-position and zNear- Returns:
- the Z precision
-
getRenderer
public RegionRenderer getRenderer()
Returns the associated RegionRenderer
-
setClearParams
public final void setClearParams(float[] clearColor, int clearMask)Sets the clear parameter forglClearColor(..)andglClear(..)to be issued atdisplay(GLAutoDrawable). Without setting these parameter, user has to issueglClearColor(..)andglClear(..)before callingdisplay(GLAutoDrawable).- Parameters:
clearColor-glClearColor(..)argumentsclearMask-glClear(..)mask, default isGL.GL_COLOR_BUFFER_BIT|GL.GL_DEPTH_BUFFER_BIT
-
getClearColor
public final float[] getClearColor()
Returns theglClearColor(..)arguments, seesetClearParams(float[], int).
-
getClearMask
public final int getClearMask()
Returns theglClear(..)mask, seesetClearParams(float[], int).
-
setPMvCullingEnabled
public final void setPMvCullingEnabled(boolean v)
Description copied from interface:ContainerEnable or disableProject-Modelview (PMv) frustumculling perShapefor this container. Default is disabled.- Specified by:
setPMvCullingEnabledin interfaceContainer
-
isPMvCullingEnabled
public final boolean isPMvCullingEnabled()
Description copied from interface:ContainerReturn whetherProject-Modelview (PMv) frustum cullingis enabled for this container.- Specified by:
isPMvCullingEnabledin interfaceContainer
-
isCullingEnabled
public final boolean isCullingEnabled()
Description copied from interface:ContainerReturn whetherProject-Modelview (PMv) frustum cullingorGroup's Modelview (Mv) frustum clippingis enabled for this container. Default is disabled.- Specified by:
isCullingEnabledin interfaceContainer
-
attachGLAutoDrawable
public void attachGLAutoDrawable(GLAutoDrawable drawable)
-
detachGLAutoDrawable
public void detachGLAutoDrawable(GLAutoDrawable drawable)
-
attachInputListenerTo
public void attachInputListenerTo(GLWindow window)
-
detachInputListenerFrom
public void detachInputListenerFrom(GLWindow window)
-
getShapeCount
public int getShapeCount()
Description copied from interface:ContainerReturns number ofShapes, seeContainer.getShapes().- Specified by:
getShapeCountin interfaceContainer
-
getRenderedShapes
public List<Shape> getRenderedShapes()
Description copied from interface:ContainerReturnsadded shapeswhich are rendered and sorted by z-axis in ascending order toward z-near.The rendered shapes are
visibleand not deemed outside of this container due toculling.Only rendered shapes are considered for picking/activation.
The returned list is data-race free, i.e. won't be mutated by the rendering thread as it gets completely replace at each rendering loop using a local volatile reference.
Only when disposing the container, the list gets cleared, hence shall be used in the loop.- Specified by:
getRenderedShapesin interfaceContainer- See Also:
Container.addShape(Shape),Container.isCullingEnabled(),Shape.isVisible(),Container.isOutside(PMVMatrix4f, Shape)
-
removeShape
public Shape removeShape(Shape s)
Description copied from interface:ContainerRemoves given shape, w/oShape.destroy(GL2ES2, RegionRenderer).- Specified by:
removeShapein interfaceContainer- Returns:
- the removed shape or null if not contained
-
removeShapes
public void removeShapes(Collection<? extends Shape> shapes)
Description copied from interface:ContainerRemoves all given shapes, w/oShape.destroy(GL2ES2, RegionRenderer).- Specified by:
removeShapesin interfaceContainer
-
removeShape
public boolean removeShape(GL2ES2 gl, RegionRenderer renderer, Shape s)
Description copied from interface:ContainerRemoves given shape withShape.destroy(GL2ES2, RegionRenderer), if contained.- Specified by:
removeShapein interfaceContainer- Parameters:
gl- GL2ES2 contexts- the shape to be removed- Returns:
- true if given Shape is removed and destroyed
-
removeShape
public boolean removeShape(GL2ES2 gl, Shape s)
Removes given shape and destroy it, if contained - convenient call forremoveShape(GL2ES2, RegionRenderer, Shape).
-
addShapes
public void addShapes(Collection<? extends Shape> shapes)
-
removeShapes
public void removeShapes(GL2ES2 gl, RegionRenderer renderer, Collection<? extends Shape> shapes)
Description copied from interface:ContainerRemoves all given shapes withShape.destroy(GL2ES2, RegionRenderer).- Specified by:
removeShapesin interfaceContainer
-
removeShapes
public void removeShapes(GL2ES2 gl, Collection<? extends Shape> shapes)
Removes all given shapes and destroys them, convenient call forremoveShape(GL2ES2, RegionRenderer, Shape)
-
removeAllShapes
public void removeAllShapes(GL2ES2 gl, RegionRenderer renderer)
Description copied from interface:ContainerRemoves all contained shapes withShape.destroy(GL2ES2, RegionRenderer).- Specified by:
removeAllShapesin interfaceContainer
-
removeAllShapes
public void removeAllShapes(GL2ES2 gl)
Removes all given shapes and destroys them, convenient call forremoveAllShapes(GL2ES2, RegionRenderer).
-
getShapeByIdx
public Shape getShapeByIdx(int id)
- Specified by:
getShapeByIdxin interfaceContainer
-
getShapeByID
public Shape getShapeByID(int id)
- Specified by:
getShapeByIDin interfaceContainer
-
getShapeByName
public Shape getShapeByName(String name)
- Specified by:
getShapeByNamein interfaceContainer
-
getSampleCount
public int getSampleCount()
ReturnsRegionRenderer.getSampleCount().
-
setSampleCount
public int setSampleCount(int v)
- Returns:
- clipped and set value
-
getAAQuality
public int getAAQuality()
ReturnsRegionRenderer.getAAQuality().
-
setAAQuality
public int setAAQuality(int v)
- Returns:
- clipped and set value
-
setSharpness
public void setSharpness(float sharpness)
-
markShapesDirty
public void markShapesDirty()
-
markStatesDirty
public void markStatesDirty()
-
init
public void init(GLAutoDrawable drawable)
Description copied from interface:GLEventListenerCalled by the drawable immediately after the OpenGL context is initialized. Can be used to perform one-time OpenGL initialization per GLContext, such as setup of lights and display lists.Note that this method may be called more than once if the underlying OpenGL context for the GLAutoDrawable is destroyed and recreated, for example if a GLCanvas is removed from the widget hierarchy and later added again.
- Specified by:
initin interfaceGLEventListener
-
invoke
public boolean invoke(boolean wait, GLRunnable glRunnable) throws IllegalStateExceptionEnqueues a one-shotGLRunnable, which will be executed within the nextGLAutoDrawable.display()call if thisScenehas been added as aGLEventListenerandinit(GLAutoDrawable)has been called.- Parameters:
wait- iftrueblock until execution ofglRunnableis finished, otherwise return immediately w/o waitingglRunnable- theGLRunnableto execute within#display()- Returns:
trueif theGLRunnablehas been processed or queued, otherwisefalse.- Throws:
IllegalStateException- in case of a detected deadlock situation ahead, see above.- See Also:
GLAutoDrawable.invoke(boolean, GLRunnable)
-
addGLEventListener
public void addGLEventListener(GLEventListener listener)
-
removeGLEventListener
public void removeGLEventListener(GLEventListener listener)
-
reshape
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
Reshape scene using#setupMatrix(PMVMatrix4f, int, int, int, int)usingScene.PMVMatrixSetup.Called by the drawable during the first repaint after the component has been resized.
The client can update it's viewport associated data and view volume of the window appropriately.
For efficiency the GL viewport has already been updated via
glViewport(x, y, width, height)when this method is called.- Specified by:
reshapein interfaceGLEventListener- Parameters:
drawable- the triggeringGLAutoDrawablex- lower left corner of the viewport rectangle in pixel unitsy- lower left corner of the viewport rectangle in pixel unitswidth- width of the viewport rectangle in pixel unitsheight- height of the viewport rectangle in pixel units- See Also:
Scene.PMVMatrixSetup,setPMVMatrixSetup(PMVMatrixSetup),#setupMatrix(PMVMatrix4f, int, int, int, int),getBounds(),#getBoundsCenter()
-
isOutside
public final boolean isOutside(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)Description copied from interface:ContainerReturns whether the givenShapeis completely outside of this container.Note: If method returns false, the box may only be partially inside, i.e. intersects with this container
- Specified by:
isOutsidein interfaceContainer- Parameters:
pmv- currentPMVMatrix4fof this containershape- theShapeto test- See Also:
Container.isOutside2(Matrix4f, Shape, PMVMatrix4f),Shape#isOutside()
-
isOutside2
public boolean isOutside2(com.jogamp.math.Matrix4f mvCont, Shape shape, com.jogamp.math.util.PMVMatrix4f pmvShape)Description copied from interface:ContainerReturns whether the givenShapeis completely outside of this container.Note: If method returns false, the box may only be partially inside, i.e. intersects with this container
- Specified by:
isOutside2in interfaceContainer- Parameters:
mvCont- copy of the model-view {@link Matrix4f) of this containershape- theShapeto testpmvShape- currentPMVMatrix4fof the shape to test- See Also:
Container.isOutside(PMVMatrix4f, Shape),Shape#isOutside()
-
display
public void display(GLAutoDrawable drawable)
Description copied from interface:GLEventListenerCalled by the drawable to initiate OpenGL rendering by the client. After all GLEventListeners have been notified of a display event, the drawable will swap its buffers ifsetAutoSwapBufferModeis enabled.- Specified by:
displayin interfaceGLEventListener
-
waitUntilDisplayed
public void waitUntilDisplayed()
Blocks until firstdisplay(GLAutoDrawable)has completed after construction or {@link #dispose(GLAutoDrawable).
-
dispose
public void dispose(GLAutoDrawable drawable)
Disposes alladdedShapes.Implementation also issues
RegionRenderer.destroy(GL2ES2)if set anddetachInputListenerFrom(GLWindow)in case the drawable is of typeGLWindow.Notifies the listener to perform the release of all OpenGL resources per GLContext, such as memory buffers and GLSL programs.
Called by the drawable before the OpenGL context is destroyed by an external event, like a reconfiguration of the
GLAutoDrawableclosing an attached window, but also manually by callingdestroy.Note that this event does not imply the end of life of the application. It could be produced with a followup call to
GLEventListener.init(GLAutoDrawable)in case the GLContext has been recreated, e.g. due to a pixel configuration change in a multihead environment.- Specified by:
disposein interfaceGLEventListener
-
addDisposeAction
public void addDisposeAction(GLRunnable action)
Add a user one-timeGLRunnabledisposal action to an internal list, all invoked at where the list is cleared afterwards similar to all shapes.This allows proper take-down of custom user resources at exit.
- Parameters:
action- the customGLRunnabledisposal action
-
winToShapeCoord
public void winToShapeCoord(Shape shape, int glWinX, int glWinY, com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Vec3f objPos, Runnable runnable)
CallingShape#winToObjCoord(Scene, int, int, float[]), retrieving its Shape object position.- Parameters:
shape-glWinX- in GL window coordinates, origin bottom-leftglWinY- in GL window coordinates, origin bottom-leftpmv- a newPMVMatrix4fwhich willbe setup,shape-transformedand can be reused by the caller and runnable.objPos- resulting object positionrunnable- action
-
getBounds
public com.jogamp.math.geom.AABBox getBounds(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)Description copied from interface:Container
-
getPMVMatrixSetup
public final Scene.PMVMatrixSetup getPMVMatrixSetup()
Return the default orsetPMVMatrixSetup(PMVMatrixSetup)Scene.PMVMatrixSetup.
-
setPMVMatrixSetup
public final void setPMVMatrixSetup(Scene.PMVMatrixSetup setup)
Set a customScene.PMVMatrixSetup.
-
setupMatrix
public void setupMatrix(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Recti viewport)SetupPMVMatrix4fGLMatrixFunc.GL_PROJECTIONandGLMatrixFunc.GL_MODELVIEWby callinggetPMVMatrixSetup()'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti).- Parameters:
pmv- thePMVMatrix4fto setupRecti- viewport
-
setupMatrix
public void setupMatrix(com.jogamp.math.util.PMVMatrix4f pmv)
SetupPMVMatrix4fGLMatrixFunc.GL_PROJECTIONandGLMatrixFunc.GL_MODELVIEWusing implicitgetViewport()surface dimension by callinggetPMVMatrixSetup()'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti).- Parameters:
pmv- thePMVMatrix4fto setup
-
getViewport
public final com.jogamp.math.Recti getViewport(com.jogamp.math.Recti target)
Copies the current int[4] viewport in given target and returns it for chaining. It is set after initialreshape(GLAutoDrawable, int, int, int, int).
-
getViewport
public com.jogamp.math.Recti getViewport()
Borrows the current int[4] viewport w/o copying. It is set after initialreshape(GLAutoDrawable, int, int, int, int).
-
getWidth
public int getWidth()
Returns thegetViewport()'s width, set after initialreshape(GLAutoDrawable, int, int, int, int).
-
getHeight
public int getHeight()
Returns thegetViewport()'s height, set after initialreshape(GLAutoDrawable, int, int, int, int).
-
getMatrix
public com.jogamp.math.util.PMVMatrix4f getMatrix()
Borrow the currentPMVMatrix4f.
-
getBounds
public com.jogamp.math.geom.AABBox getBounds()
Describing the scene's object model-dimensions of the plane at scene-distance covering the visible viewport rectangle.The value is evaluated at
reshape(GLAutoDrawable, int, int, int, int)viaAABBox.getWidth()andAABBox.getHeight()define scene's dimension covered by surface size.AABBoxis setup viagetPMVMatrixSetup()'sScene.PMVMatrixSetup.setPlaneBox(AABBox, PMVMatrix4f, Recti).The default
Scene.PMVMatrixSetupimplementation scales to normalized plane dimensions, 1 for the greater of width and height.
-
getZEpsilon
public float getZEpsilon(int zBits)
Return Z precision on using currentgetPMVMatrixSetup()'sScene.PMVMatrixSetup.getSceneDist()z-position andScene.PMVMatrixSetup.getZNear().- Parameters:
zBits- depth buffer bit-depth, minimum 16-bit- Returns:
- the Z precision
-
winToPlaneCoord
public static void winToPlaneCoord(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Recti viewport, float zNear, float zFar, float winX, float winY, float objOrthoZ, com.jogamp.math.Vec3f objPos)- Parameters:
pmv-viewport-zNear-zFar-winX-winY-objOrthoZ-objPos- float[3] storage for object coord resultwinZ-
-
surfaceToPlaneSize
public void surfaceToPlaneSize(com.jogamp.math.Recti viewport, float zNear, float zFar, float objOrthoDist, com.jogamp.math.Vec2f objSceneSize)Map given window surface-size to object coordinates relative to this scene using the give projection parameters.- Parameters:
viewport- viewport rectanglezNear- customDEFAULT_ZNEARzFar- customDEFAULT_ZFARobjOrthoDist- customDEFAULT_SCENE_DISTobjSceneSize- Vec2f storage for object surface size result
-
surfaceToPlaneSize
public void surfaceToPlaneSize(com.jogamp.math.Recti viewport, com.jogamp.math.Vec2f objSceneSize)Map given window surface-size to object coordinates relative to this scene using the defaultScene.PMVMatrixSetup, i.e.DEFAULT_ZNEAR,DEFAULT_ZFARandDEFAULT_SCENE_DIST- Parameters:
viewport- viewport rectangleobjSceneSize- Vec2f storage for object surface size result
-
getActiveShape
public final Shape getActiveShape()
-
releaseActiveShape
public void releaseActiveShape()
-
getActiveShapeZOffsetScale
public float getActiveShapeZOffsetScale()
Returns the activeShapeZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.
-
setActiveShapeZOffsetScale
public void setActiveShapeZOffsetScale(float v)
Sets the activeShapeZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.
-
getActiveTopLevelZOffsetScale
public float getActiveTopLevelZOffsetScale()
Returns the generaltop-level widgetZ-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE.
-
setActiveTopLevelZOffsetScale
public void setActiveTopLevelZOffsetScale(float v)
Sets the generaltop-level widgetZ-Offset scale, defaults toDEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE.
-
pickShapeGL
public void pickShapeGL(int glWinX, int glWinY, com.jogamp.math.Vec3f objPos, Shape[] shape, Runnable runnable)
-
pickShape
public Shape pickShape(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Ray ray, int glWinX, int glWinY, com.jogamp.math.Vec3f objPos, Shape.Visitor1 visitor)
Attempt to pick aShapeusing the window coordinates and contained 'sAABBoxboundsusing a ray-intersection algorithm in Z-axis descending order.If
Shapewas found the given action is performed.Method performs on current thread and returns after either a shaper is determined to be picked/active or probing every
Shapew/o result.- Parameters:
pmv- a newPMVMatrix4fwhich willbe setup,shape-transformedand can be reused by the caller and runnable.ray- temporaryRaystorage, passed for reusageglWinX- window X coordinate, bottom-left originglWinY- window Y coordinate, bottom-left originobjPos- storage for found object position in model-space of foundShaperunnable- the action to perform ifShapewas found- Returns:
- last picked (inner) Shape if any or null
-
getStatusText
public String getStatusText(GLAutoDrawable glad, int renderModes, float dpi)
Return a formatted status string containing avg fps and avg frame duration.- Parameters:
glad- GLAutoDrawable instance for FPSCounter, its chosen GLCapabilities and its GL's swap-intervalrenderModes- render modes forRegion.getRenderModeString(int, int, int, int)dpi- the monitor's DPI (vertical preferred)- Returns:
- formatted status string
-
getStatusText
public static String getStatusText(FPSCounter fpsCounter)
Return a formatted status string containing avg fps and avg frame duration.- Parameters:
fpsCounter- the counter, must not be null- Returns:
- formatted status string
-
nextScreenshotFile
public File nextScreenshotFile(String dir, String prefix, int renderModes, GLCapabilitiesImmutable caps, String contentDetail)
Return the unique next technical screenshot PNGFileinstance as follows:filename = [{dir}][{prefix}-]Implementation incrementsRegion.getRenderModeString(int, int, int, int)[-{contentDetails}]-snap{screenShotCount}-{resolution}.pnggetScreenshotCount().- Parameters:
dir- the target directory, may be `null` or an empty stringprefix- the prefix, may be `null` or an empty stringrenderModes- the used Graph renderModes, seecreate(..)caps- the usedGLCapabilitiesImmutableused to retrieved the full-screen AA (fsaa)GLCapabilitiesImmutable.getNumSamples()contentDetail- user content details to be added at the end but beforegetScreenshotCount(), may be `null` or an empty string- Returns:
- a unique descriptive screenshot filename
- See Also:
screenshot(GL, File),screenshot(boolean, File),getScreenshotCount()
-
getScreenshotCount
public int getScreenshotCount()
Return the number ofnextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String)calls.
-
screenshot
public void screenshot(GL gl, File file)
Write current read drawable (screen) to a file.Best to be
invoked on the display call, see#screenshot(boolean, String).- Parameters:
gl- current GL objectfile- the target file to be used, consider usingnextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String)- See Also:
nextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String),getScreenshotCount(),screenshot(boolean, File)
-
screenshot
public void screenshot(boolean wait, File file)Write current read drawable (screen) to a file onon the display call.- Parameters:
wait- if true block until execution of screenshotGLRunnableis finished, otherwise return immediately w/o waitingfile- the target file to be used, consider usingnextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String)- See Also:
nextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String),getScreenshotCount(),screenshot(GL, File)
-
-