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 providedGLEventListener
from 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 customPMVMatrix4f
setup.- See Also:
Shape
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Scene.DefaultPMVMatrixSetup
Default implementation ofScene.PMVMatrixSetup
, implementingScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)
as follows:GLMatrixFunc.GL_PROJECTION
Matrix Identity PerspectiveScene.DefaultPMVMatrixSetup.getAngle()
withScene.DefaultPMVMatrixSetup.getZNear()
andScene.DefaultPMVMatrixSetup.getZFar()
Translated to givenScene.DefaultPMVMatrixSetup.getSceneDist()
GLMatrixFunc.GL_MODELVIEW
Matrix identitystatic interface
Scene.PMVMatrixSetup
Interface providinga method
to setupPMVMatrix4f
'sGLMatrixFunc.GL_PROJECTION
andGLMatrixFunc.GL_MODELVIEW
.
-
Field Summary
Fields Modifier and Type Field Description static float
DEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE
Default Z precision scale, i.e.static float
DEFAULT_ACTIVE_ZOFFSET_SCALE
Default Z precision scale, i.e.static float
DEFAULT_ANGLE
Default projection angle in radians is PI/4, i.e.static float
DEFAULT_SCENE_DIST
Default scene distance on z-axis to projection is -1/5f.static float
DEFAULT_Z16_EPSILON
Default Z precision on 16-bit depth buffer usingDEFAULT_SCENE_DIST
z-position andDEFAULT_ZNEAR
.static float
DEFAULT_ZFAR
Default projection z-far value is 7000.0f.static float
DEFAULT_ZNEAR
Default 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 void
addDisposeAction(GLRunnable action)
Add a user one-timeGLRunnable
disposal action to an internal list, all invoked at where the list is cleared afterwards similar to all shapes.void
addGLEventListener(GLEventListener listener)
void
addShape(Shape s)
Adds aShape
.void
addShapes(Collection<? extends Shape> shapes)
void
attachGLAutoDrawable(GLAutoDrawable drawable)
void
attachInputListenerTo(GLWindow window)
boolean
contains(Shape s)
void
detachGLAutoDrawable(GLAutoDrawable drawable)
void
detachInputListenerFrom(GLWindow window)
void
display(GLAutoDrawable drawable)
Called by the drawable to initiate OpenGL rendering by the client.void
dispose(GLAutoDrawable drawable)
int
getAAQuality()
ReturnsRegionRenderer.getAAQuality()
.Shape
getActiveShape()
float
getActiveShapeZOffsetScale()
Returns the activeShape
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.float
getActiveTopLevelZOffsetScale()
Returns the generaltop-level widget
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.com.jogamp.math.geom.AABBox
getBounds()
Describing the scene's object model-dimensions of the plane at scene-distance covering the visible viewport rectangle.com.jogamp.math.geom.AABBox
getBounds(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)
ReturnsAABBox
dimension of givenShape
from this container's perspective, i.e.float[]
getClearColor()
Returns theglClearColor(..)
arguments, seesetClearParams(float[], int)
.int
getClearMask()
Returns theglClear(..)
mask, seesetClearParams(float[], int)
.int
getHeight()
Returns thegetViewport()
's height, set after initialreshape(GLAutoDrawable, int, int, int, int)
.com.jogamp.math.util.PMVMatrix4f
getMatrix()
Borrow the currentPMVMatrix4f
.Scene.PMVMatrixSetup
getPMVMatrixSetup()
Return the default orsetPMVMatrixSetup(PMVMatrixSetup)
Scene.PMVMatrixSetup
.List<Shape>
getRenderedShapes()
Returnsadded shapes
which are rendered and sorted by z-axis in ascending order toward z-near.RegionRenderer
getRenderer()
Returns the associated RegionRendererint
getSampleCount()
ReturnsRegionRenderer.getSampleCount()
.int
getScreenshotCount()
Return the number ofnextScreenshotFile(String, String, int, GLCapabilitiesImmutable, String)
calls.Shape
getShapeByID(int id)
Shape
getShapeByIdx(int id)
Shape
getShapeByName(String name)
int
getShapeCount()
Returns number ofShape
s, seeContainer.getShapes()
.List<Shape>
getShapes()
static String
getStatusText(FPSCounter fpsCounter)
Return a formatted status string containing avg fps and avg frame duration.String
getStatusText(GLAutoDrawable glad, int renderModes, float dpi)
Return a formatted status string containing avg fps and avg frame duration.com.jogamp.math.Recti
getViewport()
Borrows the current int[4] viewport w/o copying.com.jogamp.math.Recti
getViewport(com.jogamp.math.Recti target)
Copies the current int[4] viewport in given target and returns it for chaining.int
getWidth()
Returns thegetViewport()
's width, set after initialreshape(GLAutoDrawable, int, int, int, int)
.float
getZEpsilon(int zBits)
Return Z precision on using currentgetPMVMatrixSetup()
'sScene.PMVMatrixSetup.getSceneDist()
z-position andScene.PMVMatrixSetup.getZNear()
.static float
getZEpsilon(int zBits, Scene.PMVMatrixSetup setup)
Return Z precision on usingScene.PMVMatrixSetup.getSceneDist()
z-position andScene.PMVMatrixSetup.getZNear()
.void
init(GLAutoDrawable drawable)
Called by the drawable immediately after the OpenGL context is initialized.boolean
invoke(boolean wait, GLRunnable glRunnable)
Enqueues a one-shotGLRunnable
, which will be executed within the nextGLAutoDrawable.display()
call if thisScene
has been added as aGLEventListener
andinit(GLAutoDrawable)
has been called.boolean
isCullingEnabled()
Return whetherProject-Modelview (PMv) frustum culling
orGroup's Modelview (Mv) frustum clipping
is enabled for this container.boolean
isOutside(com.jogamp.math.util.PMVMatrix4f pmv, Shape shape)
Returns whether the givenShape
is completely outside of this container.boolean
isOutside2(com.jogamp.math.Matrix4f mvCont, Shape shape, com.jogamp.math.util.PMVMatrix4f pmvShape)
Returns whether the givenShape
is completely outside of this container.boolean
isPMvCullingEnabled()
Return whetherProject-Modelview (PMv) frustum culling
is enabled for this container.void
markShapesDirty()
void
markStatesDirty()
File
nextScreenshotFile(String dir, String prefix, int renderModes, GLCapabilitiesImmutable caps, String contentDetail)
Return the unique next technical screenshot PNGFile
instance as follows: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)
void
pickShapeGL(int glWinX, int glWinY, com.jogamp.math.Vec3f objPos, Shape[] shape, Runnable runnable)
Attempt to pick aShape
using the OpenGL false color rendering.void
releaseActiveShape()
void
removeAllShapes(GL2ES2 gl)
Removes all given shapes and destroys them, convenient call forremoveAllShapes(GL2ES2, RegionRenderer)
.void
removeAllShapes(GL2ES2 gl, RegionRenderer renderer)
Removes all contained shapes withShape.destroy(GL2ES2, RegionRenderer)
.void
removeGLEventListener(GLEventListener listener)
Shape
removeShape(Shape s)
Removes given shape, w/oShape.destroy(GL2ES2, RegionRenderer)
.boolean
removeShape(GL2ES2 gl, RegionRenderer renderer, Shape s)
Removes given shape withShape.destroy(GL2ES2, RegionRenderer)
, if contained.boolean
removeShape(GL2ES2 gl, Shape s)
Removes given shape and destroy it, if contained - convenient call forremoveShape(GL2ES2, RegionRenderer, Shape)
.void
removeShapes(GL2ES2 gl, RegionRenderer renderer, Collection<? extends Shape> shapes)
Removes all given shapes withShape.destroy(GL2ES2, RegionRenderer)
.void
removeShapes(GL2ES2 gl, Collection<? extends Shape> shapes)
Removes all given shapes and destroys them, convenient call forremoveShape(GL2ES2, RegionRenderer, Shape)
void
removeShapes(Collection<? extends Shape> shapes)
Removes all given shapes, w/oShape.destroy(GL2ES2, RegionRenderer)
.void
reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
Reshape scene using#setupMatrix(PMVMatrix4f, int, int, int, int)
usingScene.PMVMatrixSetup
.void
screenshot(boolean wait, File file)
Write current read drawable (screen) to a file onon the display call
.void
screenshot(GL gl, File file)
Write current read drawable (screen) to a file.int
setAAQuality(int v)
void
setActiveShapeZOffsetScale(float v)
Sets the activeShape
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.void
setActiveTopLevelZOffsetScale(float v)
Sets the generaltop-level widget
Z-Offset scale, defaults toDEFAULT_ACTIVE_TOPLEVEL_ZOFFSET_SCALE
.void
setClearParams(float[] clearColor, int clearMask)
Sets the clear parameter forglClearColor(..)
andglClear(..)
to be issued atdisplay(GLAutoDrawable)
.void
setPMvCullingEnabled(boolean v)
Enable or disableProject-Modelview (PMv) frustum
culling perShape
for this container.void
setPMVMatrixSetup(Scene.PMVMatrixSetup setup)
Set a customScene.PMVMatrixSetup
.int
setSampleCount(int v)
void
setSharpness(float sharpness)
void
setupMatrix(com.jogamp.math.util.PMVMatrix4f pmv)
SetupPMVMatrix4f
GLMatrixFunc.GL_PROJECTION
andGLMatrixFunc.GL_MODELVIEW
using implicitgetViewport()
surface dimension by callinggetPMVMatrixSetup()
'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)
.void
setupMatrix(com.jogamp.math.util.PMVMatrix4f pmv, com.jogamp.math.Recti viewport)
SetupPMVMatrix4f
GLMatrixFunc.GL_PROJECTION
andGLMatrixFunc.GL_MODELVIEW
by callinggetPMVMatrixSetup()
'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)
.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.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.void
waitUntilDisplayed()
Blocks until firstdisplay(GLAutoDrawable)
has completed after construction or {@link #dispose(GLAutoDrawable).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)
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.
-
-
-
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_DIST
z-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_EPSILON
forsetActiveShapeZOffsetScale(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_EPSILON
forsetActiveTopLevelZOffsetScale(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_BIT
orRegion.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
-RegionRenderer
to 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.PMVMatrixSetup
for 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:Container
Enable or disableProject-Modelview (PMv) frustum
culling perShape
for this container. Default is disabled.- Specified by:
setPMvCullingEnabled
in interfaceContainer
-
isPMvCullingEnabled
public final boolean isPMvCullingEnabled()
Description copied from interface:Container
Return whetherProject-Modelview (PMv) frustum culling
is enabled for this container.- Specified by:
isPMvCullingEnabled
in interfaceContainer
-
isCullingEnabled
public final boolean isCullingEnabled()
Description copied from interface:Container
Return whetherProject-Modelview (PMv) frustum culling
orGroup's Modelview (Mv) frustum clipping
is enabled for this container. Default is disabled.- Specified by:
isCullingEnabled
in 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:Container
Returns number ofShape
s, seeContainer.getShapes()
.- Specified by:
getShapeCount
in interfaceContainer
-
getRenderedShapes
public List<Shape> getRenderedShapes()
Description copied from interface:Container
Returnsadded shapes
which are rendered and sorted by z-axis in ascending order toward z-near.The rendered shapes are
visible
and 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:
getRenderedShapes
in interfaceContainer
- See Also:
Container.addShape(Shape)
,Container.isCullingEnabled()
,Shape.isVisible()
,Container.isOutside(PMVMatrix4f, Shape)
-
removeShape
public Shape removeShape(Shape s)
Description copied from interface:Container
Removes given shape, w/oShape.destroy(GL2ES2, RegionRenderer)
.- Specified by:
removeShape
in interfaceContainer
- Returns:
- the removed shape or null if not contained
-
removeShapes
public void removeShapes(Collection<? extends Shape> shapes)
Description copied from interface:Container
Removes all given shapes, w/oShape.destroy(GL2ES2, RegionRenderer)
.- Specified by:
removeShapes
in interfaceContainer
-
removeShape
public boolean removeShape(GL2ES2 gl, RegionRenderer renderer, Shape s)
Description copied from interface:Container
Removes given shape withShape.destroy(GL2ES2, RegionRenderer)
, if contained.- Specified by:
removeShape
in 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:Container
Removes all given shapes withShape.destroy(GL2ES2, RegionRenderer)
.- Specified by:
removeShapes
in 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:Container
Removes all contained shapes withShape.destroy(GL2ES2, RegionRenderer)
.- Specified by:
removeAllShapes
in 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:
getShapeByIdx
in interfaceContainer
-
getShapeByID
public Shape getShapeByID(int id)
- Specified by:
getShapeByID
in interfaceContainer
-
getShapeByName
public Shape getShapeByName(String name)
- Specified by:
getShapeByName
in 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:GLEventListener
Called 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:
init
in interfaceGLEventListener
-
invoke
public boolean invoke(boolean wait, GLRunnable glRunnable) throws IllegalStateException
Enqueues a one-shotGLRunnable
, which will be executed within the nextGLAutoDrawable.display()
call if thisScene
has been added as aGLEventListener
andinit(GLAutoDrawable)
has been called.- Parameters:
wait
- iftrue
block until execution ofglRunnable
is finished, otherwise return immediately w/o waitingglRunnable
- theGLRunnable
to execute within#display()
- Returns:
true
if theGLRunnable
has 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:
reshape
in interfaceGLEventListener
- Parameters:
drawable
- the triggeringGLAutoDrawable
x
- 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:Container
Returns whether the givenShape
is 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:
isOutside
in interfaceContainer
- Parameters:
pmv
- currentPMVMatrix4f
of this containershape
- theShape
to 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:Container
Returns whether the givenShape
is 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:
isOutside2
in interfaceContainer
- Parameters:
mvCont
- copy of the model-view {@link Matrix4f) of this containershape
- theShape
to testpmvShape
- currentPMVMatrix4f
of the shape to test- See Also:
Container.isOutside(PMVMatrix4f, Shape)
,Shape#isOutside()
-
display
public void display(GLAutoDrawable drawable)
Description copied from interface:GLEventListener
Called 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 ifsetAutoSwapBufferMode
is enabled.- Specified by:
display
in interfaceGLEventListener
-
waitUntilDisplayed
public void waitUntilDisplayed()
Blocks until firstdisplay(GLAutoDrawable)
has completed after construction or {@link #dispose(GLAutoDrawable).
-
dispose
public void dispose(GLAutoDrawable drawable)
Disposes alladded
Shape
s.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
GLAutoDrawable
closing 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:
dispose
in interfaceGLEventListener
-
addDisposeAction
public void addDisposeAction(GLRunnable action)
Add a user one-timeGLRunnable
disposal 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 customGLRunnable
disposal 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 newPMVMatrix4f
which willbe setup
,shape-transformed
and 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)
SetupPMVMatrix4f
GLMatrixFunc.GL_PROJECTION
andGLMatrixFunc.GL_MODELVIEW
by callinggetPMVMatrixSetup()
'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)
.- Parameters:
pmv
- thePMVMatrix4f
to setupRecti
- viewport
-
setupMatrix
public void setupMatrix(com.jogamp.math.util.PMVMatrix4f pmv)
SetupPMVMatrix4f
GLMatrixFunc.GL_PROJECTION
andGLMatrixFunc.GL_MODELVIEW
using implicitgetViewport()
surface dimension by callinggetPMVMatrixSetup()
'sScene.PMVMatrixSetup.set(PMVMatrix4f, Recti)
.- Parameters:
pmv
- thePMVMatrix4f
to 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.AABBox
is setup viagetPMVMatrixSetup()
'sScene.PMVMatrixSetup.setPlaneBox(AABBox, PMVMatrix4f, Recti)
.The default
Scene.PMVMatrixSetup
implementation 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_ZNEAR
zFar
- customDEFAULT_ZFAR
objOrthoDist
- customDEFAULT_SCENE_DIST
objSceneSize
- 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_ZFAR
andDEFAULT_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 activeShape
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.
-
setActiveShapeZOffsetScale
public void setActiveShapeZOffsetScale(float v)
Sets the activeShape
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.
-
getActiveTopLevelZOffsetScale
public float getActiveTopLevelZOffsetScale()
Returns the generaltop-level widget
Z-Offset scale, defaults toDEFAULT_ACTIVE_ZOFFSET_SCALE
.
-
setActiveTopLevelZOffsetScale
public void setActiveTopLevelZOffsetScale(float v)
Sets the generaltop-level widget
Z-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 aShape
using the window coordinates and contained 'sAABBox
bounds
using a ray-intersection algorithm in Z-axis descending order.If
Shape
was 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
Shape
w/o result.- Parameters:
pmv
- a newPMVMatrix4f
which willbe setup
,shape-transformed
and can be reused by the caller and runnable.ray
- temporaryRay
storage, passed for reusageglWinX
- window X coordinate, bottom-left originglWinY
- window Y coordinate, bottom-left originobjPos
- storage for found object position in model-space of foundShape
runnable
- the action to perform ifShape
was 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 PNGFile
instance 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 usedGLCapabilitiesImmutable
used 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 screenshotGLRunnable
is 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)
-
-