From 024b93a7e82d2cabda30e29bada71273269cb5ad Mon Sep 17 00:00:00 2001 From: Alessandro Borges Date: Tue, 24 Feb 2009 23:25:44 +0000 Subject: Issue number: 607 Submitted by: Lamer77 Reviewed by: Aces Issue : Fixes state bleed from TexCoordGeneration onto Raster git-svn-id: https://svn.java.net/svn/j3d-core~svn/branches/dev-1_6@940 ba19aa83-45c5-6ac9-afd3-db810772062c --- src/classes/share/javax/media/j3d/Canvas3D.java | 641 ++++++++++++------------ 1 file changed, 321 insertions(+), 320 deletions(-) (limited to 'src/classes') diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java index 68fa48a..62ef700 100644 --- a/src/classes/share/javax/media/j3d/Canvas3D.java +++ b/src/classes/share/javax/media/j3d/Canvas3D.java @@ -43,21 +43,21 @@ import java.util.*; * Canvas3D is an extension of the AWT Canvas class that users may * further subclass to implement additional functionality. *

- * The Canvas3D object extends the Canvas object to include - * 3D-related information such as the size of the canvas in pixels, - * the Canvas3D's location, also in pixels, within a Screen3D object, + * The Canvas3D object extends the Canvas object to include + * 3D-related information such as the size of the canvas in pixels, + * the Canvas3D's location, also in pixels, within a Screen3D object, * and whether or not the canvas has stereo enabled. *

- * Because all Canvas3D objects contain a - * reference to a Screen3D object and because Screen3D objects define - * the size of a pixel in physical units, Java 3D can convert a Canvas3D - * size in pixels to a physical world size in meters. It can also + * Because all Canvas3D objects contain a + * reference to a Screen3D object and because Screen3D objects define + * the size of a pixel in physical units, Java 3D can convert a Canvas3D + * size in pixels to a physical world size in meters. It can also * determine the Canvas3D's position and orientation in the * physical world. *

* On-screen Rendering vs. Off-screen Rendering *

- * The Canvas3D class is used either for on-screen rendering or + * The Canvas3D class is used either for on-screen rendering or * off-screen rendering. * On-screen Canvas3Ds are added to AWT or Swing Container objects * like any other canvas. Java 3D automatically and continuously @@ -74,115 +74,115 @@ import java.util.*; * the Canvas when the rendering is complete, at "buffer swap" time. * Off-screen Canvas3Ds are monoscopic. *

- * The setOffScreenBuffer method sets the off-screen buffer for this - * Canvas3D. The specified image is written into by the Java 3D renderer. - * The size of the specified ImageComponent determines the size, in - * pixels, of this Canvas3D - the size inherited from Component is + * The setOffScreenBuffer method sets the off-screen buffer for this + * Canvas3D. The specified image is written into by the Java 3D renderer. + * The size of the specified ImageComponent determines the size, in + * pixels, of this Canvas3D - the size inherited from Component is * ignored. Note that the size, physical width, and physical height of the * associated Screen3D must be set - * explicitly prior to rendering. Failure to do so will result in an + * explicitly prior to rendering. Failure to do so will result in an * exception. *

- * The getOffScreenBuffer method retrieves the off-screen + * The getOffScreenBuffer method retrieves the off-screen * buffer for this Canvas3D. *

- * The renderOffScreenBuffer method schedules the rendering of a frame - * into this Canvas3D's off-screen buffer. The rendering is done from - * the point of view of the View object to which this Canvas3D has been - * added. No rendering is performed if this Canvas3D object has not been - * added to an active View. This method does not wait for the rendering - * to actually happen. An application that wishes to know when the + * The renderOffScreenBuffer method schedules the rendering of a frame + * into this Canvas3D's off-screen buffer. The rendering is done from + * the point of view of the View object to which this Canvas3D has been + * added. No rendering is performed if this Canvas3D object has not been + * added to an active View. This method does not wait for the rendering + * to actually happen. An application that wishes to know when the * rendering is complete must either subclass Canvas3D and * override the postSwap method, or call waitForOffScreenRendering. *

- * The setOfScreenLocation methods set the location of this off-screen - * Canvas3D. The location is the upper-left corner of the Canvas3D - * relative to the upper-left corner of the corresponding off-screen - * Screen3D. The function of these methods is similar to that of - * Component.setLocation for on-screen Canvas3D objects. The default + * The setOfScreenLocation methods set the location of this off-screen + * Canvas3D. The location is the upper-left corner of the Canvas3D + * relative to the upper-left corner of the corresponding off-screen + * Screen3D. The function of these methods is similar to that of + * Component.setLocation for on-screen Canvas3D objects. The default * location is (0,0). *

* Accessing and Modifying an Eye's Image Plate Position *

- * A Canvas3D object provides sophisticated applications with access - * to the eye's position information in head-tracked, room-mounted - * runtime environments. It also allows applications to manipulate - * the position of an eye relative to an image plate in non-head-tracked + * A Canvas3D object provides sophisticated applications with access + * to the eye's position information in head-tracked, room-mounted + * runtime environments. It also allows applications to manipulate + * the position of an eye relative to an image plate in non-head-tracked * runtime environments. *

* The setLeftManualEyeInImagePlate and setRightManualEyeInImagePlate - * methods set the position of the manual left and right eyes in image - * plate coordinates. These values determine eye placement when a head - * tracker is not in use and the application is directly controlling the - * eye position in image plate coordinates. In head-tracked mode or + * methods set the position of the manual left and right eyes in image + * plate coordinates. These values determine eye placement when a head + * tracker is not in use and the application is directly controlling the + * eye position in image plate coordinates. In head-tracked mode or * when the windowEyepointPolicy is RELATIVE_TO_FIELD_OF_VIEW or - * RELATIVE_TO_COEXISTENCE, this - * value is ignored. When the windowEyepointPolicy is RELATIVE_TO_WINDOW, + * RELATIVE_TO_COEXISTENCE, this + * value is ignored. When the windowEyepointPolicy is RELATIVE_TO_WINDOW, * only the Z value is used. *

* The getLeftEyeInImagePlate, getRightEyeInImagePlate, and - * getCenterEyeInImagePlate methods retrieve the actual position of the - * left eye, right eye, and center eye in image plate coordinates and - * copy that value into the object provided. The center eye is the - * fictional eye half-way between the left and right eye. These three - * values are a function of the windowEyepointPolicy, the tracking + * getCenterEyeInImagePlate methods retrieve the actual position of the + * left eye, right eye, and center eye in image plate coordinates and + * copy that value into the object provided. The center eye is the + * fictional eye half-way between the left and right eye. These three + * values are a function of the windowEyepointPolicy, the tracking * enable flag, and the manual left, right, and center eye positions. *

* Monoscopic View Policy *

* The setMonoscopicViewPolicy and getMonoscopicViewPolicy methods - * set and retrieve the policy regarding how Java 3D generates monoscopic - * view. If the policy is set to View.LEFT_EYE_VIEW, the view generated - * corresponds to the view as seen from the left eye. If set to - * View.RIGHT_EYE_VIEW, the view generated corresponds to the view as - * seen from the right eye. If set to View.CYCLOPEAN_EYE_VIEW, the view - * generated corresponds to the view as seen from the "center eye," the - * fictional eye half-way between the left and right eye. The default + * set and retrieve the policy regarding how Java 3D generates monoscopic + * view. If the policy is set to View.LEFT_EYE_VIEW, the view generated + * corresponds to the view as seen from the left eye. If set to + * View.RIGHT_EYE_VIEW, the view generated corresponds to the view as + * seen from the right eye. If set to View.CYCLOPEAN_EYE_VIEW, the view + * generated corresponds to the view as seen from the "center eye," the + * fictional eye half-way between the left and right eye. The default * monoscopic view policy is View.CYCLOPEAN_EYE_VIEW. *

* Immediate Mode Rendering *

- * Pure immediate-mode rendering provides for those applications and - * applets that do not want Java 3D to do any automatic rendering of - * the scene graph. Such applications may not even wish to build a - * scene graph to represent their graphical data. However, they use - * Java 3D's attribute objects to set graphics state and Java 3D's + * Pure immediate-mode rendering provides for those applications and + * applets that do not want Java 3D to do any automatic rendering of + * the scene graph. Such applications may not even wish to build a + * scene graph to represent their graphical data. However, they use + * Java 3D's attribute objects to set graphics state and Java 3D's * geometric objects to render geometry. *

- * A pure immediate mode application must create a minimal set of - * Java 3D objects before rendering. In addition to a Canvas3D object, - * the application must create a View object, with its associated - * PhysicalBody and PhysicalEnvironment objects, and the following - * scene graph elements: a VirtualUniverse object, a high-resolution - * Locale object, a BranchGroup node object, a TransformGroup node - * object with associated transform, and a ViewPlatform + * A pure immediate mode application must create a minimal set of + * Java 3D objects before rendering. In addition to a Canvas3D object, + * the application must create a View object, with its associated + * PhysicalBody and PhysicalEnvironment objects, and the following + * scene graph elements: a VirtualUniverse object, a high-resolution + * Locale object, a BranchGroup node object, a TransformGroup node + * object with associated transform, and a ViewPlatform * leaf node object that defines the position and orientation within * the virtual universe that generates the view. *

- * In immediate mode, all rendering is done completely under user - * control. It is necessary for the user to clear the 3D canvas, - * render all geometry, and swap the buffers. Additionally, + * In immediate mode, all rendering is done completely under user + * control. It is necessary for the user to clear the 3D canvas, + * render all geometry, and swap the buffers. Additionally, * rendering the right and left eye for stereo viewing becomes the - * sole responsibility of the application. In pure immediate mode, + * sole responsibility of the application. In pure immediate mode, * the user must stop the Java 3D renderer, via the - * Canvas3D object stopRenderer method, prior to adding the - * Canvas3D object to an active View object (that is, one that is + * Canvas3D object stopRenderer method, prior to adding the + * Canvas3D object to an active View object (that is, one that is * attached to a live ViewPlatform object). *

* Other Canvas3D methods related to immediate mode rendering are: *

*

@@ -190,9 +190,9 @@ import java.util.*; *

* Mixed Mode Rendering *

- * Mixing immediate mode and retained or compiled-retained mode - * requires more structure than pure immediate mode. In mixed mode, - * the Java 3D renderer is running continuously, rendering the scene + * Mixing immediate mode and retained or compiled-retained mode + * requires more structure than pure immediate mode. In mixed mode, + * the Java 3D renderer is running continuously, rendering the scene * graph into the canvas. * *

@@ -200,30 +200,30 @@ import java.util.*; * *

*

*

* The above callback methods are called by the Java 3D rendering system * and should not be called by an application directly. * *

- * The basic Java 3D stereo rendering loop, + * The basic Java 3D stereo rendering loop, * executed for each Canvas3D, is as follows: *

*

- * In both cases, the entire loop, beginning with clearing the canvas - * and ending with swapping the buffers, defines a frame. The application - * is given the opportunity to render immediate-mode geometry at any of - * the clearly identified spots in the rendering loop. A user specifies - * his or her own rendering methods by extending the Canvas3D class and - * overriding the preRender, postRender, postSwap, and/or renderField + * In both cases, the entire loop, beginning with clearing the canvas + * and ending with swapping the buffers, defines a frame. The application + * is given the opportunity to render immediate-mode geometry at any of + * the clearly identified spots in the rendering loop. A user specifies + * his or her own rendering methods by extending the Canvas3D class and + * overriding the preRender, postRender, postSwap, and/or renderField * methods. * Updates to live Geometry, Texture, and ImageComponent objects * in the scene graph are not allowed from any of these callback @@ -302,10 +302,10 @@ public class Canvas3D extends Canvas { */ public static final int FIELD_ALL = 2; - // + // // The following constants are bit masks to specify which of the node // components are dirty and need updates. - // + // // Values for the geometryType field. static final int POLYGONATTRS_DIRTY = 0x01; static final int LINEATTRS_DIRTY = 0x02; @@ -323,7 +323,7 @@ public class Canvas3D extends Canvas { static final int TEXTUREATTRIBUTES_DIRTY = 0x800; static final int RENDERMOLECULE_DIRTY = 0x1000; static final int FOG_DIRTY = 0x2000; - static final int MODELCLIP_DIRTY = 0x4000; + static final int MODELCLIP_DIRTY = 0x4000; static final int VIEW_MATRIX_DIRTY = 0x8000; // static final int SHADER_DIRTY = 0x10000; Not ready for this yet -- JADA @@ -403,7 +403,7 @@ public class Canvas3D extends Canvas { // int monoscopicViewPolicy = View.CYCLOPEAN_EYE_VIEW; - // User requested stencil size + // User requested stencil size int requestedStencilSize; // Actual stencil size return for this canvas @@ -413,8 +413,8 @@ public class Canvas3D extends Canvas { boolean userStencilAvailable; // True if stencil buffer is available for system ( decal ) - boolean systemStencilAvailable; - + boolean systemStencilAvailable; + // // Read-only flag that indicates whether double buffering is supported // for this canvas. This is always false for off-screen canvases. @@ -439,7 +439,7 @@ public class Canvas3D extends Canvas { // is supported for this canvas. // boolean sceneAntialiasingAvailable; - boolean sceneAntialiasingMultiSamplesAvailable; + boolean sceneAntialiasingMultiSamplesAvailable; // Use to see whether antialiasing is already set boolean antialiasingSet = false; @@ -451,10 +451,10 @@ public class Canvas3D extends Canvas { // int textureColorTableSize; - // number of active/enabled texture unit + // number of active/enabled texture unit int numActiveTexUnit = 0; - // index iof last enabled texture unit + // index iof last enabled texture unit int lastActiveTexUnit = -1; // True if shadingLanguage is supported, otherwise false. @@ -490,10 +490,10 @@ public class Canvas3D extends Canvas { // View cache for this canvas and its associated view. // CanvasViewCache canvasViewCache = null; - + // Issue 109: View cache for this canvas, for computing view frustum planes CanvasViewCache canvasViewCacheFrustum = null; - + // Since multiple renderAtomListInfo, share the same vecBounds // we want to do the intersection test only once per renderAtom // this flag is set to true after the first intersect and set to @@ -501,7 +501,7 @@ public class Canvas3D extends Canvas { boolean raIsVisible = false; RenderAtom ra = null; - + // Stereo related field has changed. static final int STEREO_DIRTY = 0x01; // MonoscopicViewPolicy field has changed. @@ -509,7 +509,7 @@ public class Canvas3D extends Canvas { // Left/right eye in image plate field has changed. static final int EYE_IN_IMAGE_PLATE_DIRTY = 0x04; // Canvas has moved/resized. - static final int MOVED_OR_RESIZED_DIRTY = 0x08; + static final int MOVED_OR_RESIZED_DIRTY = 0x08; // Canvas Background changed (this may affect doInfinite flag) static final int BACKGROUND_DIRTY = 0x10; @@ -517,15 +517,15 @@ public class Canvas3D extends Canvas { // Canvas Background Image changed static final int BACKGROUND_IMAGE_DIRTY = 0x20; - + // Mask that indicates this Canvas view dependence info. has changed, // and CanvasViewCache may need to recompute the final view matries. - static final int VIEW_INFO_DIRTY = (STEREO_DIRTY | + static final int VIEW_INFO_DIRTY = (STEREO_DIRTY | MONOSCOPIC_VIEW_POLICY_DIRTY | - EYE_IN_IMAGE_PLATE_DIRTY | - MOVED_OR_RESIZED_DIRTY | + EYE_IN_IMAGE_PLATE_DIRTY | + MOVED_OR_RESIZED_DIRTY | BACKGROUND_DIRTY | - BACKGROUND_IMAGE_DIRTY); + BACKGROUND_IMAGE_DIRTY); // Issue 163: Array of dirty bits is used because the Renderer and // RenderBin run asynchronously. Now that they each have a separate @@ -561,15 +561,15 @@ public class Canvas3D extends Canvas { // The Screen3D that corresponds to this Canvas3D Screen3D screen = null; - // Flag to indicate that image is render completely + // Flag to indicate that image is render completely // so swap is valid. boolean imageReady = false; // - // The current fog enable state - // - int fogOn = 0; + // The current fog enable state + // + int fogOn = 0; // The 3D Graphics context used for immediate mode rendering // into this canvas. @@ -578,7 +578,7 @@ public class Canvas3D extends Canvas { boolean swapDone = false; GraphicsConfiguration graphicsConfiguration; - + // The Java 3D Graphics2D object used for Java2D/AWT rendering // into this Canvas3D J3DGraphics2DImpl graphics2D = null; @@ -602,7 +602,7 @@ public class Canvas3D extends Canvas { // is defined by the Pipeline. Drawable drawable = null; - // fbConfig is a pointer to the fbConfig object that is associated with + // fbConfig is a pointer to the fbConfig object that is associated with // the GraphicsConfiguration object used to create this Canvas. // // For Unix : Fix for issue 20. @@ -631,17 +631,17 @@ public class Canvas3D extends Canvas { static Hashtable graphicsConfigTable = new Hashtable(); - // The native graphics version, vendor, and renderer information + // The native graphics version, vendor, and renderer information String nativeGraphicsVersion = ""; String nativeGraphicsVendor = ""; String nativeGraphicsRenderer = ""; - + boolean firstPaintCalled = false; // This reflects whether or not this canvas has seen an addNotify. It is // forced to true for off-screen canvases boolean added = false; - + // Flag indicating whether addNotify has been called (so we don't process it twice). private boolean addNotifyCalled = false; @@ -656,7 +656,7 @@ public class Canvas3D extends Canvas { // The current context setting for local eye lighting boolean ctxEyeLightingEnable = false; - // This AppearanceRetained Object refelects the current state of this + // This AppearanceRetained Object refelects the current state of this // canvas. It is used to optimize setting of attributes at render time. AppearanceRetained currentAppear = new AppearanceRetained(); @@ -670,7 +670,7 @@ public class Canvas3D extends Canvas { CachedFrustum viewFrustum = new CachedFrustum(); /** - * The RenderBin bundle references used to decide what the underlying + * The RenderBin bundle references used to decide what the underlying * context contains. */ LightBin lightBin = null; @@ -688,7 +688,7 @@ public class Canvas3D extends Canvas { Transform3D modelMatrix = null; Transform3D projTrans = null; TextureBin textureBin = null; - + /** * cached RenderBin states for lazy native states update @@ -700,7 +700,7 @@ public class Canvas3D extends Canvas { ModelClipRetained modelClip = null; Color3f sceneAmbient = new Color3f(); TextureUnitStateRetained[] texUnitState = null; - + /** * These cached values are only used in Pure Immediate and Mixed Mode rendering */ @@ -709,7 +709,7 @@ public class Canvas3D extends Canvas { TexCoordGenerationRetained texCoordGeneration = null; RenderingAttributesRetained renderingAttrs = null; AppearanceRetained appearance = null; - + ShaderProgramRetained shaderProgram = null; // only used in Mixed Mode rendering @@ -723,7 +723,7 @@ public class Canvas3D extends Canvas { * * TODO aces : is this still true in DX9? */ - boolean texLinearMode = false; + boolean texLinearMode = false; /** * Dirty bit to determine if the NodeComponent needs to be re-sent @@ -749,8 +749,8 @@ public class Canvas3D extends Canvas { int canvasId = 0; // Indicates whether the canvasId has been allocated private boolean canvasIdAlloc = false; - - // Avoid using this as lock, it cause deadlock + + // Avoid using this as lock, it cause deadlock Object cvLock = new Object(); Object evaluateLock = new Object(); Object dirtyMaskLock = new Object(); @@ -786,12 +786,12 @@ public class Canvas3D extends Canvas { static final int TEXTURE_ANISOTROPIC_FILTER = 0x0800; static final int TEXTURE_LOD_RANGE = 0x1000; static final int TEXTURE_LOD_OFFSET = 0x2000; - // Use by D3D to indicate using one pass Blend mode + // Use by D3D to indicate using one pass Blend mode // if Texture interpolation mode is support. static final int TEXTURE_LERP = 0x4000; static final int TEXTURE_NON_POWER_OF_TWO = 0x8000; static final int TEXTURE_AUTO_MIPMAP_GENERATION = 0x10000; - + int textureExtendedFeatures = 0; // Extensions supported by the underlying canvas @@ -831,7 +831,7 @@ public class Canvas3D extends Canvas { // Max number of combined shader texture units int maxCombinedTextureImageUnits = 0; - + // Max number of vertex attrs (not counting coord, etc.) int maxVertexAttrs = 0; @@ -855,7 +855,7 @@ public class Canvas3D extends Canvas { // We don't want to call canvas.getxx method in Renderer // since it will cause deadlock as removeNotify() need to get // component lock of Canvas also and need to wait Renderer to - // finish before continue. So we invoke the method now in + // finish before continue. So we invoke the method now in // CanvasViewEventCatcher. Point newPosition = new Point(); Dimension newSize = new Dimension(); @@ -877,7 +877,7 @@ public class Canvas3D extends Canvas { static final int SHADERBIN_BIT = 0x6; // bitmask to specify if the corresponding "bin" needs to be updated - int stateUpdateMask = 0; + int stateUpdateMask = 0; // the set of current "bins" that is to be updated, the stateUpdateMask // specifies if each bin in this set is updated or not. @@ -1153,7 +1153,7 @@ public class Canvas3D extends Canvas { eventCatcher = new EventCatcher(this); canvasViewEventCatcher = new CanvasViewEventCatcher(this); - + synchronized(VirtualUniverse.mc.deviceScreenMap) { screen = (Screen3D) VirtualUniverse.mc. deviceScreenMap.get(graphicsDevice); @@ -1199,7 +1199,7 @@ public class Canvas3D extends Canvas { void sendEventToBehaviorScheduler(AWTEvent evt) { ViewPlatform vp; - + if ((view != null) && ((vp = view.getViewPlatform()) != null)) { VirtualUniverse univ = @@ -1272,7 +1272,7 @@ public class Canvas3D extends Canvas { try { newSize = getSize(); - newPosition = getLocationOnScreen(); + newPosition = getLocationOnScreen(); } catch (IllegalComponentStateException e) { return; } @@ -1284,12 +1284,12 @@ public class Canvas3D extends Canvas { firstPaintCalled = true; visible = true; evaluateActive(); - } + } redraw(); } // When this canvas is added to a frame, this notification gets called. We - // can get drawing surface information at this time. Note: we cannot get + // can get drawing surface information at this time. Note: we cannot get // the X11 window id yet, unless it is a reset condition. /** * Canvas3D uses the addNotify callback to track when it is added @@ -1438,7 +1438,7 @@ public class Canvas3D extends Canvas { // runMonotor(RUN_RENDERER_CLEANUP) which skip userStop // thread checking. // For non-offscreen rendering the following call will - // block waiting until all resources is free before + // block waiting until all resources is free before // continue synchronized (drawingSurfaceObject) { @@ -1463,7 +1463,7 @@ public class Canvas3D extends Canvas { graphicsContext3D = null; ctx = null; - // must be after removeCtx() because + // must be after removeCtx() because // it will free graphics2D textureID graphics2D = null; @@ -1514,7 +1514,7 @@ public class Canvas3D extends Canvas { canvasIdAlloc = true; } } - + void freeCanvasId() { if (canvasIdAlloc) { VirtualUniverse.mc.freeCanvasId(canvasId); @@ -1523,14 +1523,14 @@ public class Canvas3D extends Canvas { canvasIdAlloc = false; } } - + // This decides if the canvas is active void evaluateActive() { // Note that no need to check for isRunning, we want // view register in order to create scheduler in pure immedite mode // Also we can't use this as lock, otherwise there is a // deadlock where updateViewCache get a lock of this and - // get a lock of this component. But Container + // get a lock of this component. But Container // remove will get a lock of this component follows by evaluateActive. synchronized (evaluateLock) { @@ -1540,12 +1540,12 @@ public class Canvas3D extends Canvas { active = true; if (pendingView != null) { pendingView.evaluateActive(); - } + } } else { if ((pendingView != null) && !pendingView.activeStatus) { pendingView.evaluateActive(); - } + } } } else { if (active) { @@ -1553,10 +1553,10 @@ public class Canvas3D extends Canvas { if (view != null) { view.evaluateActive(); } - } + } } } - + if ((view != null) && (!active)) { VirtualUniverse u = view.universe; if ((u != null) && !u.isSceneGraphLock) { @@ -1566,7 +1566,7 @@ public class Canvas3D extends Canvas { } void setFrustumPlanes(Vector4d[] planes) { - + if(VirtualUniverse.mc.viewFrustumCulling) { /* System.err.println("Canvas3D.setFrustumPlanes()"); */ viewFrustum.set(planes); @@ -1855,17 +1855,17 @@ public class Canvas3D extends Canvas { // Check that offScreenBufferPending is not already set J3dDebug.doAssert(!offScreenBufferPending, "!offScreenBufferPending"); - + if (offScreenBuffer != null && offScreenBuffer != buffer) { - ImageComponent2DRetained i2dRetained = - (ImageComponent2DRetained)offScreenBuffer.retained; + ImageComponent2DRetained i2dRetained = + (ImageComponent2DRetained)offScreenBuffer.retained; i2dRetained.setUsedByOffScreen(false); } if (buffer != null) { ImageComponent2DRetained bufferRetained = (ImageComponent2DRetained)buffer.retained; - + if (bufferRetained.byReference && !(bufferRetained.getRefImage(0) instanceof BufferedImage)) { @@ -1912,23 +1912,23 @@ public class Canvas3D extends Canvas { if (drawable != null) { // Fix for Issue 18 and Issue 175 - // Will do destroyOffScreenBuffer in the Renderer thread. + // Will do destroyOffScreenBuffer in the Renderer thread. sendDestroyCtxAndOffScreenBuffer(); drawable = null; } // Issue 396. Since context is invalid here, we should set it to null. ctx = null; - + // set the canvas dimension according to the buffer dimension offScreenCanvasSize.setSize(width, height); this.setSize(offScreenCanvasSize); - if (width > 0 && height > 0) { + if (width > 0 && height > 0) { sendCreateOffScreenBuffer(); } } - else if (ctx != null) { + else if (ctx != null) { removeCtx(); } @@ -2032,7 +2032,7 @@ public class Canvas3D extends Canvas { // Fix to issue 66 if ((!active) || (pendingView == null)) { - /* No rendering is performed if this Canvas3D object has not been + /* No rendering is performed if this Canvas3D object has not been added to an active View. */ return; } @@ -2045,23 +2045,23 @@ public class Canvas3D extends Canvas { // Fix to issue 66. /* This is an attempt to do the following check in one atomic operation : ((view != null) && (view.inCanvasCallback)) */ - + boolean inCanvasCallback = false; try { inCanvasCallback = view.inCanvasCallback; - + } catch (NullPointerException npe) { /* Do nothing here */ } if (inCanvasCallback) { // Here we assume that view is stable if inCanvasCallback - // is true. This assumption is valid among all j3d threads as + // is true. This assumption is valid among all j3d threads as // all access to view is synchronized by MasterControl. // Issue : user threads access to view isn't synchronize hence // is model will break. if (screen.renderer == null) { - + // It is possible that screen.renderer = null when this View // is shared by another onScreen Canvas and this callback // is from that Canvas. In this case it need one more @@ -2073,7 +2073,7 @@ public class Canvas3D extends Canvas { // screen sharing the same View not yet initialize. } - // if called from render call back, send a message directly to + // if called from render call back, send a message directly to // the renderer message queue, and call renderer doWork // to do the offscreen rendering now if (Thread.currentThread() == screen.renderer) { @@ -2084,9 +2084,9 @@ public class Canvas3D extends Canvas { createMessage.universe = this.view.universe; createMessage.view = this.view; createMessage.args[0] = this; - + screen.renderer.rendererStructure.addMessage(createMessage); - + // modify the args to reflect offScreen rendering screen.renderer.args = new Object[4]; ((Object[])screen.renderer.args)[0] = @@ -2096,13 +2096,13 @@ public class Canvas3D extends Canvas { // This extra argument 3 is needed in MasterControl to // test whether offscreen Rendering is used or not ((Object[])screen.renderer.args)[3] = null; - + // call renderer doWork directly since we are already in // the renderer thread screen.renderer.doWork(0); } else { - // XXXX: + // XXXX: // Now we are in trouble, this will cause deadlock if // waitForOffScreenRendering() is invoked J3dMessage createMessage = new J3dMessage(); @@ -2117,9 +2117,9 @@ public class Canvas3D extends Canvas { } else if (Thread.currentThread() instanceof BehaviorScheduler) { - // If called from behavior scheduler, send a message directly to + // If called from behavior scheduler, send a message directly to // the renderer message queue. - // Note that we didn't use + // Note that we didn't use // currentThread() == view.universe.behaviorScheduler // since the caller may be another universe Behavior // scheduler. @@ -2134,7 +2134,7 @@ public class Canvas3D extends Canvas { } else { // send a message to renderBin - // Fix for issue 66 : Since view might not been set yet, + // Fix for issue 66 : Since view might not been set yet, // we have to use pendingView instead. J3dMessage createMessage = new J3dMessage(); createMessage.threads = J3dThread.UPDATE_RENDER; @@ -2299,7 +2299,7 @@ public class Canvas3D extends Canvas { } void endOffScreenRendering() { - + ImageComponent2DRetained icRetained = (ImageComponent2DRetained)offScreenBuffer.retained; boolean isByRef = icRetained.isByReference(); boolean isYUp = icRetained.isYUp(); @@ -2321,17 +2321,17 @@ public class Canvas3D extends Canvas { readOffScreenBuffer(ctx, icRetained.getImageFormatTypeIntValue(false), icRetained.getImageDataTypeIntValue(), imageData.get(), offScreenCanvasSize.width, offScreenCanvasSize.height); - + } else { icRetained.geomLock.getLock(); // Create a copy of format converted image in imageData if format is unsupported. icRetained.evaluateExtensions(this); - + // read the image from the offscreen buffer readOffScreenBuffer(ctx, icRetained.getImageFormatTypeIntValue(false), icRetained.getImageDataTypeIntValue(), imageData.get(), offScreenCanvasSize.width, offScreenCanvasSize.height); - + // For byRef, we might have to copy buffer back into // the user's referenced ImageComponent2D if(!imageData.isDataByRef()) { @@ -2342,7 +2342,7 @@ public class Canvas3D extends Canvas { icRetained.copyToRefImageWithFormatConversion(0); } } - + icRetained.geomLock.unLock(); } } @@ -2376,7 +2376,7 @@ public class Canvas3D extends Canvas { } if (view != null && graphicsContext3D != null) { - if ((view.universe != null) && + if ((view.universe != null) && (Thread.currentThread() == view.universe.behaviorScheduler)) { graphicsContext3D.sendRenderMessage(false, GraphicsContext3D.SWAP, null, null); } else { @@ -2400,7 +2400,7 @@ public class Canvas3D extends Canvas { this.syncRender(ctx, true); int status = swapBuffers(ctx, screen.display, drawable); if (status != NOCHANGE) { - resetImmediateRendering(status); + resetImmediateRendering(status); } drawingSurfaceObject.unLock(); } @@ -2427,7 +2427,7 @@ public class Canvas3D extends Canvas { // reset everything if (status != NOCHANGE) { resetImmediateRendering(status); - } + } reEvaluateCanvasCmd = 0; } graphicsContext3D.runMonitor(J3dThread.NOTIFY); @@ -2446,10 +2446,10 @@ public class Canvas3D extends Canvas { VirtualUniverse.mc.cgLibraryAvailable); // compute the max available texture units maxAvailableTextureUnits = Math.max(maxTextureUnits, maxTextureImageUnits); - + return retVal; } - + /** * Make the context associated with the specified canvas current. */ @@ -2518,7 +2518,7 @@ public class Canvas3D extends Canvas { } redraw(); } - + /** * Sets the position of the manual right eye in image-plate * coordinates. This value determines eye placement when a head @@ -2610,7 +2610,7 @@ public class Canvas3D extends Canvas { * @param position the object that will receive the position * @see #setMonoscopicViewPolicy */ - // XXXX: This might not make sense for field-sequential HMD. + // XXXX: This might not make sense for field-sequential HMD. public void getCenterEyeInImagePlate(Point3d position) { if (canvasViewCache != null) { synchronized(canvasViewCache) { @@ -2676,7 +2676,7 @@ public class Canvas3D extends Canvas { void getPixelLocationInImagePlate(double x, double y, double z, Point3d imagePlatePoint) { if (canvasViewCache != null) { - synchronized(canvasViewCache) { + synchronized(canvasViewCache) { canvasViewCache.getPixelLocationInImagePlate( x, y, z, imagePlatePoint); } @@ -2698,7 +2698,7 @@ public class Canvas3D extends Canvas { * * @since Java 3D 1.2 */ - // TODO: Document -- This transform the pixel location to the left image plate. + // TODO: Document -- This transform the pixel location to the left image plate. public void getPixelLocationInImagePlate(Point2d pixelLocation, Point3d imagePlatePoint) { @@ -2768,14 +2768,14 @@ public class Canvas3D extends Canvas { (ViewPlatformRetained)view.getViewPlatform().retained; synchronized(canvasViewCache) { - leftProjection.mul(canvasViewCache.getLeftProjection(), + leftProjection.mul(canvasViewCache.getLeftProjection(), canvasViewCache.getLeftVpcToEc()); leftProjection.mul(viewPlatformRetained.getVworldToVpc()); // caluclate right eye if in stereo, otherwise // this is the same as the left eye. if (useStereo) { - rightProjection.mul(canvasViewCache.getRightProjection(), + rightProjection.mul(canvasViewCache.getRightProjection(), canvasViewCache.getRightVpcToEc()); rightProjection.mul(viewPlatformRetained.getVworldToVpc()); } @@ -2921,7 +2921,7 @@ public class Canvas3D extends Canvas { canvasViewCache = null; canvasViewCacheFrustum = null; } else { - + canvasViewCache = new CanvasViewCache(this, screen.screenViewCache, view.viewCache); @@ -2991,8 +2991,8 @@ public class Canvas3D extends Canvas { public boolean getStereoEnable() { return this.stereoEnable; } - - + + /** * Specifies how Java 3D generates monoscopic view. If set to * View.LEFT_EYE_VIEW, the view generated corresponds to the view as @@ -3020,14 +3020,14 @@ public class Canvas3D extends Canvas { */ public void setMonoscopicViewPolicy(int policy) { - + if((view !=null) && (view.viewPolicy == View.HMD_VIEW) && (monoscopicViewPolicy == View.CYCLOPEAN_EYE_VIEW) && (!useStereo)) { throw new IllegalStateException(J3dI18N.getString("View31")); } - + monoscopicViewPolicy = policy; synchronized(dirtyMaskLock) { cvDirtyMask[0] |= MONOSCOPIC_VIEW_POLICY_DIRTY; @@ -3135,7 +3135,7 @@ public class Canvas3D extends Canvas { public boolean isShadingLanguageSupported(int shadingLanguage) { // Call queryProperties to ensure that the shading language flags are valid queryProperties(); - + // Return flag for specified shading language switch (shadingLanguage) { case Shader.SHADING_LANGUAGE_GLSL: @@ -3308,7 +3308,7 @@ public class Canvas3D extends Canvas { * shadingLanguageCg *

* * @@ -3316,7 +3316,7 @@ public class Canvas3D extends Canvas { * shadingLanguageGLSL * * * @@ -3356,11 +3356,11 @@ public class Canvas3D extends Canvas { * sceneAntialiasingNumPasses * * * @@ -3368,7 +3368,7 @@ public class Canvas3D extends Canvas { * stencilSize * * * @@ -3401,10 +3401,10 @@ public class Canvas3D extends Canvas { * textureLodRangeAvailable * * * @@ -3446,10 +3446,10 @@ public class Canvas3D extends Canvas { * textureBoundaryWidthMax * * @@ -3469,7 +3469,7 @@ public class Canvas3D extends Canvas { *
  • * textureCombineDot3Available *