These three top-level directories must be named exactly as
shown above and they must be sibling directories. To ensure this, run
-the svn checkout command for each of the respositories from the same
+the git clone command for each of the respositories from the same
parent
directory. For example:
NOTE: you must first build the javax.vecmath package before building
the javax.media.j3d and com.sun.j3d.* packages. See the
-
+
--
cgit v1.2.3
From d4925af4fb2eda60837d37e8be6f62fd562fb23c Mon Sep 17 00:00:00 2001
From: Julien Gouesse
Date: Sun, 29 Mar 2015 17:08:30 +0200
Subject: j3dcore: fix up compile to build with JOGL release 2.3.1
Signed-off-by: Julien Gouesse
Signed-off-by: Harvey Harrison
---
build.xml | 4 +-
src/classes/share/javax/media/j3d/JoglContext.java | 4 +-
.../share/javax/media/j3d/JoglDrawable.java | 4 +-
.../javax/media/j3d/JoglGraphicsConfiguration.java | 2 +-
.../share/javax/media/j3d/JoglPipeline.java | 54 +++++++++++-----------
5 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/build.xml b/build.xml
index 9e7d70c..31cc73e 100644
--- a/build.xml
+++ b/build.xml
@@ -11,8 +11,8 @@
-
-
+
+
diff --git a/src/classes/share/javax/media/j3d/JoglContext.java b/src/classes/share/javax/media/j3d/JoglContext.java
index f9bd82e..718a092 100644
--- a/src/classes/share/javax/media/j3d/JoglContext.java
+++ b/src/classes/share/javax/media/j3d/JoglContext.java
@@ -29,8 +29,8 @@ package javax.media.j3d;
import java.nio.Buffer;
import java.nio.FloatBuffer;
-import javax.media.opengl.GL;
-import javax.media.opengl.GLContext;
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GLContext;
/**
* Graphics context objects for Jogl rendering pipeline.
diff --git a/src/classes/share/javax/media/j3d/JoglDrawable.java b/src/classes/share/javax/media/j3d/JoglDrawable.java
index 1ce492e..54c134e 100644
--- a/src/classes/share/javax/media/j3d/JoglDrawable.java
+++ b/src/classes/share/javax/media/j3d/JoglDrawable.java
@@ -26,8 +26,8 @@
package javax.media.j3d;
-import javax.media.nativewindow.NativeWindow;
-import javax.media.opengl.GLDrawable;
+import com.jogamp.nativewindow.NativeWindow;
+import com.jogamp.opengl.GLDrawable;
/**
* Drawable class for the Jogl rendering pipeline.
diff --git a/src/classes/share/javax/media/j3d/JoglGraphicsConfiguration.java b/src/classes/share/javax/media/j3d/JoglGraphicsConfiguration.java
index d7dc3f1..181dcec 100644
--- a/src/classes/share/javax/media/j3d/JoglGraphicsConfiguration.java
+++ b/src/classes/share/javax/media/j3d/JoglGraphicsConfiguration.java
@@ -38,7 +38,7 @@ import java.awt.image.ColorModel;
import java.awt.image.VolatileImage;
import com.jogamp.nativewindow.awt.AWTGraphicsDevice;
-import javax.media.opengl.GLCapabilities;
+import com.jogamp.opengl.GLCapabilities;
/**
* Class implementing the GraphicsConfiguration API, but not a "real"
diff --git a/src/classes/share/javax/media/j3d/JoglPipeline.java b/src/classes/share/javax/media/j3d/JoglPipeline.java
index a60a73f..2f38fd8 100644
--- a/src/classes/share/javax/media/j3d/JoglPipeline.java
+++ b/src/classes/share/javax/media/j3d/JoglPipeline.java
@@ -52,28 +52,28 @@ import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.media.nativewindow.AbstractGraphicsDevice;
-import javax.media.nativewindow.AbstractGraphicsScreen;
-import javax.media.nativewindow.CapabilitiesChooser;
-import javax.media.nativewindow.GraphicsConfigurationFactory;
-import javax.media.nativewindow.NativeSurface;
-import javax.media.nativewindow.NativeWindowFactory;
-import javax.media.nativewindow.ProxySurface;
-import javax.media.nativewindow.UpstreamSurfaceHook;
-import javax.media.nativewindow.VisualIDHolder;
-import javax.media.opengl.DefaultGLCapabilitiesChooser;
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2;
-import javax.media.opengl.GLCapabilities;
-import javax.media.opengl.GLCapabilitiesChooser;
-import javax.media.opengl.GLCapabilitiesImmutable;
-import javax.media.opengl.GLContext;
-import javax.media.opengl.GLDrawable;
-import javax.media.opengl.GLDrawableFactory;
-import javax.media.opengl.GLException;
-import javax.media.opengl.GLFBODrawable;
-import javax.media.opengl.GLProfile;
-import javax.media.opengl.Threading;
+import com.jogamp.nativewindow.AbstractGraphicsDevice;
+import com.jogamp.nativewindow.AbstractGraphicsScreen;
+import com.jogamp.nativewindow.CapabilitiesChooser;
+import com.jogamp.nativewindow.GraphicsConfigurationFactory;
+import com.jogamp.nativewindow.NativeSurface;
+import com.jogamp.nativewindow.NativeWindowFactory;
+import com.jogamp.nativewindow.ProxySurface;
+import com.jogamp.nativewindow.UpstreamSurfaceHook;
+import com.jogamp.nativewindow.VisualIDHolder;
+import com.jogamp.opengl.DefaultGLCapabilitiesChooser;
+import com.jogamp.opengl.GL;
+import com.jogamp.opengl.GL2;
+import com.jogamp.opengl.GLCapabilities;
+import com.jogamp.opengl.GLCapabilitiesChooser;
+import com.jogamp.opengl.GLCapabilitiesImmutable;
+import com.jogamp.opengl.GLContext;
+import com.jogamp.opengl.GLDrawable;
+import com.jogamp.opengl.GLDrawableFactory;
+import com.jogamp.opengl.GLException;
+import com.jogamp.opengl.GLFBODrawable;
+import com.jogamp.opengl.GLProfile;
+import com.jogamp.opengl.Threading;
import com.jogamp.common.nio.Buffers;
import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
@@ -3086,9 +3086,9 @@ class JoglPipeline extends Pipeline {
int shaderHandle = 0;
if (shaderType == Shader.SHADER_TYPE_VERTEX) {
- shaderHandle = gl.glCreateShaderObjectARB(GL2.GL_VERTEX_SHADER);
+ shaderHandle = (int) gl.glCreateShaderObjectARB(GL2.GL_VERTEX_SHADER);
} else if (shaderType == Shader.SHADER_TYPE_FRAGMENT) {
- shaderHandle = gl.glCreateShaderObjectARB(GL2.GL_FRAGMENT_SHADER);
+ shaderHandle = (int) gl.glCreateShaderObjectARB(GL2.GL_FRAGMENT_SHADER);
}
if (shaderHandle == 0) {
@@ -3141,7 +3141,7 @@ class JoglPipeline extends Pipeline {
GL2 gl = context(ctx).getGL().getGL2();
- int shaderProgramHandle = gl.glCreateProgramObjectARB();
+ int shaderProgramHandle = (int) gl.glCreateProgramObjectARB();
if (shaderProgramHandle == 0) {
return new ShaderError(ShaderError.LINK_ERROR,
"Unable to create native shader program object");
@@ -6287,7 +6287,7 @@ class JoglPipeline extends Pipeline {
// if multisampled the FBO sink (GL_FRONT) will be resized before the swap is executed
int numSamples = ((GLFBODrawable)glDrawble).getChosenGLCapabilities().getNumSamples();
FBObject fboObjectBack = ((GLFBODrawable)glDrawble).getFBObject( GL.GL_BACK );
- fboObjectBack.reset(gl, newWidth, newHeight, numSamples, false); // false = don't reset SamplingSinkFBO immediately
+ fboObjectBack.reset(gl, newWidth, newHeight, numSamples/*, false*/); // false = don't reset SamplingSinkFBO immediately
fboObjectBack.bind(gl);
// If double buffered without antialiasing the GL_FRONT FBObject
@@ -6626,7 +6626,7 @@ class JoglPipeline extends Pipeline {
// !! a 'null' capability chooser; JOGL doesn't call a chooser for offscreen drawable
- // If FBO : 'offDrawable' is of type javax.media.opengl.GLFBODrawable
+ // If FBO : 'offDrawable' is of type com.jogamp.opengl.GLFBODrawable
GLDrawable offDrawable = GLDrawableFactory.getFactory(profile).createOffscreenDrawable(device, offCaps, null, width, height);
// !! these chosen caps are not final as long as the corresponding context is made current
--
cgit v1.2.3
From 0caa19463a539270cbd65c3544b735aed8207258 Mon Sep 17 00:00:00 2001
From: Harvey Harrison
Date: Sun, 19 Apr 2015 20:07:18 -0700
Subject: README: expand the build instructions to include the jogl jars
Signed-off-by: Harvey Harrison
---
README-build.html | 9 ++++++---
build.xml | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/README-build.html b/README-build.html
index 9734c16..c12cd7f 100644
--- a/README-build.html
+++ b/README-build.html
@@ -23,14 +23,17 @@ repositories:
These three top-level directories must be named exactly as
shown above and they must be sibling directories. To ensure this, run
the git clone command for each of the respositories from the same
-parent
-directory. For example:
+parent directory. You will also need the gluegen and jogl builds for at least
+version 2.3.1. For example:
- *
- * loopCount -- This is the number of times to run this
- * Alpha; a value of -1 specifies that the Alpha loops
- * indefinitely.
- *
- * triggerTime -- This is the time in milliseconds since
- * the start time that this object first triggers. If (startTime +
- * triggerTime >= currentTime) then the Alpha object starts running.
- *
- * phaseDelayDuration -- This is an additional number of
- * milliseconds to wait after triggerTime before actually starting
- * this Alpha.
- *
- * mode -- This can be set to INCREASING_ENABLE,
- * DECREASING_ENABLE, or the Or'ed value of the two.
- * INCREASING_ENABLE activates the increasing Alpha parameters listed
- * below; DECREASING_ENABLE activates the decreasing Alpha parameters
- * listed below.
- *
- *
Increasing Alpha parameters:
- *
- * increasingAlphaDuration -- This is the period of time
- * during which Alpha goes from zero to one.
- *
- * increasingAlphaRampDuration -- This is the period of
- * time during which the Alpha step size increases at the beginning of
- * the increasingAlphaDuration and, correspondingly, decreases at the
- * end of the increasingAlphaDuration. This parameter is clamped to
- * half of increasingAlphaDuration. When this parameter is non-zero,
- * one gets constant acceleration while it is in effect; constant
- * positive acceleration at the beginning of the ramp and constant
- * negative acceleration at the end of the ramp. If this parameter is
- * zero, then the effective velocity of the Alpha value is constant
- * and the acceleration is zero (ie, a linearly increasing alpha
- * ramp).
- *
- * alphaAtOneDuration -- This is the period of time that
- * Alpha stays at one.
Decreasing Alpha parameters:
- *
- * decreasingAlphaDuration -- This is the period of time
- * during which Alpha goes from one to zero.
- *
- * decreasingAlphaRampDuration -- This is the period of
- * time during which the Alpha step size increases at the beginning of
- * the decreasingAlphaDuration and, correspondingly, decreases at the
- * end of the decreasingAlphaDuration. This parameter is clamped to
- * half of decreasingAlphaDuration. When this parameter is non-zero,
- * one gets constant acceleration while it is in effect; constant
- * positive acceleration at the beginning of the ramp and constant
- * negative acceleration at the end of the ramp. If this parameter is
- * zero, the effective velocity of the Alpha value is constant and the
- * acceleration is zero (i.e., a linearly-decreasing alpha ramp).
- *
- * alphaAtZeroDuration -- This is the period of time that
- * Alpha stays at zero.
- *
- *
- *
- * @see Interpolator
- */
-
-public class Alpha extends NodeComponent {
-
- // loopCount < -1 --> reserved
- // loopCount == -1 --> repeat forever
- // loopCount >= 0 --> repeat count
- private int loopCount;
-
- /**
- * Specifies that the increasing component of the alpha is used.
- */
- public static final int INCREASING_ENABLE = 1;
-
- /**
- * Specifies that the decreasing component of the alpha is used
- */
- public static final int DECREASING_ENABLE = 2;
-
- /**
- * This alpha's mode, specifies whether to process
- * increasing and decreasing alphas.
- */
- private int mode;
-
- private float triggerTime;
- private float phaseDelay;
- private float increasingAlpha;
- private long increasingAlphaRamp;
- private float incAlphaRampInternal;
- private float alphaAtOne;
- private float decreasingAlpha;
- private long decreasingAlphaRamp;
- private float decAlphaRampInternal;
- private float alphaAtZero;
-
- // For pausing and resuming Alpha
- private long pauseTime = 0L;
- private boolean paused = false;
-
- // Stop time gets used only for loopCount > 0
- private float stopTime;
-
- // Start time in milliseconds
- private long startTime = MasterControl.systemStartTime;
-
- /**
- * Constructs an Alpha object with default parameters. The default
- * values are as follows:
- *
- */
- public Alpha() {
- loopCount = -1;
- mode = INCREASING_ENABLE;
- increasingAlpha = 1.0f; // converted to seconds internally
- /*
- // Java initialize them to zero by default
- triggerTime = 0L;
- phaseDelay = 0.0f;
- increasingAlphaRamp = 0.0f;
- alphaAtOne = 0.0f;
- decreasingAlpha = 0.0f;
- decreasingAlphaRamp = 0.0f;
- alphaAtZero = 0.0f;
- */
- }
-
-
- /**
- * This constructor takes all of the Alpha user-definable parameters.
- * @param loopCount number of times to run this alpha; a value
- * of -1 specifies that the alpha loops indefinitely
- * @param mode indicates whether the increasing alpha parameters or
- * the decreasing alpha parameters or both are active. This parameter
- * accepts the following values, INCREASING_ENABLE or
- * DECREASING_ENABLE, which may be ORed together to specify
- * that both are active.
- * The increasing alpha parameters are increasingAlphaDuration,
- * increasingAlphaRampDuration, and alphaAtOneDuration.
- * The decreasing alpha parameters are decreasingAlphaDuration,
- * decreasingAlphaRampDuration, and alphaAtZeroDuration.
- * @param triggerTime time in milliseconds since the start time
- * that this object first triggers
- * @param phaseDelayDuration number of milliseconds to wait after
- * triggerTime before actually starting this alpha
- * @param increasingAlphaDuration period of time during which alpha goes
- * from zero to one
- * @param increasingAlphaRampDuration period of time during which
- * the alpha step size increases at the beginning of the
- * increasingAlphaDuration and, correspondingly, decreases at the end
- * of the increasingAlphaDuration. This value is clamped to half of
- * increasingAlphaDuration. NOTE: a value of zero means that the alpha
- * step size remains constant during the entire increasingAlphaDuration.
- * @param alphaAtOneDuration period of time that alpha stays at one
- * @param decreasingAlphaDuration period of time during which alpha goes
- * from one to zero
- * @param decreasingAlphaRampDuration period of time during which
- * the alpha step size increases at the beginning of the
- * decreasingAlphaDuration and, correspondingly, decreases at the end
- * of the decreasingAlphaDuration. This value is clamped to half of
- * decreasingAlphaDuration. NOTE: a value of zero means that the alpha
- * step size remains constant during the entire decreasingAlphaDuration.
- * @param alphaAtZeroDuration period of time that alpha stays at zero
- */
- public Alpha(int loopCount, int mode,
- long triggerTime, long phaseDelayDuration,
- long increasingAlphaDuration,
- long increasingAlphaRampDuration,
- long alphaAtOneDuration,
- long decreasingAlphaDuration,
- long decreasingAlphaRampDuration,
- long alphaAtZeroDuration) {
-
- this.loopCount = loopCount;
- this.mode = mode;
- this.triggerTime = (float) triggerTime * .001f;
- phaseDelay = (float) phaseDelayDuration * .001f;
-
- increasingAlpha = (float) increasingAlphaDuration * .001f;
- alphaAtOne = (float)alphaAtOneDuration * .001f;
- increasingAlphaRamp = increasingAlphaRampDuration;
- incAlphaRampInternal = increasingAlphaRampDuration * .001f;
- if (incAlphaRampInternal > (0.5f * increasingAlpha)) {
- incAlphaRampInternal = 0.5f * increasingAlpha;
- }
-
- decreasingAlpha = (float)decreasingAlphaDuration * .001f;
- alphaAtZero = (float)alphaAtZeroDuration * .001f;
- decreasingAlphaRamp = decreasingAlphaRampDuration;
- decAlphaRampInternal = decreasingAlphaRampDuration * .001f;
- if (decAlphaRampInternal > (0.5f * decreasingAlpha)) {
- decAlphaRampInternal = 0.5f * decreasingAlpha;
- }
- computeStopTime();
- }
-
-
- /**
- * Constructs a new Alpha object that assumes that the mode is
- * INCREASING_ENABLE.
- *
- * @param loopCount number of times to run this alpha; a value
- * of -1 specifies that the alpha loops indefinitely.
- * @param triggerTime time in milliseconds since the start time
- * that this object first triggers
- * @param phaseDelayDuration number of milliseconds to wait after
- * triggerTime before actually starting this alpha
- * @param increasingAlphaDuration period of time during which alpha goes
- * from zero to one
- * @param increasingAlphaRampDuration period of time during which
- * the alpha step size increases at the beginning of the
- * increasingAlphaDuration and, correspondingly, decreases at the end
- * of the increasingAlphaDuration. This value is clamped to half of
- * increasingAlphaDuration. NOTE: a value of zero means that the alpha
- * step size remains constant during the entire increasingAlphaDuration.
- * @param alphaAtOneDuration period of time that alpha stays at one
- */
-
- public Alpha(int loopCount,
- long triggerTime, long phaseDelayDuration,
- long increasingAlphaDuration,
- long increasingAlphaRampDuration,
- long alphaAtOneDuration) {
- this(loopCount, INCREASING_ENABLE,
- triggerTime, phaseDelayDuration,
- increasingAlphaDuration, increasingAlphaRampDuration,
- alphaAtOneDuration, 0, 0, 0);
- }
-
-
- /**
- * This constructor takes only the loopCount and increasingAlphaDuration
- * as parameters and assigns the default values to all of the other
- * parameters.
- * @param loopCount number of times to run this alpha; a value
- * of -1 specifies that the alpha loops indefinitely
- * @param increasingAlphaDuration period of time during which alpha goes
- * from zero to one
- */
- public Alpha(int loopCount, long increasingAlphaDuration) {
- // defaults
- mode = INCREASING_ENABLE;
- increasingAlpha = (float) increasingAlphaDuration * .001f;
- this.loopCount = loopCount;
-
- if (loopCount >= 0) {
- stopTime = loopCount*increasingAlpha;
- }
- }
-
-
- /**
- * Pauses this alpha object. The current system time when this
- * method is called will be used in place of the actual current
- * time when calculating subsequent alpha values. This has the
- * effect of freezing the interpolator at the time the method is
- * called.
- *
- * @since Java 3D 1.3
- */
- public void pause() {
- pause(J3dClock.currentTimeMillis());
- }
-
- /**
- * Pauses this alpha object as of the specified time. The specified
- * time will be used in place of the actual current time when
- * calculating subsequent alpha values. This has the effect of freezing
- * the interpolator at the specified time. Note that specifying a
- * time in the future (that is, a time greater than
- * System.currentTimeMillis()) will cause the alpha to immediately
- * advance to that point before pausing. Similarly, specifying a
- * time in the past (that is, a time less than
- * System.currentTimeMillis()) will cause the alpha to immediately
- * revert to that point before pausing.
- *
- * @param time the time at which to pause the alpha
- *
- * @exception IllegalArgumentException if time <= 0
- *
- * @since Java 3D 1.3
- */
- public void pause(long time) {
- if (time <= 0L) {
- throw new IllegalArgumentException(J3dI18N.getString("Alpha0"));
- }
-
- paused = true;
- pauseTime = time;
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Resumes this alpha object. If the alpha
- * object was paused, the difference between the current
- * time and the pause time will be used to adjust the startTime of
- * this alpha. The equation is as follows:
- *
- *
- *
- * Since the alpha object is no longer paused, this has the effect
- * of resuming the interpolator as of the current time. If the
- * alpha object is not paused when this method is called, then this
- * method does nothing--the start time is not adjusted in this case.
- *
- * @since Java 3D 1.3
- */
- public void resume() {
- resume(J3dClock.currentTimeMillis());
- }
-
- /**
- * Resumes this alpha object as of the specified time. If the alpha
- * object was paused, the difference between the specified
- * time and the pause time will be used to adjust the startTime of
- * this alpha. The equation is as follows:
- *
- *
startTime += time - pauseTime
- *
- * Since the alpha object is no longer paused, this has the effect
- * of resuming the interpolator as of the specified time. If the
- * alpha object is not paused when this method is called, then this
- * method does nothing--the start time is not adjusted in this case.
- *
- * @param time the time at which to resume the alpha
- *
- * @exception IllegalArgumentException if time <= 0
- *
- * @since Java 3D 1.3
- */
- public void resume(long time) {
- if (time <= 0L) {
- throw new IllegalArgumentException(J3dI18N.getString("Alpha0"));
- }
-
- if (paused) {
- long newStartTime = startTime + time - pauseTime;
- paused = false;
- pauseTime = 0L;
- setStartTime(newStartTime);
- }
- }
-
- /**
- * Returns true if this alpha object is paused.
- * @return true if this alpha object is paused, false otherwise
- *
- * @since Java 3D 1.3
- */
- public boolean isPaused() {
- return paused;
- }
-
- /**
- * Returns the time at which this alpha was paused.
- * @return the pause time; returns 0 if this alpha is not paused
- *
- * @since Java 3D 1.3
- */
- public long getPauseTime() {
- return pauseTime;
- }
-
-
- /**
- * This method returns a value between 0.0 and 1.0 inclusive,
- * based on the current time and the time-to-alpha parameters
- * established for this alpha. If this alpha object is paused,
- * the value will be based on the pause time rather than the
- * current time.
- * This method will return the starting alpha value if the alpha
- * has not yet started (that is, if the current time is less
- * than startTime + triggerTime + phaseDelayDuration). This
- * method will return the ending alpha value if the alpha has
- * finished (that is, if the loop count has expired).
- *
- * @return a value between 0.0 and 1.0 based on the current time
- */
- public float value() {
- long currentTime = paused ? pauseTime : J3dClock.currentTimeMillis();
- return this.value(currentTime);
- }
-
- /**
- * This method returns a value between 0.0 and 1.0 inclusive,
- * based on the specified time and the time-to-alpha parameters
- * established for this alpha.
- * This method will return the starting alpha value if the alpha
- * has not yet started (that is, if the specified time is less
- * than startTime + triggerTime + phaseDelayDuration). This
- * method will return the ending alpha value if the alpha has
- * finished (that is, if the loop count has expired).
- *
- * @param atTime The time for which we wish to compute alpha
- * @return a value between 0.0 and 1.0 based on the specified time
- */
- public float value(long atTime) {
- float interpolatorTime
- = (float)(atTime - startTime) * .001f; // startTime is in millisec
- float alpha, a1, a2, dt, alphaRampDuration;
-
- // System.err.println("alpha mode: " + mode);
-
- // If non-looping and before start
- // if ((loopCount != -1) &&
- // interpolatorTime <= ( triggerTime + phaseDelay)) {
- //
- // if (( mode & INCREASING_ENABLE ) == 0 &&
- // ( mode & DECREASING_ENABLE) != 0)
- // alpha = 1.0f;
- // else
- // alpha = 0.0f;
- // return alpha;
- // }
-
-
- // Case of {constantly} moving forward, snap back, forward again
- if (( mode & INCREASING_ENABLE ) != 0 &&
- ( mode & DECREASING_ENABLE) == 0) {
-
- if(interpolatorTime <= (triggerTime + phaseDelay))
- return 0.0f;
-
- if((loopCount != -1) && (interpolatorTime >= stopTime))
- return 1.0f;
-
- // Constant velocity case
- if (incAlphaRampInternal == 0.0f) {
-
- alpha = mfmod((interpolatorTime - triggerTime - phaseDelay) +
- 6.0f*( increasingAlpha + alphaAtOne),
- (increasingAlpha + alphaAtOne))/ increasingAlpha;
-
- if ( alpha > 1.0f) alpha = 1.0f;
- return alpha;
- }
-
- // Ramped velocity case
- alphaRampDuration = incAlphaRampInternal;
-
- dt = mfmod((interpolatorTime - triggerTime - phaseDelay) +
- 6.0f*( increasingAlpha + alphaAtOne),
- ( increasingAlpha + alphaAtOne));
- if (dt >= increasingAlpha) { alpha = 1.0f; return alpha; }
-
- // Original equation kept to help understand
- // computation logic - simplification saves
- // a multiply and an add
- // a1 = 1.0f/(alphaRampDuration*alphaRampDuration +
- // ( increasingAlpha - 2*alphaRampDuration)*
- // alphaRampDuration);
-
- a1 = 1.0f/(increasingAlpha * alphaRampDuration -
- alphaRampDuration * alphaRampDuration);
-
- if (dt < alphaRampDuration) {
- alpha = 0.5f*a1*dt*dt;
- } else if (dt < increasingAlpha - alphaRampDuration) {
- alpha = 0.5f*a1*alphaRampDuration*
- alphaRampDuration +
- (dt - alphaRampDuration)*a1*
- alphaRampDuration;
- } else {
- alpha = a1*alphaRampDuration*alphaRampDuration +
- ( increasingAlpha - 2.0f*alphaRampDuration)*a1*
- alphaRampDuration -
- 0.5f*a1*( increasingAlpha - dt)*
- ( increasingAlpha - dt);
- }
- return alpha;
-
- } else
-
-
- // Case of {constantly} moving backward, snap forward, backward
- // again
- if (( mode & INCREASING_ENABLE ) == 0 &&
- ( mode & DECREASING_ENABLE) != 0) {
-
- // If non-looping and past end
- // if ((loopCount != -1)
- // && (interpolatorTime
- // >= (triggerTime + phaseDelay + decreasingAlpha))) {
- // alpha = 0.0f;
- // return alpha;
- // }
-
- if(interpolatorTime <= (triggerTime + phaseDelay))
- return 1.0f;
-
- if((loopCount != -1) && (interpolatorTime >= stopTime) )
- return 0.0f;
-
-
-
- // Constant velocity case
- if (decAlphaRampInternal == 0.0f) {
- alpha = mfmod((interpolatorTime - triggerTime -
- phaseDelay) +
- 6.0f*( decreasingAlpha + alphaAtZero),
- (decreasingAlpha + alphaAtZero))/ decreasingAlpha;
- if ( alpha > 1.0f) { alpha = 0.0f; return alpha; }
- alpha = 1.0f - alpha;
- return alpha;
- }
-
- // Ramped velocity case
- alphaRampDuration = decAlphaRampInternal;
-
- dt = mfmod((interpolatorTime - triggerTime - phaseDelay) +
- 6.0f*( decreasingAlpha + alphaAtZero),
- ( decreasingAlpha + alphaAtZero));
- if (dt >= decreasingAlpha) { alpha = 0.0f; return alpha; }
-
- // Original equation kept to help understand
- // computation logic - simplification saves
- // a multiply and an add
- // a1 = 1.0f/(alphaRampDuration*alphaRampDuration +
- // ( decreasingAlpha - 2*alphaRampDuration)*
- // alphaRampDuration);
-
- a1 = 1.0f/(decreasingAlpha * alphaRampDuration -
- alphaRampDuration * alphaRampDuration);
-
- if (dt < alphaRampDuration) {
- alpha = 0.5f*a1*dt*dt;
- } else if (dt < decreasingAlpha - alphaRampDuration) {
- alpha = 0.5f*a1*alphaRampDuration*
- alphaRampDuration +
- (dt - alphaRampDuration)*a1*
- alphaRampDuration;
- } else {
- alpha = a1*alphaRampDuration*alphaRampDuration +
- ( decreasingAlpha - 2.0f*alphaRampDuration)*a1*
- alphaRampDuration -
- 0.5f*a1*( decreasingAlpha - dt)*
- ( decreasingAlpha - dt);
- }
- alpha = 1.0f - alpha;
- return alpha;
-
- } else
-
-
- // Case of {osscilating} increasing and decreasing alpha
- if (( mode & INCREASING_ENABLE) != 0 &&
- ( mode & DECREASING_ENABLE) != 0) {
-
- // If non-looping and past end
- // if ((loopCount != -1) &&
- // (interpolatorTime >=
- // (triggerTime + phaseDelay + increasingAlpha +
- // alphaAtOne + decreasingAlpha))) {
- // alpha = 0.0f;
- // return alpha;
- // }
-
-
- // If non-looping and past end, we always end up at zero since
- // decreasing alpha has been requested.
- if(interpolatorTime <= (triggerTime + phaseDelay))
- return 0.0f;
-
- if( (loopCount != -1) && (interpolatorTime >= stopTime))
- return 0.0f;
-
- // Constant velocity case
- if (incAlphaRampInternal == 0.0f
- && decAlphaRampInternal == 0.0f) {
- dt = mfmod(interpolatorTime - triggerTime - phaseDelay +
- 6.0f*(increasingAlpha + alphaAtOne +
- decreasingAlpha + alphaAtZero),
- increasingAlpha + alphaAtOne +
- decreasingAlpha + alphaAtZero);
- alpha = dt / increasingAlpha;
- if ( alpha < 1.0f) return alpha;
- // sub all increasing alpha time
- dt -= increasingAlpha;
- if (dt < alphaAtOne) { alpha = 1.0f; return alpha; }
- // sub out alpha @ 1 time
- dt -= alphaAtOne;
- alpha = dt/ decreasingAlpha;
- if ( alpha < 1.0f) alpha = 1.0f - alpha;
- else alpha = 0.0f;
- return alpha;
- }
-
- // Ramped velocity case
- alphaRampDuration = incAlphaRampInternal;
-
- // work around for bug 4308308
- if (alphaRampDuration == 0.0f)
- alphaRampDuration = .00001f;
-
- dt = mfmod(interpolatorTime - triggerTime - phaseDelay +
- 6.0f*( increasingAlpha + alphaAtOne +
- decreasingAlpha + alphaAtZero),
- increasingAlpha + alphaAtOne +
- decreasingAlpha + alphaAtZero);
- if (dt <= increasingAlpha) {
-
- // Original equation kept to help understand
- // computation logic - simplification saves
- // a multiply and an add
- // a1 = 1.0f/(alphaRampDuration*alphaRampDuration +
- // ( increasingAlpha - 2*alphaRampDuration)*
- // alphaRampDuration);
-
- a1 = 1.0f/(increasingAlpha * alphaRampDuration -
- alphaRampDuration * alphaRampDuration);
-
- if (dt < alphaRampDuration) {
- alpha = 0.5f*a1*dt*dt;
- } else if (dt < increasingAlpha - alphaRampDuration) {
- alpha = 0.5f*a1*alphaRampDuration*
- alphaRampDuration +
- (dt - alphaRampDuration)*a1*
- alphaRampDuration;
- } else {
- alpha = a1*alphaRampDuration*alphaRampDuration+
- ( increasingAlpha - 2.0f*alphaRampDuration)*a1*
- alphaRampDuration -
- 0.5f*a1*( increasingAlpha - dt)*
- ( increasingAlpha - dt);
- }
- return alpha;
- }
- else if (dt <= increasingAlpha + alphaAtOne) {
- alpha = 1.0f; return alpha;
- }
- else if (dt >= increasingAlpha + alphaAtOne + decreasingAlpha) {
- alpha = 0.0f; return alpha;
- }
- else {
- dt -= increasingAlpha + alphaAtOne;
-
- alphaRampDuration = decAlphaRampInternal;
-
- // work around for bug 4308308
- if (alphaRampDuration == 0.0f)
- alphaRampDuration = .00001f;
-
- // Original equation kept to help understand
- // computation logic - simplification saves
- // a multiply and an add
- // a1 = 1.0f/(alphaRampDuration*alphaRampDuration +
- // ( decreasingAlpha - 2*alphaRampDuration)*
- // alphaRampDuration);
-
- a1 = 1.0f/(decreasingAlpha * alphaRampDuration -
- alphaRampDuration * alphaRampDuration);
-
- if (dt < alphaRampDuration) {
- alpha = 0.5f*a1*dt*dt;
- } else if (dt < decreasingAlpha - alphaRampDuration) {
- alpha = 0.5f*a1*alphaRampDuration*
- alphaRampDuration +
- (dt - alphaRampDuration)*a1*
- alphaRampDuration;
- } else {
- alpha =
- a1*alphaRampDuration*alphaRampDuration +
- (decreasingAlpha - 2.0f*alphaRampDuration)*a1*
- alphaRampDuration -
- 0.5f*a1*( decreasingAlpha - dt)*
- (decreasingAlpha - dt);
- }
- alpha = 1.0f - alpha;
- return alpha;
- }
-
- }
- return 0.0f;
- }
-
- float mfmod(float a, float b) {
- float fm, ta = (a), tb = (b);
- int fmint;
- if (tb < 0.0f) tb = -tb;
- if (ta < 0.0f) ta = -ta;
-
- fmint =(int)( ta/tb);
- fm = ta - (float)fmint * tb;
-
- if ((a) < 0.0f) return ((b) - fm);
- else return fm;
- }
-
- /**
- * Retrieves this alpha's startTime, the base
- * for all relative time specifications; the default value
- * for startTime is the system start time.
- * @return this alpha's startTime.
- */
- public long getStartTime() {
- return this.startTime;
- }
-
- /**
- * Sets this alpha's startTime to that specified in the argument;
- * startTime sets the base (or zero) for all relative time
- * computations; the default value for startTime is the system
- * start time.
- * @param startTime the new startTime value
- */
- public void setStartTime(long startTime) {
- this.startTime = startTime;
- // This is used for passive wakeupOnElapsedFrame in
- // Interpolator to restart behavior after alpha.finished()
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's loopCount.
- * @return this alpha's loopCount.
- */
- public int getLoopCount() {
- return this.loopCount;
- }
-
- /**
- * Set this alpha's loopCount to that specified in the argument.
- * @param loopCount the new loopCount value
- */
- public void setLoopCount(int loopCount) {
- this.loopCount = loopCount;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's mode.
- * @return this alpha's mode: any combination of
- * INCREASING_ENABLE and DECREASING_ENABLE
- */
- public int getMode() {
- return this.mode;
- }
-
- /**
- * Set this alpha's mode to that specified in the argument.
- * @param mode indicates whether the increasing alpha parameters or
- * the decreasing alpha parameters or both are active. This parameter
- * accepts the following values, INCREASING_ENABLE or
- * DECREASING_ENABLE, which may be ORed together to specify
- * that both are active.
- * The increasing alpha parameters are increasingAlphaDuration,
- * increasingAlphaRampDuration, and alphaAtOneDuration.
- * The decreasing alpha parameters are decreasingAlphaDuration,
- * decreasingAlphaRampDuration, and alphaAtZeroDuration.
- */
- public void setMode(int mode) {
- this.mode = mode;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's triggerTime.
- * @return this alpha's triggerTime.
- */
- public long getTriggerTime() {
- return (long) (this.triggerTime * 1000f);
- }
-
- /**
- * Set this alpha's triggerTime to that specified in the argument.
- * @param triggerTime the new triggerTime
- */
- public void setTriggerTime(long triggerTime) {
- this.triggerTime = (float) triggerTime * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's phaseDelayDuration.
- * @return this alpha's phaseDelayDuration.
- */
- public long getPhaseDelayDuration() {
- return (long)(this.phaseDelay * 1000f);
- }
-
- /**
- * Set this alpha's phaseDelayDuration to that specified in
- * the argument.
- * @param phaseDelayDuration the new phaseDelayDuration
- */
- public void setPhaseDelayDuration(long phaseDelayDuration) {
- this.phaseDelay = (float) phaseDelayDuration * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's increasingAlphaDuration.
- * @return this alpha's increasingAlphaDuration.
- */
- public long getIncreasingAlphaDuration() {
- return (long)(this.increasingAlpha * 1000f);
- }
-
- /**
- * Set this alpha's increasingAlphaDuration to that specified in
- * the argument.
- * @param increasingAlphaDuration the new increasingAlphaDuration
- */
- public void setIncreasingAlphaDuration(long increasingAlphaDuration) {
- this.increasingAlpha = (float) increasingAlphaDuration * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's increasingAlphaRampDuration.
- * @return this alpha's increasingAlphaRampDuration.
- */
- public long getIncreasingAlphaRampDuration() {
- return increasingAlphaRamp;
- }
-
- /**
- * Set this alpha's increasingAlphaRampDuration to that specified
- * in the argument.
- * @param increasingAlphaRampDuration the new increasingAlphaRampDuration
- */
- public void setIncreasingAlphaRampDuration(long increasingAlphaRampDuration) {
- increasingAlphaRamp = increasingAlphaRampDuration;
- incAlphaRampInternal = (float) increasingAlphaRampDuration * .001f;
- if (incAlphaRampInternal > (0.5f * increasingAlpha)) {
- incAlphaRampInternal = 0.5f * increasingAlpha;
- }
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's alphaAtOneDuration.
- * @return this alpha's alphaAtOneDuration.
- */
- public long getAlphaAtOneDuration() {
- return (long)(this.alphaAtOne * 1000f);
- }
-
- /**
- * Set this alpha object's alphaAtOneDuration to the specified
- * value.
- * @param alphaAtOneDuration the new alphaAtOneDuration
- */
- public void setAlphaAtOneDuration(long alphaAtOneDuration) {
- this.alphaAtOne = (float) alphaAtOneDuration * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's decreasingAlphaDuration.
- * @return this alpha's decreasingAlphaDuration.
- */
- public long getDecreasingAlphaDuration() {
- return (long)(this.decreasingAlpha * 1000f);
- }
-
- /**
- * Set this alpha's decreasingAlphaDuration to that specified in
- * the argument.
- * @param decreasingAlphaDuration the new decreasingAlphaDuration
- */
- public void setDecreasingAlphaDuration(long decreasingAlphaDuration) {
- this.decreasingAlpha = (float) decreasingAlphaDuration * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's decreasingAlphaRampDuration.
- * @return this alpha's decreasingAlphaRampDuration.
- */
- public long getDecreasingAlphaRampDuration() {
- return decreasingAlphaRamp;
- }
-
- /**
- * Set this alpha's decreasingAlphaRampDuration to that specified
- * in the argument.
- * @param decreasingAlphaRampDuration the new decreasingAlphaRampDuration
- */
- public void setDecreasingAlphaRampDuration(long decreasingAlphaRampDuration) {
- decreasingAlphaRamp = decreasingAlphaRampDuration;
- decAlphaRampInternal = (float) decreasingAlphaRampDuration * .001f;
- if (decAlphaRampInternal > (0.5f * decreasingAlpha)) {
- decAlphaRampInternal = 0.5f * decreasingAlpha;
- }
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Retrieves this alpha's alphaAtZeroDuration.
- * @return this alpha's alphaAtZeroDuration.
- */
- public long getAlphaAtZeroDuration() {
- return (long)(this.alphaAtZero * 1000f);
- }
-
- /**
- * Set this alpha object's alphaAtZeroDuration to the specified
- * value.
- * @param alphaAtZeroDuration the new alphaAtZeroDuration
- */
- public void setAlphaAtZeroDuration(long alphaAtZeroDuration) {
- this.alphaAtZero = (float) alphaAtZeroDuration * .001f;
- computeStopTime();
- VirtualUniverse.mc.sendRunMessage(J3dThread.RENDER_THREAD);
- }
-
- /**
- * Query to test if this alpha object is past its activity window,
- * that is, if it has finished looping.
- * @return true if no longer looping, false otherwise
- */
- public boolean finished() {
- long currentTime = paused ? pauseTime : J3dClock.currentTimeMillis();
- return ((loopCount != -1) &&
- ((float)(currentTime - startTime) * .001f > stopTime));
- }
-
- final private void computeStopTime() {
- if (loopCount >= 0) {
- float sum = 0;
- if (( mode & INCREASING_ENABLE ) != 0) {
- sum = increasingAlpha+alphaAtOne;
- }
- if ((mode & DECREASING_ENABLE) != 0) {
- sum += decreasingAlpha+alphaAtZero;
- }
- stopTime = this.triggerTime + phaseDelay + loopCount*sum;
- } else {
- stopTime = 0;
- }
- }
-
- /**
- * This internal method returns a clone of the Alpha
- *
- * @return a duplicate of this Alpha
- */
- Alpha cloneAlpha() {
- Alpha a = new Alpha();
- a.setStartTime(getStartTime());
- a.setLoopCount(getLoopCount());
- a.setMode(getMode());
- a.setTriggerTime(getTriggerTime());
- a.setPhaseDelayDuration(getPhaseDelayDuration());
- a.setIncreasingAlphaDuration(getIncreasingAlphaDuration());
- a.setIncreasingAlphaRampDuration(getIncreasingAlphaRampDuration());
- a.setAlphaAtOneDuration(getAlphaAtOneDuration());
- a.setDecreasingAlphaDuration(getDecreasingAlphaDuration());
- a.setDecreasingAlphaRampDuration(getDecreasingAlphaRampDuration());
- a.setAlphaAtZeroDuration(getAlphaAtZeroDuration());
- return a;
- }
-
- static {
- VirtualUniverse.loadLibraries();
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AlternateAppearance.java b/src/classes/share/javax/media/j3d/AlternateAppearance.java
deleted file mode 100644
index 48b9066..0000000
--- a/src/classes/share/javax/media/j3d/AlternateAppearance.java
+++ /dev/null
@@ -1,619 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.Enumeration;
-
-
-/**
- * The AlternateAppearance leaf node is used for overriding the
- * Appearance component of selected nodes. It defines an Appearance
- * component object and a region of influence in which this
- * AlternateAppearance node is active. An AlternateAppearance node
- * also contains a list of Group nodes that specifies the hierarchical
- * scope of this AlternateAppearance. If the scope list is empty,
- * then the AlternateAppearance node has universe scope: all nodes
- * within the region of influence are affected by this
- * AlternateAppearance node. If the scope list is non-empty, then
- * only those Leaf nodes under the Group nodes in the scope list are
- * affected by this AlternateAppearance node (subject to the
- * influencing bounds).
- *
- *
- * An AlternateAppearance node affects Shape3D and Morph nodes by
- * overriding their appearance component with the appearance
- * component in this AlternateAppearance node. Only those Shape3D and
- * Morph nodes that explicitly allow their appearance to be
- * overridden are affected. The AlternateAppearance node has no
- * effect on Shape3D and Morph nodes that do not allow their
- * appearance to be overridden.
- *
- *
- * If the regions of influence of multiple AlternateAppearance nodes
- * overlap, the Java 3D system will choose a single alternate
- * appearance for those objects that lie in the intersection. This is
- * done in an implementation-dependent manner, but in general, the
- * AlternateAppearance node that is "closest" to the object is chosen.
- *
- * @since Java 3D 1.2
- */
-
-public class AlternateAppearance extends Leaf {
- /**
- * Specifies that this AlternateAppearance node allows read access to its
- * influencing bounds and bounds leaf information.
- */
- public static final int ALLOW_INFLUENCING_BOUNDS_READ =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_INFLUENCING_BOUNDS_READ;
-
- /**
- * Specifies that this AlternateAppearance node allows write access to its
- * influencing bounds and bounds leaf information.
- */
- public static final int ALLOW_INFLUENCING_BOUNDS_WRITE =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_INFLUENCING_BOUNDS_WRITE;
-
- /**
- * Specifies that this AlternateAppearance node allows read access to
- * its appearance information.
- */
- public static final int ALLOW_APPEARANCE_READ =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_APPEARANCE_READ;
-
- /**
- * Specifies that this AlternateAppearance node allows write access to
- * its appearance information.
- * information.
- */
- public static final int ALLOW_APPEARANCE_WRITE =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_APPEARANCE_WRITE;
-
- /**
- * Specifies that this AlternateAppearance node allows read access
- * to its scope information at runtime.
- */
- public static final int ALLOW_SCOPE_READ =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_SCOPE_READ;
-
- /**
- * Specifies that this AlternateAppearance node allows write access
- * to its scope information at runtime.
- */
- public static final int ALLOW_SCOPE_WRITE =
- CapabilityBits.ALTERNATE_APPEARANCE_ALLOW_SCOPE_WRITE;
-
- // Array for setting default read capabilities
- private static final int[] readCapabilities = {
- ALLOW_INFLUENCING_BOUNDS_READ,
- ALLOW_APPEARANCE_READ,
- ALLOW_SCOPE_READ
- };
-
- /**
- * Constructs an AlternateAppearance node with default
- * parameters. The default values are as follows:
- *
- *
- */
- public AlternateAppearance() {
- // Just use the defaults
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- }
-
- /**
- * Constructs an AlternateAppearance node with the specified appearance.
- * @param appearance the appearance that is used for those nodes affected
- * by this AlternateAppearance node.
- */
- public AlternateAppearance(Appearance appearance) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
- ((AlternateAppearanceRetained)retained).initAppearance(appearance);
- }
-
- /**
- * Creates the retained mode AlternateAppearanceRetained object that this
- * Alternate Appearance component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new AlternateAppearanceRetained();
- this.retained.setSource(this);
- }
-
- /**
- * Sets the appearance of this AlternateAppearance node.
- * This appearance overrides the appearance in those Shape3D and
- * Morph nodes affected by this AlternateAppearance node.
- * @param appearance the new appearance.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setAppearance(Appearance appearance) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPEARANCE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance0"));
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).setAppearance(appearance);
- else
- ((AlternateAppearanceRetained)this.retained).initAppearance(appearance);
- }
-
-
- /**
- * Retrieves the appearance from this AlternateAppearance node.
- * @return the current appearance.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Appearance getAppearance() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPEARANCE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance2"));
-
- return ((AlternateAppearanceRetained)this.retained).getAppearance();
-
- }
-
- /**
- * Sets the AlternateAppearance's influencing region to the specified
- * bounds.
- * This is used when the influencing bounding leaf is set to null.
- * @param region the bounds that contains the AlternateAppearance's
- * new influencing region.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setInfluencingBounds(Bounds region) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance3"));
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).setInfluencingBounds(region);
- else
- ((AlternateAppearanceRetained)this.retained).initInfluencingBounds(region);
- }
-
- /**
- * Retrieves the AlternateAppearance node's influencing bounds.
- * @return this AlternateAppearance's influencing bounds information
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Bounds getInfluencingBounds() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance4"));
-
-
- return ((AlternateAppearanceRetained)this.retained).getInfluencingBounds();
- }
-
-
- /**
- * Sets the AlternateAppearance's influencing region to the specified
- * bounding leaf.
- * When set to a value other than null, this overrides the influencing
- * bounds object.
- * @param region the bounding leaf node used to specify the
- * AlternateAppearance node's new influencing region.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setInfluencingBoundingLeaf(BoundingLeaf region) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance3"));
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).setInfluencingBoundingLeaf(region);
- else
- ((AlternateAppearanceRetained)this.retained).initInfluencingBoundingLeaf(region);
- }
-
-
- /**
- * Retrieves the AlternateAppearance node's influencing bounding leaf.
- * @return this AlternateAppearance's influencing bounding leaf information
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public BoundingLeaf getInfluencingBoundingLeaf() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_INFLUENCING_BOUNDS_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance4"));
-
-
- return ((AlternateAppearanceRetained)this.retained).getInfluencingBoundingLeaf();
- }
-
-
- /**
- * Replaces the node at the specified index in this
- * AlternateAppearance node's
- * list of scopes with the specified Group node.
- * By default, AlternateAppearance nodes are scoped only by their
- * influencing
- * bounds. This allows them to be further scoped by a list of
- * nodes in the hierarchy.
- * @param scope the Group node to be stored at the specified index.
- * @param index the index of the Group node to be replaced.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if the specified group node
- * is part of a compiled scene graph
- */
- public void setScope(Group scope, int index) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance7"));
-
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).setScope(scope, index);
- else
- ((AlternateAppearanceRetained)this.retained).initScope(scope, index);
- }
-
-
- /**
- * Retrieves the Group node at the specified index from
- * this AlternateAppearance node's list of scopes.
- * @param index the index of the Group node to be returned.
- * @return the Group node at the specified index.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Group getScope(int index) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance8"));
-
-
- return ((AlternateAppearanceRetained)this.retained).getScope(index);
- }
-
-
- /**
- * Inserts the specified Group node into this AlternateAppearance node's
- * list of scopes at the specified index.
- * By default, AlternateAppearance nodes are scoped only by their
- * influencing
- * bounds. This allows them to be further scoped by a list of
- * nodes in the hierarchy.
- * @param scope the Group node to be inserted at the specified index.
- * @param index the index at which the Group node is inserted.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if the specified group node
- * is part of a compiled scene graph
- */
- public void insertScope(Group scope, int index) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance9"));
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).insertScope(scope, index);
- else
- ((AlternateAppearanceRetained)this.retained).initInsertScope(scope, index);
- }
-
-
- /**
- * Removes the node at the specified index from this AlternateAppearance
- * node's
- * list of scopes. If this operation causes the list of scopes to
- * become empty, then this AlternateAppearance will have universe scope:
- * all nodes
- * within the region of influence will be affected by this
- * AlternateAppearance node.
- * @param index the index of the Group node to be removed.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if the group node at the
- * specified index is part of a compiled scene graph
- */
- public void removeScope(int index) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance10"));
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).removeScope(index);
- else
- ((AlternateAppearanceRetained)this.retained).initRemoveScope(index);
- }
-
-
-/**
- * Returns an enumeration of this AlternateAppearance node's list
- * of scopes.
- * @return an Enumeration object containing all nodes in this
- * AlternateAppearance node's list of scopes.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
-public Enumeration getAllScopes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_SCOPE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance11"));
-
- return ((AlternateAppearanceRetained)this.retained).getAllScopes();
-}
-
-
- /**
- * Appends the specified Group node to this AlternateAppearance node's
- * list of scopes.
- * By default, AlternateAppearance nodes are scoped only by their
- * influencing
- * bounds. This allows them to be further scoped by a list of
- * nodes in the hierarchy.
- * @param scope the Group node to be appended.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if the specified group node
- * is part of a compiled scene graph
- */
- public void addScope(Group scope) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance12"));
-
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).addScope(scope);
- else
- ((AlternateAppearanceRetained)this.retained).initAddScope(scope);
- }
-
-
- /**
- * Returns the number of nodes in this AlternateAppearance node's list
- * of scopes.
- * If this number is 0, then the list of scopes is empty and this
- * AlternateAppearance node has universe scope: all nodes within the
- * region of
- * influence are affected by this AlternateAppearance node.
- * @return the number of nodes in this AlternateAppearance node's list
- * of scopes.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public int numScopes() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance11"));
-
-
- return ((AlternateAppearanceRetained)this.retained).numScopes();
- }
-
-
- /**
- * Retrieves the index of the specified Group node in this
- * AlternateAppearance node's list of scopes.
- *
- * @param scope the Group node to be looked up.
- * @return the index of the specified Group node;
- * returns -1 if the object is not in the list.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @since Java 3D 1.3
- */
- public int indexOfScope(Group scope) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance8"));
-
- return ((AlternateAppearanceRetained)this.retained).indexOfScope(scope);
- }
-
-
- /**
- * Removes the specified Group node from this AlternateAppearance
- * node's list of scopes. If the specified object is not in the
- * list, the list is not modified. If this operation causes the
- * list of scopes to become empty, then this AlternateAppearance
- * will have universe scope: all nodes within the region of
- * influence will be affected by this AlternateAppearance node.
- *
- * @param scope the Group node to be removed.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if the specified group node
- * is part of a compiled scene graph
- *
- * @since Java 3D 1.3
- */
- public void removeScope(Group scope) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance10"));
-
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).removeScope(scope);
- else
- ((AlternateAppearanceRetained)this.retained).initRemoveScope(scope);
- }
-
-
- /**
- * Removes all Group nodes from this AlternateAppearance node's
- * list of scopes. The AlternateAppearance node will then have
- * universe scope: all nodes within the region of influence will
- * be affected by this AlternateAppearance node.
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception RestrictedAccessException if any group node in this
- * node's list of scopes is part of a compiled scene graph
- *
- * @since Java 3D 1.3
- */
- public void removeAllScopes() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_SCOPE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AlternateAppearance10"));
- if (isLive())
- ((AlternateAppearanceRetained)this.retained).removeAllScopes();
- else
- ((AlternateAppearanceRetained)this.retained).initRemoveAllScopes();
- }
-
-
- /**
- * Copies all AlternateAppearance information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- super.duplicateAttributes(originalNode, forceDuplicate);
-
- AlternateAppearanceRetained attr = (AlternateAppearanceRetained)
- originalNode.retained;
- AlternateAppearanceRetained rt = (AlternateAppearanceRetained) retained;
-
- rt.initAppearance((Appearance) getNodeComponent(
- attr.getAppearance(),
- forceDuplicate,
- originalNode.nodeHashtable));
-
- rt.initInfluencingBounds(attr.getInfluencingBounds());
-
- Enumeration elm = attr.getAllScopes();
- while (elm.hasMoreElements()) {
- // this reference will set correctly in updateNodeReferences() callback
- rt.initAddScope(elm.nextElement());
- }
-
- // correct value will set in updateNodeReferences
- rt.initInfluencingBoundingLeaf(attr.getInfluencingBoundingLeaf());
-
- }
-
- /**
- * Callback used to allow a node to check if any nodes referenced
- * by that node have been duplicated via a call to cloneTree.
- * This method is called by cloneTree after all nodes in
- * the sub-graph have been duplicated. The cloned Leaf node's method
- * will be called and the Leaf node can then look up any node references
- * by using the getNewObjectReference method found in the
- * NodeReferenceTable object. If a match is found, a
- * reference to the corresponding Node in the newly cloned sub-graph
- * is returned. If no corresponding reference is found, either a
- * DanglingReferenceException is thrown or a reference to the original
- * node is returned depending on the value of the
- * allowDanglingReferences parameter passed in the
- * cloneTree call.
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneTree method.
- *
- * @param referenceTable a NodeReferenceTableObject that contains the
- * getNewObjectReference method needed to search for
- * new object instances.
- * @see NodeReferenceTable
- * @see Node#cloneTree
- * @see DanglingReferenceException
- */
- @Override
- public void updateNodeReferences(NodeReferenceTable referenceTable) {
-
- AlternateAppearanceRetained rt = (AlternateAppearanceRetained)
- retained;
-
- BoundingLeaf bl = rt.getInfluencingBoundingLeaf();
-
- if (bl != null) {
- Object o = referenceTable.getNewObjectReference(bl);
- rt.initInfluencingBoundingLeaf((BoundingLeaf) o);
- }
-
- int num = rt.numScopes();
- for (int i=0; i < num; i++) {
- rt.initScope((Group) referenceTable.
- getNewObjectReference(rt.getScope(i)), i);
- }
- }
-
-
- /**
- * Used to create a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- AlternateAppearance app = new AlternateAppearance();
- app.duplicateNode(this, forceDuplicate);
- return app;
- }
-}
-
diff --git a/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java b/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java
deleted file mode 100644
index 636bc13..0000000
--- a/src/classes/share/javax/media/j3d/AlternateAppearanceRetained.java
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Vector;
-
-
-class AlternateAppearanceRetained extends LeafRetained {
-
-
- // Statics used when something in the alternate app changes
- static final int APPEARANCE_CHANGED = 0x0001;
- static final int SCOPE_CHANGED = 0x0002;
- static final int BOUNDS_CHANGED = 0x0004;
- static final int BOUNDINGLEAF_CHANGED = 0x0008;
- static final int INIT_MIRROR = 0x0010; // setLive
- static final int CLEAR_MIRROR = 0x0020; // clearLive
-
-
- /**
- * The Boundary object defining the lights's region of influence.
- */
- Bounds regionOfInfluence = null;
-
- /**
- * The bounding leaf reference
- */
- BoundingLeafRetained boundingLeaf = null;
-
-/**
- * Vector of GroupRetained nodes that scopes this alternate app .
- */
-Vector scopes = new Vector();
-
- // This is true when this alternate app is referenced in an immediate mode context
- boolean inImmCtx = false;
-
- // Target threads to be notified when light changes
- static final int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
- J3dThread.UPDATE_RENDER;
-
- // Boolean to indicate if this object is scoped (only used for mirror objects
- boolean isScoped = false;
-
- // The object that contains the dynamic HashKey - a string type object
- // Used in scoping
- HashKey tempKey = new HashKey(250);
-
- /**
- * The transformed value of the applicationRegion.
- */
- Bounds region = null;
-
- /**
- * mirror Alternate appearance
- */
- AlternateAppearanceRetained mirrorAltApp = null;
-
- /**
- * Appearance for this object
- */
- AppearanceRetained appearance;
-
- /**
- * A reference to the scene graph alternateApp
- */
- AlternateAppearanceRetained sgAltApp = null;
-
- /**
- * Is true, if the mirror altapp is viewScoped
- */
- boolean isViewScoped = false;
-
- AlternateAppearanceRetained() {
- this.nodeType = NodeRetained.ALTERNATEAPPEARANCE;
- localBounds = new BoundingBox((Bounds)null);
- }
-
- /**
- * Initializes the appearance
- */
- void initAppearance(Appearance app) {
- if (app != null)
- appearance = (AppearanceRetained) app.retained;
- else
- appearance = null;
- }
-
-
- /**
- * sets the appearance and send a message
- */
- void setAppearance(Appearance app) {
- if (appearance != null)
- synchronized(appearance.liveStateLock) {
- appearance.clearLive(refCount);
- }
- initAppearance(app);
- if (appearance != null) {
- synchronized(appearance.liveStateLock) {
- appearance.setLive(inBackgroundGroup, refCount);
- }
- }
- // There is no need to clone the appearance's mirror
- sendMessage(APPEARANCE_CHANGED,
- (appearance != null ? appearance.mirror: null));
- }
-
-
-
- Appearance getAppearance() {
- return (appearance == null ? null: (Appearance) appearance.source);
- }
-
-
- /**
- * Set the alternate's region of influence.
- */
- void initInfluencingBounds(Bounds region) {
- if (region != null) {
- this.regionOfInfluence = (Bounds) region.clone();
- } else {
- this.regionOfInfluence = null;
- }
- }
-
- /**
- * Set the alternate's region of influence and send message
- */
- void setInfluencingBounds(Bounds region) {
- initInfluencingBounds(region);
- sendMessage(BOUNDS_CHANGED,
- (region != null ? region.clone() : null));
- }
-
- /**
- * Get the alternate's region of Influence.
- */
- Bounds getInfluencingBounds() {
- return (regionOfInfluence != null ?
- (Bounds) regionOfInfluence.clone() : null);
- }
-
- /**
- * Set the alternate's region of influence to the specified Leaf node.
- */
- void initInfluencingBoundingLeaf(BoundingLeaf region) {
- if (region != null) {
- boundingLeaf = (BoundingLeafRetained)region.retained;
- } else {
- boundingLeaf = null;
- }
- }
-
- /**
- * Set the alternate's region of influence to the specified Leaf node.
- */
- void setInfluencingBoundingLeaf(BoundingLeaf region) {
- if (boundingLeaf != null)
- boundingLeaf.mirrorBoundingLeaf.removeUser(mirrorAltApp);
- if (region != null) {
- boundingLeaf = (BoundingLeafRetained)region.retained;
- boundingLeaf.mirrorBoundingLeaf.addUser(mirrorAltApp);
- } else {
- boundingLeaf = null;
- }
- sendMessage(BOUNDINGLEAF_CHANGED,
- (boundingLeaf != null ?
- boundingLeaf.mirrorBoundingLeaf : null));
- }
-
- /**
- * Get the alternate's region of influence.
- */
- BoundingLeaf getInfluencingBoundingLeaf() {
- return (boundingLeaf != null ?
- (BoundingLeaf)boundingLeaf.source : null);
- }
-
-
-
- /**
- * Replaces the specified scope with the scope provided.
- * @param scope the new scope
- * @param index which scope to replace
- */
- void initScope(Group scope, int index) {
- scopes.setElementAt((GroupRetained)(scope.retained), index);
-
- }
-
- /**
- * Replaces the specified scope with the scope provided.
- * @param scope the new scope
- * @param index which scope to replace
- */
- void setScope(Group scope, int index) {
-
- ArrayList removeScopeList = new ArrayList();
- ArrayList addScopeList = new ArrayList();
- Object[] scopeInfo = new Object[3];
-
- GroupRetained group = scopes.get(index);
- tempKey.reset();
- group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);
-
- group = (GroupRetained)scope.retained;
- initScope(scope, index);
- tempKey.reset();
-
- // If its a group, then add the scope to the group, if
- // its a shape, then keep a list to be added during
- // updateMirrorObject
- group.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);
- scopeInfo[0] = addScopeList;
- scopeInfo[1] = removeScopeList;
- scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE:Boolean.FALSE);
- sendMessage(SCOPE_CHANGED, scopeInfo);
- }
-
- Group getScope(int index) {
- return (Group)scopes.elementAt(index).source;
- }
-
-
- /**
- * Inserts the specified scope at specified index.before the
- * alt app is live
- * @param scope the new scope
- * @param index position to insert new scope at
- */
- void initInsertScope(Node scope, int index) {
- GroupRetained group = (GroupRetained)scope.retained;
- scopes.insertElementAt(group, index);
- group.setAltAppScope();
- }
-
- /**
- * Inserts the specified scope at specified index and sends
- * a message
- * @param scope the new scope
- * @param index position to insert new scope at
- */
- void insertScope(Node scope, int index) {
- Object[] scopeInfo = new Object[3];
- ArrayList addScopeList = new ArrayList();
- GroupRetained group = (GroupRetained)scope.retained;
-
- initInsertScope(scope, index);
- group = (GroupRetained)scope.retained;
- tempKey.reset();
- group.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);
-
- scopeInfo[0] = addScopeList;
- scopeInfo[1] = null;
- scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
- sendMessage(SCOPE_CHANGED, scopeInfo);
- }
-
-
-
- void initRemoveScope(int index) {
- GroupRetained group = scopes.remove(index);
- group.removeAltAppScope();
-
- }
-
- void removeScope(int index) {
-
- Object[] scopeInfo = new Object[3];
- ArrayList removeScopeList = new ArrayList();
- GroupRetained group = scopes.elementAt(index);
-
- tempKey.reset();
- group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);
-
- initRemoveScope(index);
- scopeInfo[0] = null;
- scopeInfo[1] = removeScopeList;
- scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
- sendMessage(SCOPE_CHANGED, scopeInfo);
- }
-
- /**
- * Removes the specified Group node from this node's list of scopes.
- * Method is a no-op if the
- * specified node is not found
- * @param The Group node to be removed
- */
- void removeScope(Group scope) {
- int ind = indexOfScope(scope);
- if(ind >= 0)
- removeScope(ind);
- }
-
- void initRemoveScope(Group scope) {
- int ind = indexOfScope(scope);
- if(ind >= 0)
- initRemoveScope(ind);
- }
-
- void removeAllScopes() {
- ArrayList removeScopeList = new ArrayList();
- int n = scopes.size();
- for(int index = n-1; index >= 0; index--) {
- GroupRetained group = scopes.elementAt(index);
- tempKey.reset();
- group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);
- initRemoveScope(index);
- }
- Object[] scopeInfo = new Object[3];
- scopeInfo[0] = null;
- scopeInfo[1] = removeScopeList;
- scopeInfo[2] = (Boolean.FALSE);
- sendMessage(SCOPE_CHANGED, scopeInfo);
- }
-
- void initRemoveAllScopes() {
- int n = scopes.size();
- for(int i = n-1; i >= 0; i--)
- initRemoveScope(i);
- }
-
-/**
- * Returns an enumeration object of the scoperen.
- * @return an enumeration object of the scoperen
- */
-Enumeration getAllScopes() {
- Enumeration elm = scopes.elements();
- Vector v = new Vector(scopes.size());
- while (elm.hasMoreElements()) {
- v.add((Group)elm.nextElement().source);
- }
- return v.elements();
-}
-
- /**
- * Returns the index of the specified Group node in this node's list of scopes.
- * @param scope the Group node whose index is needed
- */
- int indexOfScope(Group scope) {
- if(scope != null)
- return scopes.indexOf(scope.retained);
- else
- return scopes.indexOf(null);
- }
-
- /**
- * Appends the specified scope to this node's list of scopes before
- * the alt app is alive
- * @param scope the scope to add to this node's list of scopes
- */
- void initAddScope(Group scope) {
- GroupRetained group = (GroupRetained)scope.retained;
- scopes.addElement(group);
- group.setAltAppScope();
- }
-
- /**
- * Appends the specified scope to this node's list of scopes.
- * @param scope the scope to add to this node's list of scopes
- */
- void addScope(Group scope) {
-
- Object[] scopeInfo = new Object[3];
- ArrayList addScopeList = new ArrayList();
- GroupRetained group = (GroupRetained)scope.retained;
-
- initAddScope(scope);
- tempKey.reset();
- group.addAllNodesForScopedAltApp(mirrorAltApp,addScopeList, tempKey);
- scopeInfo[0] = addScopeList;
- scopeInfo[1] = null;
- scopeInfo[2] = (scopes.size() > 0 ? Boolean.TRUE: Boolean.FALSE);
- sendMessage(SCOPE_CHANGED, scopeInfo);
- }
-
-
-
- /**
- * Returns a count of this nodes' scopes.
- * @return the number of scopes descendant from this node
- */
- int numScopes() {
- return scopes.size();
- }
-
-
- /**
- * This sets the immedate mode context flag
- */
- void setInImmCtx(boolean inCtx) {
- inImmCtx = inCtx;
- }
-
- /**
- * This gets the immedate mode context flag
- */
- boolean getInImmCtx() {
- return (inImmCtx);
- }
-
- boolean isScoped() {
- return (scopes != null);
- }
-
-
- void updateImmediateMirrorObject(Object[] objs) {
- int component = ((Integer)objs[1]).intValue();
- if ((component & APPEARANCE_CHANGED) != 0) {
- mirrorAltApp.appearance = (AppearanceRetained)objs[2];
- }
- if ((component & BOUNDS_CHANGED) != 0) {
- mirrorAltApp.regionOfInfluence = (Bounds) objs[2];
- if (mirrorAltApp.boundingLeaf == null) {
- if (objs[2] != null) {
- mirrorAltApp.region = mirrorAltApp.regionOfInfluence.copy(mirrorAltApp.region);
- mirrorAltApp.region.transform(
- mirrorAltApp.regionOfInfluence,
- getCurrentLocalToVworld());
- }
- else {
- mirrorAltApp.region = null;
- }
- }
- }
- else if ((component & BOUNDINGLEAF_CHANGED) != 0) {
- mirrorAltApp.boundingLeaf = (BoundingLeafRetained)objs[2];
- if (objs[2] != null) {
- mirrorAltApp.region = mirrorAltApp.boundingLeaf.transformedRegion;
- }
- else {
- if (mirrorAltApp.regionOfInfluence != null) {
- mirrorAltApp.region = mirrorAltApp.regionOfInfluence.copy(mirrorAltApp.region);
- mirrorAltApp.region.transform(
- mirrorAltApp.regionOfInfluence,
- getCurrentLocalToVworld());
- }
- else {
- mirrorAltApp.region = null;
- }
-
- }
- }
- else if ((component & SCOPE_CHANGED) != 0) {
- Object[] scopeList = (Object[])objs[2];
- ArrayList addList = (ArrayList)scopeList[0];
- ArrayList removeList = (ArrayList)scopeList[1];
- boolean isScoped = ((Boolean)scopeList[2]).booleanValue();
-
- if (addList != null) {
- mirrorAltApp.isScoped = isScoped;
- for (int i = 0; i < addList.size(); i++) {
- Shape3DRetained obj = ((GeometryAtom)addList.get(i)).source;
- obj.addAltApp(mirrorAltApp);
- }
- }
-
- if (removeList != null) {
- mirrorAltApp.isScoped = isScoped;
- for (int i = 0; i < removeList.size(); i++) {
- Shape3DRetained obj = ((GeometryAtom)removeList.get(i)).source;
- obj.removeAltApp(mirrorAltApp);
- }
- }
- }
-
-
- }
-
-
- /** Note: This routine will only be called on
- * the mirror object - will update the object's
- * cached region and transformed region
- */
-
- @Override
- void updateBoundingLeaf() {
- if (boundingLeaf != null && boundingLeaf.switchState.currentSwitchOn) {
- region = boundingLeaf.transformedRegion;
- } else {
- if (regionOfInfluence != null) {
- region = regionOfInfluence.copy(region);
- region.transform(regionOfInfluence, getCurrentLocalToVworld());
- } else {
- region = null;
- }
- }
- }
-
- @Override
- void setLive(SetLiveState s) {
-
- if (inImmCtx) {
- throw new IllegalSharingException(J3dI18N.getString("AlternateAppearanceRetained13"));
- }
-
- if (inSharedGroup) {
- throw new
- IllegalSharingException(J3dI18N.getString("AlternateAppearanceRetained15"));
- }
-
- if (inBackgroundGroup) {
- throw new
- IllegalSceneGraphException(J3dI18N.getString("AlternateAppearanceRetained16"));
- }
-
- super.doSetLive(s);
-
- if (appearance != null) {
- if (appearance.getInImmCtx()) {
- throw new IllegalSharingException(J3dI18N.getString("AlternateAppearanceRetained14"));
- }
- synchronized(appearance.liveStateLock) {
- appearance.setLive(inBackgroundGroup, s.refCount);
- }
- }
-
- // Create the mirror object
- // Initialization of the mirror object during the INSERT_NODE
- // message (in updateMirrorObject)
- if (mirrorAltApp == null) {
- mirrorAltApp = (AlternateAppearanceRetained)this.clone();
- // Assign the bounding leaf of this mirror object as null
- // it will later be assigned to be the mirror of the alternate app
- // bounding leaf object
- mirrorAltApp.boundingLeaf = null;
- mirrorAltApp.sgAltApp = this;
- }
- // If bounding leaf is not null, add the mirror object as a user
- // so that any changes to the bounding leaf will be received
- if (boundingLeaf != null) {
- boundingLeaf.mirrorBoundingLeaf.addUser(mirrorAltApp);
- }
-
- if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
- s.viewScopedNodeList.add(mirrorAltApp);
- s.scopedNodesViewList.add(s.viewLists.get(0));
- } else {
- s.nodeList.add(mirrorAltApp);
- }
-
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(mirrorAltApp,
- Targets.ENV_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
-
- // process switch leaf
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(mirrorAltApp, Targets.ENV_TARGETS);
- }
- mirrorAltApp.switchState = s.switchStates.get(0);
-
- s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
- J3dThread.UPDATE_RENDER;
-
- // At the end make it live
- super.markAsLive();
-
- // Initialize the mirror object, this needs to be done, when
- // renderBin is not accessing any of the fields
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
- createMessage.universe = universe;
- createMessage.type = J3dMessage.ALTERNATEAPPEARANCE_CHANGED;
- createMessage.args[0] = this;
- // a snapshot of all attributes that needs to be initialized
- // in the mirror object
- createMessage.args[1]= new Integer(INIT_MIRROR);
- ArrayList addScopeList = new ArrayList();
- for (int i = 0; i < scopes.size(); i++) {
- GroupRetained group = scopes.get(i);
- tempKey.reset();
- group.addAllNodesForScopedAltApp(mirrorAltApp, addScopeList, tempKey);
- }
- Object[] scopeInfo = new Object[2];
- scopeInfo[0] = ((scopes.size() > 0) ? Boolean.TRUE:Boolean.FALSE);
- scopeInfo[1] = addScopeList;
- createMessage.args[2] = scopeInfo;
- if (appearance != null) {
- createMessage.args[3] = appearance.mirror;
- }
- else {
- createMessage.args[3] = null;
- }
- Object[] obj = new Object[2];
- obj[0] = boundingLeaf;
- obj[1] = (regionOfInfluence != null?regionOfInfluence.clone():null);
- createMessage.args[4] = obj;
- VirtualUniverse.mc.processMessage(createMessage);
-
-
-
-
-
- }
-
- /**
- * This is called on the parent object
- */
- void initMirrorObject(Object[] args) {
- Shape3DRetained shape;
- Object[] scopeInfo = (Object[]) args[2];
- Boolean scoped = (Boolean)scopeInfo[0];
- ArrayList shapeList = (ArrayList)scopeInfo[1];
- AppearanceRetained app = (AppearanceRetained)args[3];
- BoundingLeafRetained bl=(BoundingLeafRetained)((Object[])args[4])[0];
- Bounds bnds = (Bounds)((Object[])args[4])[1];
-
- for (int i = 0; i < shapeList.size(); i++) {
- shape = ((GeometryAtom)shapeList.get(i)).source;
- shape.addAltApp(mirrorAltApp);
- }
- mirrorAltApp.isScoped = scoped.booleanValue();
-
- if (app != null)
- mirrorAltApp.appearance = app;
-
- if (bl != null) {
- mirrorAltApp.boundingLeaf = bl.mirrorBoundingLeaf;
- mirrorAltApp.region = boundingLeaf.transformedRegion;
- } else {
- mirrorAltApp.boundingLeaf = null;
- mirrorAltApp.region = null;
- }
-
- if (bnds != null) {
- mirrorAltApp.regionOfInfluence = bnds;
- if (mirrorAltApp.region == null) {
- mirrorAltApp.region = (Bounds)regionOfInfluence.clone();
- mirrorAltApp.region.transform(regionOfInfluence, getLastLocalToVworld());
- }
- }
- else {
- mirrorAltApp.regionOfInfluence = null;
- }
-
- }
-
- void clearMirrorObject(Object[] args) {
- Shape3DRetained shape;
- ArrayList shapeList = (ArrayList)args[2];
- ArrayList removeScopeList = new ArrayList();
-
- for (int i = 0; i < shapeList.size(); i++) {
- shape = ((GeometryAtom)shapeList.get(i)).source;
- shape.removeAltApp(mirrorAltApp);
- }
- mirrorAltApp.isScoped = false;
-
-
-
- }
-
-
- /**
- * This clearLive routine first calls the superclass's method, then
- * it removes itself to the list of alt app
- */
- @Override
- void clearLive(SetLiveState s) {
- int i, j;
- GroupRetained group;
-
- if (appearance != null) {
- synchronized(appearance.liveStateLock) {
- appearance.clearLive(s.refCount);
- }
- }
-
- super.clearLive(s);
- s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
- J3dThread.UPDATE_RENDER;
-
- // Remove this mirror light as users of the bounding leaf
- if (mirrorAltApp.boundingLeaf != null)
- mirrorAltApp.boundingLeaf.removeUser(mirrorAltApp);
-
- if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
- s.viewScopedNodeList.add(mirrorAltApp);
- s.scopedNodesViewList.add(s.viewLists.get(0));
- } else {
- s.nodeList.add(mirrorAltApp);
- }
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(mirrorAltApp,
- Targets.ENV_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(mirrorAltApp, Targets.ENV_TARGETS);
- }
-
-
- if (scopes.size() > 0) {
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
- createMessage.universe = universe;
- createMessage.type = J3dMessage.ALTERNATEAPPEARANCE_CHANGED;
- createMessage.args[0] = this;
- createMessage.args[1]= new Integer(CLEAR_MIRROR);
- ArrayList removeScopeList = new ArrayList();
- for (i = 0; i < scopes.size(); i++) {
- group = scopes.get(i);
- tempKey.reset();
- group.removeAllNodesForScopedAltApp(mirrorAltApp, removeScopeList, tempKey);
- }
- createMessage.args[2] = removeScopeList;
- VirtualUniverse.mc.processMessage(createMessage);
- }
- }
-
-
-
- @Override
- void updateTransformChange() {
- }
-
- /**
- * Called on mirror object
- */
- void updateImmediateTransformChange() {
- // If bounding leaf is null, tranform the bounds object
- if (boundingLeaf == null) {
- if (regionOfInfluence != null) {
- region = regionOfInfluence.copy(region);
- region.transform(regionOfInfluence,
- sgAltApp.getCurrentLocalToVworld());
- }
-
- }
- }
-
- final void sendMessage(int attrMask, Object attr) {
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = targetThreads;
- createMessage.universe = universe;
- createMessage.type = J3dMessage.ALTERNATEAPPEARANCE_CHANGED;
- createMessage.args[0] = this;
- createMessage.args[1]= new Integer(attrMask);
- createMessage.args[2] = attr;
- VirtualUniverse.mc.processMessage(createMessage);
- }
-
-
- @Override
- void getMirrorObjects(ArrayList leafList, HashKey key) {
- leafList.add(mirrorAltApp);
- }
-
-
- /**
- * Copies all AlternateAppearance information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- throw new RuntimeException("method not implemented");
-
-// super.duplicateAttributes(originalNode, forceDuplicate);
-
-// AlternateAppearance alternate appearance = (AlternateAppearance) originalNode;
-
-// // XXXX: clone appearance
-
-// setInfluencingBounds(alternate appearance.getInfluencingBounds());
-
-// Enumeration elm = alternate appearance.getAllScopes();
-// while (elm.hasMoreElements()) {
-// // this reference will set correctly in updateNodeReferences() callback
-// addScope((Group) elm.nextElement());
-// }
-
-// // this reference will set correctly in updateNodeReferences() callback
-// setInfluencingBoundingLeaf(alternate appearance.getInfluencingBoundingLeaf());
- }
-
-// /**
-// * Callback used to allow a node to check if any nodes referenced
-// * by that node have been duplicated via a call to cloneTree.
-// * This method is called by cloneTree after all nodes in
-// * the sub-graph have been duplicated. The cloned Leaf node's method
-// * will be called and the Leaf node can then look up any node references
-// * by using the getNewObjectReference method found in the
-// * NodeReferenceTable object. If a match is found, a
-// * reference to the corresponding Node in the newly cloned sub-graph
-// * is returned. If no corresponding reference is found, either a
-// * DanglingReferenceException is thrown or a reference to the original
-// * node is returned depending on the value of the
-// * allowDanglingReferences parameter passed in the
-// * cloneTree call.
-// *
-// * NOTE: Applications should not call this method directly.
-// * It should only be called by the cloneTree method.
-// *
-// * @param referenceTable a NodeReferenceTableObject that contains the
-// * getNewObjectReference method needed to search for
-// * new object instances.
-// * @see NodeReferenceTable
-// * @see Node#cloneTree
-// * @see DanglingReferenceException
-// */
-// public void updateNodeReferences(NodeReferenceTable referenceTable) {
-// throw new RuntimeException("method not implemented");
-//
-// Object o;
-//
-// BoundingLeaf bl = getInfluencingBoundingLeaf();
-// if (bl != null) {
-// o = referenceTable.getNewObjectReference(bl);
-// setInfluencingBoundingLeaf((BoundingLeaf) o);
-// }
-//
-// for (int i=0; i < numScopes(); i++) {
-// o = referenceTable.getNewObjectReference(getScope(i));
-// setScope((Group) o, i);
-// }
-// }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AmbientLight.java b/src/classes/share/javax/media/j3d/AmbientLight.java
deleted file mode 100644
index 588ea51..0000000
--- a/src/classes/share/javax/media/j3d/AmbientLight.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Color3f;
-
-/**
- * An ambient light source object. Ambient light is that light
- * that seems to come from all directions. The AmbientLight object
- * has the same attributes as a Light node, including color,
- * influencing bounds, scopes, and
- * a flag indicating whether this light source is on or off.
- * Ambient reflections do not depend on the orientation or
- * position of a surface.
- * Ambient light has only an ambient reflection component.
- * It does not have diffuse or specular reflection components.
- *
- * For more information on Java 3D lighting, see the class description
- * for Light.
- *
- */
-
-public class AmbientLight extends Light {
- /**
- * Constructs and initializes an ambient light using default parameters.
- */
- public AmbientLight() {
- }
-
-
- /**
- * Constructs and initializes an ambient light using the specified
- * parameters.
- * @param color the color of the light source.
- */
- public AmbientLight(Color3f color) {
- super(color);
- }
-
-
- /**
- * Constructs and initializes an ambient light using the specified
- * parameters.
- * @param lightOn flag indicating whether this light is on or off.
- * @param color the color of the light source.
- */
- public AmbientLight(boolean lightOn, Color3f color) {
- super(lightOn, color);
- }
-
- /**
- * Creates the retained mode AmbientLightRetained object that this
- * AmbientLight component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new AmbientLightRetained();
- this.retained.setSource(this);
- }
-
- /**
- * Used to create a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- AmbientLight a = new AmbientLight();
- a.duplicateNode(this, forceDuplicate);
- return a;
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AmbientLightRetained.java b/src/classes/share/javax/media/j3d/AmbientLightRetained.java
deleted file mode 100644
index dcc7c22..0000000
--- a/src/classes/share/javax/media/j3d/AmbientLightRetained.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-/**
- * An ambient light source object.
- */
-
-class AmbientLightRetained extends LightRetained {
-
- AmbientLightRetained() {
- this.nodeType = NodeRetained.AMBIENTLIGHT;
- lightType = 1;
- localBounds = new BoundingBox((Bounds)null);
- }
-
- @Override
- void setLive(SetLiveState s) {
- super.setLive(s);
- J3dMessage createMessage = super.initMessage(7);
- VirtualUniverse.mc.processMessage(createMessage);
- }
-
- @Override
- void update(Context ctx, int lightSlot, double scale) {
- }
-}
diff --git a/src/classes/share/javax/media/j3d/Appearance.java b/src/classes/share/javax/media/j3d/Appearance.java
deleted file mode 100644
index a26eb84..0000000
--- a/src/classes/share/javax/media/j3d/Appearance.java
+++ /dev/null
@@ -1,1032 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.Hashtable;
-
-/**
- * The Appearance object defines all rendering state that can be set
- * as a component object of a Shape3D node. The rendering state
- * consists of the following:
- *
- *
Coloring attributes - defines attributes used in color selection
- * and shading. These attributes are defined in a ColoringAttributes
- * object.
- *
- *
Line attributes - defines attributes used to define lines, including
- * the pattern, width, and whether antialiasing is to be used. These
- * attributes are defined in a LineAttributes object.
- *
- *
Point attributes - defines attributes used to define points,
- * including the size and whether antialiasing is to be used. These
- * attributes are defined in a PointAttributes object.
- *
- *
Polygon attributes - defines the attributes used to define
- * polygons, including culling, rasterization mode (filled, lines,
- * or points), constant offset, offset factor, and whether back
- * back facing normals are flipped. These attributes are defined
- * in a PolygonAttributes object.
- *
- *
Rendering attributes - defines rendering operations,
- * including the alpha test function and test value, the raster
- * operation, whether vertex colors are ignored, whether invisible
- * objects are rendered, and whether the depth buffer is enabled.
- * These attributes are defined in a RenderingAttributes
- * object.
- *
- *
Transparency attributes - defines the attributes that affect
- * transparency of the object, such as the transparency mode
- * (blended, screen-door), blending function (used in transparency
- * and antialiasing operations), and a blend value that defines
- * the amount of transparency to be applied to this Appearance
- * component object.
- *
- *
Material - defines the appearance of an object under illumination,
- * such as the ambient color, diffuse color, specular color, emissive
- * color, and shininess. These attributes are defined in a Material
- * object.
- *
- *
Texture - defines the texture image and filtering
- * parameters used when texture mapping is enabled. These attributes
- * are defined in a Texture object.
- *
- *
Texture attributes - defines the attributes that apply to
- * texture mapping, such as the texture mode, texture transform,
- * blend color, and perspective correction mode. These attributes
- * are defined in a TextureAttributes object.
- *
- *
Texture coordinate generation - defines the attributes
- * that apply to texture coordinate generation, such as whether
- * texture coordinate generation is enabled, coordinate format
- * (2D or 3D coordinates), coordinate generation mode (object
- * linear, eye linear, or spherical reflection mapping), and the
- * R, S, and T coordinate plane equations. These attributes
- * are defined in a TexCoordGeneration object.
- *
- *
Texture unit state - array that defines texture state for each
- * of N separate texture units. This allows multiple textures
- * to be applied to geometry. Each TextureUnitState object contains a
- * Texture object, TextureAttributes, and TexCoordGeneration object
- * for one texture unit. If the length of the texture unit state
- * array is greater than 0, then the array is used for all texture
- * state; the individual Texture, TextureAttributes, and
- * TexCoordGeneration objects in this Appearance object are not used
- * and and must not be set by an application. If the length of the
- * texture unit state array is 0, the multi-texture is disabled and
- * the Texture, TextureAttributes, and TexCoordGeneration objects
- * in the Appearance object are used. If the application sets the
- * existing Texture, TextureAttributes, and TexCoordGeneration
- * objects to non-null values, they effectively define the state
- * for texture unit 0. If the TextureUnitState array is set to a
- * non-null, non-empty array, the individual TextureUnitState
- * objects define the state for texture units 0 through n
- * -1. If both the old and new values are set, an exception is thrown.
- *
- *
- *
- *
- * @see ColoringAttributes
- * @see LineAttributes
- * @see PointAttributes
- * @see PolygonAttributes
- * @see RenderingAttributes
- * @see TransparencyAttributes
- * @see Material
- * @see Texture
- * @see TextureAttributes
- * @see TexCoordGeneration
- * @see TextureUnitState
- */
-public class Appearance extends NodeComponent {
-
- /**
- * Specifies that this Appearance object
- * allows reading its coloringAttributes component
- * information.
- */
- public static final int
- ALLOW_COLORING_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_COLORING_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its coloringAttributes component
- * information.
- */
- public static final int
- ALLOW_COLORING_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_COLORING_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its transparency component
- * information.
- */
- public static final int
- ALLOW_TRANSPARENCY_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_TRANSPARENCY_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its transparency component
- * information.
- */
- public static final int
- ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its rendering/rasterization component
- * information.
- */
- public static final int
- ALLOW_RENDERING_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_RENDERING_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its rendering/rasterization component
- * information.
- */
- public static final int
- ALLOW_RENDERING_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_RENDERING_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its polygon component
- * information.
- */
- public static final int
- ALLOW_POLYGON_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_POLYGON_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its polygon component
- * information.
- */
- public static final int
- ALLOW_POLYGON_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_POLYGON_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its line component
- * information.
- */
- public static final int
- ALLOW_LINE_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_LINE_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its line component
- * information.
- */
- public static final int
- ALLOW_LINE_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_LINE_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its point component
- * information.
- */
- public static final int
- ALLOW_POINT_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_POINT_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its point component
- * information.
- */
- public static final int
- ALLOW_POINT_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_POINT_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its material component information.
- */
- public static final int
- ALLOW_MATERIAL_READ = CapabilityBits.APPEARANCE_ALLOW_MATERIAL_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its material component information.
- */
- public static final int
- ALLOW_MATERIAL_WRITE = CapabilityBits.APPEARANCE_ALLOW_MATERIAL_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its texture component information.
- */
- public static final int
- ALLOW_TEXTURE_READ = CapabilityBits.APPEARANCE_ALLOW_TEXTURE_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its texture component information.
- */
- public static final int
- ALLOW_TEXTURE_WRITE = CapabilityBits.APPEARANCE_ALLOW_TEXTURE_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its textureAttributes component
- * information.
- */
- public static final int
- ALLOW_TEXTURE_ATTRIBUTES_READ = CapabilityBits.APPEARANCE_ALLOW_TEXTURE_ATTRIBUTES_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its textureAttributes component
- * information.
- */
- public static final int
- ALLOW_TEXTURE_ATTRIBUTES_WRITE = CapabilityBits.APPEARANCE_ALLOW_TEXTURE_ATTRIBUTES_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its texture coordinate generation component
- * information.
- */
- public static final int
- ALLOW_TEXGEN_READ = CapabilityBits.APPEARANCE_ALLOW_TEXGEN_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its texture coordinate generation component
- * information.
- */
- public static final int
- ALLOW_TEXGEN_WRITE = CapabilityBits.APPEARANCE_ALLOW_TEXGEN_WRITE;
-
- /**
- * Specifies that this Appearance object
- * allows reading its texture unit state component
- * information.
- *
- * @since Java 3D 1.2
- */
- public static final int ALLOW_TEXTURE_UNIT_STATE_READ =
- CapabilityBits.APPEARANCE_ALLOW_TEXTURE_UNIT_STATE_READ;
-
- /**
- * Specifies that this Appearance object
- * allows writing its texture unit state component
- * information.
- *
- * @since Java 3D 1.2
- */
- public static final int ALLOW_TEXTURE_UNIT_STATE_WRITE =
- CapabilityBits.APPEARANCE_ALLOW_TEXTURE_UNIT_STATE_WRITE;
-
- // Array for setting default read capabilities
- private static final int[] readCapabilities = {
- ALLOW_COLORING_ATTRIBUTES_READ,
- ALLOW_LINE_ATTRIBUTES_READ,
- ALLOW_MATERIAL_READ,
- ALLOW_POINT_ATTRIBUTES_READ,
- ALLOW_POLYGON_ATTRIBUTES_READ,
- ALLOW_RENDERING_ATTRIBUTES_READ,
- ALLOW_TEXGEN_READ,
- ALLOW_TEXTURE_ATTRIBUTES_READ,
- ALLOW_TEXTURE_READ,
- ALLOW_TEXTURE_UNIT_STATE_READ,
- ALLOW_TRANSPARENCY_ATTRIBUTES_READ
- };
-
- /**
- * Constructs an Appearance component object using defaults for all
- * state variables. All component object references are initialized
- * to null.
- */
- public Appearance() {
- // Just use default values
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
- }
-
- /**
- * Creates the retained mode AppearanceRetained object that this
- * Appearance component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new AppearanceRetained();
- this.retained.setSource(this);
- }
-
- /**
- * Sets the material object to the specified object.
- * Setting it to null disables lighting.
- * @param material object that specifies the desired material
- * properties
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setMaterial(Material material) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_MATERIAL_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance0"));
- ((AppearanceRetained)this.retained).setMaterial(material);
- }
-
- /**
- * Retrieves the current material object.
- * @return the material object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Material getMaterial() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_MATERIAL_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance1"));
- return ((AppearanceRetained)this.retained).getMaterial();
- }
-
- /**
- * Sets the coloringAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param coloringAttributes object that specifies the desired
- * coloringAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setColoringAttributes(ColoringAttributes coloringAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_COLORING_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance6"));
- ((AppearanceRetained)this.retained).setColoringAttributes(coloringAttributes);
- }
-
- /**
- * Retrieves the current coloringAttributes object.
- * @return the coloringAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public ColoringAttributes getColoringAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_COLORING_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance7"));
- return ((AppearanceRetained)this.retained).getColoringAttributes();
- }
-
- /**
- * Sets the transparencyAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param transparencyAttributes object that specifies the desired
- * transparencyAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setTransparencyAttributes(TransparencyAttributes transparencyAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance8"));
- ((AppearanceRetained)this.retained).setTransparencyAttributes(transparencyAttributes);
- }
-
- /**
- * Retrieves the current transparencyAttributes object.
- * @return the transparencyAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public TransparencyAttributes getTransparencyAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TRANSPARENCY_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance9"));
- return ((AppearanceRetained)this.retained).getTransparencyAttributes();
- }
-
- /**
- * Sets the renderingAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param renderingAttributes object that specifies the desired
- * renderingAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setRenderingAttributes(RenderingAttributes renderingAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_RENDERING_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance10"));
- ((AppearanceRetained)this.retained).setRenderingAttributes(renderingAttributes);
- }
-
- /**
- * Retrieves the current renderingAttributes object.
- * @return the renderingAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public RenderingAttributes getRenderingAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_RENDERING_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance11"));
- return ((AppearanceRetained)this.retained).getRenderingAttributes();
- }
-
- /**
- * Sets the polygonAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param polygonAttributes object that specifies the desired
- * polygonAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setPolygonAttributes(PolygonAttributes polygonAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_POLYGON_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance12"));
- ((AppearanceRetained)this.retained).setPolygonAttributes(polygonAttributes);
- }
-
- /**
- * Retrieves the current polygonAttributes object.
- * @return the polygonAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public PolygonAttributes getPolygonAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_POLYGON_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance13"));
- return ((AppearanceRetained)this.retained).getPolygonAttributes();
- }
-
- /**
- * Sets the lineAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param lineAttributes object that specifies the desired
- * lineAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setLineAttributes(LineAttributes lineAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_LINE_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance14"));
- ((AppearanceRetained)this.retained).setLineAttributes(lineAttributes);
- }
-
- /**
- * Retrieves the current lineAttributes object.
- * @return the lineAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public LineAttributes getLineAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_LINE_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance15"));
- return ((AppearanceRetained)this.retained).getLineAttributes();
- }
-
- /**
- * Sets the pointAttributes object to the specified object.
- * Setting it to null will result in default attribute usage.
- * @param pointAttributes object that specifies the desired
- * pointAttributes parameters
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setPointAttributes(PointAttributes pointAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_POINT_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance16"));
- ((AppearanceRetained)this.retained).setPointAttributes(pointAttributes);
- }
-
- /**
- * Retrieves the current pointAttributes object.
- * @return the pointAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public PointAttributes getPointAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_POINT_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance17"));
- return ((AppearanceRetained)this.retained).getPointAttributes();
- }
-
- /**
- * Sets the texture object to the specified object.
- * Setting it to null disables texture mapping.
- *
- *
- * Applications must not set individual texture component objects
- * (texture, textureAttributes, or texCoordGeneration) and
- * the texture unit state array in the same Appearance object.
- * Doing so will result in an exception being thrown.
- *
- * @param texture object that specifies the desired texture
- * map and texture parameters
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @exception IllegalStateException if the specified texture
- * object is non-null and the texture unit state array in this
- * appearance object is already non-null.
- *
- * @exception IllegalSharingException if this Appearance is live and
- * the specified texture refers to an ImageComponent2D that is being used
- * by a Canvas3D as an off-screen buffer.
- *
- * @exception IllegalSharingException if this Appearance is
- * being used by an immediate mode context and
- * the specified texture refers to an ImageComponent2D that is being used
- * by a Canvas3D as an off-screen buffer.
- */
- public void setTexture(Texture texture) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance2"));
-
- // Do illegal sharing check
- if(texture != null) {
- ImageComponent[] images = ((TextureRetained)(texture.retained)).getImages();
- if(images != null) {
- for(int i=0; i
- * Applications must not set individual texture component objects
- * (texture, textureAttributes, or texCoordGeneration) and
- * the texture unit state array in the same Appearance object.
- * Doing so will result in an exception being thrown.
- *
- * @param textureAttributes object that specifies the desired
- * textureAttributes map and textureAttributes parameters
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @exception IllegalStateException if the specified textureAttributes
- * object is non-null and the texture unit state array in this
- * appearance object is already non-null.
- */
- public void setTextureAttributes(TextureAttributes textureAttributes) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_ATTRIBUTES_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance4"));
- ((AppearanceRetained)this.retained).setTextureAttributes(textureAttributes);
- }
-
- /**
- * Retrieves the current textureAttributes object.
- * @return the textureAttributes object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public TextureAttributes getTextureAttributes() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_ATTRIBUTES_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance5"));
- return ((AppearanceRetained)this.retained).getTextureAttributes();
- }
-
- /**
- * Sets the texCoordGeneration object to the specified object.
- * Setting it to null disables texture coordinate generation.
- *
- *
- * Applications must not set individual texture component objects
- * (texture, textureAttributes, or texCoordGeneration) and
- * the texture unit state array in the same Appearance object.
- * Doing so will result in an exception being thrown.
- *
- * @param texCoordGeneration object that specifies the texture coordinate
- * generation parameters
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @exception IllegalStateException if the specified texCoordGeneration
- * object is non-null and the texture unit state array in this
- * appearance object is already non-null.
- */
- public void setTexCoordGeneration(TexCoordGeneration texCoordGeneration) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXGEN_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance18"));
- ((AppearanceRetained)this.retained).setTexCoordGeneration(texCoordGeneration);
- }
-
- /**
- * Retrieves the current texCoordGeneration object.
- * @return the texCoordGeneration object
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public TexCoordGeneration getTexCoordGeneration() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXGEN_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance19"));
- return ((AppearanceRetained)this.retained).getTexCoordGeneration();
- }
-
- /**
- * Sets the texture unit state array for this appearance object to the
- * specified array. A shallow copy of the array of references to
- * the TextureUnitState objects is made. If the specified array
- * is null or if the length of the array is 0, multi-texture is
- * disabled. Within the array, a null TextureUnitState element
- * disables the corresponding texture unit.
- *
- *
- * Applications must not set individual texture component objects
- * (texture, textureAttributes, or texCoordGeneration) and
- * the texture unit state array in the same Appearance object.
- * Doing so will result in an exception being thrown.
- *
- * @param stateArray array of TextureUnitState objects that
- * specify the desired texture state for each unit. The length of
- * this array specifies the maximum number of texture units that
- * will be used by this appearance object. The texture units are
- * numbered from 0 through
- * stateArray.length-1.
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @exception IllegalStateException if the specified array is
- * non-null and any of the texture object, textureAttributes
- * object, or texCoordGeneration object in this appearance object
- * is already non-null.
- *
- * @exception IllegalSharingException if this Appearance is live and
- * any of the specified textures refers to an ImageComponent2D that is
- * being used by a Canvas3D as an off-screen buffer.
- *
- * @exception IllegalSharingException if this Appearance is
- * being used by an immediate mode context and
- * any of the specified textures refers to an ImageComponent2D that is
- * being used by a Canvas3D as an off-screen buffer.
- *
- * @since Java 3D 1.2
- */
- public void setTextureUnitState(TextureUnitState[] stateArray) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance20"));
-
- // Do illegal sharing check
- if (stateArray != null) {
- for(int j=0; j[0, stateArray.length-1].
- *
- * @param index the array index of the object to be set
- *
- * @param state new texture unit state object
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception NullPointerException if the texture unit state array is
- * null.
- * @exception ArrayIndexOutOfBoundsException if index >=
- * stateArray.length.
- *
- * @exception IllegalSharingException if this Appearance is live and
- * the specified texture refers to an ImageComponent2D that is being used
- * by a Canvas3D as an off-screen buffer.
- *
- * @exception IllegalSharingException if this Appearance is
- * being used by an immediate mode context and
- * the specified texture refers to an ImageComponent2D that is being used
- * by a Canvas3D as an off-screen buffer.
- *
- * @since Java 3D 1.2
- */
- public void setTextureUnitState(int index, TextureUnitState state) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance20"));
-
- // Do illegal sharing check
- if (state != null) {
- TextureRetained texRetained =
- ((TextureUnitStateRetained)state.retained).texture;
- if(texRetained != null) {
- ImageComponent[] images = texRetained.getImages();
- if(images != null) {
- for(int i=0; i[0, stateArray.length-1].
- *
- * @param index the array index of the object to be retrieved
- *
- * @return the texture unit state object at the specified index
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @since Java 3D 1.2
- */
- public TextureUnitState getTextureUnitState(int index) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance21"));
-
- return ((AppearanceRetained)this.retained).getTextureUnitState(index);
- }
-
- /**
- * Retrieves the length of the texture unit state array from
- * this appearance object. The length of this array specifies the
- * maximum number of texture units that will be used by this
- * appearance object. If the array is null, a count of 0 is
- * returned.
- *
- * @return the length of the texture unit state array
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @since Java 3D 1.2
- */
- public int getTextureUnitCount() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_TEXTURE_UNIT_STATE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Appearance21"));
-
- return ((AppearanceRetained)this.retained).getTextureUnitCount();
- }
-
-
- /**
- * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
- */
- @Override
- public NodeComponent cloneNodeComponent() {
- Appearance a = new Appearance();
- a.duplicateNodeComponent(this);
- return a;
- }
-
- /**
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneNode method.
- *
- * @deprecated replaced with duplicateNodeComponent(
- * NodeComponent originalNodeComponent, boolean forceDuplicate)
- */
- @Override
- public void duplicateNodeComponent(NodeComponent originalNodeComponent) {
- checkDuplicateNodeComponent(originalNodeComponent);
- }
-
- /**
- * Copies all Appearance information from
- * originalNodeComponent into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNodeComponent the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(NodeComponent originalNodeComponent,
- boolean forceDuplicate) {
- super.duplicateAttributes(originalNodeComponent, forceDuplicate);
-
- Hashtable hashtable = originalNodeComponent.nodeHashtable;
-
- AppearanceRetained app = (AppearanceRetained) originalNodeComponent.retained;
-
- AppearanceRetained rt = (AppearanceRetained) retained;
-
- rt.setMaterial((Material) getNodeComponent(app.getMaterial(),
- forceDuplicate,
- hashtable));
-
- rt.setColoringAttributes((ColoringAttributes) getNodeComponent(
- app.getColoringAttributes(),
- forceDuplicate,
- hashtable));
-
-
- rt.setTransparencyAttributes((TransparencyAttributes) getNodeComponent(
- app.getTransparencyAttributes(),
- forceDuplicate,
- hashtable));
-
-
- rt.setRenderingAttributes((RenderingAttributes) getNodeComponent(
- app.getRenderingAttributes(),
- forceDuplicate,
- hashtable));
-
-
- rt.setPolygonAttributes((PolygonAttributes) getNodeComponent(
- app.getPolygonAttributes(),
- forceDuplicate,
- hashtable));
-
-
- rt.setLineAttributes((LineAttributes) getNodeComponent(
- app.getLineAttributes(),
- forceDuplicate,
- hashtable));
-
-
- rt.setPointAttributes((PointAttributes) getNodeComponent(
- app.getPointAttributes(),
- forceDuplicate,
- hashtable));
-
- rt.setTexture((Texture) getNodeComponent(app.getTexture(),
- forceDuplicate,
- hashtable));
-
- rt.setTextureAttributes((TextureAttributes) getNodeComponent(
- app.getTextureAttributes(),
- forceDuplicate,
- hashtable));
-
- rt.setTexCoordGeneration((TexCoordGeneration) getNodeComponent(
- app.getTexCoordGeneration(),
- forceDuplicate,
- hashtable));
-
- TextureUnitState state[] = app.getTextureUnitState();
- if (state != null) {
- rt.setTextureUnitState(state);
- for (int i=0; i < state.length; i++) {
- rt.setTextureUnitState(i, (TextureUnitState)
- getNodeComponent(state[i],
- forceDuplicate,
- hashtable));
- }
- }
-
- }
-
- /**
- * This function is called from getNodeComponent() to see if any of
- * the sub-NodeComponents duplicateOnCloneTree flag is true.
- * If it is the case, current NodeComponent needs to
- * duplicate also even though current duplicateOnCloneTree flag is false.
- * This should be overwrite by NodeComponent which contains sub-NodeComponent.
- */
- @Override
- boolean duplicateChild() {
- if (getDuplicateOnCloneTree())
- return true;
-
- AppearanceRetained rt = (AppearanceRetained) retained;
-
- NodeComponent nc;
-
- nc = rt.getMaterial();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getColoringAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getTransparencyAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getPolygonAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getLineAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getPointAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getTexture();
- if ((nc != null) && nc.duplicateChild())
- return true;
-
- nc = rt.getTextureAttributes();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- nc = rt.getTexCoordGeneration();
- if ((nc != null) && nc.getDuplicateOnCloneTree())
- return true;
-
- // XXXX: TextureUnitState
-
- return false;
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AppearanceRetained.java b/src/classes/share/javax/media/j3d/AppearanceRetained.java
deleted file mode 100644
index 987e911..0000000
--- a/src/classes/share/javax/media/j3d/AppearanceRetained.java
+++ /dev/null
@@ -1,1413 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-
-
-/**
- * The Appearance object defines all rendering state that can be set
- * as a component object of a Shape3D node.
- */
-class AppearanceRetained extends NodeComponentRetained {
-
- //
- // State variables: these should all be initialized to approproate
- // Java 3D defaults.
- //
-
- // Material object used when lighting is enabled
- MaterialRetained material = null;
-
- // Texture object used to apply a texture map to an object
- TextureRetained texture = null;
-
- // Texture coordinate generation object
- TexCoordGenerationRetained texCoordGeneration = null;
-
- // Texture Attributes bundle object
- TextureAttributesRetained textureAttributes = null;
-
- TextureUnitStateRetained texUnitState[] = null;
-
- // Coloring Attributes bundle object
- ColoringAttributesRetained coloringAttributes = null;
-
- // Transparency Attributes bundle object
- TransparencyAttributesRetained transparencyAttributes = null;
-
- // Rendering Attributes bundle object
- RenderingAttributesRetained renderingAttributes = null;
-
- // Polygon Attributes bundle object
- PolygonAttributesRetained polygonAttributes = null;
-
- // Line Attributes bundle object
- LineAttributesRetained lineAttributes = null;
-
- // Point Attributes bundle object
- PointAttributesRetained pointAttributes = null;
-
-
- // Lock used for synchronization of live state
- Object liveStateLock = new Object();
-
- // NOTE: Consider grouping random state into common objects
-
- // Cache used during compilation. If map == compState, then
- // mapAppearance can be used for this appearance
- CompileState map = null;
- AppearanceRetained mapAppearance = null;
-
- static final int MATERIAL = 0x0001;
- static final int TEXTURE = 0x0002;
- static final int TEXCOORD_GEN = 0x0004;
- static final int TEXTURE_ATTR = 0x0008;
- static final int COLOR = 0x0010;
- static final int TRANSPARENCY = 0x0020;
- static final int RENDERING = 0x0040;
- static final int POLYGON = 0x0080;
- static final int LINE = 0x0100;
- static final int POINT = 0x0200;
- static final int TEXTURE_UNIT_STATE = 0x0400;
-
- static final int ALL_SOLE_USERS = 0;
-
- // A pointer to the scene graph appearance object
- AppearanceRetained sgApp = null;
-
- // The object level hashcode for this appearance
- // int objHashCode = super.hashCode();
-
- /**
- * Set the material object to the specified object.
- * @param material object that specifies the desired material
- * @exception IllegalSharingException
- * properties
- */
- void setMaterial(Material material) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.material != null) {
- this.material.clearLive(refCount);
- this.material.removeMirrorUsers(this);
- }
- if (material != null) {
- ((MaterialRetained)material.retained).setLive(inBackgroundGroup, refCount);
- // If appearance is live, then copy all the users of this
- // appaearance as users of this material
- ((MaterialRetained)material.retained).copyMirrorUsers(this);
- }
- sendMessage(MATERIAL,
- (material != null ?
- ((MaterialRetained)material.retained).mirror : null), true);
- }
- if (material == null) {
- this.material = null;
- } else {
- this.material = (MaterialRetained)material.retained;
- }
- }
- }
-
- /**
- * Retrieve the current material object.
- * @return the material object
- */
- Material getMaterial() {
- return (material == null ? null : (Material)material.source);
- }
-
- /**
- * Sets the texture object to the specified object.
- * @param texture object that specifies the desired texture
- * map and texture parameters
- */
- void setTexture(Texture texture) {
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.texture != null) {
- this.texture.clearLive(refCount);
- this.texture.removeMirrorUsers(this);
- }
-
- if (texture != null) {
- ((TextureRetained)texture.retained).setLive(inBackgroundGroup, refCount);
- ((TextureRetained)texture.retained).copyMirrorUsers(this);
- }
- sendMessage(TEXTURE,
- (texture != null ?
- ((TextureRetained)texture.retained).mirror : null), true);
-
- }
-
-
- if (texture == null) {
- this.texture = null;
- } else {
- this.texture = (TextureRetained)texture.retained;
- }
- }
- }
-
- /**
- * Retrieves the current texture object.
- * @return the texture object
- */
- Texture getTexture() {
- return (texture == null ? null : (Texture)texture.source);
- }
-
- /**
- * Sets the textureAttrbutes object to the specified object.
- * @param textureAttributes object that specifies the desired texture
- * attributes
- */
- void setTextureAttributes(TextureAttributes textureAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.textureAttributes != null) {
- this.textureAttributes.clearLive(refCount);
- this.textureAttributes.removeMirrorUsers(this);
- }
-
- if (textureAttributes != null) {
- ((TextureAttributesRetained)textureAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((TextureAttributesRetained)textureAttributes.retained).copyMirrorUsers(this);
- }
- sendMessage(TEXTURE_ATTR,
- (textureAttributes != null ?
- ((TextureAttributesRetained)textureAttributes.retained).mirror:
- null), true);
-
- }
-
-
- if (textureAttributes == null) {
- this.textureAttributes = null;
- } else {
- this.textureAttributes = (TextureAttributesRetained)textureAttributes.retained;
- }
- }
- }
-
- /**
- * Retrieves the current textureAttributes object.
- * @return the textureAttributes object
- */
- TextureAttributes getTextureAttributes() {
- return (textureAttributes == null ? null :
- (TextureAttributes)textureAttributes.source);
- }
-
- /**
- * Sets the coloringAttrbutes object to the specified object.
- * @param coloringAttributes object that specifies the desired texture
- * attributes
- */
- void setColoringAttributes(ColoringAttributes coloringAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.coloringAttributes != null) {
- this.coloringAttributes.clearLive(refCount);
- this.coloringAttributes.removeMirrorUsers(this);
- }
-
- if (coloringAttributes != null) {
- ((ColoringAttributesRetained)coloringAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((ColoringAttributesRetained)coloringAttributes.retained).copyMirrorUsers(this);
- }
- sendMessage(COLOR,
- (coloringAttributes != null ?
- ((ColoringAttributesRetained)coloringAttributes.retained).mirror:
- null), true);
- }
-
-
- if (coloringAttributes == null) {
- this.coloringAttributes = null;
- } else {
- this.coloringAttributes = (ColoringAttributesRetained)coloringAttributes.retained;
- }
- }
- }
-
- /**
- * Retrieves the current coloringAttributes object.
- * @return the coloringAttributes object
- */
- ColoringAttributes getColoringAttributes() {
- return (coloringAttributes == null ? null :
- (ColoringAttributes)coloringAttributes.source);
- }
-
- /**
- * Sets the transparencyAttrbutes object to the specified object.
- * @param transparencyAttributes object that specifies the desired texture
- * attributes
- */
- void setTransparencyAttributes(TransparencyAttributes transparencyAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.transparencyAttributes != null) {
- this.transparencyAttributes.clearLive(refCount);
- this.transparencyAttributes.removeMirrorUsers(this);
- }
-
- if (transparencyAttributes != null) {
- ((TransparencyAttributesRetained)transparencyAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((TransparencyAttributesRetained)transparencyAttributes.retained).copyMirrorUsers(this);
- }
-
- sendMessage(TRANSPARENCY,
- (transparencyAttributes != null ?
- ((TransparencyAttributesRetained)transparencyAttributes.retained).mirror: null), true);
- }
-
-
- if (transparencyAttributes == null) {
- this.transparencyAttributes = null;
- } else {
- this.transparencyAttributes = (TransparencyAttributesRetained)transparencyAttributes.retained;
-
- }
- }
- }
-
- /**
- * Retrieves the current transparencyAttributes object.
- * @return the transparencyAttributes object
- */
- TransparencyAttributes getTransparencyAttributes() {
- return (transparencyAttributes == null ? null :
- (TransparencyAttributes)transparencyAttributes.source);
- }
-
- /**
- * Sets the renderingAttrbutes object to the specified object.
- * @param renderingAttributes object that specifies the desired texture
- * attributes
- */
- void setRenderingAttributes(RenderingAttributes renderingAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
- if (this.renderingAttributes != null) {
- this.renderingAttributes.clearLive(refCount);
- this.renderingAttributes.removeMirrorUsers(this);
- }
-
- if (renderingAttributes != null) {
- ((RenderingAttributesRetained)renderingAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((RenderingAttributesRetained)renderingAttributes.retained).copyMirrorUsers(this);
- }
- Object m = null;
- boolean v = true;
- if (renderingAttributes != null) {
- m = ((RenderingAttributesRetained)renderingAttributes.retained).mirror;
- v = ((RenderingAttributesRetained)renderingAttributes.retained).visible;
- }
- sendMessage(RENDERING,m, v);
- // Also need to send a message to GeometryStructure.
- sendRenderingAttributesChangedMessage( v);
- }
- if (renderingAttributes == null) {
- this.renderingAttributes = null;
- } else {
- this.renderingAttributes = (RenderingAttributesRetained)renderingAttributes.retained;
-
- }
- }
- }
-
- /**
- * Retrieves the current renderingAttributes object.
- * @return the renderingAttributes object
- */
- RenderingAttributes getRenderingAttributes() {
- if (renderingAttributes == null)
- return null;
-
- return (RenderingAttributes)renderingAttributes.source;
- }
-
- /**
- * Sets the polygonAttrbutes object to the specified object.
- * @param polygonAttributes object that specifies the desired texture
- * attributes
- */
- void setPolygonAttributes(PolygonAttributes polygonAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
- if (this.polygonAttributes != null) {
- this.polygonAttributes.clearLive(refCount);
- this.polygonAttributes.removeMirrorUsers(this);
- }
-
- if (polygonAttributes != null) {
- ((PolygonAttributesRetained)polygonAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((PolygonAttributesRetained)polygonAttributes.retained).copyMirrorUsers(this);
- }
- sendMessage(POLYGON,
- (polygonAttributes != null ?
- ((PolygonAttributesRetained)polygonAttributes.retained).mirror :
- null), true);
-
- }
-
- if (polygonAttributes == null) {
- this.polygonAttributes = null;
- } else {
- this.polygonAttributes = (PolygonAttributesRetained)polygonAttributes.retained;
- }
- }
- }
-
- /**
- * Retrieves the current polygonAttributes object.
- * @return the polygonAttributes object
- */
- PolygonAttributes getPolygonAttributes() {
- return (polygonAttributes == null ? null:
- (PolygonAttributes)polygonAttributes.source);
- }
-
- /**
- * Sets the lineAttrbutes object to the specified object.
- * @param lineAttributes object that specifies the desired texture
- * attributes
- */
- void setLineAttributes(LineAttributes lineAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.lineAttributes != null) {
- this.lineAttributes.clearLive(refCount);
- this.lineAttributes.removeMirrorUsers(this);
- }
-
- if (lineAttributes != null) {
- ((LineAttributesRetained)lineAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((LineAttributesRetained)lineAttributes.retained).copyMirrorUsers(this);
- }
- sendMessage(LINE,
- (lineAttributes != null ?
- ((LineAttributesRetained)lineAttributes.retained).mirror: null), true);
- }
-
-
- if (lineAttributes == null) {
- this.lineAttributes = null;
- } else {
- this.lineAttributes = (LineAttributesRetained)lineAttributes.retained;
- }
- }
- }
-
- /**
- * Retrieves the current lineAttributes object.
- * @return the lineAttributes object
- */
- LineAttributes getLineAttributes() {
- return (lineAttributes == null ? null :
- (LineAttributes)lineAttributes.source);
- }
-
- /**
- * Sets the pointAttrbutes object to the specified object.
- * @param pointAttributes object that specifies the desired texture
- * attributes
- */
- void setPointAttributes(PointAttributes pointAttributes) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.pointAttributes != null) {
- this.pointAttributes.clearLive(refCount);
- this.pointAttributes.removeMirrorUsers(this);
- }
- if (pointAttributes != null) {
- ((PointAttributesRetained)pointAttributes.retained).setLive(inBackgroundGroup, refCount);
- ((PointAttributesRetained)pointAttributes.retained).copyMirrorUsers(this);
- }
- sendMessage(POINT,
- (pointAttributes != null ?
- ((PointAttributesRetained)pointAttributes.retained).mirror:
- null), true);
- }
-
-
- if (pointAttributes == null) {
- this.pointAttributes = null;
- } else {
- this.pointAttributes = (PointAttributesRetained)pointAttributes.retained;
- }
- }
- }
-
- /**
- * Retrieves the current pointAttributes object.
- * @return the pointAttributes object
- */
- PointAttributes getPointAttributes() {
- return (pointAttributes == null? null : (PointAttributes)pointAttributes.source);
- }
-
- /**
- * Sets the texCoordGeneration object to the specified object.
- * @param texCoordGeneration object that specifies the texture coordinate
- * generation parameters
- */
- void setTexCoordGeneration(TexCoordGeneration texGen) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- if (this.texCoordGeneration != null) {
- this.texCoordGeneration.clearLive(refCount);
- this.texCoordGeneration.removeMirrorUsers(this);
- }
-
- if (texGen != null) {
- ((TexCoordGenerationRetained)texGen.retained).setLive(inBackgroundGroup, refCount);
- ((TexCoordGenerationRetained)texGen.retained).copyMirrorUsers(this);
- }
- sendMessage(TEXCOORD_GEN,
- (texGen != null ?
- ((TexCoordGenerationRetained)texGen.retained).mirror : null), true);
- }
-
- if (texGen == null) {
- this.texCoordGeneration = null;
- } else {
- this.texCoordGeneration = (TexCoordGenerationRetained)texGen.retained;
- }
- }
- }
-
- /**
- * Retrieves the current texCoordGeneration object.
- * @return the texCoordGeneration object
- */
- TexCoordGeneration getTexCoordGeneration() {
- return (texCoordGeneration == null ? null :
- (TexCoordGeneration)texCoordGeneration.source);
- }
-
-
- /**
- * Sets the texture unit state array to the specified array.
- * @param textureUnitState array that specifies the texture unit state
- */
- void setTextureUnitState(TextureUnitState[] stateArray) {
-
- int i;
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- // remove the existing texture unit states from this appearance
- if (this.texUnitState != null) {
- for (i = 0; i < this.texUnitState.length; i++) {
- if (this.texUnitState[i] != null) {
- this.texUnitState[i].clearLive(refCount);
- this.texUnitState[i].removeMirrorUsers(this);
- }
- }
- }
-
- // add the specified texture unit states to this appearance
- // also make a copy of the array of references to the units
- if (stateArray != null && stateArray.length > 0) {
-
- Object [] args = new Object[2];
-
- // -1 index means the entire array is to be set
- args[0] = new Integer(-1);
-
- // make a copy of the array for the message,
- TextureUnitStateRetained mirrorStateArray[] =
- new TextureUnitStateRetained[stateArray.length];
-
- args[1] = mirrorStateArray;
-
- for (i = 0; i < stateArray.length; i++) {
- TextureUnitState tu = stateArray[i];
- if (tu != null) {
- ((TextureUnitStateRetained)tu.retained).setLive(
- inBackgroundGroup, refCount);
- ((TextureUnitStateRetained)tu.retained).copyMirrorUsers(
- this);
- mirrorStateArray[i] = (TextureUnitStateRetained)
- ((TextureUnitStateRetained)tu.retained).mirror;
- } else {
- mirrorStateArray[i] = null;
- }
- }
- sendMessage(TEXTURE_UNIT_STATE, args, true);
-
- } else {
- sendMessage(TEXTURE_UNIT_STATE, null, true);
- }
- }
-
- // assign the retained copy of the texture unit state to the
- // appearance
- if (stateArray == null) {
- this.texUnitState = null;
- } else {
-
- // make another copy of the array for the retained object
- // itself if it doesn't have a copy or the array size is
- // not the same
- if ((this.texUnitState == null) ||
- (this.texUnitState.length != stateArray.length)) {
- this.texUnitState = new TextureUnitStateRetained[
- stateArray.length];
- }
- for (i = 0; i < stateArray.length; i++) {
- if (stateArray[i] != null) {
- this.texUnitState[i] =
- (TextureUnitStateRetained)stateArray[i].retained;
- } else {
- this.texUnitState[i] = null;
- }
- }
- }
- }
- }
-
- void setTextureUnitState(int index, TextureUnitState state) {
-
- synchronized(liveStateLock) {
- if (source.isLive()) {
-
- // remove the existing texture unit states from this appearance
- // Note: Let Java throw an exception if texUnitState is null
- // or index is >= texUnitState.length.
- if (this.texUnitState[index] != null) {
- this.texUnitState[index].clearLive(refCount);
- this.texUnitState[index].removeMirrorUsers(this);
- }
-
- // add the specified texture unit states to this appearance
- // also make a copy of the array of references to the units
- Object args[] = new Object[2];
- args[0] = new Integer(index);
-
- if (state != null) {
- ((TextureUnitStateRetained)state.retained).setLive(
- inBackgroundGroup, refCount);
- ((TextureUnitStateRetained)state.retained).copyMirrorUsers(this);
- args[1] = ((TextureUnitStateRetained)state.retained).mirror;
- sendMessage(TEXTURE_UNIT_STATE, args, true);
- } else {
- args[1] = null;
- sendMessage(TEXTURE_UNIT_STATE, args, true);
- }
- }
-
- // assign the retained copy of the texture unit state to the
- // appearance
- if (state != null) {
- this.texUnitState[index] = (TextureUnitStateRetained)state.retained;
- } else {
- this.texUnitState[index] = null;
- }
- }
- }
-
-
-
- /**
- * Retrieves the array of texture unit state objects from this
- * Appearance object. A shallow copy of the array of references to
- * the TextureUnitState objects is returned.
- *
- */
- TextureUnitState[] getTextureUnitState() {
- if (texUnitState == null) {
- return null;
- } else {
- TextureUnitState tus[] =
- new TextureUnitState[texUnitState.length];
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null) {
- tus[i] = (TextureUnitState) texUnitState[i].source;
- } else {
- tus[i] = null;
- }
- }
- return tus;
- }
- }
-
- /**
- * Retrieves the texture unit state object at the specified
- * index within the texture unit state array.
- */
- TextureUnitState getTextureUnitState(int index) {
-
- // let Java throw an exception if texUnitState == null or
- // index is >= length
- if (texUnitState[index] != null)
- return (TextureUnitState)texUnitState[index].source;
- else
- return null;
- }
-
-
- /**
- * Retrieves the length of the texture unit state array from
- * this appearance object. The length of this array specifies the
- * maximum number of texture units that will be used by this
- * appearance object. If the array is null, a count of 0 is
- * returned.
- */
-
- int getTextureUnitCount() {
- if (texUnitState == null)
- return 0;
- else
- return texUnitState.length;
- }
-
-
- @Override
- synchronized void createMirrorObject() {
- if (mirror == null) {
- // we can't check isStatic() since it sub-NodeComponent
- // create a new one, we should create a
- // new AppearanceRetained() even though isStatic() = true.
- // For simplicity, always create a retained side.
- mirror = new AppearanceRetained();
- }
- initMirrorObject();
- }
-
- /**
- * This routine updates the mirror appearance for this appearance.
- * It also calls the update method for each node component if it
- * is not null.
- */
- @Override
- synchronized void initMirrorObject() {
-
- AppearanceRetained mirrorApp = (AppearanceRetained)mirror;
-
- mirrorApp.source = source;
- mirrorApp.sgApp = this;
-
- // Fix for Issue 33: copy the changedFrequent mask to mirror
- mirrorApp.changedFrequent = changedFrequent;
-
- if (material != null) {
- mirrorApp.material = (MaterialRetained)material.mirror;
- } else {
- mirrorApp.material = null;
- }
-
- if (texture != null) {
- mirrorApp.texture = (TextureRetained)texture.mirror;
- } else {
- mirrorApp.texture = null;
- }
- if (texCoordGeneration != null) {
- mirrorApp.texCoordGeneration = (TexCoordGenerationRetained)texCoordGeneration.mirror;
- } else {
- mirrorApp.texCoordGeneration = null;
- }
-
- if (textureAttributes != null) {
- mirrorApp.textureAttributes = (TextureAttributesRetained)textureAttributes.mirror;
- } else {
- mirrorApp.textureAttributes = null;
- }
-
- // TextureUnitState supercedes the single texture interface
- if (texUnitState != null && texUnitState.length > 0) {
- mirrorApp.texUnitState =
- new TextureUnitStateRetained[texUnitState.length];
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null) {
- mirrorApp.texUnitState[i] =
- (TextureUnitStateRetained)texUnitState[i].mirror;
- }
- }
- } else if (mirrorApp.texture != null ||
- mirrorApp.textureAttributes != null ||
- mirrorApp.texCoordGeneration != null) {
-
- mirrorApp.texUnitState = new TextureUnitStateRetained[1];
- mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
- mirrorApp.texUnitState[0].set(
- mirrorApp.texture,
- mirrorApp.textureAttributes,
- mirrorApp.texCoordGeneration);
- }
-
- if (coloringAttributes != null) {
- mirrorApp.coloringAttributes = (ColoringAttributesRetained)coloringAttributes.mirror;
- } else {
- mirrorApp.coloringAttributes = null;
- }
- if (transparencyAttributes != null) {
- mirrorApp.transparencyAttributes = (TransparencyAttributesRetained)transparencyAttributes.mirror;
- } else {
- mirrorApp.transparencyAttributes = null;
- }
-
- if (renderingAttributes != null) {
- mirrorApp.renderingAttributes = (RenderingAttributesRetained)renderingAttributes.mirror;
- } else {
- mirrorApp.renderingAttributes = null;
- }
-
- if (polygonAttributes != null) {
- mirrorApp.polygonAttributes = (PolygonAttributesRetained)polygonAttributes.mirror;
- } else {
- mirrorApp.polygonAttributes = null;
- }
-
- if (lineAttributes != null) {
- mirrorApp.lineAttributes = (LineAttributesRetained)lineAttributes.mirror;
- } else {
- mirrorApp.lineAttributes = null;
- }
-
- if (pointAttributes != null) {
- mirrorApp.pointAttributes = (PointAttributesRetained)pointAttributes.mirror;
- } else {
- mirrorApp.pointAttributes = null;
- }
- }
-
- /**
- * Update the "component" field of the mirror object with the
- * given "value"
- */
- @Override
- synchronized void updateMirrorObject(int component, Object value) {
- AppearanceRetained mirrorApp = (AppearanceRetained)mirror;
- if ((component & MATERIAL) != 0) {
- mirrorApp.material = (MaterialRetained)value;
- }
- else if ((component & TEXTURE) != 0) {
- // Issue 435: set mirror texture
- mirrorApp.texture = (TextureRetained)value;
- if (mirrorApp.texUnitState == null) {
- mirrorApp.texUnitState = new TextureUnitStateRetained[1];
- mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
- }
- mirrorApp.texUnitState[0].texture = (TextureRetained)value;
- }
- else if ((component & TEXCOORD_GEN) != 0) {
- if (mirrorApp.texUnitState == null) {
- mirrorApp.texUnitState = new TextureUnitStateRetained[1];
- mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
- }
- mirrorApp.texUnitState[0].texGen = (TexCoordGenerationRetained)value;
- }
- else if ((component & TEXTURE_ATTR) != 0) {
- if (mirrorApp.texUnitState == null) {
- mirrorApp.texUnitState = new TextureUnitStateRetained[1];
- mirrorApp.texUnitState[0] = new TextureUnitStateRetained();
- }
- mirrorApp.texUnitState[0].texAttrs = (TextureAttributesRetained)value;
- }
- else if ((component & TEXTURE_UNIT_STATE) != 0) {
- Object [] args = (Object [])value;
-
- if (args == null) {
- mirrorApp.texUnitState = null;
- } else {
- int index = ((Integer)args[0]).intValue();
- if (index == -1) {
- mirrorApp.texUnitState =
- (TextureUnitStateRetained [])args[1];
- } else {
- mirrorApp.texUnitState[index] =
- (TextureUnitStateRetained)args[1];
- }
- }
- }
- else if ((component & COLOR) != 0) {
- mirrorApp.coloringAttributes = (ColoringAttributesRetained)value;
- }
- else if ((component & TRANSPARENCY) != 0) {
- mirrorApp.transparencyAttributes = (TransparencyAttributesRetained)value;
- }
- else if ((component & RENDERING) != 0) {
- mirrorApp.renderingAttributes = (RenderingAttributesRetained)value;
- }
- else if ((component & POLYGON) != 0) {
- mirrorApp.polygonAttributes = (PolygonAttributesRetained)value;
- }
- else if ((component & LINE) != 0) {
- mirrorApp.lineAttributes = (LineAttributesRetained)value;
- }
- else if ((component & POINT) != 0) {
- mirrorApp.pointAttributes = (PointAttributesRetained)value;
- }
-
- }
-
- @Override
- void setLive(boolean backgroundGroup, int refCount) {
- // System.err.println("AppearceRetained.setLive()");
- doSetLive(backgroundGroup, refCount);
- markAsLive();
- }
-
- /**
- * This method calls the setLive method of all appearance bundle
- * objects.
- */
- @Override
- void doSetLive(boolean backgroundGroup, int refCount) {
- // System.err.println("AppearceRetained.doSetLive()");
-
- if (material != null) {
-
- material.setLive(backgroundGroup, refCount);
- }
-
- if (texture != null) {
-
- texture.setLive(backgroundGroup, refCount);
- }
-
- if (texCoordGeneration != null) {
-
- texCoordGeneration.setLive(backgroundGroup, refCount);
- }
-
- if (textureAttributes != null) {
-
- textureAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null)
- texUnitState[i].setLive(backgroundGroup, refCount);
- }
- }
-
-
- if (coloringAttributes != null) {
- coloringAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (transparencyAttributes != null) {
- transparencyAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (renderingAttributes != null) {
- renderingAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (polygonAttributes != null) {
- polygonAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (lineAttributes != null) {
- lineAttributes.setLive(backgroundGroup, refCount);
- }
-
- if (pointAttributes != null) {
- pointAttributes.setLive(backgroundGroup, refCount);
- }
-
-
- // Increment the reference count and initialize the appearance
- // mirror object
- super.doSetLive(backgroundGroup, refCount);
- }
-
- /**
- * This method calls the clearLive method of all appearance bundle
- * objects.
- */
- @Override
- void clearLive(int refCount) {
- super.clearLive(refCount);
-
- if (texture != null) {
- texture.clearLive(refCount);
- }
-
- if (texCoordGeneration != null) {
- texCoordGeneration.clearLive(refCount);
- }
-
- if (textureAttributes != null) {
- textureAttributes.clearLive(refCount);
- }
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null)
- texUnitState[i].clearLive(refCount);
- }
- }
-
- if (coloringAttributes != null) {
- coloringAttributes.clearLive(refCount);
- }
-
- if (transparencyAttributes != null) {
- transparencyAttributes.clearLive(refCount);
- }
-
- if (renderingAttributes != null) {
- renderingAttributes.clearLive(refCount);
- }
-
- if (polygonAttributes != null) {
- polygonAttributes.clearLive(refCount);
- }
-
- if (lineAttributes != null) {
- lineAttributes.clearLive(refCount);
- }
-
- if (pointAttributes != null) {
- pointAttributes.clearLive(refCount);
- }
-
- if (material != null) {
- material.clearLive(refCount);
- }
- }
-
-
- @Override
- boolean isStatic() {
- boolean flag;
-
- flag = (source.capabilityBitsEmpty() &&
- ((texture == null) ||
- texture.source.capabilityBitsEmpty()) &&
- ((texCoordGeneration == null) ||
- texCoordGeneration.source.capabilityBitsEmpty()) &&
- ((textureAttributes == null) ||
- textureAttributes.source.capabilityBitsEmpty()) &&
- ((coloringAttributes == null) ||
- coloringAttributes.source.capabilityBitsEmpty()) &&
- ((transparencyAttributes == null) ||
- transparencyAttributes.source.capabilityBitsEmpty()) &&
- ((renderingAttributes == null) ||
- renderingAttributes.source.capabilityBitsEmpty()) &&
- ((polygonAttributes == null) ||
- polygonAttributes.source.capabilityBitsEmpty()) &&
- ((lineAttributes == null) ||
- lineAttributes.source.capabilityBitsEmpty()) &&
- ((pointAttributes == null) ||
- pointAttributes.source.capabilityBitsEmpty()) &&
- ((material == null) ||
- material.source.capabilityBitsEmpty()));
-
- if (!flag)
- return flag;
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length && flag; i++) {
- if (texUnitState[i] != null) {
- flag = flag && texUnitState[i].isStatic();
- }
- }
- }
-
- return flag;
- }
-
- // Issue 209 - enable this method (was previously commented out)
- // Simply pass along to the NodeComponents
- @Override
- void compile(CompileState compState) {
- setCompiled();
-
- if (texture != null) {
- texture.compile(compState);
- }
-
- if (texCoordGeneration != null) {
- texCoordGeneration.compile(compState);
- }
-
- if (textureAttributes != null) {
- textureAttributes.compile(compState);
- }
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null)
- texUnitState[i].compile(compState);
- }
- }
-
- if (coloringAttributes != null) {
- coloringAttributes.compile(compState);
- }
-
- if (transparencyAttributes != null) {
- transparencyAttributes.compile(compState);
- }
-
- if (renderingAttributes != null) {
- renderingAttributes.compile(compState);
- }
-
- if (polygonAttributes != null) {
- polygonAttributes.compile(compState);
- }
-
- if (lineAttributes != null) {
- lineAttributes.compile(compState);
- }
-
- if (pointAttributes != null) {
- pointAttributes.compile(compState);
- }
-
- if (material != null) {
- material.compile(compState);
- }
- }
-
- /**
- * Returns the hashcode for this object.
- * hashcode should be constant for object but same for two objects
- * if .equals() is true. For an appearance (where .equals() is going
- * to use the values in the appearance), the only way to have a
- * constant value is for all appearances to have the same hashcode, so
- * we use the hashcode of the class obj.
- *
- * Since hashCode is only used by AppearanceMap (at present) we may be
- * able to improve efficency by calcing a hashCode from the values.
- */
- @Override
- public int hashCode() {
- return getClass().hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- return ((obj instanceof AppearanceRetained) &&
- equals((AppearanceRetained) obj));
- }
-
- boolean equals(AppearanceRetained app) {
- boolean flag;
-
- flag = (app == this) ||
- ((app != null) &&
- (((material == app.material) ||
- ((material != null) && material.equivalent(app.material))) &&
- ((texture == app.texture) ||
- ((texture != null) && texture.equals(app.texture))) &&
- ((renderingAttributes == app.renderingAttributes) ||
- ((renderingAttributes != null) &&
- renderingAttributes.equivalent(
- app.renderingAttributes))) &&
- ((polygonAttributes == app.polygonAttributes) ||
- ((polygonAttributes != null) &&
- polygonAttributes.equivalent(app.polygonAttributes))) &&
- ((texCoordGeneration == app.texCoordGeneration) ||
- ((texCoordGeneration != null) &&
- texCoordGeneration.equivalent(app.texCoordGeneration))) &&
- ((textureAttributes == app.textureAttributes) ||
- ((textureAttributes != null) &&
- textureAttributes.equivalent(app.textureAttributes))) &&
- ((coloringAttributes == app.coloringAttributes) ||
- ((coloringAttributes != null) &&
- coloringAttributes.equivalent(app.coloringAttributes))) &&
- ((transparencyAttributes == app.transparencyAttributes) ||
- ((transparencyAttributes != null) &&
- transparencyAttributes.equivalent(
- app.transparencyAttributes))) &&
- ((lineAttributes == app.lineAttributes) ||
- ((lineAttributes != null) &&
- lineAttributes.equivalent(app.lineAttributes))) &&
- ((pointAttributes == app.pointAttributes) ||
- ((pointAttributes != null) &&
- pointAttributes.equivalent(app.pointAttributes)))));
-
- if (!flag)
- return (flag);
-
- if (texUnitState == app.texUnitState)
- return (flag);
-
- if (texUnitState == null || app.texUnitState == null ||
- texUnitState.length != app.texUnitState.length)
- return (false);
-
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] == app.texUnitState[i])
- continue;
-
- if (texUnitState[i] == null || app.texUnitState[i] == null ||
- !texUnitState[i].equals(app.texUnitState[i]))
- return (false);
- }
- return (true);
- }
-
-
-
-
- @Override
- synchronized void addAMirrorUser(Shape3DRetained shape) {
-
- super.addAMirrorUser(shape);
- if (material != null)
- material.addAMirrorUser(shape);
-
- if (texture != null)
- texture.addAMirrorUser(shape);
- if (texCoordGeneration != null)
- texCoordGeneration.addAMirrorUser(shape);
- if (textureAttributes != null)
- textureAttributes.addAMirrorUser(shape);
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null)
- texUnitState[i].addAMirrorUser(shape);
- }
- }
-
- if (coloringAttributes != null)
- coloringAttributes.addAMirrorUser(shape);
- if (transparencyAttributes != null)
- transparencyAttributes.addAMirrorUser(shape);
- if (renderingAttributes != null)
- renderingAttributes.addAMirrorUser(shape);
- if (polygonAttributes != null)
- polygonAttributes.addAMirrorUser(shape);
- if (lineAttributes != null)
- lineAttributes.addAMirrorUser(shape);
- if (pointAttributes != null)
- pointAttributes.addAMirrorUser(shape);
- }
-
- @Override
- synchronized void removeAMirrorUser(Shape3DRetained shape) {
- super.removeAMirrorUser(shape);
- if (material != null)
- material.removeAMirrorUser(shape);
- if (texture != null)
- texture.removeAMirrorUser(shape);
- if (texCoordGeneration != null)
- texCoordGeneration.removeAMirrorUser(shape);
- if (textureAttributes != null)
- textureAttributes.removeAMirrorUser(shape);
-
- if (texUnitState != null) {
- for (int i = 0; i < texUnitState.length; i++) {
- if (texUnitState[i] != null)
- texUnitState[i].removeAMirrorUser(shape);
- }
- }
-
- if (coloringAttributes != null)
- coloringAttributes.removeAMirrorUser(shape);
- if (transparencyAttributes != null)
- transparencyAttributes.removeAMirrorUser(shape);
- if (renderingAttributes != null)
- renderingAttributes.removeAMirrorUser(shape);
- if (polygonAttributes != null)
- polygonAttributes.removeAMirrorUser(shape);
- if (lineAttributes != null)
- lineAttributes.removeAMirrorUser(shape);
- if (pointAttributes != null)
- pointAttributes.removeAMirrorUser(shape);
- }
-
- // 3rd argument used only when Rendering Attr comp changes
- final void sendMessage(int attrMask, Object attr, boolean visible) {
- ArrayList univList = new ArrayList();
- ArrayList> gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList);
- // Send to rendering attribute structure, regardless of
- // whether there are users or not (alternate appearance case ..)
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = J3dThread.UPDATE_RENDERING_ATTRIBUTES;
- createMessage.type = J3dMessage.APPEARANCE_CHANGED;
- createMessage.universe = null;
- createMessage.args[0] = this;
- createMessage.args[1]= new Integer(attrMask);
- createMessage.args[2] = attr;
- createMessage.args[3] = new Integer(changedFrequent);
-
- VirtualUniverse.mc.processMessage(createMessage);
-
-
- // System.err.println("univList.size is " + univList.size());
- for(int i=0; i gL = gaList.get(i);
- GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
- gL.toArray(gaArr);
- createMessage.args[3] = gaArr;
- // Send the value itself, since Geometry Structure cannot rely on the
- // mirror (which may be updated lazily)
- if (attrMask == RENDERING) {
- if (attr != null) {
- createMessage.args[4] = visible?Boolean.TRUE:Boolean.FALSE;
- }
- else {
- createMessage.args[4] = Boolean.TRUE;
- }
- }
- VirtualUniverse.mc.processMessage(createMessage);
- }
- }
-
-
-
- final void sendRenderingAttributesChangedMessage(boolean visible) {
-
- ArrayList univList = new ArrayList();
- ArrayList> gaList = Shape3DRetained.getGeomAtomsList(mirror.users, univList);
-
- // System.err.println("univList.size is " + univList.size());
- for(int i=0; i gL = gaList.get(i);
- GeometryAtom[] gaArr = new GeometryAtom[gL.size()];
- gL.toArray(gaArr);
- createMessage.args[3] = gaArr;
- VirtualUniverse.mc.processMessage(createMessage);
- }
- }
-
- boolean isOpaque(int geoType) {
- if (TransparencyAttributesRetained.useAlpha(transparencyAttributes))
- return false;
-
- switch (geoType) {
- case GeometryRetained.GEO_TYPE_POINT_SET:
- case GeometryRetained.GEO_TYPE_INDEXED_POINT_SET:
- if ((pointAttributes != null) &&
- pointAttributes.pointAntialiasing) {
- return (false);
- }
- break;
- case GeometryRetained.GEO_TYPE_LINE_SET:
- case GeometryRetained.GEO_TYPE_LINE_STRIP_SET:
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_SET:
- case GeometryRetained.GEO_TYPE_INDEXED_LINE_STRIP_SET:
- if ((lineAttributes != null) &&
- lineAttributes.lineAntialiasing) {
- return (false);
- }
- break;
- case GeometryRetained.GEO_TYPE_RASTER:
- case GeometryRetained.GEO_TYPE_COMPRESSED:
- break;
- default:
- if (polygonAttributes != null) {
- if((polygonAttributes.polygonMode ==
- PolygonAttributes.POLYGON_POINT) &&
- (pointAttributes != null) &&
- pointAttributes.pointAntialiasing) {
- return (false);
- } else if ((polygonAttributes.polygonMode ==
- PolygonAttributes.POLYGON_LINE) &&
- (lineAttributes != null) &&
- lineAttributes.lineAntialiasing) {
- return (false);
- }
- }
- break;
- }
-
- return(true);
- }
-
- @Override
- void handleFrequencyChange(int bit) {
- int mask = 0;
- if (bit == Appearance.ALLOW_COLORING_ATTRIBUTES_WRITE)
- mask = COLOR;
- else if(bit == Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE)
- mask = TRANSPARENCY;
- else if(bit == Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE)
- mask = RENDERING;
- else if (bit == Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE)
- mask = POLYGON;
- else if (bit == Appearance.ALLOW_LINE_ATTRIBUTES_WRITE)
- mask = LINE;
- else if (bit == Appearance.ALLOW_POINT_ATTRIBUTES_WRITE)
- mask = POINT;
- else if (bit == Appearance.ALLOW_MATERIAL_WRITE)
- mask = MATERIAL;
- else if (bit == Appearance.ALLOW_TEXTURE_WRITE)
- mask = TEXTURE;
- else if (bit == Appearance.ALLOW_TEXTURE_ATTRIBUTES_WRITE)
- mask = TEXTURE_ATTR;
- else if (bit == Appearance.ALLOW_TEXGEN_WRITE)
- mask = TEXCOORD_GEN;
- else if (bit == Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE)
- mask = TEXTURE_UNIT_STATE;
-
- if (mask != 0)
- setFrequencyChangeMask(bit, mask);
- }
-}
-
-
diff --git a/src/classes/share/javax/media/j3d/AssertionFailureException.java b/src/classes/share/javax/media/j3d/AssertionFailureException.java
deleted file mode 100644
index 2135e12..0000000
--- a/src/classes/share/javax/media/j3d/AssertionFailureException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-/**
- * Indicates an assertion failure.
- */
-
-class AssertionFailureException extends RuntimeException {
-
- /**
- * Create the exception object with default values.
- */
- AssertionFailureException() {
- }
-
- /**
- * Create the exception object that outputs message.
- * @param str the message string to be output.
- */
- AssertionFailureException(String str) {
- super(str);
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AttributeBin.java b/src/classes/share/javax/media/j3d/AttributeBin.java
deleted file mode 100644
index 95ce52a..0000000
--- a/src/classes/share/javax/media/j3d/AttributeBin.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-
-/**
- * The AttributeBin manages a collection of TextureBin objects.
- * All objects in the AttributeBin share the same RenderingAttributes
- */
-
-class AttributeBin extends Object implements ObjectUpdate {
-
- /**
- * The RenderingAttributes for this AttributeBin
- */
- RenderingAttributesRetained definingRenderingAttributes = null;
-
- /**
- * The RenderBin for this object
- */
- RenderBin renderBin = null;
-
- /**
- * The EnvirionmentSet that this AttributeBin resides
- */
- EnvironmentSet environmentSet = null;
-
- /**
- * The references to the next and previous AttributeBins in the
- * list.
- */
- AttributeBin next = null;
- AttributeBin prev = null;
-
- /**
- * The list of ShaderBins in this AttributeBin
- */
- ShaderBin shaderBinList = null;
-
-/**
- * List of shaderBins to be added next frame
- */
-ArrayList addShaderBins = new ArrayList();
-
- /**
- * If the RenderingAttribute component of the appearance will be changed
- * frequently, then confine it to a separate bin
- */
- boolean soleUser = false;
- AppearanceRetained app = null;
-
- int onUpdateList = 0;
- static int ON_OBJ_UPDATE_LIST = 0x1;
- static int ON_CHANGED_FREQUENT_UPDATE_LIST = 0x2;
-
- // Cache it outside, to avoid the "if" check in renderMethod
- // for whether the definingRendering attrs is non-null;
- boolean ignoreVertexColors = false;
-
- // XXXX: use definingMaterial etc. instead of these
- // when sole user is completely implement
- RenderingAttributesRetained renderingAttrs;
-
- int numEditingShaderBins = 0;
-
- AttributeBin(AppearanceRetained app, RenderingAttributesRetained renderingAttributes, RenderBin rBin) {
-
- reset(app, renderingAttributes, rBin);
- }
-
- void reset(AppearanceRetained app, RenderingAttributesRetained renderingAttributes, RenderBin rBin) {
- prev = null;
- next = null;
- shaderBinList = null;
- onUpdateList = 0;
- numEditingShaderBins = 0;
- renderingAttrs = renderingAttributes;
-
- renderBin = rBin;
-
- // Issue 249 - check for sole user only if property is set
- soleUser = false;
- if (VirtualUniverse.mc.allowSoleUser) {
- if (app != null) {
- soleUser = ((app.changedFrequent & AppearanceRetained.RENDERING) != 0);
- }
- }
-
- //System.err.println("soleUser = "+soleUser+" renderingAttributes ="+renderingAttributes);
- // Set the appearance only for soleUser case
- if (soleUser)
- this.app = app;
- else
- app = null;
-
- if (renderingAttributes != null) {
- if (renderingAttributes.changedFrequent != 0) {
- definingRenderingAttributes = renderingAttributes;
- if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0 ) {
- renderBin.aBinUpdateList.add(this);
- onUpdateList |= AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST;
- }
- }
- else {
- if (definingRenderingAttributes != null) {
- definingRenderingAttributes.set(renderingAttributes);
- }
- else {
- definingRenderingAttributes = (RenderingAttributesRetained)renderingAttributes.clone();
- }
- }
- ignoreVertexColors = definingRenderingAttributes.ignoreVertexColors;
- } else {
- definingRenderingAttributes = null;
- ignoreVertexColors = false;
- }
- }
-
-
- /**
- * This tests if the given attributes match this AttributeBin
- */
- boolean equals(RenderingAttributesRetained renderingAttributes, RenderAtom ra) {
-
- // If the any reference to the appearance components that is cached renderMolecule
- // can change frequently, make a separate bin
- if (soleUser || (ra.geometryAtom.source.appearance != null &&
- ((ra.geometryAtom.source.appearance.changedFrequent &
- AppearanceRetained.RENDERING) != 0))) {
- if (app == ra.geometryAtom.source.appearance) {
-
- // if this AttributeBin is currently on a zombie state,
- // we'll need to put it on the update list to reevaluate
- // the state, because while it is on a zombie state,
- // rendering attributes reference could have been changed.
- // Example, application could have detached an appearance,
- // made changes to the reference, and then
- // reattached the appearance. In this case, the rendering
- // attributes reference change would not have reflected to
- // the AttributeBin
-
- if (numEditingShaderBins == 0) {
- if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0) {
- renderBin.aBinUpdateList.add(this);
- onUpdateList |=
- AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST;
- }
- }
- return true;
- }
- else {
- return false;
- }
-
- }
- // Either a changedFrequent or a null case
- // and the incoming one is not equal or null
- // then return;
- // This check also handles null == null case
- if (definingRenderingAttributes != null) {
- if ((this.definingRenderingAttributes.changedFrequent != 0) ||
- (renderingAttributes !=null && renderingAttributes.changedFrequent != 0))
- if (definingRenderingAttributes == renderingAttributes) {
- if (definingRenderingAttributes.compChanged != 0) {
- if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) == 0 ) {
- renderBin.aBinUpdateList.add(this);
- onUpdateList |= AttributeBin.ON_CHANGED_FREQUENT_UPDATE_LIST;
- }
- }
- }
- else {
- return false;
- }
- else if (!definingRenderingAttributes.equivalent(renderingAttributes)) {
- return false;
- }
- }
- else if (renderingAttributes != null) {
- return false;
- }
-
- return (true);
- }
-
- @Override
- public void updateObject() {
- ShaderBin sb;
- int i, size;
-
- size = addShaderBins.size();
- if (size > 0) {
- sb = addShaderBins.get(0);
- if (shaderBinList == null) {
- shaderBinList = sb;
- }
- else {
- sb.next = shaderBinList;
- shaderBinList.prev = sb;
- shaderBinList = sb;
- }
-
- for (i = 1; i < size ; i++) {
- sb = addShaderBins.get(i);
- sb.next = shaderBinList;
- shaderBinList.prev = sb;
- shaderBinList = sb;
- }
- }
- addShaderBins.clear();
- onUpdateList &= ~ON_OBJ_UPDATE_LIST;
- }
-
-
- /**
- * Adds the given shaderBin to this AttributeBin.
- */
- void addShaderBin(ShaderBin sb, RenderBin rb, ShaderAppearanceRetained sApp) {
-
- sb.attributeBin = this;
-
- if(sApp != null) {
- // ShaderBin should reference to the mirror components. -- JADA.
- // System.err.println("AttributeBin : sApp.isMirror = " + sApp.isMirror);
- assert(sApp.isMirror);
- sb.shaderProgram = sApp.shaderProgram;
- sb.shaderAttributeSet = sApp.shaderAttributeSet;
- }
- sb.shaderAppearance = sApp;
-
- // TODO : JADA - sort by ShaderProgram to avoid state trashing.
- addShaderBins.add(sb);
- if ((onUpdateList & ON_OBJ_UPDATE_LIST) == 0) {
- onUpdateList |= ON_OBJ_UPDATE_LIST;
- rb.objUpdateList.add(this);
- }
-
- }
-
-
- /**
- * Removes the given shaderBin from this AttributeBin.
- */
- void removeShaderBin(ShaderBin sb) {
-
- // If the shaderBin being remove is contained in addShaderBins,
- // then remove the shadereBin from the addList
- if (addShaderBins.contains(sb)) {
- addShaderBins.remove(addShaderBins.indexOf(sb));
- }
- else {
- if (sb.prev == null) { // At the head of the list
- shaderBinList = sb.next;
- if (sb.next != null) {
- sb.next.prev = null;
- }
- } else { // In the middle or at the end.
- sb.prev.next = sb.next;
- if (sb.next != null) {
- sb.next.prev = sb.prev;
- }
- }
- }
-
- sb.clear();
-
- if (shaderBinList == null && addShaderBins.size() == 0 ) {
- // Note: Removal of this attributebin as a user of the rendering
- // atttrs is done during removeRenderAtom() in RenderMolecule.java
- environmentSet.removeAttributeBin(this);
- }
- }
-
- /**
- * Renders this AttributeBin
- */
- void render(Canvas3D cv) {
-
- ShaderBin sb;
-
- boolean visible = (definingRenderingAttributes == null ||
- definingRenderingAttributes.visible);
-
- if ( (renderBin.view.viewCache.visibilityPolicy
- == View.VISIBILITY_DRAW_VISIBLE && !visible) ||
- (renderBin.view.viewCache.visibilityPolicy
- == View.VISIBILITY_DRAW_INVISIBLE && visible)) {
- return;
- }
-
-
- // include this AttributeBin to the to-be-updated list in Canvas
- cv.setStateToUpdate(Canvas3D.ATTRIBUTEBIN_BIT, this);
-
- sb = shaderBinList;
- while (sb != null) {
- sb.render(cv);
- sb = sb.next;
- }
- }
-
-
- void updateAttributes(Canvas3D cv) {
-
- if ((cv.canvasDirty & Canvas3D.ATTRIBUTEBIN_DIRTY) != 0) {
- // Update Attribute Bundles
- if (definingRenderingAttributes == null) {
- cv.resetRenderingAttributes(cv.ctx,
- cv.depthBufferWriteEnableOverride,
- cv.depthBufferEnableOverride);
- } else {
- definingRenderingAttributes.updateNative(
- cv,
- cv.depthBufferWriteEnableOverride,
- cv.depthBufferEnableOverride);
- }
- cv.renderingAttrs = renderingAttrs;
- }
-
- else if (cv.renderingAttrs != renderingAttrs &&
- cv.attributeBin != this) {
- // Update Attribute Bundles
- if (definingRenderingAttributes == null) {
- cv.resetRenderingAttributes(
- cv.ctx,
- cv.depthBufferWriteEnableOverride,
- cv.depthBufferEnableOverride);
- } else {
- definingRenderingAttributes.updateNative(
- cv,
- cv.depthBufferWriteEnableOverride,
- cv.depthBufferEnableOverride);
- }
- cv.renderingAttrs = renderingAttrs;
- }
- cv.attributeBin = this;
- cv.canvasDirty &= ~Canvas3D.ATTRIBUTEBIN_DIRTY;
- }
-
- void updateNodeComponent() {
- // May be in the freelist already (due to freq bit changing)
- // if so, don't update anything
- if ((onUpdateList & ON_CHANGED_FREQUENT_UPDATE_LIST) != 0) {
- if (soleUser) {
- boolean cloned = definingRenderingAttributes != null && definingRenderingAttributes != renderingAttrs;
- renderingAttrs = app.renderingAttributes;
-
- if (renderingAttrs == null) {
- definingRenderingAttributes = null;
- ignoreVertexColors = false;
- }
- else {
- if (renderingAttrs.changedFrequent != 0) {
- definingRenderingAttributes = renderingAttrs;
- }
- else {
- if (cloned) {
- definingRenderingAttributes.set(renderingAttrs);
- }
- else {
- definingRenderingAttributes = (RenderingAttributesRetained)renderingAttrs.clone();
- }
- }
- ignoreVertexColors = definingRenderingAttributes.ignoreVertexColors;
- }
- }
- else {
- ignoreVertexColors = definingRenderingAttributes.ignoreVertexColors;
- }
- }
-
- onUpdateList &= ~ON_CHANGED_FREQUENT_UPDATE_LIST;
- }
-
- void incrActiveShaderBin() {
- numEditingShaderBins++;
- }
-
- void decrActiveShaderBin() {
- numEditingShaderBins--;
- }
-
- void updateFromShaderBin(RenderAtom ra) {
-
- AppearanceRetained raApp = ra.geometryAtom.source.appearance;
- RenderingAttributesRetained rAttrs =
- (raApp == null)? null : raApp.renderingAttributes;
-
- if (!soleUser && renderingAttrs != rAttrs) {
- // no longer sole user
- renderingAttrs = definingRenderingAttributes;
- }
- }
-}
diff --git a/src/classes/share/javax/media/j3d/AudioDevice.java b/src/classes/share/javax/media/j3d/AudioDevice.java
deleted file mode 100644
index 1aab9fc..0000000
--- a/src/classes/share/javax/media/j3d/AudioDevice.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-/**
- * The AudioDevice Class defines and encapsulates the
- * audio device's basic information and characteristics.
- *
- * A Java3D application running on a particular machine could have one of
- * several options available to it for playing the audio image created by the
- * sound renderer. Perhaps the machine Java3D is executing on has more than
- * one sound card (e.g., one that is a Wave Table Synthesis card and the other
- * with accelerated sound spatialization hardware). Furthermore, suppose there
- * are Java3D audio device drivers that execute Java3D audio methods on each of
- * these specific cards. In such a case the application would have at least two
- * audio device drivers through which the audio could be produced. For such a
- * case the Java3D application must choose the audio device driver with which
- * sound rendering is to be performed. Once this audio device is chosen, the
- * application can additionally select the type of audio playback type the
- * rendered sound image is to be output on. The playback device (headphones or
- * speaker(s)) is physically connected to the port the selected device driver
- * outputs to.
- *
- * AudioDevice Interface
- *
- *
The selection of this device driver is done through methods in the
- * PhysicalEnvironment object - see PhysicalEnvironment class.
- * The application would query how many audio devices are available. For
- * each device, the user can get the AudioDevice object that describes it
- * and query its characteristics. Once a decision is made about which of
- * the available audio devices to use for a PhysicalEnvironment, the
- * particular device is set into this PhysicalEnvironment's fields. Each
- * PhysicalEnvironment object may use only a single audio device.
- *
- * The AudioDevice object interface specifies an abstract input device
- * that creators of Java3D class libraries would implement for a particular
- * device. Java3D's uses several methods to interact with specific devices.
- * Since all audio devices implement this consistent interface, the user
- * could have a portable means of initialize, set particular audio device
- * elements and query generic characteristics for any audio device.
- *
- *Initialization
- *
- * Each audio device driver must be initialized.
- * The chosen device driver should be initialized before any Java3D
- * Sound methods are executed because the implementation of the Sound
- * methods, in general, are potentially device driver dependent.
- *
- * Audio Playback Type
- *
- * These methods set and retrieve the audio playback type used to output
- * the analog audio from rendering Java3D Sound nodes.
- * The audio playback type specifies that playback will be through:
- * stereo headphones, a monaural speaker, or a pair of speakers.
- * For the stereo speakers, it is assumed that the two output speakers are
- * equally distant from the listener, both at same angle from the head
- * axis (thus oriented symmetrically about the listener), and at the same
- * elevation.
- * The type of playback chosen affects the sound image generated.
- * Cross-talk cancellation is applied to the audio image if playback over
- * stereo speakers is selected.
- *
- * Distance to Speaker
- *
- * These methods set and retrieve the distance in meters from the center
- * ear (the midpoint between the left and right ears) and one of the
- * speakers in the listener's environment. For monaural speaker playback,
- * a typical distance from the listener to the speaker in a workstation
- * cabinet is 0.76 meters. For stereo speakers placed at the sides of the
- * display, this might be 0.82 meters.
- *
- * Angular Offset of Speakers
- *
- * These methods set and retrieve the angle in radians between the vectors
- * from the center ear to each of the speaker transducers and the vectors
- * from the center ear parallel to the head coordinate's Z axis. Speakers
- * placed at the sides of the computer display typically range between
- * 0.28 to 0.35 radians (between 10 and 20 degrees).
- *
- * Device Driver Specific Data
- *
- * While the sound image created for final output to the playback system
- * is either only mono or stereo (for this version of Java3D) most device
- * driver implementations will mix the left and right image signals
- * generated for each rendered sound source before outputting the final
- * playback image. Each sound source will use N input channels of this
- * internal mixer. Each implemented Java3D audio device driver will have
- * its own limitations and driver-specific characteristics. These include
- * channel availability and usage (during rendering). Methods for
- * querying these device-driver specific characteristics are provided.
- *
- * Instantiating and Registering a New Device
- *
- *
A browser or applications developer must instantiate whatever system-
- * specific audio devices that he or she needs and that exist on the system.
- * This device information typically exists in a site configuration file.
- * The browser or application will instantiate the physical environment as
- * requested by the end-user.
- *
- * The API for instantiating devices is site-specific, but it consists of
- * a device object with a constructor and at least all of the methods
- * specified in the AudioDevice interface.
- *
- * Once instantiated, the browser or application must register the device
- * with the Java3D sound scheduler by associating this device with a
- * PhysicalEnvironment. The setAudioDevice method introduces new devices
- * to the Java3D environment and the allAudioDevices method produces an
- * enumeration that allows examining all available devices within a Java3D
- * environment. See PhysicalEnvironment class for more details.
- *
- * General Rules for calling AudioDevice methods:
- * It is illegal for an application to call any non-query AudioDevice method
- * if the AudioDevice is created then explicitly assigned to a
- * PhysicalEnvironment using PhysicalEnvironment.setAudioDevice();
- * When either PhysicalEnvironment.setAudioDevice() is called - including
- * when implicitly called by SimpleUniverse.getViewer().createAudioDevice()
- * - the Core creates a SoundScheduler thread which makes calls to
- * the AudioDevice.
- *
- * If an application creates it's own instance of an AudioDevice and
- * initializes it directly, rather than using PhysicalEnvironment.
- * setAudioDevice(), that application may make any AudioDevice3D methods calls
- * without fear of the Java 3D Core also trying to control the AudioDevice.
- * Under this condition it is safe to call AudioDevice non-query methods.
- */
-
-public interface AudioDevice {
-
- /** *************
- *
- * Constants
- *
- ****************/
- /**
- * Audio Playback Types
- *
- * Types of audio output device Java3D sound is played over:
- * Headphones, MONO_SPEAKER, STEREO_SPEAKERS
- */
- /**
- * Choosing Headphones as the audio playback type
- * specifies that the audio playback will be through stereo headphones.
- */
- public static final int HEADPHONES = 0;
-
- /**
- * Choosing a
- * single near-field monoaural speaker
- * as the audio playback type
- * specifies that the audio playback will be through a single speaker
- * some supplied distance away from the listener.
- */
- public static final int MONO_SPEAKER = 1;
-
- /**
- * Choosing a
- * two near-field stereo speakers
- * as the audio playback type
- * specifies that the audio playback will be through stereo speakers
- * some supplied distance away from, and at some given angle to
- * the listener.
- */
- public static final int STEREO_SPEAKERS = 2;
-
- /**
- * Initialize the audio device.
- * Exactly what occurs during initialization is implementation dependent.
- * This method provides explicit control by the user over when this
- * initialization occurs.
- * Initialization must be initiated before any other AudioDevice
- * methods are called.
- * @return true if initialization was successful without errors
- */
- public abstract boolean initialize();
-
- /**
- * Code to close the device and release resources.
- * @return true if close of device was successful without errors
- */
- public abstract boolean close();
-
- /**
- * Set Type of Audio Playback physical transducer(s) sound is output to.
- * Valid types are HEADPHONES, MONO_SPEAKER, STEREO_SPEAKERS
- * @param type audio playback type
- */
- public abstract void setAudioPlaybackType(int type);
-
- /**
- * Get Type of Audio Playback Output Device.
- * @return audio playback type
- */
- public abstract int getAudioPlaybackType();
-
- /**
- * Set Distance from interaural mid-point between Ears to a Speaker.
- * @param distance from interaural midpoint between the ears to closest speaker
- */
- public abstract void setCenterEarToSpeaker(float distance);
-
- /**
- * Get Distance from interaural mid-point between Ears to a Speaker.
- * @return distance from interaural midpoint between the ears to closest speaker
- */
- public abstract float getCenterEarToSpeaker();
-
- /**
- * Set Angle Offset (in radians) To Speaker.
- * @param angle in radians from head Z axis and vector from center ear to speaker
- */
- public abstract void setAngleOffsetToSpeaker(float angle);
-
- /**
- * Get Angle Offset (in radians) To Speaker.
- * @return angle in radians from head Z axis and vector from center ear to speaker
- */
- public abstract float getAngleOffsetToSpeaker();
-
- /**
- * Query total number of channels available for sound rendering
- * for this audio device. This returns the maximum number of channels
- * available for Java3D sound rendering for all sound sources.
- * @return total number of channels that can be used for this audio device
- */
- public abstract int getTotalChannels();
-
- /**
- * Query number of channels currently available for use.
- * During rendering, when sound nodes are playing, this method returns the
- * number of channels still available to Java3D for rendering additional
- * sound nodes.
- * @return total number of channels current available
- */
- public abstract int getChannelsAvailable();
-
- /**
- * Query number of channels that are used, or would be used to render
- * a particular sound node. This method returns the number of channels
- * needed to render a particular Sound node. The return value is the same
- * no matter if the Sound is currently active and enabled (being played) or
- * is inactive.
- * @return number of channels a particular Sound node is using or would used
- * if enabled and activated (rendered).
- */
- public abstract int getChannelsUsedForSound(Sound node);
-}
diff --git a/src/classes/share/javax/media/j3d/AudioDevice3D.java b/src/classes/share/javax/media/j3d/AudioDevice3D.java
deleted file mode 100644
index 7f152e4..0000000
--- a/src/classes/share/javax/media/j3d/AudioDevice3D.java
+++ /dev/null
@@ -1,533 +0,0 @@
-/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Point2f;
-import javax.vecmath.Point3d;
-import javax.vecmath.Point3f;
-import javax.vecmath.Vector3d;
-import javax.vecmath.Vector3f;
-
-
-/**
- * The AudioDevice3D class defines a 3D audio device that is used to set
- * sound and aural attributes.
- *
- * After the application chooses the AudioDevice3D that Java3D sound
- * is to be rendered on, the Java 3D Sound Scheduler will call these
- * methods for all active sounds to render them on the audio device.
- *
- * The intent is for this interface to be implemented by AudioDevice Driver
- * developers using a software or hardware sound engine of their choice.
- *
- * Methods in this interface provide the Java3D Core a generic way to
- * set and query the audio device the application has chosen audio rendering
- * to be performed on. Methods in this interface include:
- *
- * Set up and clear the sound as a sample on the device.
- *
- * Start, stop, pause, unpause, mute, and unmute of sample on the device.
- *
- * Set parameters for each sample corresponding to the fields in the
- * Sound node.
- *
- * Set the current active aural parameters that affect all positional samples.
- *
- *
- * Sound Types
- *
- * Sound types match the Sound node classes defined for Java 3D core
- * for BackgroundSound, PointSound, and ConeSound. The type of sound
- * a sample is loaded as determines which methods affect it.
- *
- *
- * Sound Data Types
- *
- * Samples can be processed as streaming or buffered data.
- * Fully spatializing sound sources may require data to be buffered.
- *
- */
-
-public interface AudioDevice3D extends AudioDevice {
-
- /**
- * Specifies the sound type as background sound.
- */
- public static final int BACKGROUND_SOUND = 1;
-
- /**
- * Specifies the sound type as point sound.
- */
- public static final int POINT_SOUND = 2;
-
- /**
- * Specifies the sound type as cone sound.
- */
-
- public static final int CONE_SOUND = 3;
-
- /**
- * Sound data specified as Streaming is not copied by the AudioDevice
- * driver implementation. It is up to the application to ensure that
- * this data is continuously accessible during sound rendering.
- * Furthermore, full sound spatialization may not be possible, for
- * all AudioDevice3D implementations on unbuffered sound data.
- */
- public static final int STREAMING_AUDIO_DATA = 1;
- /**
- * Sound data specified as Buffered is copied by the AudioDevice
- * driver implementation.
- */
- public static final int BUFFERED_AUDIO_DATA = 2;
-
-
- /**
- * Accepts a reference to the current View.
- * Passes reference to current View Object. The PhysicalEnvironment
- * parameters (with playback type and speaker placement), and the
- * PhysicalBody parameters (position/orientation of ears)
- * can be obtained from this object, and the transformations to/from
- * ViewPlatform coordinate (space the listener's head is in) and
- * Virtual World coordinates (space sounds are in).
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param reference the current View
- */
- public abstract void setView(View reference);
-
- /**
- * Accepts a reference to the MediaContainer
- * which contains a reference to sound data and information about the
- * type of data it is. A "sound type" input parameter denotes if the
- * Java 3D sound associated with this sample is a Background, Point, or
- * Cone Sound node.
- * Depending on the type of MediaContainer the sound data is and on the
- * implementation of the AudioDevice used, sound data preparation could
- * consist of opening, attaching, or loading sound data into the device.
- * Unless the cached flag is true, this sound data should NOT be copied,
- * if possible, into host or device memory.
- *
- * Once this preparation is complete for the sound sample, an AudioDevice
- * specific index, used to reference the sample in future method calls,
- * is returned. All the rest of the methods described below require
- * this index as a parameter.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param soundType defines the type of Sound Node: Background, Point, and
- * Cone
- * @param soundData reference to MediaContainer sound data and cached flag
- * @return device specific sample index used for referencing this sound
- */
- public abstract int prepareSound(int soundType, MediaContainer soundData);
-
- /**
- * Requests that the AudioDevice free all
- * resources associated with sample with index id.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void clearSound(int index);
-
- /**
- * Returns the duration in milliseconds of the sound sample,
- * if this information can be determined.
- * For non-cached
- * streams, this method returns Sound.DURATION_UNKNOWN.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @return sound duration in milliseconds if this can be determined,
- * otherwise (for non-cached streams) Sound.DURATION_UNKNOWN is returned
- */
- public abstract long getSampleDuration(int index);
-
- /**
- *
- * Retrieves the number of channels (on executing audio device) that
- * this sound is using, if it is playing, or is expected to use
- * if it were begun to be played. This form of this method takes the
- * sound's current state (including whether it is muted or unmuted)
- * into account.
- *
- * For some AudioDevice3D implementations:
- *
- * Muted sound take channels up on the systems mixer (because they're
- * rendered as samples playing with gain zero.
- *
- * A single sound could be rendered using multiple samples, each taking
- * up mixer channels.
- *
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @return number of channels used by sound if it were playing
- */
- public abstract int getNumberOfChannelsUsed(int index);
-
- /**
- *
- * Retrieves the number of channels (on executing audio device) that
- * this sound is using, if it is playing, or is projected to use if
- * it were to be started playing. Rather than using the actual current
- * muted/unmuted state of the sound, the muted parameter is used in
- * making the determination.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param muted flag to use as the current muted state ignoring current
- * mute state
- * @return number of channels used by sound if it were playing
- */
- public abstract int getNumberOfChannelsUsed(int index, boolean muted);
-
- /**
- * Begins a sound playing on the AudioDevice.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @return flag denoting if sample was started; 1 if true, 0 if false
- */
- public abstract int startSample(int index);
-
- /**
- * Returns the system time of when the sound
- * was last "started". Note that this start time will be as accurate
- * as the AudioDevice implementation can make it - but that it is not
- * guaranteed to be exact.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @return system time in milliseconds of the last time sound was started
- */
- public abstract long getStartTime(int index);
-
- /**
- * Stops the sound on the AudioDevice.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * associated with sound data to be played
- * @return flag denoting if sample was stopped; 1 if true, 0 if false
- */
- public abstract int stopSample(int index);
-
- /**
- * Sets the overall gain scale factor applied to data associated with this
- * source to increase or decrease its overall amplitude.
- * The gain scale factor value passed into this method is the combined value
- * of the Sound node's Initial Gain and the current AuralAttribute Gain
- * scale factors.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param scaleFactor amplitude (gain) scale factor
- */
- public abstract void setSampleGain(int index, float scaleFactor);
-
- /**
- * Sets a sound's loop count.
- * A full description of this parameter and how it is used is in
- * the documentation for Sound.setLoop.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param count number of times sound is looped during play
- * @see Sound#setLoop
- */
- public abstract void setLoop(int index, int count);
-
- /**
- * Passes a reference to the concatenated transformation to be applied to
- * local sound position and direction parameters.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param trans transformation matrix applied to local coordinate parameters
- */
- public abstract void setVworldXfrm(int index, Transform3D trans);
-
-
- /**
- * Sets this sound's location (in Local coordinates) from specified
- * Point. The form of the position parameter matches those of the PointSound
- * method of the same name.
- * A full description of this parameter and how it is used is in
- * the documentation for PointSound class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param position location of Point or Cone Sound in Virtual World
- * coordinates
- * @see PointSound#setPosition(float x, float y, float z)
- * @see PointSound#setPosition(Point3f position)
- */
- public abstract void setPosition(int index, Point3d position);
-
- /**
- * Sets this sound's distance gain elliptical attenuation (not
- * including filter cutoff frequency) by defining corresponding
- * arrays containing distances from the sound's origin and gain
- * scale factors applied to all active positional sounds.
- * Gain scale factor is applied to sound based on the distance
- * the listener
- * is from sound source.
- * These attenuation parameters are ignored for BackgroundSound nodes.
- * The back attenuation parameter is ignored for PointSound nodes.
- *
- * The form of the attenuation parameters match that of the ConeSound method
- * of the same name.
- * A full description of this parameter and how it is used is in
- * the documentation for ConeSound class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param frontDistance defines an array of distance along positive axis
- * through which ellipses pass
- * @param frontAttenuationScaleFactor gain scale factors
- * @param backDistance defines an array of distance along the negative axis
- * through which ellipses pass
- * @param backAttenuationScaleFactor gain scale factors
- * @see ConeSound#setDistanceGain(float[] frontDistance, float[] frontGain,
- * float[] backDistance, float[] backGain)
- * @see ConeSound#setDistanceGain(Point2f[] frontAttenuation,
- * Point2f[] backAttenuation)
- */
- public abstract void setDistanceGain(int index,
- double[] frontDistance, float[] frontAttenuationScaleFactor,
- double[] backDistance, float[] backAttenuationScaleFactor);
- /**
- * Sets this sound's direction from the local coordinate vector provided.
- * The form of the direction parameter matches that of the ConeSound method
- * of the same name.
- * A full description of this parameter and how it is used is in
- * the documentation for the ConeSound class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param direction the new direction vector in local coordinates
- * @see ConeSound#setDirection(float x, float y, float z)
- * @see ConeSound#setDirection(Vector3f direction)
- */
- public abstract void setDirection(int index, Vector3d direction);
-
- /**
- * Sets this sound's angular gain attenuation (including filter)
- * by defining corresponding arrays containing angular offsets from
- * the sound's axis, gain scale factors, and frequency cutoff applied
- * to all active directional sounds.
- * Gain scale factor is applied to sound based on the angle between the
- * sound's axis and the ray from the sound source origin to the listener.
- * The form of the attenuation parameter matches that of the ConeSound
- * method of the same name.
- * A full description of this parameter and how it is used is in
- * the documentation for the ConeSound class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- * @param filterType describes type (if any) of filtering defined by attenuation
- * @param angle array containing angular distances from sound axis
- * @param attenuationScaleFactor array containing gain scale factor
- * @param filterCutoff array containing filter cutoff frequencies.
- * The filter values for each tuples can be set to Sound.NO_FILTER.
- * @see ConeSound#setAngularAttenuation(float[] distance, float[] gain,
- * float[] filter)
- * @see ConeSound#setAngularAttenuation(Point3f[] attenuation)
- * @see ConeSound#setAngularAttenuation(Point2f[] attenuation)
- */
- public abstract void setAngularAttenuation(int index, int filterType,
- double[] angle, float[] attenuationScaleFactor, float[] filterCutoff);
-
- /**
- * Changes the speed of sound factor.
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param rolloff atmospheric gain scale factor (changing speed of sound)
- * @see AuralAttributes#setRolloff
- */
- public abstract void setRolloff(float rolloff);
-
- /**
- * Sets the Reflective Coefficient scale factor applied to distinct
- * low-order early reflections of sound off the surfaces in the region
- * defined by the current listening region.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param coefficient reflection/absorption factor applied to reverb
- * @see AuralAttributes#setReflectionCoefficient
- */
- public abstract void setReflectionCoefficient(float coefficient);
-
- /**
- * Sets the reverberation delay time.
- * In this form, while reverberation is being rendered, the parameter
- * specifies the delay time between each order of late reflections
- * explicitly given in milliseconds.
- * A value for delay time of 0.0 disables
- * reverberation.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param reverbDelay time between each order of late reflection
- * @see AuralAttributes#setReverbDelay(float reverbDelay)
- */
- public abstract void setReverbDelay(float reverbDelay);
-
- /**
- * Sets the reverberation order of reflections.
- * The reverbOrder parameter specifies the number of times reflections are added to
- * reverberation being calculated. A value of -1 specifies an unbounded
- * number of reverberations.
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param reverbOrder number of times reflections added to reverb signal
- * @see AuralAttributes#setReverbOrder
- */
- public abstract void setReverbOrder(int reverbOrder);
-
- /**
- * Sets Distance Filter corresponding arrays containing distances and
- * frequency cutoff applied to all active positional sounds.
- * Gain scale factor is applied to sound based on the distance the listener
- * is from the sound source.
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param filterType denotes the type of filtering to be applied
- * @param distance array of offset distances from sound origin
- * @param filterCutoff array of frequency cutoff
- * @see AuralAttributes#setDistanceFilter(float[] distance,
- * float[] frequencyCutoff)
- * @see AuralAttributes#setDistanceFilter(Point2f[] attenuation)
- */
- public abstract void setDistanceFilter(int filterType,
- double[] distance, float[] filterCutoff);
-
- /**
- * Specifies a scale factor applied to the frequency (or
- * wavelength). A value less than 1.0 will result of slowing the playback
- * rate of the sample. A value greater than 1.0 will increase the playback
- * rate.
- * This parameter is also used to expand or contract the usual
- * frequency shift applied to the sound source due to Doppler effect
- * calculations. Valid values are >= 0.0.
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param frequencyScaleFactor factor applied to change of frequency
- * @see AuralAttributes#setFrequencyScaleFactor
- */
- public abstract void setFrequencyScaleFactor(float frequencyScaleFactor);
-
- /**
- * Sets the Velocity scale factor applied during Doppler Effect calculation.
- * This parameter specifies a scale factor applied to the velocity of sound
- * relative to the listener's position and movement in relation to the sound's
- * position and movement. This scale factor is multipled by the calculated
- * velocity portion of the Doppler effect equation used during sound rendering.
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param velocityScaleFactor applied to velocity of sound in relation
- * to listener
- * @see AuralAttributes#setVelocityScaleFactor
- */
- public abstract void setVelocityScaleFactor(float velocityScaleFactor);
-
- /**
- * Makes the sample 'play silently'.
- * This method implements (as efficiently as possible) the muting
- * of a playing sound sample. Ideally this is implemented by
- * stopping a sample and freeing channel resources (rather than
- * just setting the gain of the sample to zero).
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void muteSample(int index);
-
- /**
- * Makes a silently playing sample audible.
- * In the ideal, this restarts a muted sample by offset from the
- * beginning by the number of milliseconds since the time the sample
- * began playing (rather than setting gain to current non-zero gain).
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void unmuteSample(int index);
-
- /**
- * Temporarily stops a cached sample from playing without resetting the
- * sample's current pointer back to the beginning of the sound data so
- * that it can be unpaused at a later time from the same location in the
- * sample when the pause was initiated. Pausing a streaming, non-cached
- * sound sample will be treated as a mute.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void pauseSample(int index);
-
- /**
- * Restarts the paused sample from the location in the sample where
- * paused.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void unpauseSample(int index);
-
- /**
- *
- * Explicitly updates a Sample.
- * This method is called when a Sound is to be explicitly updated.
- * It is only called when all a sounds parameters are known to have
- * been passed to the audio device. In this way, an implementation
- * can choose to perform lazy-evaluation of a sample, rather than
- * updating the rendering state of the sample after every individual
- * parameter changed.
- * This method can be left as a null method if the implementor so chooses.
- *
- * This method should only be called by Java3D Core and NOT by any application.
- * @param index device specific reference number to device driver sample
- */
- public abstract void updateSample(int index);
-
-}
diff --git a/src/classes/share/javax/media/j3d/AudioDevice3DL2.java b/src/classes/share/javax/media/j3d/AudioDevice3DL2.java
deleted file mode 100644
index 337328c..0000000
--- a/src/classes/share/javax/media/j3d/AudioDevice3DL2.java
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-/**
- * Extends AudioDevice3D to include reverb and environmental audio parameters
- * that are defined in the MIDI Manufactures' Association Interactive Audio
- * Special Interest Group (MMA IASIG) Level 2 Specification.
- *
- * The reverberation methods of AudioDevice3DL2 interface augment the
- * reverberation methods defined in AudioDevice3D.
- *
- * The intent is for this interface to be implemented by AudioDevice Driver
- * developers using a software or hardware sound engine of their choice.
- *
- * Methods in this interface provide the Java3D Core a generic way to
- * set and query the audio device the application has chosen audio rendering
- * to be performed on.
- *
- * The non-query methods of this interface should only be called by
- * an application if the AudioDevice instance
- * is not referenced by any PhysicalEnvironment
- * explicitly with .setAudioDevice() or implicitly through Universe
- * utility method in which case these are called by Core Java 3D
- * Sound classes and Sound Scheduler thread(s).
- *
- * After the application chooses the AudioDevice3DL2 implementation
- * that Java3D sound is to be rendered on, the Java 3D Sound Scheduler
- * will call these methods for all active sounds to render them on the
- * audio device.
- *
- * The AudioDevice3DL2 methods should not be call by any application if the
- * audio device is associated with a Physical Environment and thus used by
- * Java3D Core.
- *
- * Filtering for this extended AudioDevice interface is defined uniformly as
- * a simple low-pass filter defined by a cutoff frequency. This will allow the
- * same type of high-frequency attenuation that the MMA IASIG Level 2 filtering
- * model with its 'reference frequency' and 'attenuation ratio' parameters
- * affords. Use of a cutoff frequency is consistent with the filtering type
- * for distance and angular attenuation for ConeSound and AuralAttributes.
- * The filter methods will likely be overloaded in some future extension of this
- * interface.
- *
- * @see Sound
- * @see AuralAttributes
- * @see AudioDevice3D
- * @since Java 3D 1.3
- */
-
-public interface AudioDevice3DL2 extends AudioDevice3D {
-
- /**
- * Pause audio device engine (thread/server) without closing the device.
- * Causes all cached sounds to be paused and all streaming sounds to be
- * stopped.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * This method will be implicitly called when View (associated with this
- * device) is deactivated.
- */
- public abstract void pause();
-
- /**
- * Resumes audio device engine (if previously paused) without reinitializing
- * the device.
- * Causes all paused cached sounds to be resumed and all streaming sounds
- * restarted.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * This method will be implicitly called when View (associated with this
- * device) is actived.
- */
- public abstract void resume();
-
- /**
- * Set overall gain control of all sounds playing on the audio device.
- * Default: 1.0f = no attenuation.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param scaleFactor scale factor applied to calculated amplitudes for
- * all sounds playing on this device
- */
- public abstract void setGain(float scaleFactor);
-
- /**
- * Set scale factor applied to sample playback rate for a particular sound
- * associated with the audio device.
- * Changing the device sample rate affects both the pitch and speed.
- * This scale factor is applied to ALL sound types.
- * Changes (scales) the playback rate of a sound independent of
- * Doppler rate changes.
- * Default: 1.0f = original sample rate is unchanged
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param sampleId device specific reference number to device driver sample
- * @param scaleFactor non-negative factor applied to calculated
- * amplitudes for all sounds playing on this device
- */
- public abstract void setRateScaleFactor(int sampleId, float scaleFactor);
-
-
- /**
- * Set late reflection (referred to as 'reverb') attenuation.
- * This scale factor is applied to iterative, indistinguishable
- * late reflections that constitute the tail of reverberated sound in
- * the aural environment.
- * This parameter, along with the early reflection coefficient, defines
- * the reflective/absorptive characteristic of the surfaces in the
- * current listening region.
- * A coefficient value of 0 disables reverberation.
- * Valid values of parameters range from 0.0 to 1.0.
- * Default: 0.0f.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param coefficient late reflection attenuation factor
- * @see AuralAttributes#setReverbCoefficient
- */
- public abstract void setReverbCoefficient(float coefficient);
-
-
- /**
- * Sets the early reflection delay time.
- * In this form, the parameter specifies the delay time between each order
- * of reflection (while reverberation is being rendered) explicitly given
- * in milliseconds.
- * Valid values are non-negative floats.
- * There may be limitations imposed by the device on how small or large this
- * value can be made.
- * A value of 0.0 would result in early reflections being added as soon as
- * possible after the sound begins.
- * Default = 20.0 milliseconds.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param reflectionDelay time between each order of early reflection
- * @see AuralAttributes#setReflectionDelay
- */
- public abstract void setReflectionDelay(float reflectionDelay);
-
- /**
- * Set reverb decay time.
- * Defines the reverberation decay curve.
- * Default: 1000.0 milliseconds.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param time decay time in milliseconds
- * @see AuralAttributes#setDecayTime
- */
- public abstract void setDecayTime(float time);
-
- /**
- * Set reverb decay filter.
- * This provides for frequencies above the given cutoff frequency to be
- * attenuated during reverb decay at a different rate than frequencies
- * below this value. Thus, defining a different reverb decay curve for
- * frequencies above the cutoff value.
- * Default: 1.0 decay is uniform for all frequencies.
- *
- * There is no corresponding Core AuralAttributes method at this time.
- * Until high frequency attenuation is supported by new Core API,
- * this will be set by the Core with the value 1.0.
- * It is highly recommended that this method should NOT be
- * called by any application if the audio device is associated with
- * a Physical Environment used by Java3D Core.
- * @param frequencyCutoff value of frequencies in Hertz above which a
- * low-pass filter is applied.
- * @see AuralAttributes#setDecayFilter
- */
- public abstract void setDecayFilter(float frequencyCutoff);
-
- /**
- * Set reverb diffusion.
- * This defines the echo dispersement (also referred to as 'echo density').
- * The value of this reverb parameter is expressed as a percent of the
- * audio device's minimum-to-maximum values.
- * Default: 1.0f - maximum diffusion on device.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param diffusion percentage expressed within the range of 0.0 and 1.0
- * @see AuralAttributes#setDiffusion
- */
- public abstract void setDiffusion(float diffusion);
-
- /**
- * Set reverb density.
- * This defines the modal density (also referred to as 'spectral
- * coloration').
- * The value of this parameter is expressed as a percent of the audio
- * device's minimum-to-maximum values for this reverb parameter.
- * Default: 1.0f - maximum density on device.
- *
- * A full description of this parameter and how it is used is in
- * the documentation for the AuralAttributes class.
- *
- * This method should NOT be called by any application if the audio device
- * is associated with a Physical Environment used by Java3D Core.
- * @param density reverb density expressed as a percentage,
- * within the range of 0.0 and 1.0
- * @see AuralAttributes#setDensity
- */
- public abstract void setDensity(float density);
-
-
- /**
- * Set the obstruction gain control. This method allows for attenuating
- * sound waves traveling between the sound source and the listener
- * obstructed by objects. Direct sound signals/waves for obstructed sound
- * source are attenuated but not indirect (reflected) waves.
- * Default: 1.0 - gain is not attenuated; obstruction is not occurring.
- *
- * There is no corresponding Core AuralAttributes method at this time.
- * Even so, this method should NOT be called by any application if the
- * audio device is associated with a Physical Environment used by Java3D
- * Core.
- * @param sampleId device specific reference number to device driver sample
- * @param scaleFactor non-negative factor applied to direct sound gain
- */
- public abstract void setObstructionGain(int sampleId, float scaleFactor);
-
- /**
- * Set the obstruction filter control.
- * This provides for frequencies above the given cutoff frequency
- * to be attenuated, during while the gain of an obstruction signal
- * is being calculated, at a different rate than frequencies
- * below this value.
- * Default: 1.0 - filtering is uniform for all frequencies.
- *
- * There is no corresponding Core AuralAttributes method at this time.
- * Until high frequency attenuation is supported by new Core API
- * this will be set by the Core with the value 1.0.
- * It is highly recommended that this method should NOT be
- * called by any application if the audio device is associated with
- * a Physical Environment used by Java3D Core.
- * @param frequencyCutoff value of frequencies in Hertz above which a
- * low-pass filter is applied.
- */
-
- public abstract void setObstructionFilter(int sampleId, float frequencyCutoff);
-
- /**
- * Set the occlusion gain control. This method allows for attenuating
- * sound waves traveling between the sound source and the listener
- * occluded by objects. Both direct and indirect sound signals/waves
- * for occluded sound sources are attenuated.
- * Default: 1.0 - gain is not attenuated; occlusion is not occurring.
- *
- * There is no corresponding Core AuralAttributes method at this time.
- * Even so, this method should NOT be called by any application if the
- * audio device is associated with a Physical Environment used by Java3D
- * Core.
- * @param sampleId device specific reference number to device driver sample
- * @param scaleFactor non-negative factor applied to direct sound gain
- */
- public abstract void setOcclusionGain(int sampleId, float scaleFactor);
-
- /**
- * Set the occlusion filter control.
- * This provides for frequencies above the given cutoff frequency
- * to be attenuated, during while the gain of an occluded signal
- * is being calculated, at a different rate than frequencies below
- * this value.
- * Default: 1.0 - filtering is uniform for all frequencies.
- *
- * There is no corresponding Core AuralAttributes method at this time.
- * Until high frequency attenuation is supported by new Core API
- * this will be set by the Core with the value 1.0.
- * It is highly recommended that this method should NOT be
- * called by any application if the audio device is associated with
- * a Physical Environment used by Java3D Core.
- * @param frequencyCutoff value of frequencies in Hertz above which a
- * low-pass filter is applied.
- */
- public abstract void setOcclusionFilter(int sampleId, float frequencyCutoff);
-}
diff --git a/src/classes/share/javax/media/j3d/AudioDeviceEnumerator.java b/src/classes/share/javax/media/j3d/AudioDeviceEnumerator.java
deleted file mode 100644
index dbab9b3..0000000
--- a/src/classes/share/javax/media/j3d/AudioDeviceEnumerator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-/**
- * The class that enumerates all AudioDevices defined in the environment
- *
- * An AudioDeviceEnumerator generates the audio devices defined with the
- * execution environment of the currently running Java 3D application.
- */
-
-class AudioDeviceEnumerator implements Enumeration {
-
- boolean endOfList; // NOTE: list length always equals one or zero
- AudioDevice device;
-
- AudioDeviceEnumerator(PhysicalEnvironment physicalEnvironment) {
- device = physicalEnvironment.getAudioDevice();
- if(device == null)
- endOfList = true;
- else
- endOfList = false;
- }
-
- void reset() {
- if(device != null)
- endOfList = false;
- }
-
-
- /**
- * Query that tells whether the enumerator has more elements
- * @return true if the enumerator has more elements, false otherwise
- */
- @Override
- public boolean hasMoreElements() {
- if(endOfList == false)
- return true;
- else
- return false;
- }
-
- /**
- * Return the next element in the enumerators
- * @return the next element in this enumerator
- */
- @Override
- public Object nextElement() {
- if (this.hasMoreElements()) {
- endOfList = true;
- return ((Object) device);
- } else {
- throw new NoSuchElementException(J3dI18N.getString("AudioDeviceEnumerator0"));
- }
- }
-}
diff --git a/src/classes/share/javax/media/j3d/AuralAttributes.java b/src/classes/share/javax/media/j3d/AuralAttributes.java
deleted file mode 100644
index 563bc3a..0000000
--- a/src/classes/share/javax/media/j3d/AuralAttributes.java
+++ /dev/null
@@ -1,1307 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Point2f;
-
-/**
- * The AuralAttributes object is a component object of a Soundscape node that
- * defines environmental audio parameters that affect sound rendering. These
- * attributes include gain scale factor, atmospheric rolloff, and parameters
- * controlling reverberation, distance frequency filtering, and velocity-based
- * Doppler effect.
- *
- * Attribute Gain
- *
- * Scale factor applied to all sound's amplitude active within this region.
- * This factor attenuates both direct and reflected/reverbered amplitudes.
- * Valid values are >= 0.0
- *
- *
- * Attribute Gain Rolloff
- *
- * Rolloff scale factor is used to model atmospheric changes from normal
- * speed of sound. The base value, 0.344 meters/millisecond is used
- * to approximate the speed of sound through air at room temperature,
- * is multipled by this scale factor whenever the speed of sound is
- * applied during spatialization calculations.
- * Valid values are >= 0.0. Values > 1.0 increase the speed of sound,
- * while values < 1.0 decrease its speed. A value of zero makes sound
- * silent (but it continues to play).
- *
- *
- * Auralization
- *
- * Auralization is the environmental modeling of sound iteratively
- * reflecting off the surfaces of the bounded region the listener is in.
- * Auralization components include
- * early, distinct, low-order reflections and later, dense,
- * higher-order reflections referred to as reverberation.
- * These reflections are attenuated relative to the direct, unreflected
- * sound. The difference in gain between direct and reflected sound
- * gives the listener a sense of the surface material and
- * the relative distance of the sound.
- * The delay between the start of the direct sound and start of
- * reverberation (as detected by the listener),
- * as well as the length of time reverberation is audible as it
- * exponentially decays, give the listener a sense of the size of the
- * listening space.
- *
- * In Java3D's model for auralization there are several parameters
- * that approximate sound reflection and reverberation for a particular
- * listening space:
- *
Reflection Coefficient
Gain attenuation of the initial
- * reflections across all frequencies.
- *
(Early) Reflection Delay
The time it takes for the first
- * low-order reflected sound to reach the listener.
- *
Reverb Coefficient
Gain attenuation of the late reflections
- * (referred to as 'reverb') across all frequencies.
- *
Reverb Delay
The time it takes for reverbered sound
- * to reach the listener.
- *
Decay Time
Describes the reverb decay curve by defining the
- * length of time reverb takes to decay to effective zero.
- *
- *
Decay Filter
High-frequencies of the late reverberation
- * can be attenuated at a different rate.
- *
Density
Modal density (spectral coloration) of
- * reverberation.
- *
Diffusion
Echo dispersement of reverberation.
- *
Reverb Bounds
Approximates the volume of the listening space.
- * If specified, it defines the reverberation delay.
- *
Reverb Order
Optionally limits the amount of times during
- * reverb calculation that a sound is recursively reflected off the
- * bounding region.
- *
- * Reflection Coefficient
- *
- * The reflection coefficient is an amplitude scale factor used to
- * approximate the average reflective or absorptive characteristics
- * for early reflections
- * of the composite surfaces in the region the listener is in.
- * This scale factor is applied to the sound's amplitude regardless of the
- * sound's position.
- * The range of valid values is 0.0 to 1.0.
- * A value of 1.0 denotes that reflections are unattenuated -
- * the amplitude of reflected sound waves are not decreased.
- * A value of 0.0 represents full absorption of reflections
- * by the surfaces in the listening space (no reflections occur
- * thus reverberation is disabled).
- *
- *
- * Reflection Delay
- *
- * The early reflection delay time (in milliseconds) can be explicitly
- * set. Well-defined values are floats > 0.0.
- * A value of 0.0 results in reverberation being added as soon as
- * possible after the sound begins.
- *
- *
- * Reverberation Coefficient
- *
- * The reverb coefficient is an amplitude scale factor used to
- * approximate the average reflective or absorptive characteristics
- * of late reflections.
- * A value of 0.0 represents full absorption of reflections
- * by the surfaces in the listening space (no reflections occur
- * thus reverberation is disabled).
- *
- *
- * Reverberation Delay
- *
- * The reverb delay time (in milliseconds) is set either explicitly,
- * or implicitly by supplying a reverb bounds volume (from which the
- * delay time can be calculated). Well-defined values are floats > 0.0.
- * A value of 0.0 results in reverberation being added as soon as
- * possible after the sound begins. Reverb delay, as calculated from non-
- * null reverb bounds, takes precedence over explicitly set delay time.
- *
- *
- * Reverberation Bounds
- *
- * The reverb bounding region defines the overall size of space
- * that reverberation is calculated for.
- * This optional bounds does not have to be the same as the application
- * region of the Soundscape node referencing this AuralAttributes object.
- * If this bounding region is specified then reverb decay and delay are
- * internally calculated from this bounds.
- *
- *
- * Reverberation Order
- *
- * The reverb order is a hint that can be used during reverberation
- * to limit the number of late reflections required in calculation of
- * reverb decay.
- * All positive values can be interpreted during reverb rendering
- * as the maximum order of reflections to be calculated.
- * A non-positive value signifies that no limit is placed on the order of
- * reflections calculated during reverberation rendering.
- * In the case where reverb order is not limited, reverb decay is defined
- * strictly by the Reverberation Decay Time parameter.
- *
- *
- * Decay Time
- *
- * The reverberation decay time explicitly defines the length of time in
- * milliseconds it takes for the amplitude of late reflections to
- * exponentally decrease to effective zero.
- * In the case where reverb delay is set non-positive
- * the renderer will perform the shortest reverberation decay
- * possible.
- * If ReverbOrder is set, this parameter is clamped by the reverb
- * time calculated as time = reverb Delay * reverb Order.
- * If ReverbOrder is 0, the decay time parameter is not clamped.
- *
- *
- * Decay Filter
- *
- * The reverberation decay filter defines how frequencies above a given
- * value are attenuated by the listening space. This allows for modelling
- * materials on surfaces that absorb high frequencies at a faster rate
- * than low frequencies.
- *
- *
- * Reverberation Diffusion
- *
- * The reverberation diffusion explicitly defines echo dispersement
- * (sometimes refered to as echo density). The value for diffusion
- * is proportional to the number of echos per second heard in late
- * reverberation, especially noticable at the tail of the reverberation
- * decay. The greater the diffusion the more 'natural' the reverberation
- * decay sounds. Reducing diffusion makes the decay sound hollow as
- * produced in a small highly reflecive space (such as a bathroom).
- *
- *
- * Reverberation Density
- *
- * The reverberation density explicitly defines modal reverb density
- * The value for this modal density is proportional to the number of
- * resonances heard in late reverberation perceived as spectral
- * coloration. The greater the density, the smoother, less grainy the
- * later reverberation decay.
- *
- *
- *
- * Distance Filter
- *
- * This parameter specifies a (distance, filter) attenuation pairs array.
- * If this is not set, no distance filtering is performed (equivalent to
- * using a distance filter of Sound.NO_FILTER for all distances). Currently,
- * this filter is a low-pass cutoff frequency. This array of pairs defines
- * a piece-wise linear slope for range of values. This attenuation array is
- * similar to the PointSound node's distanceAttenuation pair array, except
- * paired with distances in this list are frequency values. Using these
- * pairs, distance-based low-pass frequency filtering can be applied during
- * sound rendering. Distances, specified in the local coordinate system in
- * meters, must be > 0. Frequencies (in Hz) must be > 0.
- *
- * If the distance from the listener to the sound source is less than the
- * first distance in the array, the first filter is applied to the sound
- * source. This creates a spherical region around the listener within
- * which a sound is uniformly attenuated by the first filter in the array.
- * If the distance from the listener to the sound source is greater than
- * the last distance in the array, the last filter is applied to the sound
- * source.
- *
- * Distance elements in these array of pairs is a monotonically-increasing
- * set of floating point numbers measured from the location of the sound
- * source. FrequencyCutoff elements in this list of pairs can be any
- * positive float. While for most applications this list of values will
- * usually be monotonically-decreasing, they do not have to be.
- *
- * The getDistanceFilterLength method returns the length of the distance filter
- * arrays. Arrays passed into getDistanceFilter methods should all be at
- * least this size.
- *
- * Doppler Effect Model
- *
- * Doppler effect can be used to create a greater sense of movement of
- * sound sources, and can help reduce front-back localization errors.
- * The frequency of sound waves emanating from the source are raised or
- * lowered based on the speed of the source in relation to the listener,
- * and several AuralAttribute parameters.
- *
- * The FrequencyScaleFactor can be used to increase or reduce the change
- * of frequency associated with normal Doppler calculation, or to shift
- * the pitch of the sound directly if Doppler effect is disabled.
- * Values must be > zero for sounds to be heard. If the value is zero,
- * sounds affected by this AuralAttribute object are paused.
- *
- * To simulate Doppler effect, the relative velocity (change in
- * distance in the local coordinate system between the sound source and
- * the listener over time, in meters per second) is calculated. This
- * calculated velocity is multipled by the given VelocityScaleFactor.
- * Values must be >= zero. If is a scale factor value of zero is given,
- * Doppler effect is not calculated or applied to sound.
- */
-public class AuralAttributes extends NodeComponent {
-
- /**
- *
- * Constants
- *
- * These flags, when enabled using the setCapability method, allow an
- * application to invoke methods that read or write its parameters.
- *
- */
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's attribute gain scale factor information.
- */
- public static final int
- ALLOW_ATTRIBUTE_GAIN_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_ATTRIBUTE_GAIN_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's attribute gain scale factor information.
- */
- public static final int
- ALLOW_ATTRIBUTE_GAIN_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_ATTRIBUTE_GAIN_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's atmospheric rolloff.
- */
- public static final int
- ALLOW_ROLLOFF_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_ROLLOFF_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's atmospheric rolloff.
- */
- public static final int
- ALLOW_ROLLOFF_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_ROLLOFF_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reflection coefficient.
- */
- public static final int
- ALLOW_REFLECTION_COEFFICIENT_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REFLECTION_COEFFICIENT_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reflection coefficient.
- */
- public static final int
- ALLOW_REFLECTION_COEFFICIENT_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REFLECTION_COEFFICIENT_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reflection delay information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_REFLECTION_DELAY_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REFLECTION_DELAY_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reflection delay information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_REFLECTION_DELAY_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REFLECTION_DELAY_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb coefficient.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_REVERB_COEFFICIENT_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_COEFFICIENT_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb coefficient.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_REVERB_COEFFICIENT_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_COEFFICIENT_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverberation delay information.
- */
- public static final int
- ALLOW_REVERB_DELAY_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_DELAY_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverberation delay information.
- */
- public static final int
- ALLOW_REVERB_DELAY_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_DELAY_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb order (feedback loop) information.
- */
- public static final int
- ALLOW_REVERB_ORDER_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_ORDER_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb order (feedback loop) information.
- */
- public static final int
- ALLOW_REVERB_ORDER_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_REVERB_ORDER_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb decay time information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DECAY_TIME_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DECAY_TIME_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb decay time information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DECAY_TIME_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DECAY_TIME_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb decay filter information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DECAY_FILTER_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DECAY_FILTER_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb decay filter information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DECAY_FILTER_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DECAY_FILTER_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb diffusion information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DIFFUSION_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DIFFUSION_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb diffusion information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DIFFUSION_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DIFFUSION_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's reverb density information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DENSITY_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DENSITY_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's reverb density information.
- *
- * @since Java 3D 1.3
- */
- public static final int
- ALLOW_DENSITY_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DENSITY_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's frequency cutoff information.
- */
- public static final int
- ALLOW_DISTANCE_FILTER_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DISTANCE_FILTER_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's frequency cutoff information.
- */
- public static final int
- ALLOW_DISTANCE_FILTER_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_DISTANCE_FILTER_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's frequency scale factor information.
- */
- public static final int
- ALLOW_FREQUENCY_SCALE_FACTOR_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_FREQUENCY_SCALE_FACTOR_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's frequency scale factor information.
- */
- public static final int
- ALLOW_FREQUENCY_SCALE_FACTOR_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_FREQUENCY_SCALE_FACTOR_WRITE;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the reading of it's velocity scale factor information.
- */
- public static final int
- ALLOW_VELOCITY_SCALE_FACTOR_READ = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_VELOCITY_SCALE_FACTOR_READ;
-
- /**
- * For AuralAttributes component objects, specifies that this object
- * allows the writing of it's velocity scale factor information.
- */
- public static final int
- ALLOW_VELOCITY_SCALE_FACTOR_WRITE = CapabilityBits.AURAL_ATTRIBUTES_ALLOW_VELOCITY_SCALE_FACTOR_WRITE;
-
- // Array for setting default read capabilities
- private static final int[] readCapabilities = {
- ALLOW_ATTRIBUTE_GAIN_READ,
- ALLOW_DECAY_FILTER_READ,
- ALLOW_DECAY_TIME_READ,
- ALLOW_DENSITY_READ,
- ALLOW_DIFFUSION_READ,
- ALLOW_DISTANCE_FILTER_READ,
- ALLOW_FREQUENCY_SCALE_FACTOR_READ,
- ALLOW_REFLECTION_COEFFICIENT_READ,
- ALLOW_REFLECTION_DELAY_READ,
- ALLOW_REVERB_COEFFICIENT_READ,
- ALLOW_REVERB_DELAY_READ,
- ALLOW_REVERB_ORDER_READ,
- ALLOW_ROLLOFF_READ,
- ALLOW_VELOCITY_SCALE_FACTOR_READ
- };
-
- /** *****************
- *
- * Constructors
- *
- * ******************/
- /**
- * Constructs and initializes a new AuralAttributes object using default
- * parameters. The following default values are used:
- *
- */
- public AuralAttributes() {
- // Just use default values
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
- }
-
- /**
- * Constructs and initializes a new AuralAttributes object using specified
- * parameters including an array of Point2f for the distanceFilter.
- * @param gain amplitude scale factor
- * @param rolloff atmospheric (changing speed of sound) scale factor
- * @param reflectionCoefficient reflective/absorptive factor applied to reflections
- * @param reverbDelay delay time before start of reverberation
- * @param reverbOrder limit to number of reflections added to reverb signal
- * @param distanceFilter frequency cutoff
- * @param frequencyScaleFactor applied to change of pitch
- * @param velocityScaleFactor applied to velocity of sound in relation to listener
- */
- public AuralAttributes(float gain,
- float rolloff,
- float reflectionCoefficient,
- float reverbDelay,
- int reverbOrder,
- Point2f[] distanceFilter,
- float frequencyScaleFactor,
- float velocityScaleFactor) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((AuralAttributesRetained)this.retained).setAttributeGain(gain);
- ((AuralAttributesRetained)this.retained).setRolloff(rolloff);
- ((AuralAttributesRetained)this.retained).setReflectionCoefficient(
- reflectionCoefficient);
- ((AuralAttributesRetained)this.retained).setReverbDelay(reverbDelay);
- ((AuralAttributesRetained)this.retained).setReverbOrder(reverbOrder);
- ((AuralAttributesRetained)this.retained).setDistanceFilter(
- distanceFilter);
- ((AuralAttributesRetained)this.retained).setFrequencyScaleFactor(
- frequencyScaleFactor);
- ((AuralAttributesRetained)this.retained).setVelocityScaleFactor(
- velocityScaleFactor);
- }
- /**
- * Constructs and initializes a new AuralAttributes object using specified
- * parameters with separate float arrays for components of distanceFilter.
- * @param gain amplitude scale factor
- * @param rolloff atmospheric (changing speed of sound) scale factor
- * @param reflectionCoefficient reflection/absorption factor applied to reflections
- * @param reverbDelay delay time before start of reverberation
- * @param reverbOrder limit to number of reflections added to reverb signal
- * @param distance filter frequency cutoff distances
- * @param frequencyCutoff distance filter frequency cutoff
- * @param frequencyScaleFactor applied to velocity/wave-length
- * @param velocityScaleFactor applied to velocity of sound in relation to listener
- */
- public AuralAttributes(float gain,
- float rolloff,
- float reflectionCoefficient,
- float reverbDelay,
- int reverbOrder,
- float[] distance,
- float[] frequencyCutoff,
- float frequencyScaleFactor,
- float velocityScaleFactor) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((AuralAttributesRetained)this.retained).setAttributeGain(gain);
- ((AuralAttributesRetained)this.retained).setRolloff(rolloff);
- ((AuralAttributesRetained)this.retained).setReflectionCoefficient(
- reflectionCoefficient);
- ((AuralAttributesRetained)this.retained).setReverbDelay(reverbDelay);
- ((AuralAttributesRetained)this.retained).setReverbOrder(reverbOrder);
- ((AuralAttributesRetained)this.retained).setDistanceFilter(distance,
- frequencyCutoff);
- ((AuralAttributesRetained)this.retained).setFrequencyScaleFactor(
- frequencyScaleFactor);
- ((AuralAttributesRetained)this.retained).setVelocityScaleFactor(
- velocityScaleFactor);
- }
-
- /**
- * Constructs and initializes a new AuralAttributes object using specified
- * parameters with separate float arrays for components of distanceFilter
- * and full reverb parameters.
- * @param gain amplitude scale factor
- * @param rolloff atmospheric (changing speed of sound) scale factor
- * @param reflectionCoefficient factor applied to early reflections
- * @param reflectionDelay delay time before start of early reflections
- * @param reverbCoefficient factor applied to late reflections
- * @param reverbDelay delay time before start of late reverberation
- * @param decayTime time (in milliseconds) reverb takes to decay to -60bD
- * @param decayFilter reverb decay filter frequency cutoff
- * @param diffusion percentage of echo dispersement between min and max
- * @param density percentage of modal density between min and max
- * @param distance filter frequency cutoff distances
- * @param frequencyCutoff distance filter frequency cutoff
- * @param frequencyScaleFactor applied to velocity/wave-length
- * @param velocityScaleFactor applied to velocity of sound in relation to listener
- * @since Java 3D 1.3
- */
- public AuralAttributes(float gain,
- float rolloff,
- float reflectionCoefficient,
- float reflectionDelay,
- float reverbCoefficient,
- float reverbDelay,
- float decayTime,
- float decayFilter,
- float diffusion,
- float density,
- float[] distance,
- float[] frequencyCutoff,
- float frequencyScaleFactor,
- float velocityScaleFactor) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((AuralAttributesRetained)this.retained).setAttributeGain(gain);
- ((AuralAttributesRetained)this.retained).setRolloff(rolloff);
- ((AuralAttributesRetained)this.retained).setReflectionCoefficient(
- reflectionCoefficient);
- ((AuralAttributesRetained)this.retained).setReflectionDelay(
- reflectionDelay);
- ((AuralAttributesRetained)this.retained).setReverbCoefficient(
- reverbCoefficient);
- ((AuralAttributesRetained)this.retained).setReverbDelay(
- reverbDelay);
- ((AuralAttributesRetained)this.retained).setDecayTime(decayTime);
- ((AuralAttributesRetained)this.retained).setDecayFilter(decayFilter);
- ((AuralAttributesRetained)this.retained).setDiffusion(diffusion);
- ((AuralAttributesRetained)this.retained).setDensity(density);
- ((AuralAttributesRetained)this.retained).setDistanceFilter(distance,
- frequencyCutoff);
- ((AuralAttributesRetained)this.retained).setFrequencyScaleFactor(
- frequencyScaleFactor);
- ((AuralAttributesRetained)this.retained).setVelocityScaleFactor(
- velocityScaleFactor);
- }
-
- /**
- * Creates the retained mode AuralAttributesRetained object that this
- * component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new AuralAttributesRetained();
- this.retained.setSource(this);
- }
-
- /** ****************************************
- *
- * Attribute Gain
- *
- * ****************************************/
- /**
- * Set Attribute Gain (amplitude) scale factor.
- * @param gain scale factor applied to amplitude of direct and reflected sound
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setAttributeGain(float gain) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_ATTRIBUTE_GAIN_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes0"));
- ((AuralAttributesRetained)this.retained).setAttributeGain(gain);
- }
-
- /**
- * Retrieve Attribute Gain (amplitude).
- * @return gain amplitude scale factor
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getAttributeGain() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_ATTRIBUTE_GAIN_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes1"));
- return ((AuralAttributesRetained)this.retained).getAttributeGain();
- }
-
- /**
- * Set Attribute Gain Rolloff.
- * @param rolloff atmospheric gain scale factor (changing speed of sound)
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setRolloff(float rolloff) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_ROLLOFF_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes2"));
- ((AuralAttributesRetained)this.retained).setRolloff(rolloff);
- }
-
- /**
- * Retrieve Attribute Gain Rolloff.
- * @return rolloff atmospheric gain scale factor (changing speed of sound)
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getRolloff() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_ROLLOFF_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes3"));
- return ((AuralAttributesRetained)this.retained).getRolloff();
- }
-
- /**
- * Set Reflective Coefficient.
- * Scales the amplitude of the early reflections of reverberated sounds
- * @param coefficient reflection/absorption factor applied to reflections
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setReflectionCoefficient(float coefficient) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REFLECTION_COEFFICIENT_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes4"));
- ((AuralAttributesRetained)this.retained).setReflectionCoefficient(coefficient);
- }
-
- /**
- * Retrieve Reflective Coefficient.
- * @return reflection coeff reflection/absorption factor
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getReflectionCoefficient() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REFLECTION_COEFFICIENT_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes21"));
- return ((AuralAttributesRetained)this.retained).getReflectionCoefficient();
- }
-
- /*********************
- *
- * Early Reflection Delay
- *
- ********************/
- /**
- * Set early Refection Delay Time.
- * In this form, the parameter specifies the time between the start of the
- * direct, unreflected sound and the start of first order early reflections.
- * In this method, this time is explicitly given in milliseconds.
- * @param reflectionDelay delay time before start of reverberation
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setReflectionDelay(float reflectionDelay) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REFLECTION_DELAY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes22"));
- ((AuralAttributesRetained)this.retained).setReflectionDelay(reflectionDelay);
- }
-
- /**
- * Retrieve Reflection Delay Time.
- * @return reflection delay time
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getReflectionDelay() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REFLECTION_DELAY_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes23"));
- return ((AuralAttributesRetained)this.retained).getReflectionDelay();
- }
-
- /** ******************
- *
- * Reverb Coefficient
- *
- ********************/
- /**
- * Set Reverb Coefficient.
- * Scale the amplitude of the late reflections including the decaying tail
- * of reverberated sound.
- * @param coefficient reflective/absorptive factor applied to late reflections
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setReverbCoefficient(float coefficient) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_COEFFICIENT_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes24"));
- ((AuralAttributesRetained)this.retained).setReverbCoefficient(coefficient);
- }
-
- /**
- * Retrieve Reverb Coefficient.
- * @return late reflection coeff. reflection/absorption factor
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getReverbCoefficient() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_COEFFICIENT_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes25"));
- return ((AuralAttributesRetained)this.retained).getReverbCoefficient();
- }
-
- /*********************
- *
- * Reverberation Delay
- *
- ********************/
- /**
- * Set Reverberation Delay Time.
- * In this form, the parameter specifies the time between the start of the
- * direct, unreflected sound and the start of reverberation. In this
- * method, this time is explicitly given in milliseconds.
- * @param reverbDelay delay time before start of reverberation
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setReverbDelay(float reverbDelay) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_DELAY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes5"));
- ((AuralAttributesRetained)this.retained).setReverbDelay(reverbDelay);
- }
-
- /**
- * Retrieve Reverberation Delay Time.
- * @return reverb delay time
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getReverbDelay() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_DELAY_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes7"));
- return ((AuralAttributesRetained)this.retained).getReverbDelay();
- }
-
- /** ******************
- *
- * Decay Time
- *
- ********************/
- /**
- * Set Decay Time
- * Length of time from the start of late reflections reverberation volume
- * takes to decay to effective zero (-60 dB of initial signal amplitude).
- * @param decayTime of late reflections (reverb) in milliseconds
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setDecayTime(float decayTime) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DECAY_TIME_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes28"));
- ((AuralAttributesRetained)this.retained).setDecayTime(decayTime);
- }
-
- /**
- * Retrieve Decay Time.
- * @return reverb decay time
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getDecayTime() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DECAY_TIME_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes29"));
- return ((AuralAttributesRetained)this.retained).getDecayTime();
- }
-
- /** ******************
- *
- * Decay Filter
- *
- ********************/
- /**
- * Set Decay Filter
- * In this form, reverberation decay filtering is defined as a low-pass
- * filter, starting at the given reference frequency. This allows for
- * higher frequencies to be attenuated at a different (typically faster)
- * rate than lower frequencies.
- * @param frequencyCutoff of reverberation decay low-pass filter
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setDecayFilter(float frequencyCutoff) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DECAY_FILTER_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes30"));
- ((AuralAttributesRetained)this.retained).setDecayFilter(frequencyCutoff);
- }
-
- /**
- * Retrieve Decay Filter.
- * @return reverb decay filter cutoff frequency
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getDecayFilter() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DECAY_FILTER_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes31"));
- return ((AuralAttributesRetained)this.retained).getDecayFilter();
- }
-
- /** ******************
- *
- * Diffusion
- *
- ********************/
- /**
- * Set Diffusion.
- * Sets the echo dispersement of reverberation to an amount between
- * the minimum (0.0) to the maximum (1.0) available. Changing this
- * increases/decreases the 'smoothness' of reverb decay.
- * @param ratio reverberation echo dispersement factor
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setDiffusion(float ratio) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DIFFUSION_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes32"));
- ((AuralAttributesRetained)this.retained).setDiffusion(ratio);
- }
-
- /**
- * Retrieve Diffusion.
- * @return reverb diffusion ratio
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getDiffusion() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_DIFFUSION_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes33"));
- return ((AuralAttributesRetained)this.retained).getDiffusion();
- }
-
- /** ******************
- *
- * Density
- *
- ********************/
- /**
- * Set Density.
- * Sets the density of reverberation to an amount between
- * the minimum (0.0) to the maximum (1.0) available. Changing this
- * effects the spectral coloration (timbre) of late reflections.
- * @param ratio reverberation modal density factor
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public void setDensity(float ratio) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_DENSITY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes34"));
- ((AuralAttributesRetained)this.retained).setDensity(ratio);
- }
-
- /**
- * Retrieve Density.
- * @return reverb density
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.3
- */
- public float getDensity() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DENSITY_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes35"));
- return ((AuralAttributesRetained)this.retained).getDensity();
- }
-
- /**
- * @deprecated As of Java 3D version 1.2, replaced by
- * setReverbBounds(Bounds)
- */
- public void setReverbDelay(Bounds reverbVolume) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_DELAY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes5"));
- ((AuralAttributesRetained)this.retained).setReverbBounds(reverbVolume);
- }
-
- /**
- * Set Reverberation Bounds volume.
- * In this form, the reverberation bounds volume parameter is used to
- * calculate the reverberation Delay and Decay times. Specification
- * of a non-null bounding volume causes the explicit values given for
- * Reverb Delay and Decay to be overridden by the implicit values
- * calculated from these bounds.
- * ALLOW_REVERB_DELAY_WRITE flag used setting capability of this method.
- * @param reverbVolume the bounding region
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.2
- */
- public void setReverbBounds(Bounds reverbVolume) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_DELAY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes26"));
- ((AuralAttributesRetained)this.retained).setReverbBounds(reverbVolume);
- }
-
- /**
- * Retrieve Reverberation Delay Bounds volume.
- * @return reverb bounds volume that defines the Reverberation space and
- * indirectly the delay/decay
- * ALLOW_REVERB_DELAY_READ flag used setting capability of this method.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @since Java 3D 1.2
- */
- public Bounds getReverbBounds() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_DELAY_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes27"));
- return ((AuralAttributesRetained)this.retained).getReverbBounds();
- }
-
- /** *******************
- *
- * Reverberation Order
- *
- ********************/
- /**
- * Set Reverberation Order
- * This parameter limits the number of times reflections are added
- * to the reverberation being rendered.
- * A non-positive value specifies an unbounded number of reflections.
- * @param reverbOrder limit to the number of times reflections added to reverb signal
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setReverbOrder(int reverbOrder) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_REVERB_ORDER_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes8"));
- ((AuralAttributesRetained)this.retained).setReverbOrder(reverbOrder);
- }
-
- /**
- * Retrieve Reverberation Order
- * @return reverb order
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public int getReverbOrder() {
- if (!this.getCapability(ALLOW_REVERB_ORDER_READ))
- if (isLiveOrCompiled())
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes9"));
- return ((AuralAttributesRetained)this.retained).getReverbOrder();
- }
-
- /**
- * Set Distance Filter using a single array containing distances and
- * frequency cutoff as pairs of values as a single array of Point2f.
- * @param attenuation array of pairs of distance and frequency cutoff
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setDistanceFilter(Point2f[] attenuation) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DISTANCE_FILTER_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes10"));
- ((AuralAttributesRetained)this.retained).setDistanceFilter(attenuation);
- }
-
- /**
- * Set Distance Filter using separate arrays for distances and frequency
- * cutoff. The distance and frequencyCutoff arrays should be of the same
- * length. If the frequencyCutoff array length is greater than the distance
- * array length, the frequencyCutoff array elements beyond the length of
- * the distance array are ignored. If the frequencyCutoff array is shorter
- * than the distance array, the last frequencyCutoff array value is repeated
- * to fill an array of length equal to distance array.
- * @param distance array of float distance with corresponding cutoff values
- * @param frequencyCutoff array of frequency cutoff values in Hertz
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setDistanceFilter(float[] distance,
- float[] frequencyCutoff) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DISTANCE_FILTER_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes10"));
- ((AuralAttributesRetained)this.retained).setDistanceFilter(
- distance, frequencyCutoff );
- }
-
- /**
- * Retrieve Distance Filter array length.
- * @return attenuation array length
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public int getDistanceFilterLength() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DISTANCE_FILTER_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes12"));
- return (((AuralAttributesRetained)this.retained).getDistanceFilterLength());
- }
- /**
- * Retrieve Distance Filter as a single array containing distances
- * and frequency cutoff. The distance filter is copied into
- * the specified array.
- * The array must be large enough to hold all of the points.
- * The individual array elements must be allocated by the caller.
- * @param attenuation array of pairs of distance and frequency cutoff values
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void getDistanceFilter(Point2f[] attenuation) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DISTANCE_FILTER_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes12"));
- ((AuralAttributesRetained)this.retained).getDistanceFilter(attenuation);
- }
-
- /**
- * Retrieve Distance Filter in separate distance and frequency cutoff arrays.
- * The arrays must be large enough to hold all of the distance
- * and frequency cutoff values.
- * @param distance array
- * @param frequencyCutoff cutoff array
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void getDistanceFilter(float[] distance,
- float[] frequencyCutoff) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_DISTANCE_FILTER_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes12"));
- ((AuralAttributesRetained)this.retained).getDistanceFilter(
- distance, frequencyCutoff);
- }
-
- /**
- * This parameter specifies a scale factor applied to the frequency
- * of sound during rendering playback. If the Doppler effect is
- * disabled, this scale factor can be used to increase or
- * decrease the original pitch of the sound. During rendering,
- * this scale factor expands or contracts the usual frequency shift
- * applied to the sound source due to Doppler calculations.
- * Valid values are >= 0.0.
- * A value of zero causes playing sounds to pause.
- * @param frequencyScaleFactor factor applied to change of frequency
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setFrequencyScaleFactor(float frequencyScaleFactor) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_FREQUENCY_SCALE_FACTOR_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes15"));
- ((AuralAttributesRetained)this.retained).setFrequencyScaleFactor(
- frequencyScaleFactor);
- }
-
- /**
- * Retrieve Frequency Scale Factor.
- * @return scaleFactor factor applied to change of frequency
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getFrequencyScaleFactor() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_FREQUENCY_SCALE_FACTOR_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes17"));
- return ((AuralAttributesRetained)this.retained).getFrequencyScaleFactor();
- }
-
- /** ******************************
- *
- * Velocity Scale Factor
- *
- *********************************/
- /**
- * Set Velocity scale factor applied during Doppler Effect calculation.
- * This parameter specifies a scale factor applied to the velocity of
- * the sound relative to the listener's position and movement in relation
- * to the sound's position and movement. This scale factor is multipled
- * by the calculated velocity portion of the Doppler effect equation used
- * during sound rendering.
- * A value of zero disables Doppler calculations.
- * @param velocityScaleFactor applied to velocity of sound in relation
- * to listener
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setVelocityScaleFactor(float velocityScaleFactor) {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_VELOCITY_SCALE_FACTOR_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes19"));
- ((AuralAttributesRetained)this.retained).setVelocityScaleFactor(
- velocityScaleFactor);
- }
-
- /**
- * Retrieve Velocity Scale Factor used to calculate Doppler Effect.
- * @return scale factor applied to Doppler velocity of sound
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public float getVelocityScaleFactor() {
- if (isLiveOrCompiled())
- if (!this.getCapability(ALLOW_VELOCITY_SCALE_FACTOR_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("AuralAttributes20"));
- return ((AuralAttributesRetained)this.retained).getVelocityScaleFactor();
- }
-
-
- /**
- * @deprecated As of Java 3D version 1.2, replaced by
- * cloneNodeComponent(boolean forceDuplicate)
- */
- @Override
- public NodeComponent cloneNodeComponent() {
- AuralAttributes a = new AuralAttributes();
- a.duplicateNodeComponent(this, this.forceDuplicate);
- return a;
- }
-
-
- /**
- * Copies all AuralAttributes information from originalNodeComponent into
- * the current node. This method is called from the
- * duplicateNode method. This routine does
- * the actual duplication of all "local data" (any data defined in
- * this object).
- *
- * @param originalNodeComponent the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(NodeComponent originalNodeComponent,
- boolean forceDuplicate) {
- super.duplicateAttributes(originalNodeComponent,
- forceDuplicate);
-
- AuralAttributesRetained aural = (AuralAttributesRetained) originalNodeComponent.retained;
- AuralAttributesRetained rt = (AuralAttributesRetained) retained;
-
- rt.setAttributeGain(aural.getAttributeGain());
- rt.setRolloff(aural.getRolloff());
- rt.setReflectionCoefficient(aural.getReflectionCoefficient());
- rt.setReverbDelay(aural.getReverbDelay());
- rt.setReverbOrder(aural.getReverbOrder());
- rt.setReverbBounds(aural.getReverbBounds());
- rt.setFrequencyScaleFactor(aural.getFrequencyScaleFactor());
- rt.setVelocityScaleFactor(aural.getVelocityScaleFactor());
- int len = aural.getDistanceFilterLength();
- float distance[] = new float[len];
- float frequencyCutoff[] = new float[len];
- aural.getDistanceFilter(distance, frequencyCutoff);
- rt.setDistanceFilter(distance, frequencyCutoff);
- }
-}
diff --git a/src/classes/share/javax/media/j3d/AuralAttributesRetained.java b/src/classes/share/javax/media/j3d/AuralAttributesRetained.java
deleted file mode 100644
index f5e3d6a..0000000
--- a/src/classes/share/javax/media/j3d/AuralAttributesRetained.java
+++ /dev/null
@@ -1,667 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Point2f;
-
-/**
- * The AuralAttributesRetained object defines all rendering state that can
- * be set as a component object of a retained Soundscape node.
- */
-class AuralAttributesRetained extends NodeComponentRetained {
-
- /**
- * Gain Scale Factor applied to source with this attribute
- */
- float attributeGain = 1.0f; // Valid values are >= 0.0.
-
- /**
- * Atmospheric Rolloff - speed of sound - coeff
- * Normal gain attenuation based on distance of sound from
- * listener is scaled by a rolloff factor, which can increase
- * or decrease the usual inverse-distance-square value.
- */
- float rolloff = 1.0f; // Valid values are >= 0.0
- static final float SPEED_OF_SOUND = 0.344f; // in meters/milliseconds
-
- /*
- * Reverberation
- *
- * Within Java 3D's model for auralization, the components to
- * reverberation for a particular space are:
- * Reflection and Reverb Coefficients -
- * attenuation of sound (uniform for all frequencies) due to
- * absorption of reflected sound off materials within the
- * listening space.
- * Reflection and Reverb Delay -
- * approximating time from the start of the direct sound that
- * initial early and late reflection waves take to reach listener.
- * Reverb Decay -
- * approximating time from the start of the direct sound that
- * reverberation is audible.
- */
-
- /**
- * Coefficients for reverberation
- * The (early) Reflection and Reverberation coefficient scale factors
- * are used to approximate the reflective/absorptive characteristics
- * of the surfaces in this bounded Auralizaton environment.
- * Theses scale factors is applied to sound's amplitude regardless
- * of sound's position.
- * Value of 1.0 represents complete (unattenuated) sound reflection.
- * Value of 0.0 represents full absorption; reverberation is disabled.
- */
- float reflectionCoefficient = 0.0f; // Range of values 0.0 to 1.0
- float reverbCoefficient = 1.0f; // Range of values 0.0 to 1.0
-
- /**
- * Time Delays in milliseconds
- * Set with either explicitly with time, or impliciticly by supplying
- * bounds volume and having the delay time calculated.
- * Bounds of reverberation space does not have to be the same as
- * Attribute bounds.
- */
- float reflectionDelay = 20.0f; // in milliseconds
- float reverbDelay = 40.0f; // in milliseconds
- Bounds reverbBounds = null;
-
- /**
- * Decay parameters
- * Length and timbre of reverb decay tail
- */
- float decayTime = 1000.0f; // in milliseconds
- float decayFilter = 5000.0f; // low-pass cutoff frequency
-
- /**
- * Reverb Diffusion and Density ratios (0=min, 1=max)
- */
- float diffusion = 1.0f;
- float density = 1.0f;
-
- /**
- * Reverberation order
- * This limits the number of Reverberation iterations executed while
- * sound is being reverberated. As long as reflection coefficient is
- * small enough, the reverberated sound decreases (as it would naturally)
- * each successive iteration.
- * Value of > zero defines the greatest reflection order to be used by
- * the reverberator.
- * All positive values are used as the number of loop iteration.
- * Value of <= zero signifies that reverberation is to loop until reverb
- * gain reaches zero (-60dB or 1/1000 of sound amplitude).
- */
- int reverbOrder = 0;
-
- /**
- * Distance Filter
- * Each sound source is attenuated by a filter based on it's distance
- * from the listener.
- * For now the only supported filterType will be LOW_PASS frequency cutoff.
- * At some time full FIR filtering will be supported.
- */
- static final int NO_FILTERING = -1;
- static final int LOW_PASS = 1;
-
- int filterType = NO_FILTERING;
- float[] distance = null;
- float[] frequencyCutoff = null;
-
- /**
- * Doppler Effect parameters
- * Between two snapshots of the head and sound source positions some
- * delta time apart, the distance between head and source is compared.
- * If there has been no change in the distance between head and sound
- * source over this delta time:
- * f' = f
- *
- * If there has been a change in the distance between head and sound:
- * f' = f * Af * v
- *
- * When head and sound are moving towards each other then
- * | (S * Ar) + (deltaV(h,t) * Av) |
- * v = | -------------------------------- |
- * | (S * Ar) - (deltaV(s,t) * Av) |
- *
- * When head and sound are moving away from each other then
- * | (S * Ar) - (deltaV(h,t) * Av) |
- * v = | -------------------------------- |
- * | (S * Ar) + (deltaV(s,t) * Av) |
- *
- *
- * Af = AuralAttribute frequency scalefactor
- * Ar = AuralAttribute rolloff scalefactor
- * Av = AuralAttribute velocity scalefactor
- * deltaV = delta velocity
- * f = frequency of sound
- * h = Listeners head position
- * v = Ratio of delta velocities
- * Vh = Vector from center ear to sound source
- * S = Speed of sound
- * s = Sound source position
- * t = time
- *
- * If adjusted velocity of head or adjusted velocity of sound is
- * greater than adjusted speed of sound, f' is undefined.
- */
- /**
- * Frequency Scale Factor
- * used to increase or reduce the change of frequency associated
- * with normal rate of playback.
- * Value of zero causes sounds to be paused.
- */
- float frequencyScaleFactor = 1.0f;
- /**
- * Velocity Scale Factor
- * Float value applied to the Change of distance between Sound Source
- * and Listener over some delta time. Non-zero if listener moving
- * even if sound is not. Value of zero implies no Doppler applied.
- */
- float velocityScaleFactor = 0.0f;
-
- /**
- * This boolean is set when something changes in the attributes
- */
- boolean aaDirty = true;
-
- /**
- * The mirror copy of this AuralAttributes.
- */
- AuralAttributesRetained mirrorAa = null;
-
- /**
- ** Debug print mechanism for Sound nodes
- **/
- static final // 'static final' so compiler doesn't include debugPrint calls
- boolean debugFlag = false;
-
- static final // 'static final' so internal error message are not compiled
- boolean internalErrors = false;
-
- void debugPrint(String message) {
- if (debugFlag) // leave test in in case debugFlag made non-static final
- System.err.println(message);
- }
-
-
- // ****************************************
- //
- // Set and Get individual attribute values
- //
- // ****************************************
-
- /**
- * Set Attribute Gain (amplitude)
- * @param gain scale factor applied to amplitude
- */
- void setAttributeGain(float gain) {
- this.attributeGain = gain;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Attribute Gain (amplitude)
- * @return gain amplitude scale factor
- */
- float getAttributeGain() {
- return this.attributeGain;
- }
-
- /**
- * Set Attribute Gain Rolloff
- * @param rolloff atmospheric gain scale factor (changing speed of sound)
- */
- void setRolloff(float rolloff) {
- this.rolloff = rolloff;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Attribute Gain Rolloff
- * @return rolloff atmospheric gain scale factor (changing speed of sound)
- */
- float getRolloff() {
- return this.rolloff;
- }
-
- /**
- * Set Reflective Coefficient
- * @param reflectionCoefficient reflection/absorption factor applied to
- * early reflections.
- */
- void setReflectionCoefficient(float reflectionCoefficient) {
- this.reflectionCoefficient = reflectionCoefficient;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Reflective Coefficient
- * @return reflection coeff reflection/absorption factor applied to
- * early reflections.
- */
- float getReflectionCoefficient() {
- return this.reflectionCoefficient;
- }
-
- /**
- * Set Reflection Delay Time
- * @param reflectionDelay time before the start of early (first order)
- * reflections.
- */
- void setReflectionDelay(float reflectionDelay) {
- this.reflectionDelay = reflectionDelay;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Reflection Delay Time
- * @return reflection delay time
- */
- float getReflectionDelay() {
- return this.reflectionDelay;
- }
-
- /**
- * Set Reverb Coefficient
- * @param reverbCoefficient reflection/absorption factor applied to
- * late reflections.
- */
- void setReverbCoefficient(float reverbCoefficient) {
- this.reverbCoefficient = reverbCoefficient;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Reverb Coefficient
- * @return reverb coeff reflection/absorption factor applied to late
- * reflections.
- */
- float getReverbCoefficient() {
- return this.reverbCoefficient;
- }
-
- /**
- * Set Revereration Delay Time
- * @param reverbDelay time between each order of reflection
- */
- void setReverbDelay(float reverbDelay) {
- this.reverbDelay = reverbDelay;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Revereration Delay Time
- * @return reverb delay time between each order of reflection
- */
- float getReverbDelay() {
- return this.reverbDelay;
- }
- /**
- * Set Decay Time
- * @param decayTime length of time reverb takes to decay
- */
- void setDecayTime(float decayTime) {
- this.decayTime = decayTime;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Revereration Decay Time
- * @return reverb delay time
- */
- float getDecayTime() {
- return this.decayTime;
- }
-
- /**
- * Set Decay Filter
- * @param decayFilter frequency referenced used in low-pass filtering
- */
- void setDecayFilter(float decayFilter) {
- this.decayFilter = decayFilter;
- this.aaDirty = true;
- notifyUsers();
- }
-
- /**
- * Retrieve Revereration Decay Filter
- * @return reverb delay Filter
- */
- float getDecayFilter() {
- return this.decayFilter;
- }
-
- /**
- * Set Reverb Diffusion
- * @param diffusion ratio between min and max device diffusion settings
- */
- void setDiffusion(float diffusion) {
- this.diffusion = diffusion;
- this.aaDirty = true;
- notifyUsers();
- }
-
- /**
- * Retrieve Revereration Decay Diffusion
- * @return reverb diffusion
- */
- float getDiffusion() {
- return this.diffusion;
- }
-
- /**
- * Set Reverb Density
- * @param density ratio between min and max device density settings
- */
- void setDensity(float density) {
- this.density = density;
- this.aaDirty = true;
- notifyUsers();
- }
-
- /**
- * Retrieve Revereration Density
- * @return reverb density
- */
- float getDensity() {
- return this.density;
- }
-
-
- /**
- * Set Revereration Bounds
- * @param reverbVolume bounds used to approximate reverb time.
- */
- synchronized void setReverbBounds(Bounds reverbVolume) {
- this.reverbBounds = reverbVolume;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Revereration Delay Bounds volume
- * @return reverb bounds volume that defines the Reverberation space and
- * indirectly the delay
- */
- Bounds getReverbBounds() {
- return this.reverbBounds;
- }
-
- /**
- * Set Reverberation Order of Reflections
- * @param reverbOrder number of times reflections added to reverb signal
- */
- void setReverbOrder(int reverbOrder) {
- this.reverbOrder = reverbOrder;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Reverberation Order of Reflections
- * @return reverb order number of times reflections added to reverb signal
- */
- int getReverbOrder() {
- return this.reverbOrder;
- }
-
- /**
- * Set Distance Filter (based on distances and frequency cutoff)
- * @param attenuation array of pairs defining distance frequency cutoff
- */
- synchronized void setDistanceFilter(Point2f[] attenuation) {
- if (attenuation == null) {
- this.filterType = NO_FILTERING;
- return;
- }
- int attenuationLength = attenuation.length;
- if (attenuationLength == 0) {
- this.filterType = NO_FILTERING;
- return;
- }
- this.filterType = LOW_PASS;
- // Reallocate every time unless size of new array equal old array
- if ( distance == null ||
- (distance != null && (distance.length != attenuationLength) ) ) {
- this.distance = new float[attenuationLength];
- this.frequencyCutoff = new float[attenuationLength];
- }
- for (int i = 0; i< attenuationLength; i++) {
- this.distance[i] = attenuation[i].x;
- this.frequencyCutoff[i] = attenuation[i].y;
- }
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Set Distance Filter (based on distances and frequency cutoff) using
- * separate arrays
- * @param distance array containing distance values
- * @param filter array containing low-pass frequency cutoff values
- */
- synchronized void setDistanceFilter(float[] distance, float[] filter) {
- if (distance == null || filter == null) {
- this.filterType = NO_FILTERING;
- return;
- }
- int distanceLength = distance.length;
- int filterLength = filter.length;
- if (distanceLength == 0 || filterLength == 0) {
- this.filterType = NO_FILTERING;
- return;
- }
- // Reallocate every time unless size of new array equal old array
- if ( this.distance == null ||
- ( this.distance != null &&
- (this.distance.length != filterLength) ) ) {
- this.distance = new float[distanceLength];
- this.frequencyCutoff = new float[distanceLength];
- }
- this.filterType = LOW_PASS;
- // Copy the distance array into nodes field
- System.arraycopy(distance, 0, this.distance, 0, distanceLength);
- // Copy the filter array an array of same length as the distance array
- if (distanceLength <= filterLength) {
- System.arraycopy(filter, 0, this.frequencyCutoff,0, distanceLength);
- }
- else {
- System.arraycopy(filter, 0, this.frequencyCutoff, 0, filterLength);
- // Extend filter array to length of distance array by
- // replicate last filter values.
- for (int i=filterLength; i< distanceLength; i++) {
- this.frequencyCutoff[i] = filter[filterLength - 1];
- }
- }
- if (debugFlag) {
- debugPrint("AAR setDistanceFilter(D,F)");
- for (int jj=0;jj attenuation.length)
- distanceLength = attenuation.length;
- for (int i=0; i< distanceLength; i++) {
- attenuation[i].x = this.distance[i];
- if (filterType == NO_FILTERING)
- attenuation[i].y = Sound.NO_FILTER;
- else if (filterType == LOW_PASS)
- attenuation[i].y = this.frequencyCutoff[i];
- if (debugFlag)
- debugPrint("AAR: getDistF: " + attenuation[i].x + ", " +
- attenuation[i].y);
- }
- }
- /**
- * Retrieve Distance Filter as arrays distances and frequency cutoff array
- * @param distance array of float values
- * @param frequencyCutoff array of float cutoff filter values in Hertz
- */
- void getDistanceFilter(float[] distance, float[] filter) {
- // Write into existing param arrays already allocated
- if (distance == null || filter == null)
- return;
- if (this.distance == null || this.frequencyCutoff == null)
- return;
- int distanceLength = this.distance.length;
- // check that distance parameter large enough to contain auralAttribute
- // distance array
- // We can assume that distance and filter lengths are the same
- // and are non-zero.
- if (distance.length < distanceLength)
- // parameter array not large enough to hold all this.distance data
- distanceLength = distance.length;
- System.arraycopy(this.distance, 0, distance, 0, distanceLength);
- if (debugFlag)
- debugPrint("AAR getDistanceFilter(D,F) " + this.distance[0]);
- int filterLength = this.frequencyCutoff.length;
- if (filter.length < filterLength)
- // parameter array not large enough to hold all this.filter data
- filterLength = filter.length;
- if (filterType == NO_FILTERING) {
- for (int i=0; i< filterLength; i++)
- filter[i] = Sound.NO_FILTER;
- }
- if (filterType == LOW_PASS) {
- System.arraycopy(this.frequencyCutoff, 0, filter, 0, filterLength);
- }
- if (debugFlag)
- debugPrint(", " + this.frequencyCutoff[0]);
- }
-
- /**
- * Set Frequency Scale Factor
- * @param frequencyScaleFactor factor applied to sound's base frequency
- */
- void setFrequencyScaleFactor(float frequencyScaleFactor) {
- this.frequencyScaleFactor = frequencyScaleFactor;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Frequency Scale Factor
- * @return frequency scale factor applied to sound's base frequency
- */
- float getFrequencyScaleFactor() {
- return this.frequencyScaleFactor;
- }
-
- /**
- * Set Velocity ScaleFactor used in calculating Doppler Effect
- * @param velocityScaleFactor applied to velocity of sound in relation to listener
- */
- void setVelocityScaleFactor(float velocityScaleFactor) {
- this.velocityScaleFactor = velocityScaleFactor;
- this.aaDirty = true;
- notifyUsers();
- }
- /**
- * Retrieve Velocity ScaleFactor used in calculating Doppler Effect
- * @return velocity scale factor
- */
- float getVelocityScaleFactor() {
- return this.velocityScaleFactor;
- }
-
- synchronized void reset(AuralAttributesRetained aa) {
- int i;
-
- this.attributeGain = aa.attributeGain;
- this.rolloff = aa.rolloff;
- this.reflectionCoefficient = aa.reflectionCoefficient;
- this.reverbCoefficient = aa.reverbCoefficient;
- this.reflectionDelay = aa.reflectionDelay;
- this.reverbDelay = aa.reverbDelay;
- this.reverbBounds = aa.reverbBounds;
- this.reverbOrder = aa.reverbOrder;
- this.decayTime = aa.decayTime;
- this.decayFilter = aa.decayFilter;
- this.diffusion = aa.diffusion;
- this.density = aa.density;
- this.frequencyScaleFactor = aa.frequencyScaleFactor;
- this.velocityScaleFactor = aa.velocityScaleFactor;
-
- if (aa.distance != null) {
- this.distance = new float[aa.distance.length];
- if (debugFlag)
- debugPrint("reset aa; aa.distance.length = " + this.distance.length);
- System.arraycopy(aa.distance, 0, this.distance, 0, this.distance.length);
- }
- else
- if (debugFlag)
- debugPrint("reset aa; aa.distance = null");
- if (aa.frequencyCutoff != null) {
- this.frequencyCutoff = new float[aa.frequencyCutoff.length];
- if (debugFlag)
- debugPrint("reset aa; aa.frequencyCutoff.length = " + this.frequencyCutoff.length);
- System.arraycopy(aa.frequencyCutoff, 0, this.frequencyCutoff, 0,
- this.frequencyCutoff.length);
- }
- else
- if (debugFlag)
- debugPrint("reset aa; aa.frequencyCutoff = null");
- // XXXX: (Enhancement) Why are these dirtyFlag cleared rather than aa->this
- this.aaDirty = false;
- aa.aaDirty = false;
- }
-
- void update(AuralAttributesRetained aa) {
- this.reset(aa);
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java b/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java
deleted file mode 100644
index 0fc0a60..0000000
--- a/src/classes/share/javax/media/j3d/AutoOffScreenCanvas3D.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright 2013 Harvey Harrison
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- */
-package javax.media.j3d;
-
-/**
- * An interface used to tag Canavs3d subclasses as being offsceen.
- */
-public interface AutoOffScreenCanvas3D {}
diff --git a/src/classes/share/javax/media/j3d/BHInsertStructure.java b/src/classes/share/javax/media/j3d/BHInsertStructure.java
deleted file mode 100644
index b64bfb5..0000000
--- a/src/classes/share/javax/media/j3d/BHInsertStructure.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-import java.util.Random;
-
-class BHInsertStructure {
-
- static boolean debug = false;
- static boolean debug2 = false;
-
- Random randomNumber;
- ArrayList[] bhListArr = null;
- ArrayList[] oldBhListArr = null;
- BHNode[] bhListArrRef = null;
- BHNode[] oldBhListArrRef = null;
- int bhListArrCnt = 0;
- int bhListArrMaxCnt = 0;
- int blockSize = 0;
-
- BHInsertStructure(int length) {
- randomNumber = new Random(0);
-
- if(length > 50) {
- length = 50;
- }
-
- blockSize = 50;
- bhListArr = new ArrayList[length];
- bhListArrRef = new BHNode[length];
- bhListArrCnt = 0;
- bhListArrMaxCnt = length;
-
- }
-
- void clear() {
-
- for(int i=0; i< bhListArrCnt; i++) {
- bhListArr[i].clear();
- bhListArrRef[i] = null;
- }
- bhListArrCnt = 0;
- }
-
- void lookupAndInsert(BHNode parent, BHNode child) {
- boolean found = false;
-
- for ( int i=0; i= bhListArrMaxCnt) {
- // allocate a bigger array here....
- if(debug)
- System.err.println("(1) Expanding bhListArr array ...");
- bhListArrMaxCnt += blockSize;
- oldBhListArr = bhListArr;
- oldBhListArrRef = bhListArrRef;
-
- bhListArr = new ArrayList[bhListArrMaxCnt];
- bhListArrRef = new BHNode[bhListArrMaxCnt];
- System.arraycopy(oldBhListArr, 0, bhListArr, 0, oldBhListArr.length);
- System.arraycopy(oldBhListArrRef, 0, bhListArrRef, 0,
- oldBhListArrRef.length);
- }
-
- bhListArrRef[bhListArrCnt] = parent;
- bhListArr[bhListArrCnt] = new ArrayList();
- bhListArr[bhListArrCnt].add(child);
- bhListArrCnt++;
- }
-
- }
-
- void updateBoundingTree(BHTree bhTree) {
-
- // based on the data in this stucture, update the tree such that
- // all things work out now .. i.e for each element of the array list
- // of bhListArr ... create a new reclustered tree.
- int size, cnt;
- BHNode child1, child2;
-
- for ( int i=0; i < bhListArrCnt; i++ ) {
- // extract and form an array of all children : l, r, and n1 ... nk
- cnt = 0;
- child1 = ((BHInternalNode)(bhListArrRef[i])).getLeftChild();
- child2 = ((BHInternalNode)(bhListArrRef[i])).getRightChild();
- if(child1 != null) cnt++;
- if(child2 != null) cnt++;
-
- size = bhListArr[i].size();
-
- BHNode bhArr[] = new BHNode[cnt + size];
-
- bhListArr[i].toArray(bhArr);
-
- //reset cnt, so that we can reuse it.
- cnt = 0;
- if(child1 != null) {
- bhArr[size] = child1;
- cnt++;
- bhArr[size + cnt] = child2;
- }
-
- if(debug2)
- if((child1 == null) || (child2 == null)) {
- System.err.println("child1 or child2 is null ...");
- System.err.println("This is bad, it shouldn't happen");
-
- }
-
- ((BHInternalNode)(bhListArrRef[i])).setRightChild(null);
- ((BHInternalNode)(bhListArrRef[i])).setLeftChild(null);
-
- bhTree.cluster((BHInternalNode)bhListArrRef[i], bhArr);
- }
- }
-
-}
-
-
diff --git a/src/classes/share/javax/media/j3d/BHInternalNode.java b/src/classes/share/javax/media/j3d/BHInternalNode.java
deleted file mode 100644
index 1272e58..0000000
--- a/src/classes/share/javax/media/j3d/BHInternalNode.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-class BHInternalNode extends BHNode {
-
- static boolean debug2 = true;
-
- BHNode rChild;
- BHNode lChild;
-
- BHInternalNode() {
- super();
- nodeType = BH_TYPE_INTERNAL;
- this.rChild = null;
- this.lChild = null;
- }
-
- BHInternalNode(BHNode parent) {
- super(parent);
- nodeType = BH_TYPE_INTERNAL;
- this.rChild = null;
- this.lChild = null;
- }
-
- BHInternalNode(BHNode parent, BHNode rChild, BHNode lChild) {
- super(parent);
- nodeType = BH_TYPE_INTERNAL;
- this.rChild = rChild;
- this.lChild = lChild;
- }
-
- BHInternalNode(BHNode parent, BoundingBox bHull) {
- super(parent, bHull);
- nodeType = BH_TYPE_INTERNAL;
- this.rChild = null;
- this.lChild = null;
- }
-
- BHInternalNode(BHNode parent, BHNode rChild, BHNode lChild, BoundingBox bHull) {
- super(parent, bHull);
- nodeType = BH_TYPE_INTERNAL;
- this.rChild = rChild;
- this.lChild = lChild;
- }
-
- BHNode getLeftChild() {
- return (BHNode) lChild;
- }
-
- BHNode getRightChild() {
- return (BHNode) rChild;
- }
-
- void setLeftChild(BHNode child) {
- lChild = child;
- }
-
- void setRightChild(BHNode child) {
- rChild = child;
- }
-
- void computeBoundingHull(BoundingBox bHull) {
- computeBoundingHull();
- bHull.set(this.bHull);
- }
-
- @Override
- void computeBoundingHull() {
- BoundingBox rChildBound = null;
- BoundingBox lChildBound = null;
- int i;
-
- if((lChild==null) && (rChild==null)) {
- bHull = null;
- return;
- }
-
- if(lChild != null)
- lChildBound = lChild.getBoundingHull();
-
- if(rChild != null)
- rChildBound = rChild.getBoundingHull();
-
- if(bHull == null)
- bHull = new BoundingBox();
-
- // Since left child is null. bHull is equal to right child's Hull.
- if(lChild == null) {
- bHull.set(rChildBound);
- return;
- }
-
- // Since right child is null. bHull is equal to left child's Hull.
- if(rChild == null) {
- bHull.set(lChildBound);
- return;
- }
-
- // Compute the combined bounds of the children.
- bHull.set(rChildBound);
- bHull.combine(lChildBound);
-
- }
-
- @Override
- void updateMarkedBoundingHull() {
-
- if(mark == false)
- return;
-
- rChild.updateMarkedBoundingHull();
- lChild.updateMarkedBoundingHull();
- computeBoundingHull();
- mark = false;
-
- }
-
- // this method inserts a single element into the tree given the stipulation
- // that the current tree node already contains the child ... 3 cases
- // one --node is inside the left child, and not inside the right
- // so recurse placing it inside the left child
- // two -- node is not inside the left but is inside the right
- // recurse placing it inside the right child
- // three -- node is not inside either one, added it to the current
- // element
-
- void insert( BHNode node, BHInsertStructure insertStructure ) {
- // NOTE: the node must already be inside this node if its not then fail.
- if(debug2)
- if ( !this.isInside(node.bHull) ) {
- System.err.println("Incorrect use of insertion, current node");
- System.err.println("must contain the input element ...");
- }
-
- boolean insideRightChild = false;
- boolean insideLeftChild = false;
-
- // leaf children are considered inpenetrable for insert so returns false
- if(this.rChild.nodeType == BHNode.BH_TYPE_LEAF) {
- insideRightChild = false;
- } else {
- insideRightChild = this.rChild.isInside(node.bHull);
- }
- if(this.lChild.nodeType == BHNode.BH_TYPE_LEAF) {
- insideLeftChild = false;
- } else {
- insideLeftChild = this.lChild.isInside(node.bHull);
- }
-
- if ( insideLeftChild && !insideRightChild ) {
- ((BHInternalNode)this.lChild).insert(node, insertStructure);
- } else if ( !insideLeftChild && insideRightChild ) {
- ((BHInternalNode)this.rChild).insert(node, insertStructure);
- } else if ( insideLeftChild && insideRightChild ) {
- // choose randomly to put it in the left or right
- if ( insertStructure.randomNumber.nextBoolean() ) {
- ((BHInternalNode)this.lChild).insert(node, insertStructure);
- } else {
- ((BHInternalNode)this.rChild).insert(node, insertStructure);
- }
- } else {
- // doesn't fit in either one ....
- // lookup the current node this in the auxilaryInsertStructure
- // if it appears then add element to the array of sub elements
- // if not then allocate a new element to the array
- insertStructure.lookupAndInsert(this, node);
- }
- }
-
- @Override
- void destroyTree(BHNode[] bhArr, int[] index) {
-
- if(rChild != null)
- rChild.destroyTree(bhArr, index);
-
- if(lChild != null)
- lChild.destroyTree(bhArr, index);
-
- rChild = null;
- lChild = null;
- }
-}
-
diff --git a/src/classes/share/javax/media/j3d/BHLeafInterface.java b/src/classes/share/javax/media/j3d/BHLeafInterface.java
deleted file mode 100644
index 195169f..0000000
--- a/src/classes/share/javax/media/j3d/BHLeafInterface.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-interface BHLeafInterface {
-
- abstract BoundingBox computeBoundingHull();
-
- abstract boolean isEnable();
-
- abstract boolean isEnable(int visibilityPolicy);
-
- // Can't use getLocale, it is used by BranchGroupRetained
- abstract Locale getLocale2();
-
-}
diff --git a/src/classes/share/javax/media/j3d/BHLeafNode.java b/src/classes/share/javax/media/j3d/BHLeafNode.java
deleted file mode 100644
index 2fcedbb..0000000
--- a/src/classes/share/javax/media/j3d/BHLeafNode.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-class BHLeafNode extends BHNode {
-
- BHLeafInterface leafIF;
-
- BHLeafNode() {
- super();
- nodeType = BH_TYPE_LEAF;
- leafIF = null;
- }
-
- BHLeafNode(BHNode parent) {
- super(parent);
- nodeType = BH_TYPE_LEAF;
- }
-
- BHLeafNode(BHLeafInterface lIF) {
- super();
- nodeType = BH_TYPE_LEAF;
- leafIF = lIF;
- }
-
- BHLeafNode(BHNode parent, BHLeafInterface lIF) {
- super(parent);
- leafIF = lIF;
- nodeType = BH_TYPE_LEAF;
- }
-
- BHLeafNode(BHNode parent, BoundingBox bHull) {
- super(parent, bHull);
- nodeType = BH_TYPE_LEAF;
- }
-
- BHLeafNode(BHNode parent, BHLeafInterface lIF, BoundingBox bHull) {
- super(parent, bHull);
- leafIF = lIF;
- nodeType = BH_TYPE_LEAF;
- }
-
- @Override
- void computeBoundingHull() {
- bHull = leafIF.computeBoundingHull();
- }
-
- @Override
- void updateMarkedBoundingHull() {
-
- if(mark == false)
- return;
-
- computeBoundingHull();
- mark = false;
- }
-
- boolean isEnable() {
- return leafIF.isEnable();
- }
-
- boolean isEnable(int vis) {
- return leafIF.isEnable(vis);
- }
-
- Locale getLocale() {
- return leafIF.getLocale2();
- }
-
- @Override
- void destroyTree(BHNode[] bhArr, int[] index) {
- if(bhArr.length <= index[0]) {
- // System.err.println("BHLeafNode : Problem bhArr overflow!!!");
- return;
- }
-
- parent = null;
- bhArr[index[0]] = this;
- index[0]++;
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/BHNode.java b/src/classes/share/javax/media/j3d/BHNode.java
deleted file mode 100644
index 23c4a93..0000000
--- a/src/classes/share/javax/media/j3d/BHNode.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-abstract class BHNode {
-
- static final byte BH_TYPE_INTERNAL = 1;
- static final byte BH_TYPE_LEAF = 2;
-
- static final int NUMBER_OF_PLANES = 6;
-
- static final boolean debug = false;
- static final boolean debug2 = false;
-
- BHNode parent;
- byte nodeType;
- BoundingBox bHull = null;
- boolean mark;
-
- BHNode () {
- this.parent = null;
- mark = false;
- }
-
- BHNode (BHNode parent) {
- this.parent = parent;
- mark = false;
- }
-
- BHNode (BHNode parent, BoundingBox bHull) {
- this.parent = parent;
- mark = false;
-
- this.bHull = bHull;
- }
-
- BHNode getParent () {
- return (this.parent) ;
- }
-
- abstract void computeBoundingHull();
- abstract void updateMarkedBoundingHull();
- abstract void destroyTree(BHNode[] bhArr, int[] index);
-
- void setParent (BHNode node) {
- this.parent = node;
- }
-
- BoundingBox getBoundingHull() {
- return (this.bHull);
- }
-
- void setBoundingHull(BoundingBox bHull) {
- this.bHull = bHull;
- }
-
- // given two nodes determine the bHull surrounding them, ie. the parent hull
- void combineBHull(BHNode node1, BHNode node2 ) {
- BoundingBox bHull1 = null;
- BoundingBox bHull2 = null;
-
- bHull1 = node1.getBoundingHull();
- bHull2 = node2.getBoundingHull();
-
- if(this.bHull==null)
- this.bHull = new BoundingBox(bHull1);
- else
- this.bHull.set(bHull1);
-
- this.bHull.combine(bHull2);
-
- }
-
- // returns true iff the bHull is completely inside this
- // bounding hull i.e. bHull values are strictly less
- // than or equal to all this.bHull values
- boolean isInside(BoundingBox bHull) {
- if(bHull == null)
- return false;
-
- if( this.bHull.isEmpty() || bHull.isEmpty() ) {
- return false;
- }
-
- if( this.bHull.upper.x < bHull.upper.x ||
- this.bHull.upper.y < bHull.upper.y ||
- this.bHull.upper.z < bHull.upper.z ||
- this.bHull.lower.x > bHull.lower.x ||
- this.bHull.lower.y > bHull.lower.y ||
- this.bHull.lower.z > bHull.lower.z )
- return false;
- else
- return true;
- }
-
- // finds the node matching the search element in the tree and returns
- // the node if found, else it returns null if the node couldn't be found
- BHNode findNode(BHNode node) {
- BHNode fNode = null;
-
- if ( this.nodeType == BHNode.BH_TYPE_LEAF) {
- if ( this == node ) {
- return this;
- }
- }
- else {
- if (((BHInternalNode) this).rChild.isInside(node.bHull)) {
- fNode = ((BHInternalNode)this).rChild.findNode(node);
- if(fNode != null) {
- return fNode;
- }
- }
- if (((BHInternalNode)this).lChild.isInside(node.bHull)) {
- return ((BHInternalNode)this).lChild.findNode(node);
- }
- }
- return null;
- }
-
- void deleteFromParent() {
- BHInternalNode parent;
-
- // System.err.println("deleteFromParent - this " + this );
- parent = (BHInternalNode) (this.parent);
- if(parent != null) {
- if(parent.rChild == this)
- parent.rChild = null;
- else if(parent.lChild == this)
- parent.lChild = null;
- else {
- if(debug2) {
- System.err.println("BHNode.java: Trouble! No match found. This can't happen.");
- System.err.println("this " + this );
- if ( this.nodeType == BHNode.BH_TYPE_INTERNAL) {
- System.err.println("rChild " + ((BHInternalNode)this).rChild +
- " lChild " + ((BHInternalNode)this).lChild);
- }
- System.err.println("parent " + parent +
- " parent.rChild " + parent.rChild +
- " parent.lChild " + parent.lChild);
- }
- }
- }
- }
-
- // delete all leaf nodes marked with DELETE_UPDATE and update the
- // bounds of the parents node
- BHNode deleteAndUpdateMarkedNodes() {
-
- if (this.mark == true) {
- if (this.nodeType == BH_TYPE_LEAF) {
- this.deleteFromParent();
- return null;
-
- } else {
- if(debug)
- if(((BHInternalNode)(this)).rChild == ((BHInternalNode)(this)).lChild)
- System.err.println("rChild " + ((BHInternalNode)(this)).rChild +
- " lChild " + ((BHInternalNode)(this)).lChild);
-
-
- if(((BHInternalNode)(this)).rChild != null)
- ((BHInternalNode)(this)).rChild =
- ((BHInternalNode)(this)).rChild.deleteAndUpdateMarkedNodes();
- if(((BHInternalNode)(this)).lChild != null)
- ((BHInternalNode)(this)).lChild =
- ((BHInternalNode)(this)).lChild.deleteAndUpdateMarkedNodes();
-
- if ((((BHInternalNode)(this)).rChild == null) &&
- (((BHInternalNode)(this)).lChild == null)) {
- this.deleteFromParent();
- return null;
- } else {
- if ( ((BHInternalNode)this).rChild == null ) {
- BHNode leftChild = ((BHInternalNode)this).lChild;
- leftChild.parent = this.parent;
- // delete self, return lChild
- this.deleteFromParent();
- return leftChild;
- } else if ( ((BHInternalNode)this).lChild == null ) {
- BHNode rightChild = ((BHInternalNode)this).rChild;
- rightChild.parent = this.parent;
- // delete self, return rChild
- this.deleteFromParent();
- return rightChild;
- } else {
- // recompute your bounds and return yourself
- this.combineBHull(((BHInternalNode)this).rChild,
- ((BHInternalNode)this).lChild);
- // update the parent's pointers
- ((BHInternalNode)this).rChild.parent = this;
- ((BHInternalNode)this).lChild.parent = this;
- this.mark = false;
- return this;
- }
- }
- }
- } else {
- // mark is NOT set, simply return self
- return this;
- }
- }
-
-
- // generic tree gathering statistics operations
-
- int countNumberOfInternals() {
- if ( this.nodeType == BHNode.BH_TYPE_LEAF ) {
- return 0;
- } else {
- return (((BHInternalNode)this).rChild.countNumberOfInternals() +
- ((BHInternalNode)this).lChild.countNumberOfInternals() + 1 );
- }
- }
-
- // recursively traverse the tree and compute the total number of leaves
- int countNumberOfLeaves() {
- if ( this.nodeType == BHNode.BH_TYPE_LEAF ) {
- return 1;
- } else {
- return ( ((BHInternalNode)this).rChild.countNumberOfLeaves() +
- ((BHInternalNode)this).lChild.countNumberOfLeaves() );
- }
- }
-
-
- // traverse tree and compute the maximum depth to a leaf
- int computeMaxDepth (int currentDepth) {
- if ( this.nodeType == BHNode.BH_TYPE_LEAF ) {
- return (currentDepth);
- } else {
- int rightDepth = ((BHInternalNode)this).rChild.computeMaxDepth(currentDepth + 1);
- int leftDepth = ((BHInternalNode)this).lChild.computeMaxDepth(currentDepth + 1);
- if( rightDepth > leftDepth )
- return rightDepth;
- return leftDepth;
- }
- }
-
- // compute the average depth of the leaves ...
- float computeAverageLeafDepth ( int numberOfLeaves, int currentDepth ) {
- int sumOfDepths = this.computeSumOfDepths(0);
- return ( (float)sumOfDepths / (float)numberOfLeaves );
- }
-
- int computeSumOfDepths ( int currentDepth ) {
- if ( this.nodeType == BHNode.BH_TYPE_LEAF ) {
- return ( currentDepth );
- } else {
- return (((BHInternalNode)this).rChild.computeSumOfDepths(currentDepth + 1) +
- ((BHInternalNode)this).lChild.computeSumOfDepths(currentDepth + 1) ) ;
- }
- }
-
-
-}
diff --git a/src/classes/share/javax/media/j3d/BHTree.java b/src/classes/share/javax/media/j3d/BHTree.java
deleted file mode 100644
index 260448c..0000000
--- a/src/classes/share/javax/media/j3d/BHTree.java
+++ /dev/null
@@ -1,1154 +0,0 @@
-/*
- * Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-import java.util.Vector;
-
-import javax.vecmath.Point4d;
-
-class BHTree {
-
- Locale locale;
-
- private BHNode root;
- private BHInsertStructure insertStructure = null;
-
- // Temporary point, so we dont generate garbage
- Point4d tPoint4d = new Point4d();
-
- // A flag to signal that number of renderAtoms sent to RenderBin is stable.
- private boolean stable = false;
-
- // An estimate of the maxmium depth of this tree (upper bound).
- int estMaxDepth;
-
- static final double LOG_OF_2 = Math.log(2);
-
- // Assume that the size avg. leaf node is 256 bytes. For a 64bit system, we'll
- // down with max depth of 56 for an ideal balance tree.
- static final int DEPTH_UPPER_BOUND = 56;
- static final int INCR_DEPTH_BOUND = 5;
- int depthUpperBound = DEPTH_UPPER_BOUND;
-
- BHTree() {
- locale = null;
- root = null;
- }
-
- BHTree(Locale loc) {
- locale = loc;
- root = null;
- }
-
- BHTree(BHNode bhArr[]) {
- locale = null;
- root = null;
- create(bhArr);
- }
-
- void setLocale(Locale loc) {
- locale = loc;
- }
-
- Locale getLocale() {
- return locale;
- }
-
- void cluster(BHInternalNode root, BHNode[] bhArr) {
-
- if(J3dDebug.devPhase) {
- if(J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_4,
- "BHTree.java :In cluster length is " + bhArr.length
- + "\n")) {
-
- for(int i=0; i= bBox.upper.x) &&
- (aBox.upper.y >= bBox.upper.y) &&
- (aBox.upper.z >= bBox.upper.z) &&
- (aBox.lower.x <= bBox.lower.x) &&
- (aBox.lower.y <= bBox.lower.y) &&
- (aBox.lower.z <= bBox.lower.z));
- }
-
-
- BHLeafInterface selectAny(GeometryAtom atom, int accurancyMode) {
- if (atom.source.geometryList == null)
- return null;
- BHNode bhNode = doSelectAny(atom, root, accurancyMode);
- if (bhNode == null) {
- return null;
- }
-
- return ((BHLeafNode) bhNode).leafIF;
- }
-
-
- BHLeafInterface selectAny(GeometryAtom atoms[], int size, int accurancyMode) {
- BHNode bhNode = doSelectAny(atoms, size, root, accurancyMode);
- if (bhNode == null) {
- return null;
- }
-
- return ((BHLeafNode) bhNode).leafIF;
- }
-
-
- private BHNode doSelectAny(GeometryAtom atoms[],int atomSize,
- BHNode bh, int accurancyMode) {
- if ((bh == null) || (bh.bHull.isEmpty())) {
- return null;
- }
- switch (bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- BHLeafInterface leaf = ((BHLeafNode) bh).leafIF;
- GeometryAtom atom;
- int i;
-
- if (leaf instanceof GeometryAtom) {
- GeometryAtom leafAtom = (GeometryAtom) leaf;
-
- if (((BHLeafNode) bh).isEnable() &&
- leafAtom.source.isCollidable) {
-
- // atom self intersection between atoms[]
- for (i=atomSize-1; i >=0; i--) {
- if (atoms[i] == leafAtom) {
- return null;
- }
- }
- for (i=atomSize-1; i >=0; i--) {
- atom = atoms[i];
- if ((atom.source.sourceNode != leafAtom.source.sourceNode) &&
- (atom.source.collisionVwcBound.intersect(leafAtom.source.collisionVwcBound)) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- ((leafAtom.source.geometryList != null) &&
- (atom.source.intersectGeometryList(leafAtom.source))))) {
- return bh;
- }
- }
- }
- } else if (leaf instanceof GroupRetained) {
- if (((BHLeafNode) bh).isEnable() &&
- ((GroupRetained) leaf).sourceNode.collidable) {
- for (i=atomSize-1; i >=0; i--) {
- atom = atoms[i];
- if (atom.source.collisionVwcBound.intersect(bh.bHull) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- (atom.source.intersectGeometryList(
- atom.source.getCurrentLocalToVworld(0), bh.bHull)))) {
- return bh;
- }
- }
- }
- }
- return null;
- case BHNode.BH_TYPE_INTERNAL:
- for (i=atomSize-1; i >=0; i--) {
- atom = atoms[i];
- if (atom.source.collisionVwcBound.intersect(bh.bHull))
- {
- BHNode hitNode = doSelectAny(atoms,
- atomSize,
- ((BHInternalNode) bh).getRightChild(),
- accurancyMode);
- if (hitNode != null)
- return hitNode;
-
- return doSelectAny(atoms, atomSize,
- ((BHInternalNode) bh).getLeftChild(),
- accurancyMode);
- }
- }
- return null;
- }
- return null;
- }
-
-
- private BHNode doSelectAny(GeometryAtom atom, BHNode bh, int accurancyMode) {
- if ((bh == null) || (bh.bHull.isEmpty())) {
- return null;
- }
- switch (bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- BHLeafInterface leaf = ((BHLeafNode) bh).leafIF;
- if (leaf instanceof GeometryAtom) {
- GeometryAtom leafAtom = (GeometryAtom) leaf;
- if ((atom.source.sourceNode != leafAtom.source.sourceNode) &&
- (((BHLeafNode) bh).isEnable()) &&
- (leafAtom.source.isCollidable) &&
- (atom.source.collisionVwcBound.intersect(leafAtom.source.collisionVwcBound)) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- ((leafAtom.source.geometryList != null) &&
- (atom.source.intersectGeometryList(leafAtom.source))))) {
- return bh;
- }
- } else if (leaf instanceof GroupRetained) {
- if (((BHLeafNode) bh).isEnable() &&
- ((GroupRetained) leaf).sourceNode.collidable &&
- atom.source.collisionVwcBound.intersect(bh.bHull) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- (atom.source.intersectGeometryList(
- atom.source.getCurrentLocalToVworld(0), bh.bHull)))) {
- return bh;
- }
- }
- return null;
- case BHNode.BH_TYPE_INTERNAL:
- if (atom.source.collisionVwcBound.intersect(bh.bHull)) {
- BHNode hitNode = doSelectAny(atom,
- ((BHInternalNode) bh).getRightChild(),
- accurancyMode);
- if (hitNode != null)
- return hitNode;
-
- return doSelectAny(atom,
- ((BHInternalNode) bh).getLeftChild(),
- accurancyMode);
- }
- return null;
- }
- return null;
- }
-
- BHLeafInterface selectAny(Bounds bound, int accurancyMode,
- NodeRetained armingNode) {
- if (bound == null) {
- return null;
- }
- BHNode bhNode = doSelectAny(bound, root, accurancyMode, armingNode);
- if (bhNode == null) {
- return null;
- }
- return ((BHLeafNode) bhNode).leafIF;
- }
-
- private BHNode doSelectAny(Bounds bound, BHNode bh, int accurancyMode,
- NodeRetained armingNode) {
- if ((bh == null) || (bh.bHull.isEmpty())) {
- return null;
- }
-
- switch (bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- BHLeafInterface leaf = ((BHLeafNode) bh).leafIF;
- if (leaf instanceof GeometryAtom) {
- GeometryAtom leafAtom = (GeometryAtom) leaf;
- if ((((BHLeafNode) bh).isEnable()) &&
- (leafAtom.source.isCollidable) &&
- (bound.intersect(leafAtom.source.collisionVwcBound)) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- ((leafAtom.source.geometryList != null) &&
- (leafAtom.source.intersectGeometryList(
- leafAtom.source.getCurrentLocalToVworld(0), bound))))) {
- return bh;
- }
- } else if (leaf instanceof GroupRetained) {
- if ((leaf != armingNode) &&
- ((BHLeafNode) bh).isEnable() &&
- ((GroupRetained) leaf).sourceNode.collidable &&
- bound.intersect(bh.bHull)) {
- return bh;
- }
- }
- return null;
- case BHNode.BH_TYPE_INTERNAL:
- if (bound.intersect(bh.bHull)) {
- BHNode hitNode = doSelectAny(bound,
- ((BHInternalNode) bh).getRightChild(),
- accurancyMode,
- armingNode);
- if (hitNode != null)
- return hitNode;
-
- return doSelectAny(bound,
- ((BHInternalNode) bh).getLeftChild(),
- accurancyMode,
- armingNode);
- }
- return null;
- }
- return null;
- }
-
-
- BHLeafInterface selectAny(Bounds bound, int accurancyMode,
- GroupRetained armingGroup) {
- if (bound == null) {
- return null;
- }
- BHNode bhNode = doSelectAny(bound, root, accurancyMode, armingGroup);
- if (bhNode == null) {
- return null;
- }
- return ((BHLeafNode) bhNode).leafIF;
- }
-
- private BHNode doSelectAny(Bounds bound, BHNode bh, int accurancyMode,
- GroupRetained armingGroup) {
- if ((bh == null) || (bh.bHull.isEmpty())) {
- return null;
- }
- switch (bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- BHLeafInterface leaf = ((BHLeafNode) bh).leafIF;
-
- if (leaf instanceof GeometryAtom) {
- GeometryAtom leafAtom = (GeometryAtom) leaf;
- if ((((BHLeafNode) bh).isEnable()) &&
- (leafAtom.source.isCollidable) &&
- (bound.intersect(leafAtom.source.collisionVwcBound)) &&
- (!isDescendent(leafAtom.source.sourceNode,
- armingGroup, leafAtom.source.key)) &&
- ((accurancyMode == WakeupOnCollisionEntry.USE_BOUNDS) ||
- ((leafAtom.source.geometryList != null) &&
- (leafAtom.source.intersectGeometryList(
- leafAtom.source.getCurrentLocalToVworld(0), bound))))) {
- return bh;
- }
- } else if (leaf instanceof GroupRetained) {
- GroupRetained group = (GroupRetained) leaf;
- if (((BHLeafNode) bh).isEnable() &&
- group.sourceNode.collidable &&
- bound.intersect(bh.bHull) &&
- !isDescendent(group.sourceNode, armingGroup, group.key)) {
- return bh;
- }
- }
- return null;
- case BHNode.BH_TYPE_INTERNAL:
- if (bound.intersect(bh.bHull)) {
- BHNode hitNode = doSelectAny(bound,
- ((BHInternalNode) bh).getRightChild(),
- accurancyMode,
- armingGroup);
- if (hitNode != null)
- return hitNode;
-
- return doSelectAny(bound,
- ((BHInternalNode) bh).getLeftChild(),
- accurancyMode,
- armingGroup);
- }
- return null;
- }
- return null;
- }
-
- // Return true if node is a descendent of group
- private boolean isDescendent(NodeRetained node,
- GroupRetained group,
- HashKey key) {
-
- synchronized (group.universe.sceneGraphLock) {
- if (node.inSharedGroup) {
- // getlastNodeId() will destroy this key
- if (key != null) {
- key = new HashKey(key);
- }
- }
-
- do {
- if (node == group) {
- return true;
- }
- if (node instanceof SharedGroupRetained) {
- // retrieve the last node ID
- String nodeId = key.getLastNodeId();
- NodeRetained prevNode = node;
- Vector parents = ((SharedGroupRetained)node).parents;
- for(int i=parents.size()-1; i >=0; i--) {
- NodeRetained link = parents.get(i);
- if (link.nodeId.equals(nodeId)) {
- node = link;
- break;
- }
- }
- if (prevNode == node) {
- // branch is already detach
- return true;
- }
- }
- node = node.parent;
- } while (node != null); // reach Locale
- }
- return false;
- }
-
-
- void select(PickShape pickShape, UnorderList hitArrList) {
-
- if((pickShape == null)||(root == null))
- return;
-
- doSelect(pickShape, hitArrList, root, tPoint4d);
-
- }
-
-
- private void doSelect(PickShape pickShape, UnorderList hitArrList,
- BHNode bh, Point4d pickPos) {
-
- if ((bh == null) || (bh.bHull.isEmpty())) {
- return;
- }
-
- switch(bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- if (((BHLeafNode)(bh)).isEnable() &&
- (((BHLeafNode) bh).leafIF instanceof GeometryAtom) &&
- ((GeometryAtom) (((BHLeafNode)
- bh).leafIF)).source.isPickable &&
- pickShape.intersect(bh.bHull, pickPos)) {
- hitArrList.add(bh);
- }
- break;
- case BHNode.BH_TYPE_INTERNAL:
- if (pickShape.intersect(bh.bHull, pickPos)) {
- doSelect(pickShape,
- hitArrList,
- ((BHInternalNode)bh).getRightChild(),
- pickPos);
- doSelect(pickShape,
- hitArrList,
- ((BHInternalNode)bh).getLeftChild(),
- pickPos);
- }
- break;
- }
- }
-
- BHNode selectAny(PickShape pickShape) {
-
- if((pickShape == null)||(root == null))
- return null;
-
- return doSelectAny(pickShape, root, tPoint4d);
-
- }
-
-
- private BHNode doSelectAny(PickShape pickShape, BHNode bh, Point4d pickPos) {
-
- BHNode hitNode = null;
-
- if((bh == null) || (bh.bHull.isEmpty()))
- return null;
-
- switch(bh.nodeType) {
- case BHNode.BH_TYPE_LEAF:
- if (((BHLeafNode)(bh)).isEnable() &&
- (((BHLeafNode) bh).leafIF instanceof GeometryAtom) &&
- ((GeometryAtom) (((BHLeafNode)
- bh).leafIF)).source.isPickable &&
- pickShape.intersect(bh.bHull, pickPos)) {
- return bh;
- }
- break;
- case BHNode.BH_TYPE_INTERNAL:
- if (pickShape.intersect(bh.bHull, pickPos)) {
- hitNode = doSelectAny(pickShape,
- ((BHInternalNode)bh).getRightChild(),
- pickPos);
-
- if (hitNode != null) {
- return hitNode;
- }
-
- return doSelectAny(pickShape,
- ((BHInternalNode)bh).getLeftChild(),
- pickPos);
- }
- break;
- }
- return null;
- }
-
-
- private void create(BHNode bhArr[]) {
- int i;
-
- if(bhArr == null) {
- root = null;
- return;
- }
-
- if(bhArr.length == 1) {
- bhArr[0].computeBoundingHull();
- root = (BHNode)bhArr[0];
- return;
- }
-
- int centerValuesIndex[] = new int[bhArr.length];
- float centerValues[][] = computeCenterValues(bhArr, centerValuesIndex);
-
- /*
- System.err.println("Length of array is " + bhArr.length);
- for(int kk=0; kk depthUpperBound) {
- int maxDepth = root.computeMaxDepth(0);
- int leafCount = root.countNumberOfLeaves();
- double compDepth = Math.log(leafCount)/LOG_OF_2;
- /*
- System.err.println("BHTree - evaluate for reConstructTree ...");
- System.err.println("compDepth " + compDepth);
- System.err.println("maxDepth " + maxDepth);
- System.err.println("leafCount " + leafCount);
- */
-
- // Upper bound guard.
- if(maxDepth > depthUpperBound) {
- reConstructTree(leafCount);
- maxDepth = root.computeMaxDepth(0);
- /*
- System.err.println("BHTree - Did reConstructTree ...");
- System.err.println("compDepth " + compDepth);
- System.err.println("maxDepth " + maxDepth);
- */
- }
-
- // Adjust depthUpperBound according to app. need.
- // If we encounter lots of overlapping bounds, the re-balanced
- // tree may not be an ideal balance tree. So there might be a
- // likehood of maxDepth exceeding the preset depthUpperBound.
- if(maxDepth > depthUpperBound) {
- depthUpperBound = depthUpperBound + INCR_DEPTH_BOUND;
- }else if((depthUpperBound != DEPTH_UPPER_BOUND) &&
- (maxDepth * 1.5 < depthUpperBound)) {
- depthUpperBound = depthUpperBound - INCR_DEPTH_BOUND;
-
- if(depthUpperBound < DEPTH_UPPER_BOUND) {
- // Be sure that DEPTH_UPPER_BOUND is the min.
- depthUpperBound = DEPTH_UPPER_BOUND;
- }
- }
-
- // This is the only place for resetting estMaxDepth to the tree real
- // maxDepth. Hence in cases where tree may get deteriorate fast, such
- // as multiple inserts and deletes frequently. estMaxDepth is accuminated,
- // and will lead to tree re-evaluation and possibly re-balancing.
- estMaxDepth = maxDepth;
- }
-
- }
-
-
- // mark all elements of the node and its parent as needing updating
- private void markParentChain(BHNode[] nArr, int size) {
- BHNode node;
-
- for(int i=0; i=0; i--) {
- sumCenters[i] = 0.0f;
- ss[i] = 0.0f;
- }
-
- for(i=arrLen-1; i>=0 ; i--) {
- sumCenters[0] += centerValues[centerValuesIndex[i]][0];
- sumCenters[1] += centerValues[centerValuesIndex[i]][1];
- sumCenters[2] += centerValues[centerValuesIndex[i]][2];
- }
-
- means[0] = sumCenters[0]/(float)arrLen;
- means[1] = sumCenters[1]/(float)arrLen;
- means[2] = sumCenters[2]/(float)arrLen;
-
- for(i=arrLen-1; i>=0 ; i--) {
- temp = (centerValues[centerValuesIndex[i]][0] - means[0]);
- ss[0] += (temp*temp);
- temp = (centerValues[centerValuesIndex[i]][1] - means[1]);
- ss[1] += (temp*temp);
- temp = (centerValues[centerValuesIndex[i]][2] - means[2]);
- ss[2] += (temp*temp);
-
- }
-
- }
-
- // find the split axis (the highest ss and return its index) for
- // a given set of ss values
- int findSplitAxis ( float ss[] ) {
- int splitAxis = -1;
- float maxSS = 0.0f;
-
- // the largest ss index value
- for (int i=0; i < 3; i++) {
- if ( ss[i] > maxSS ) {
- maxSS = ss[i];
- splitAxis = i;
- }
- }
- return splitAxis;
- }
-
- // Recursive method for constructing a binary tree.
- void constructTree( BHInternalNode parent, BHNode bhArr[],
- float[][] centerValues,
- int[] centerValuesIndex ){
-
- int i, splitAxis;
- int rightSetCount = 0;
- int leftSetCount = 0;
- float means[] = new float[3];
- float ss[] = new float[3];
-
- if(J3dDebug.devPhase)
- if ( bhArr.length <= 1 ) {
- // this is only here for debugging can be removed after testing
- // to ensure that it never gets called
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_1,
- "constructTree - bhArr.length <= 1. Bad !!!\n");
- }
-
- computeMeansAndSumSquares(centerValues, centerValuesIndex, means, ss);
-
- splitAxis = findSplitAxis(ss);
-
- // an array of decision variables for storing the values of inside
- // the right or left set for a particular element of bhArr.
- // true if its in the left set, false if its in the right set
- boolean leftOrRightSet[] = new boolean[bhArr.length];
-
- if ( splitAxis == -1 ) {
- // This is bad. Since we can't find a split axis, the best thing
- // to do is to split the set in two sets; each with about the
- // same number of elements. By doing this we can avoid constructing
- // a skew tree.
-
- // split elements into half.
- for ( i=0; i < bhArr.length; i++) {
- if(leftSetCount > rightSetCount) {
- rightSetCount++;
- leftOrRightSet[i] = false;
- } else {
- leftSetCount++;
- leftOrRightSet[i] = true;
- }
- }
- }
- else {
- for ( i=0; i < bhArr.length; i++) {
- // the split criterion, special multiple equals cases added
- if ( centerValues[centerValuesIndex[i]][splitAxis] <
- means[splitAxis]) {
-
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_4,
- "Found a left element\n");
- leftSetCount++;
- leftOrRightSet[i] = true;
- } else if ( centerValues[centerValuesIndex[i]][splitAxis] >
- means[splitAxis]) {
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_4,
- "Found a right element\n");
- rightSetCount++;
- leftOrRightSet[i] = false;
- } else {
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_4,
- "Found an equal element\n");
- if(leftSetCount > rightSetCount) {
- rightSetCount++;
- leftOrRightSet[i] = false;
- } else {
- leftSetCount++;
- leftOrRightSet[i] = true;
- }
- }
- }
- }
-
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_2,
- "LeftSetCount " + leftSetCount + " RightSetCount "+
- rightSetCount + "\n");
-
-
- // Don't think that this guard is needed, but still like to have it.
- // Just in case, bad means and the sum of squares might lead us into the guard.
- if (leftSetCount == bhArr.length) {
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_1,
- "Split Axis of = " + splitAxis + " didn't yield "+
- "any split among the objects ?\n");
- // split elements into half
- rightSetCount = 0;
- leftSetCount = 0;
- for ( i=0; i < bhArr.length; i++) {
- if(leftSetCount > rightSetCount) {
- rightSetCount++;
- leftOrRightSet[i] = false;
- } else {
- leftSetCount++;
- leftOrRightSet[i] = true;
- }
- }
- } else if (rightSetCount == bhArr.length) {
- if(J3dDebug.devPhase)
- J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_1,
- "Split Axis of = " + splitAxis + " didn't yield "+
- "any split among the objects ?\n");
- // split elements into half
- rightSetCount = 0;
- leftSetCount = 0;
- for ( i=0; i < bhArr.length; i++) {
- if(leftSetCount > rightSetCount) {
- rightSetCount++;
- leftOrRightSet[i] = false;
- } else {
- leftSetCount++;
- leftOrRightSet[i] = true;
- }
- }
- }
-
- if(J3dDebug.devPhase)
- if(J3dDebug.doDebug(J3dDebug.bHTree, J3dDebug.LEVEL_4))
- // check to make sure that rightSet and leftSet sum to the
- // number of elements in the original array.
- if ( bhArr.length != (rightSetCount + leftSetCount) ) {
- System.err.println("An error has occurred in spliting");
- }
-
- BHNode rightSet[] = new BHNode[rightSetCount];
- BHNode leftSet[] = new BHNode[leftSetCount];
- int centerValuesIndexR[] = new int[rightSetCount];
- int centerValuesIndexL[] = new int[leftSetCount];
-
- rightSetCount = 0;
- leftSetCount = 0;
-
- for (i=0; i < bhArr.length; i++) {
- if ( leftOrRightSet[i] ) { // element in left set
- leftSet[leftSetCount] = bhArr[i];
- centerValuesIndexL[leftSetCount] = centerValuesIndex[i];
- leftSetCount++;
- } else {
- rightSet[rightSetCount] = bhArr[i];
- centerValuesIndexR[rightSetCount] = centerValuesIndex[i];
- rightSetCount++;
- }
- }
-
- if (rightSet.length != 1) {
- parent.rChild = new BHInternalNode();
- parent.rChild.setParent(parent);
- constructTree((BHInternalNode)(parent.rChild), rightSet, centerValues,
- centerValuesIndexR);
- } else {
- parent.rChild = rightSet[0];
- parent.rChild.setParent(parent);
- }
-
- if (leftSet.length != 1) {
- parent.lChild = new BHInternalNode();
- parent.lChild.setParent(parent);
- constructTree((BHInternalNode)(parent.lChild), leftSet, centerValues,
- centerValuesIndexL);
- } else {
- parent.lChild = leftSet[0];
- parent.lChild.setParent(parent);
- }
-
- parent.combineBHull(parent.rChild, parent.lChild);
- }
-
-
- void reConstructTree(int numOfLeaf) {
- if(root == null)
- return;
-
- BHNode bhArr[] = new BHNode[numOfLeaf];
- int index[] = new int[1];
- index[0] = 0;
- root.destroyTree(bhArr, index);
-
- /*
- if(bhArr.length != index[0])
- System.err.println("BHTree - This isn't right!!! - bhArr.length " +
- bhArr.length + " index " + index[0]);
- */
-
- create(bhArr);
-
- }
-
- void gatherTreeStatistics() {
-
- int leafCount = root.countNumberOfLeaves();
- int internalCount = root.countNumberOfInternals();
- int maxDepth = root.computeMaxDepth(0);
- float averageDepth = root.computeAverageLeafDepth ( leafCount, 0);
-
-
- System.err.println("Statistics for tree = " + this);
- System.err.println("Total Number of nodes in tree = " +
- (leafCount + internalCount) );
- System.err.println("Number of Leaf Nodes = " + leafCount );
- System.err.println("Number of Internal Nodes = " + internalCount );
- System.err.println("Maximum Leaf depth = " + maxDepth );
- System.err.println("Average Leaf depth = " + averageDepth );
- System.err.println("root.bHull = " + root.bHull);
- // printTree(root);
-
- }
-
-
- void printTree(BHNode bh) {
- if(bh!= null) {
- if(bh.nodeType == BHNode.BH_TYPE_INTERNAL) {
- System.err.println("BH_TYPE_INTERNAL - bHull : " + bh);
- System.err.println(bh.bHull);
- System.err.println("rChild : " + ((BHInternalNode)bh).rChild +
- " lChild : " + ((BHInternalNode)bh).lChild);
- printTree(((BHInternalNode)bh).rChild);
- printTree(((BHInternalNode)bh).lChild);
- }
- else if(bh.nodeType == BHNode.BH_TYPE_LEAF) {
- System.err.println("BH_TYPE_LEAF - bHull : " + bh);
- System.err.println(bh.bHull);
- }
-
- }
-
-
- }
-}
-
-
-
-
-
-
diff --git a/src/classes/share/javax/media/j3d/Background.java b/src/classes/share/javax/media/j3d/Background.java
deleted file mode 100644
index e7cf50b..0000000
--- a/src/classes/share/javax/media/j3d/Background.java
+++ /dev/null
@@ -1,789 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Color3f;
-
-/**
- * The Background leaf node defines a solid background color
- * and a background image that are used to fill the window at the
- * beginning of each new frame. The background image may be null.
- * It optionally allows background
- * geometry---which is pre-tessellated onto a unit sphere and is drawn
- * at infinity---to be referenced. It also specifies an application
- * region in which this background is active. A Background node is
- * active when its application region intersects the ViewPlatform's
- * activation volume. If multiple Background nodes are active, the
- * Background node that is "closest" to the eye will be used. If no
- * Background nodes are active, then the window is cleared to black.
- *
- *
- * The set of nodes that can be added to a BranchGroup associated with
- * a Background node is limited. All Group nodes except
- * ViewSpecificGroup are legal in a background geometry branch
- * graph. The only Leaf nodes that are legal are Shape3D (except
- * OrientedShape3D), Morph, Light, and Fog. The presence of any other
- * Leaf node, including OrientedShape3D, or of a ViewSpecificGroup
- * node will cause an IllegalSceneGraphException to be thrown. Note
- * that Link nodes are not allowed; a background geometry branch graph
- * must not reference shared subgraphs. NodeComponent objects can be
- * shared between background branches and ordinary (non-background)
- * branches or among different background branches, however.
- *
- *
- * Light and Fog nodes in a background geometry branch graph do not
- * affect nodes outside of the background geometry branch graph, and
- * vice versa. Light and Fog nodes that appear in a background
- * geometry branch graph must not be hierarchically scoped to any
- * group node outside of that background geometry branch graph.
- * Conversely, Light and Fog nodes that appear outside of a particular
- * background geometry branch graph must not be hierarchically scoped
- * to any group node in that background geometry branch graph. Any
- * attempt to do so will be ignored.
- *
- *
- * The influencing bounds of any Light or Fog node in a background
- * geometry branch graph is effectively infinite (meaning that all
- * lights can affect all geometry objects nodes within the background
- * geometry graph, and that an arbitrary fog is selected). An
- * application wishing to limit the scope of a Light or Fog node must
- * use hierarchical scoping.
- *
- *
- * Picking and collision is ignored for nodes inside a background
- * geometry branch graph.
- */
-public class Background extends Leaf {
- /**
- * Specifies that the Background allows read access to its application
- * bounds and bounding leaf at runtime.
- */
- public static final int
- ALLOW_APPLICATION_BOUNDS_READ = CapabilityBits.BACKGROUND_ALLOW_APPLICATION_BOUNDS_READ;
-
- /**
- * Specifies that the Background allows write access to its application
- * bounds and bounding leaf at runtime.
- */
- public static final int
- ALLOW_APPLICATION_BOUNDS_WRITE = CapabilityBits.BACKGROUND_ALLOW_APPLICATION_BOUNDS_WRITE;
-
- /**
- * Specifies that the Background allows read access to its image
- * at runtime.
- */
- public static final int
- ALLOW_IMAGE_READ = CapabilityBits.BACKGROUND_ALLOW_IMAGE_READ;
-
- /**
- * Specifies that the Background allows write access to its image
- * at runtime.
- */
- public static final int
- ALLOW_IMAGE_WRITE = CapabilityBits.BACKGROUND_ALLOW_IMAGE_WRITE;
-
- /**
- * Specifies that the Background allows read access to its color
- * at runtime.
- */
- public static final int
- ALLOW_COLOR_READ = CapabilityBits.BACKGROUND_ALLOW_COLOR_READ;
-
- /**
- * Specifies that the Background allows write access to its color
- * at runtime.
- */
- public static final int
- ALLOW_COLOR_WRITE = CapabilityBits.BACKGROUND_ALLOW_COLOR_WRITE;
-
- /**
- * Specifies that the Background allows read access to its
- * background geometry at runtime.
- */
- public static final int
- ALLOW_GEOMETRY_READ = CapabilityBits.BACKGROUND_ALLOW_GEOMETRY_READ;
-
- /**
- * Specifies that the Background allows write access to its
- * background geometry at runtime.
- */
- public static final int
- ALLOW_GEOMETRY_WRITE = CapabilityBits.BACKGROUND_ALLOW_GEOMETRY_WRITE;
-
- /**
- * Specifies that the Background allows read access to its image
- * scale mode at runtime.
- *
- * @since Java 3D 1.3
- */
- public static final int ALLOW_IMAGE_SCALE_MODE_READ =
- CapabilityBits.BACKGROUND_ALLOW_IMAGE_SCALE_MODE_READ;
-
- /**
- * Specifies that the Background allows write access to its image
- * scale mode at runtime.
- *
- * @since Java 3D 1.3
- */
- public static final int ALLOW_IMAGE_SCALE_MODE_WRITE =
- CapabilityBits.BACKGROUND_ALLOW_IMAGE_SCALE_MODE_WRITE;
-
-
- /**
- * Indicates that no scaling of the background image is done. The
- * image will be drawn in its actual size. If the window is
- * smaller than the image, the image will be clipped. If the
- * window is larger than the image, the portion of the window not
- * filled by the image will be filled with the background color.
- * In all cases, the upper left corner of the image is anchored at
- * the upper-left corner of the window.
- * This is the default mode.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_NONE = 0;
-
- /**
- * Indicates that the background image is uniformly scaled to fit
- * the window such that the entire image is visible. The image is
- * scaled by the smaller of window.width/image.width
- * and window.height/image.height. The image will
- * exactly fill either the width or height of the window, but not
- * necessarily both. The portion of the window not filled by the
- * image will be filled with the background color.
- * The upper left corner of the image is anchored at the
- * upper-left corner of the window.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_FIT_MIN = 1;
-
- /**
- * Indicates that the background image is uniformly scaled to fit
- * the window such that the entire window is filled. The image is
- * scaled by the larger of window.width/image.width
- * and window.height/image.height. The image will
- * entirely fill the window, but may by clipped either in X
- * or Y.
- * The upper left corner of the image is anchored at the
- * upper-left corner of the window.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_FIT_MAX = 2;
-
-
- /**
- * Indicates that the background image is scaled to fit the
- * window. The image is scaled non-uniformly in x and
- * y by window.width/image.width and and
- * window.height/image.height, respectively. The
- * image will entirely fill the window.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_FIT_ALL = 3;
-
- /**
- * Indicates that the background image is tiled to fill the entire
- * window. The image is not scaled.
- * The upper left corner of the image is anchored at the
- * upper-left corner of the window.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_REPEAT = 4;
-
- /**
- * Indicates that the background image is centered in the window
- * and that no scaling of the image is done. The image will be
- * drawn in its actual size. If the window is smaller than the
- * image, the image will be clipped. If the window is larger than
- * the image, the portion of the window not filled by the image
- * will be filled with the background color.
- *
- * @see #setImageScaleMode
- *
- * @since Java 3D 1.3
- */
- public static final int SCALE_NONE_CENTER = 5;
-
- // Array for setting default read capabilities
- private static final int[] readCapabilities = {
- ALLOW_APPLICATION_BOUNDS_READ,
- ALLOW_COLOR_READ,
- ALLOW_GEOMETRY_READ,
- ALLOW_IMAGE_READ,
- ALLOW_IMAGE_SCALE_MODE_READ
- };
-
-
- /**
- * Constructs a Background node with default parameters. The default
- * values are as follows:
- *
- */
- public Background () {
- // Just use the defaults
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
- }
-
- /**
- * Constructs a Background node with the specified color.
- * This color is used to fill the window prior to drawing any
- * objects in the scene.
- */
- public Background(Color3f color) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((BackgroundRetained)this.retained).setColor(color);
- }
-
- /**
- * Constructs a Background node with the specified color.
- * This color is used to fill the window prior to drawing any
- * objects in the scene.
- */
- public Background(float r, float g, float b) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((BackgroundRetained)this.retained).setColor(r, g, b);
- }
-
- /**
- * Constructs a Background node with the specified image. If this
- * image is non-null, it is rendered to the window prior to
- * drawing any objects in the scene. If the image is smaller
- * than the window,
- * then that portion of the window not covered by the image is
- * filled with the background color.
- *
- * @param image pixel array object used as the background image
- *
- * @exception IllegalArgumentException if the image class of the specified
- * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
- */
- public Background(ImageComponent2D image) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- if((image != null) &&
- (image.getImageClass() == ImageComponent.ImageClass.NIO_IMAGE_BUFFER)) {
- throw new IllegalArgumentException(J3dI18N.getString("Background14"));
- }
-
- ((BackgroundRetained)this.retained).setImage(image);
- }
-
- /**
- * Constructs a Background node with the specified geometry.
- * If non-null, this background geometry is drawn on top of
- * the background color and image using a projection
- * matrix that essentially puts the geometry at infinity. The geometry
- * should be pre-tessellated onto a unit sphere.
- * @param branch the root of the background geometry
- * @exception IllegalSharingException if the BranchGroup node
- * is a child of any Group node, or is already attached to a Locale,
- * or is already referenced by another Background node.
- * @exception IllegalSceneGraphException if specified branch graph
- * contains an illegal node.
- */
- public Background(BranchGroup branch) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((BackgroundRetained)this.retained).setGeometry(branch);
- }
-
- /**
- * Sets the background color to the specified color.
- * This color is used to fill the window prior to drawing any
- * objects in the scene.
- * @param color the new background color
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setColor(Color3f color) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_COLOR_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background0"));
-
- if (isLive())
- ((BackgroundRetained)this.retained).setColor(color);
- else
- ((BackgroundRetained)this.retained).initColor(color);
-
- }
-
- /**
- * Sets the background color to the specified color.
- * This color is used to fill the window prior to drawing any
- * objects in the scene.
- * @param r the red component of the background color
- * @param g the green component of the background color
- * @param b the blue component of the background color
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setColor(float r, float g, float b) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_COLOR_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background0"));
-
- if (isLive())
- ((BackgroundRetained)this.retained).setColor(r, g, b);
- else
- ((BackgroundRetained)this.retained).initColor(r, g, b);
- }
-
- /**
- * Retrieves the background color.
- * @param color the vector that will receive the current background color
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void getColor(Color3f color) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_COLOR_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background2"));
-
- ((BackgroundRetained)this.retained).getColor(color);
- }
-
- /**
- * Sets the background image to the specified image. If this
- * image is non-null, it is rendered to the window prior to
- * drawing any objects in the scene. If the image is smaller
- * than the window,
- * then that portion of the window not covered by the image is
- * filled with the background color.
- *
- * @param image new pixel array object used as the background image
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @exception IllegalSharingException if this Background is live and
- * the specified image is being used by a Canvas3D as an off-screen buffer.
- *
- * @exception IllegalSharingException if this Background is
- * being used by an immediate mode context and
- * the specified image is being used by a Canvas3D as an off-screen buffer.
- *
- * @exception IllegalArgumentException if the image class of the specified
- * ImageComponent2D is ImageClass.NIO_IMAGE_BUFFER.
- */
- public void setImage(ImageComponent2D image) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_IMAGE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background3"));
-
- BackgroundRetained bgRetained = (BackgroundRetained)this.retained;
-
- if((image != null) &&
- (image.getImageClass() == ImageComponent.ImageClass.NIO_IMAGE_BUFFER)) {
- throw new IllegalArgumentException(J3dI18N.getString("Background14"));
- }
-
- // Do illegal sharing check
- if(image != null) {
- ImageComponent2DRetained imageRetained = (ImageComponent2DRetained) image.retained;
- if(imageRetained.getUsedByOffScreen()) {
- if(isLive()) {
- throw new IllegalSharingException(J3dI18N.getString("Background12"));
- }
- if(bgRetained.getInImmCtx()) {
- throw new IllegalSharingException(J3dI18N.getString("Background13"));
- }
- }
- }
-
- if (isLive())
- bgRetained.setImage(image);
- else
- bgRetained.initImage(image);
- }
-
- /**
- * Retrieves the background image.
- * @return the current background image
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public ImageComponent2D getImage() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_IMAGE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background4"));
-
- return ((BackgroundRetained)this.retained).getImage();
- }
-
- /**
- * Sets the image scale mode for this Background node.
- *
- * @param imageScaleMode the new image scale mode, one of:
- * SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX, SCALE_FIT_ALL,
- * SCALE_REPEAT, or SCALE_NONE_CENTER.
- *
- * @exception IllegalArgumentException if imageScaleMode
- * is a value other than SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX,
- * SCALE_FIT_ALL, SCALE_REPEAT, or SCALE_NONE_CENTER.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @since Java 3D 1.3
- */
- public void setImageScaleMode(int imageScaleMode) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_IMAGE_SCALE_MODE_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background9"));
-
- switch (imageScaleMode) {
- case SCALE_NONE:
- case SCALE_FIT_MIN:
- case SCALE_FIT_MAX:
- case SCALE_FIT_ALL:
- case SCALE_REPEAT:
- case SCALE_NONE_CENTER:
- break;
- default:
- throw new IllegalArgumentException(J3dI18N.getString("Background11"));
- }
-
- if (isLive())
- ((BackgroundRetained)this.retained).setImageScaleMode(imageScaleMode);
- else
- ((BackgroundRetained)this.retained).initImageScaleMode(imageScaleMode);
-
- }
-
- /**
- * Retrieves the current image scale mode.
- * @return the current image scale mode, one of:
- * SCALE_NONE, SCALE_FIT_MIN, SCALE_FIT_MAX, SCALE_FIT_ALL,
- * SCALE_REPEAT, or SCALE_NONE_CENTER.
- *
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- *
- * @since Java 3D 1.3
- */
- public int getImageScaleMode() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_IMAGE_SCALE_MODE_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background10"));
- return ((BackgroundRetained)this.retained).getImageScaleMode();
- }
-
- /**
- * Sets the background geometry to the specified BranchGroup node.
- * If non-null, this background geometry is drawn on top of
- * the background color and image using a projection
- * matrix that essentially puts the geometry at infinity. The geometry
- * should be pre-tessellated onto a unit sphere.
- * @param branch the root of the background geometry
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- * @exception IllegalSharingException if the BranchGroup node
- * is a child of any Group node, or is already attached to a Locale,
- * or is already referenced by another Background node.
- * @exception IllegalSceneGraphException if specified branch graph
- * contains an illegal node.
- */
- public void setGeometry(BranchGroup branch) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_GEOMETRY_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background5"));
-
- if (isLive())
- ((BackgroundRetained)this.retained).setGeometry(branch);
- else
- ((BackgroundRetained)this.retained).initGeometry(branch);
- }
-
- /**
- * Retrieves the background geometry.
- * @return the BranchGroup node that is the root of the background
- * geometry
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public BranchGroup getGeometry() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_GEOMETRY_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background6"));
-
- return ((BackgroundRetained)this.retained).getGeometry();
- }
-
- /**
- * Set the Background's application region to the specified bounds.
- * This is used when the application bounding leaf is set to null.
- * @param region the bounds that contains the Background's new application
- * region.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setApplicationBounds(Bounds region) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPLICATION_BOUNDS_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background7"));
-
- if (isLive())
- ((BackgroundRetained)this.retained).setApplicationBounds(region);
- else
- ((BackgroundRetained)this.retained).initApplicationBounds(region);
- }
-
- /**
- * Retrieves the Background node's application bounds.
- * @return this Background's application bounds information
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Bounds getApplicationBounds() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPLICATION_BOUNDS_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background8"));
-
- return ((BackgroundRetained)this.retained).getApplicationBounds();
- }
-
- /**
- * Set the Background's application region to the specified bounding leaf.
- * When set to a value other than null, this overrides the application
- * bounds object.
- * @param region the bounding leaf node used to specify the Background
- * node's new application region.
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setApplicationBoundingLeaf(BoundingLeaf region) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPLICATION_BOUNDS_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("Background7"));
-
- if (isLive())
- ((BackgroundRetained)this.retained).setApplicationBoundingLeaf(region);
- else
- ((BackgroundRetained)this.retained).initApplicationBoundingLeaf(region);
- }
-
- /**
- * Retrieves the Background node's application bounding leaf.
- * @return this Background's application bounding leaf information
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public BoundingLeaf getApplicationBoundingLeaf() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_APPLICATION_BOUNDS_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("Background8"));
-
- return ((BackgroundRetained)this.retained).getApplicationBoundingLeaf();
- }
-
- /**
- * Creates the retained mode BackgroundRetained object that this
- * Background component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new BackgroundRetained();
- this.retained.setSource(this);
- }
-
-
- /**
- * Creates a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- * Background geometry will not clone in this operation.
- * It is the user's responsibility
- * to call cloneTree on that branchGroup.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- Background b = new Background();
- b.duplicateNode(this, forceDuplicate);
- return b;
- }
-
-
- /**
- * Copies all node information from originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * For any NodeComponent objects
- * contained by the object being duplicated, each NodeComponent
- * object's duplicateOnCloneTree value is used to determine
- * whether the NodeComponent should be duplicated in the new node
- * or if just a reference to the current node should be placed in the
- * new node. This flag can be overridden by setting the
- * forceDuplicate parameter in the cloneTree
- * method to true.
- *
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneNode method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- * @exception ClassCastException if originalNode is not an instance of
- * Background
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public void duplicateNode(Node originalNode, boolean
- forceDuplicate) {
- checkDuplicateNode(originalNode, forceDuplicate);
- }
-
-
- /**
- * Copies all Background information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- super.duplicateAttributes(originalNode, forceDuplicate);
-
- BackgroundRetained attr = (BackgroundRetained) originalNode.retained;
- BackgroundRetained rt = (BackgroundRetained) retained;
-
- Color3f c = new Color3f();
- attr.getColor(c);
- rt.initColor(c);
- rt.initApplicationBounds(attr.getApplicationBounds());
- rt.initGeometry(attr.getGeometry());
- // issue # 563: add call to cloneTree()
- rt.initGeometry((BranchGroup) (attr.getGeometry() == null ? null : attr.getGeometry().cloneTree(true)));
- rt.initImage((ImageComponent2D) getNodeComponent(
- attr.getImage(),
- forceDuplicate,
- originalNode.nodeHashtable));
-
- // this will be updated in updateNodeReferences
- rt.initApplicationBoundingLeaf(attr.getApplicationBoundingLeaf());
- }
-
-
- /**
- * Callback used to allow a node to check if any scene graph objects
- * referenced
- * by that node have been duplicated via a call to cloneTree.
- * This method is called by cloneTree after all nodes in
- * the sub-graph have been duplicated. The cloned Leaf node's method
- * will be called and the Leaf node can then look up any object references
- * by using the getNewObjectReference method found in the
- * NodeReferenceTable object. If a match is found, a
- * reference to the corresponding object in the newly cloned sub-graph
- * is returned. If no corresponding reference is found, either a
- * DanglingReferenceException is thrown or a reference to the original
- * object is returned depending on the value of the
- * allowDanglingReferences parameter passed in the
- * cloneTree call.
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneTree method.
- *
- * @param referenceTable a NodeReferenceTableObject that contains the
- * getNewObjectReference method needed to search for
- * new object instances
- *
- * @see NodeReferenceTable
- * @see Node#cloneTree
- * @see DanglingReferenceException
- */
- @Override
- public void updateNodeReferences(NodeReferenceTable referenceTable) {
- super.updateNodeReferences(referenceTable);
-
- BackgroundRetained rt = (BackgroundRetained) retained;
- BoundingLeaf bl= rt.getApplicationBoundingLeaf();
-
- if (bl != null) {
- Object o = referenceTable.getNewObjectReference(bl);
- rt.initApplicationBoundingLeaf((BoundingLeaf) o);
- }
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BackgroundRetained.java b/src/classes/share/javax/media/j3d/BackgroundRetained.java
deleted file mode 100644
index 847d8de..0000000
--- a/src/classes/share/javax/media/j3d/BackgroundRetained.java
+++ /dev/null
@@ -1,782 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-
-import javax.vecmath.Color3f;
-
-
-/**
- * The Background leaf node defines either a solid background color
- * or a background image that is used to fill the window at the
- * beginning of each new frame. It also specifies an application
- * region in which this background is active.
- */
-class BackgroundRetained extends LeafRetained {
-
- static final int COLOR_CHANGED = 0x00001;
- static final int IMAGE_CHANGED = 0x00002;
- static final int GEOMETRY_CHANGED = 0x00004;
- static final int BOUNDS_CHANGED = 0x00008;
- static final int BOUNDINGLEAF_CHANGED = 0x00010;
- static final int IMAGE_SCALE_CHANGED = 0x00020;
- // Background color or image. If non-null, the image overrides the
- // color.
- Color3f color = new Color3f(0.0f, 0.0f, 0.0f);
- ImageComponent2DRetained image = null;
- Texture2DRetained texture = null;
-
- // the image scale mode if image is used.
- int imageScaleMode = Background.SCALE_NONE;
-
- /**
- * The Boundary object defining the lights's application region.
- */
- Bounds applicationRegion = null;
-
- /**
- * The bounding leaf reference
- */
- BoundingLeafRetained boundingLeaf = null;
-
- /**
- * Background geometry branch group
- */
- BranchGroup geometryBranch = null;
-
- /**
- * The transformed value of the applicationRegion.
- */
- Bounds transformedRegion = null;
-
- /**
- * The state structure used for Background Geometry
- */
- SetLiveState setLiveState = null;
-
- /**
- * The locale of this Background node since we don't have mirror object
- * when clearLive is called
- * locale is set to null, we still want locale to have a
- * non-null value, since renderingEnv structure may be using the
- * locale
- */
- Locale cachedLocale = null;
-
- // This is true when this background is referenced in an immediate mode context
- boolean inImmCtx = false;
-
-// list of light nodes for background geometry
-ArrayList lights = new ArrayList();
-
-// list of fog nodes for background geometry
-ArrayList fogs = new ArrayList();
-
-// a list of background geometry atoms
-ArrayList bgGeometryAtomList = new ArrayList();
-
-// false is background geometry atoms list has changed
-boolean bgGeometryAtomListDirty = true;
-
-// an array of background geometry atoms
-GeometryAtom[] bgGeometryAtoms = null;
-
- // Target threads to be notified when light changes
- // Note, the rendering env structure only get notified
- // when there is a bounds related change
- final static int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
- J3dThread.UPDATE_RENDER;
-
- // Is true, if the background is viewScoped
- boolean isViewScoped = false;
-
- BackgroundRetained () {
- this.nodeType = NodeRetained.BACKGROUND;
- localBounds = new BoundingBox((Bounds)null);
- }
-
- /**
- * Initializes the background color to the specified color.
- * This color is used
- * if the image is null.
- * @param color the new background color
- */
- final void initColor(Color3f color) {
- this.color.set(color);
- }
-
-
- /**
- * Sets the background color to the specified color. This color is used
- * if the image is null.
- * @param color the new background color
- */
- final void setColor(Color3f color) {
- initColor(color);
- if (source.isLive()) {
- sendMessage(COLOR_CHANGED, new Color3f(color));
- }
- }
-
- /**
- * Initializes the background color to the specified color.
- * This color is used
- * if the image is null.
- * @param r the red component of the background color
- * @param g the green component of the background color
- * @param b the blue component of the background color
- */
- final void initColor(float r, float g, float b) {
- this.color.x = r;
- this.color.y = g;
- this.color.z = b;
- }
-
-
-
- /**
- * Sets the background color to the specified color. This color is used
- * if the image is null.
- * @param r the red component of the background color
- * @param g the green component of the background color
- * @param b the blue component of the background color
- */
- final void setColor(float r, float g, float b) {
- setColor(new Color3f(r, g, b));
- }
-
-
- /**
- * Retrieves the background color.
- * @param color the vector that will receive the current background color
- */
- final void getColor(Color3f color) {
- color.set(this.color);
- }
-
- /**
- * Initialize the image scale mode to the specified mode
- * @imageScaleMode the image scale mode to the used
- */
- final void initImageScaleMode(int imageScaleMode){
- this.imageScaleMode = imageScaleMode;
- }
-
- /**
- * Sets the image scale mode for this Background node.
- * @param imageScaleMode the image scale mode
- */
- final void setImageScaleMode(int imageScaleMode){
- initImageScaleMode(imageScaleMode);
- if(source.isLive()){
- sendMessage(IMAGE_SCALE_CHANGED, new Integer(imageScaleMode));
- }
- }
-
- /**
- * gets the image scale mode for this Background node.
- */
- final int getImageScaleMode(){
- return imageScaleMode;
- }
-
- /**
- * Initializes the background image to the specified image.
- * @param image new ImageCompoent2D object used as the background image
- */
- final void initImage(ImageComponent2D img) {
- int texFormat;
-
- if (img == null) {
- image = null;
- texture = null;
- return;
- }
-
- if (img.retained != image ) {
- image = (ImageComponent2DRetained) img.retained;
- image.setEnforceNonPowerOfTwoSupport(true);
- switch(image.getNumberOfComponents()) {
- case 1:
- texFormat = Texture.INTENSITY;
- break;
- case 2:
- texFormat = Texture.LUMINANCE_ALPHA;
- break;
- case 3:
- texFormat = Texture.RGB;
- break;
- case 4:
- texFormat = Texture.RGBA;
- break;
- default:
- assert false;
- return;
- }
-
- Texture2D tex2D = new Texture2D(Texture.BASE_LEVEL, texFormat,
- img.getWidth(), img.getHeight());
- texture = (Texture2DRetained) tex2D.retained;
- // Background is special case of Raster.
- texture.setUseAsRaster(true);
- // Fix to issue 373 : ImageComponent.set(BufferedImage) ignored when used by Background
- image.addUser(texture);
- texture.initImage(0,img);
- }
- }
-
- /**
- * Sets the background image to the specified image.
- * @param image new ImageCompoent3D object used as the background image
- */
- final void setImage(ImageComponent2D img) {
- if (source.isLive()) {
- if (texture != null) {
- texture.clearLive(refCount);
- }
- }
- initImage(img);
- if (source.isLive()) {
- if (texture != null) {
- texture.setLive(inBackgroundGroup, refCount);
- }
-
- sendMessage(IMAGE_CHANGED,
- (texture != null ? texture.mirror : null));
-
- }
- }
-
- /**
- * Retrieves the background image.
- * @return the current background image
- */
- final ImageComponent2D getImage() {
- return (image == null ? null :
- (ImageComponent2D)image.source);
- }
-
- /**
- * Initializes the background geometry branch group to the specified branch.
- * @param branch new branch group object used for background geometry
- */
- final void initGeometry(BranchGroup branch) {
- geometryBranch = branch;
- }
-
-
- /**
- * Sets the background geometry branch group to the specified branch.
- * @param branch new branch group object used for background geometry
- */
- final void setGeometry(BranchGroup branch) {
- int numMessages = 0;
- int i;
-
- if (source.isLive()) {
- J3dMessage m[];
- if (geometryBranch != null)
- numMessages+=2; // REMOVE_NODES, ORDERED_GROUP_REMOVED
- if (branch != null)
- numMessages+=2; // INSERT_NODES, ORDERED_GROUP_INSERTED
- m = new J3dMessage[numMessages];
- for (i=0; i();
- setLiveState.branchGroupPaths.add(new BranchGroupRetained[0]);
-
- setLiveState.orderedPaths = new ArrayList(1);
- setLiveState.orderedPaths.add(new OrderedPath());
-
- setLiveState.switchStates = new ArrayList(1);
- setLiveState.switchStates.add(new SwitchState(false));
-
- branch.setLive(setLiveState);
-
-
- }
-
- void clearGeometryBranch(BranchGroupRetained branch) {
- setLiveState.reset(locale);
- setLiveState.inBackgroundGroup = true;
- setLiveState.geometryBackground = this;
- branch.clearLive(setLiveState);
- branch.setParent(null);
- branch.setLocale(null);
-
- }
-
- /**
- * This setLive routine first calls the superclass's method, then
- * it adds itself to the list of lights
- */
- @Override
- void setLive(SetLiveState s) {
- super.doSetLive(s);
-
- if (inImmCtx) {
- throw new IllegalSharingException(
- J3dI18N.getString("BackgroundRetained1"));
- }
- if (inBackgroundGroup) {
- throw new
- IllegalSceneGraphException(J3dI18N.getString("BackgroundRetained5"));
- }
-
- if (inSharedGroup) {
- throw new
- IllegalSharingException(J3dI18N.getString("BackgroundRetained6"));
- }
-
-
- if (geometryBranch != null) {
- BranchGroupRetained branch =
- (BranchGroupRetained)geometryBranch.retained;
- if (branch.inBackgroundGroup == true)
- throw new IllegalSharingException(
- J3dI18N.getString("BackgroundRetained0"));
-
- if (branch.parent != null)
- throw new IllegalSharingException(
- J3dI18N.getString("BackgroundRetained3"));
-
- if (branch.locale != null)
- throw new IllegalSharingException(
- J3dI18N.getString("BackgroundRetained4"));
-
- if (setLiveState == null) {
- setLiveState = new SetLiveState(universe);
- setLiveState.universe = universe;
- }
- setGeometryBranch((BranchGroupRetained)geometryBranch.retained);
- // add background geometry nodes to setLiveState's nodeList
- s.nodeList.addAll(setLiveState.nodeList);
- s.notifyThreads |= setLiveState.notifyThreads;
- s.ogList.addAll(setLiveState.ogList);
- s.ogChildIdList.addAll(setLiveState.ogChildIdList);
- s.ogOrderedIdList.addAll(setLiveState.ogOrderedIdList);
- // Free up memory.
- setLiveState.reset(null);
- }
-
- if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
- s.viewScopedNodeList.add(this);
- s.scopedNodesViewList.add(s.viewLists.get(0));
- } else {
- s.nodeList.add(this);
- }
- // System.err.println("bkg.setlive nodeList " + s.nodeList);
-
- // process switch leaf
- if (s.switchTargets != null && s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(this, Targets.ENV_TARGETS);
- }
- switchState = s.switchStates.get(0);
-
- // Initialize some mirror values
- if (boundingLeaf != null) {
- transformedRegion = boundingLeaf.mirrorBoundingLeaf.transformedRegion;
- }
- else { // Evaluate applicationRegion if not null
- if (applicationRegion != null) {
- transformedRegion = (Bounds)applicationRegion.clone();
- transformedRegion.transform(
- applicationRegion,
- getLastLocalToVworld());
- }
- else {
- transformedRegion = null;
- }
-
- }
- cachedLocale = s.locale;
-
- // add this node to the transform target
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(this, Targets.ENV_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
-
- s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
- J3dThread.UPDATE_RENDER;
-
- if (texture != null) {
- texture.setLive(inBackgroundGroup, refCount);
- }
- super.markAsLive();
-
- }
-
- /**
- * This clearLive routine first calls the superclass's method, then
- * it removes itself to the list of lights
- */
- @Override
- void clearLive(SetLiveState s) {
- super.clearLive(s);
- if ((s.viewScopedNodeList != null) && (s.viewLists != null)) {
- s.viewScopedNodeList.add(this);
- s.scopedNodesViewList.add(s.viewLists.get(0));
- } else {
- s.nodeList.add(this);
- }
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(this, Targets.ENV_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
-
- if (s.switchTargets != null && s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(this, Targets.ENV_TARGETS);
- }
-
- if (geometryBranch != null) {
- BranchGroupRetained branch = (BranchGroupRetained)geometryBranch.retained;
- clearGeometryBranch(branch);
- // add background geometry nodes to setLiveState's nodeList
- s.nodeList.addAll(setLiveState.nodeList);
- s.ogList.addAll(setLiveState.ogList);
- s.ogChildIdList.addAll(setLiveState.ogChildIdList);
- s.notifyThreads |= setLiveState.notifyThreads;
- // Free up memory.
- setLiveState.reset(null);
- lights.clear();
- fogs.clear();
- }
-
- if (texture != null) {
- texture.clearLive(refCount);
- }
-
- s.notifyThreads |= J3dThread.UPDATE_RENDERING_ENVIRONMENT|
- J3dThread.UPDATE_RENDER;
- }
-
- // The update Object function.
- synchronized void updateImmediateMirrorObject(Object[] objs) {
- int component = ((Integer)objs[1]).intValue();
- // If initialization
-
- // Bounds message only sent when boundingleaf is null
- if ((component & BOUNDS_CHANGED) != 0) {
- if (objs[2] != null) {
- transformedRegion = ((Bounds) objs[2]).copy(transformedRegion);
- transformedRegion.transform(
- (Bounds) objs[2], getCurrentLocalToVworld());
- }
- else {
- transformedRegion = null;
- }
- }
- else if ((component & BOUNDINGLEAF_CHANGED) != 0) {
- if (objs[2] != null) {
- transformedRegion = ((BoundingLeafRetained)objs[2]).transformedRegion;
- }
- else { // Evaluate applicationRegion if not null
- Bounds appRegion = (Bounds)objs[3];
- if (appRegion != null) {
- transformedRegion = appRegion.copy(transformedRegion);
- transformedRegion.transform(
- appRegion, getCurrentLocalToVworld());
- }
- else {
- transformedRegion = null;
- }
-
- }
- }
-
- }
-
- /** Note: This routine will only be called
- * to update the object's
- * transformed region
- */
- @Override
- void updateBoundingLeaf() {
- if (boundingLeaf != null &&
- boundingLeaf.mirrorBoundingLeaf.switchState.currentSwitchOn) {
- transformedRegion =
- boundingLeaf.mirrorBoundingLeaf.transformedRegion;
- } else { // Evaluate applicationRegion if not null
- if (applicationRegion != null) {
- transformedRegion = applicationRegion.copy(transformedRegion);
- transformedRegion.transform(
- applicationRegion, getCurrentLocalToVworld());
- } else {
- transformedRegion = null;
- }
- }
- }
-
- void updateImmediateTransformChange() {
- // If bounding leaf is null, tranform the bounds object
- if (boundingLeaf == null) {
- if (applicationRegion != null) {
- transformedRegion = applicationRegion.copy(transformedRegion);
- transformedRegion.transform(
- applicationRegion, getCurrentLocalToVworld());
- }
- }
- }
-
-
- final void sendMessage(int attrMask, Object attr) {
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = targetThreads;
- createMessage.universe = universe;
- createMessage.type = J3dMessage.BACKGROUND_CHANGED;
- createMessage.args[0] = this;
- createMessage.args[1]= new Integer(attrMask);
- createMessage.args[2] = attr;
- VirtualUniverse.mc.processMessage(createMessage);
- }
-
-void addBgGeometryAtomList(GeometryAtom geomAtom) {
- bgGeometryAtomList.add(geomAtom);
- bgGeometryAtomListDirty = true;
-}
-
-void removeBgGeometryAtomList(GeometryAtom geomAtom) {
- bgGeometryAtomList.remove(geomAtom);
- bgGeometryAtomListDirty = true;
-}
-
-GeometryAtom[] getBackgroundGeometryAtoms() {
- if (bgGeometryAtomListDirty) {
- int nAtoms = bgGeometryAtomList.size();
- if (nAtoms == 0) {
- bgGeometryAtoms = null;
- }
- else {
- bgGeometryAtoms = bgGeometryAtomList.toArray(new GeometryAtom[nAtoms]);
- bgGeometryAtomListDirty = false;
- }
- }
- return bgGeometryAtoms;
-}
-
- @Override
- void mergeTransform(TransformGroupRetained xform) {
- super.mergeTransform(xform);
- if (applicationRegion != null) {
- applicationRegion.transform(xform.transform);
- }
- }
-
- // notifies the Background object that the image data in a referenced
- // ImageComponent object is changed.
- // Currently we are not making use of this information.
-
- void notifyImageComponentImageChanged(ImageComponentRetained image,
- ImageComponentUpdateInfo value) {
- }
- @Override
- void getMirrorObjects(ArrayList leafList, HashKey key) {
- leafList.add(this); // No Mirror in this case
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BackgroundSound.java b/src/classes/share/javax/media/j3d/BackgroundSound.java
deleted file mode 100644
index 8ca0de0..0000000
--- a/src/classes/share/javax/media/j3d/BackgroundSound.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-/**
- * A BackgroundSound node defines an unattenuated, nonspatialized sound
- * source that has no position or direction. It has the same attributes as a
- * Sound node. This type of sound is simply added to the sound mix without
- * modification and is useful for playing a mono or stereo music track, or an
- * ambient sound effect. Unlike a Background (visual) node, more than one
- * BackgroundSound node can be simultaneously enabled and active.
- */
-public class BackgroundSound extends Sound {
- /**
- * Constructs a new BackgroundSound node using the default parameters
- * for Sound nodes.
- */
- public BackgroundSound() {
- /**
- * Uses default values defined in SoundRetained.java
- */
- }
-
- /**
- * Constructs a BackgroundSound node object using only the provided
- * parameter values for sound data and sample gain. The remaining fields
- * are set to the default values for a Sound node.
- * @param soundData sound data associated with this sound source node
- * @param initialGain amplitude scale factor applied to sound source
- */
- public BackgroundSound(MediaContainer soundData, float initialGain ) {
- super(soundData, initialGain);
- }
-
- /**
- * Constructs a BackgroundSound object accepting all the parameters
- * associated with a Sound node.
- * @param soundData sound data associated with this sound source node
- * @param initialGain amplitude scale factor applied to sound source
- * @param loopCount number of times loop is looped
- * @param release flag denoting playing sound data to end
- * @param continuous denotes that sound silently plays when disabled
- * @param enable sound switched on/off
- * @param region scheduling bounds
- * @param priority playback ranking value
- */
- public BackgroundSound(MediaContainer soundData,
- float initialGain,
- int loopCount,
- boolean release,
- boolean continuous,
- boolean enable,
- Bounds region,
- float priority) {
-
- super(soundData, initialGain, loopCount, release, continuous,
- enable, region, priority );
- }
-
-
- /**
- * Creates the retained mode BackgroundSoundRetained object that this
- * BackgroundSound component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new BackgroundSoundRetained();
- this.retained.setSource(this);
- }
-
-
- /**
- * Creates a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- BackgroundSound b = new BackgroundSound();
- b.duplicateNode(this, forceDuplicate);
- return b;
- }
-
- /**
- * Copies all node information from originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * For any NodeComponent objects
- * contained by the object being duplicated, each NodeComponent
- * object's duplicateOnCloneTree value is used to determine
- * whether the NodeComponent should be duplicated in the new node
- * or if just a reference to the current node should be placed in the
- * new node. This flag can be overridden by setting the
- * forceDuplicate parameter in the cloneTree
- * method to true.
- *
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneNode method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- * @exception ClassCastException if originalNode is not an instance of
- * Sound
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public void duplicateNode(Node originalNode, boolean forceDuplicate) {
- checkDuplicateNode(originalNode, forceDuplicate);
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BackgroundSoundRetained.java b/src/classes/share/javax/media/j3d/BackgroundSoundRetained.java
deleted file mode 100644
index 6f026f6..0000000
--- a/src/classes/share/javax/media/j3d/BackgroundSoundRetained.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-/**
- * BackgroundSound is a class for sounds that are not spatially rendered.
- * These sounds are simply added to the stereo sound mix without modification.
- * These could be used to play mono or stereo music, or ambient sound effects.
- */
-class BackgroundSoundRetained extends SoundRetained {
-
- BackgroundSoundRetained() {
- this.nodeType = NodeRetained.BACKGROUNDSOUND;
- localBounds = new BoundingBox((Bounds)null);
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BadTransformException.java b/src/classes/share/javax/media/j3d/BadTransformException.java
deleted file mode 100644
index c7c2c5c..0000000
--- a/src/classes/share/javax/media/j3d/BadTransformException.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-/**
- * Indicates an attempt to use a Tranform3D object that is
- * inappropriate for the object in which it is being used.
- * For example:
- *
- *
- * Transforms that are used in the scene graph, within a TransformGroup
- * node, must be affine. They may optionally contain a non-uniform
- * scale and/or a shear, subject to other listed restrictions.
- *
- * All transforms in the TransformGroup nodes above a ViewPlatform
- * object must be congruent. This ensures that the Vworld coordinates to
- * ViewPlatform coordinates transform is angle and length-preserving with
- * no shear and only uniform scale.
- *
- * Most viewing transforms other than those in the scene graph can
- * only contain translation and rotation.
- *
- * The projection transform is allowed to be non-affine, but it
- * must either be a single point perspective projection or a parallel
- * projection.
- *
- */
-public class BadTransformException extends RuntimeException{
-
-/**
- * Create the exception object with default values.
- */
- public BadTransformException(){
- }
-
-/**
- * Create the exception object that outputs message.
- * @param str the message string to be output.
- */
- public BadTransformException(String str){
-
- super(str);
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/Behavior.java b/src/classes/share/javax/media/j3d/Behavior.java
deleted file mode 100644
index f0e5501..0000000
--- a/src/classes/share/javax/media/j3d/Behavior.java
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-import java.util.Enumeration;
-
-/**
- * The Behavior leaf node provides a framework for adding user-defined
- * actions into the scene graph. Behavior is an abstract class that
- * defines two methods that must be overridden by a subclass: An
- * initialization method, called once when the behavior
- * becomes "live," and a processStimulus method called
- * whenever appropriate by the Java 3D behavior scheduler. The
- * Behavior node also contains an enable flag, a scheduling region,
- * a scheduling interval, and a wakeup condition.
- *
- *
- * The scheduling region defines a spatial volume that serves
- * to enable the scheduling of Behavior nodes. A Behavior node is
- * active (can receive stimuli) whenever an active ViewPlatform's
- * activation volume intersects a Behavior object's scheduling
- * region. Only active behaviors can receive stimuli.
- *
- *
- * The scheduling interval defines a partial order of execution
- * for behaviors that wake up in response to the same wakeup condition
- * (that is, those behaviors that are processed at the same "time").
- * Given a set of behaviors whose wakeup conditions are satisfied at
- * the same time, the behavior scheduler will execute all behaviors in
- * a lower scheduling interval before executing any behavior in a
- * higher scheduling interval. Within a scheduling interval,
- * behaviors can be executed in any order, or in parallel. Note that
- * this partial ordering is only guaranteed for those behaviors that
- * wake up at the same time in response to the same wakeup condition,
- * for example, the set of behaviors that wake up every frame in
- * response to a WakeupOnElapsedFrames(0) wakeup condition.
- *
- *
- * The initialize method allows a Behavior object to
- * initialize its internal state and specify its initial wakeup
- * condition(s). Java 3D invokes a behavior's initialize code when the
- * behavior's containing BranchGroup node is added to the virtual
- * universe. Java 3D does not invoke the initialize method in a new
- * thread. Thus, for Java 3D to regain control, the initialize method
- * must not execute an infinite loop; it must return. Furthermore, a
- * wakeup condition must be set or else the behavior's processStimulus
- * method is never executed.
- *
- *
- * The processStimulus method receives and processes a
- * behavior's ongoing messages. The Java 3D behavior scheduler invokes
- * a Behavior node's processStimulus method when an active ViewPlatform's
- * activation volume intersects a Behavior object's scheduling region
- * and all of that behavior's wakeup criteria are satisfied. The
- * processStimulus method performs its computations and actions
- * (possibly including the registration of state change information
- * that could cause Java 3D to wake other Behavior objects),
- * establishes its next wakeup condition, and finally exits.
- * A typical behavior will modify one or more nodes or node components
- * in the scene graph. These modifications can happen in parallel
- * with rendering. In general, applications cannot count on behavior
- * execution being synchronized with rendering. There are two
- * exceptions to this general rule:
- *
- *
All modifications to scene graph objects (not including geometry
- * by-reference or texture by-reference) made from the
- * processStimulus method of a single behavior instance
- * are guaranteed to take effect in the same rendering frame.
- *
All modifications to scene graph objects (not including geometry
- * by-reference or texture by-reference) made from the
- * processStimulus methods of the set of behaviors that
- * wake up in response to a WakeupOnElapsedFrames(0) wakeup condition
- * are guaranteed to take effect in the same rendering frame.
- *
- *
- * Note that modifications to geometry by-reference or texture
- * by-reference are not guaranteed to show up in the same frame as
- * other scene graph changes.
- *
- *
- * Code Structure
- *
- * When the Java 3D behavior scheduler invokes a Behavior object's
- * processStimulus method, that method may perform any computation it
- * wishes. Usually, it will change its internal state and specify its
- * new wakeup conditions. Most probably, it will manipulate scene
- * graph elements. However, the behavior code can only change those
- * aspects of a scene graph element permitted by the capabilities
- * associated with that scene graph element. A scene graph's
- * capabilities restrict behavioral manipulation to those
- * manipulations explicitly allowed.
- *
- *
- * The application must provide the Behavior object with references to
- * those scene graph elements that the Behavior object will
- * manipulate. The application provides those references as arguments
- * to the behavior's constructor when it creates the Behavior
- * object. Alternatively, the Behavior object itself can obtain access
- * to the relevant scene graph elements either when Java 3D invokes
- * its initialize method or each time Java 3D invokes its
- * processStimulus method.
- *
- *
- * Behavior methods have a very rigid structure. Java 3D assumes that
- * they always run to completion (if needed, they can spawn
- * threads). Each method's basic structure consists of the following:
- *
- *
- *
- *
Code to decode and extract references from the WakeupCondition
- * enumeration that caused the object's awakening.
- *
Code to perform the manipulations associated with the
- * WakeupCondition
- *
Code to establish this behavior's new WakeupCondition
- *
A path to Exit (so that execution returns to the Java 3D
- * behavior scheduler)
- *
- *
- *
- * WakeupCondition Object
- *
- * A WakeupCondition object is an abstract class specialized to
- * fourteen different WakeupCriterion objects and to four combining
- * objects containing multiple WakeupCriterion objects. A Behavior
- * node provides the Java 3D behavior scheduler with a WakeupCondition
- * object. When that object's WakeupCondition has been satisfied, the
- * behavior scheduler hands that same WakeupCondition back to the
- * Behavior via an enumeration.
- *
- *
- * WakeupCriterion Object
- *
- * Java 3D provides a rich set of wakeup criteria that Behavior
- * objects can use in specifying a complex WakeupCondition. These
- * wakeup criteria can cause Java 3D's behavior scheduler to invoke a
- * behavior's processStimulus method whenever
- *
- *
- *
The center of a ViewPlatform enters a specified region
- *
The center of a ViewPlatform exits a specified region
- *
A behavior is activated
- *
A behavior is deactivated
- *
A specified TransformGroup node's transform changes
- *
Collision is detected between a specified Shape3D node's
- * Geometry object and any other object
- *
Movement occurs between a specified Shape3D node's Geometry
- * object and any other object with which it collides
- *
A specified Shape3D node's Geometry object no longer collides
- * with any other object
- *
A specified Behavior object posts a specific event
- *
A specified AWT event occurs
- *
A specified time interval elapses
- *
A specified number of frames have been drawn
- *
The center of a specified Sensor enters a specified region
- *
The center of a specified Sensor exits a specified region
- *
- *
- *
- * A Behavior object constructs a WakeupCriterion by constructing the
- * appropriate criterion object. The Behavior object must provide the
- * appropriate arguments (usually a reference to some scene graph
- * object and possibly a region of interest). Thus, to specify a
- * WakeupOnViewPlatformEntry, a behavior would specify the region that
- * will cause the behavior to execute if an active ViewPlatform enters it.
- *
- *
- * Note that a unique WakeupCriterion object must be used with each
- * instance of a Behavior. Sharing wakeup criteria among different
- * instances of a Behavior is illegal.
- *
- *
- * Additional Information
- *
- * For more information, see the
- * Introduction to the Java 3D API and
- * Behaviors and Interpolators
- * documents.
- *
- * @see WakeupCondition
- */
-
-public abstract class Behavior extends Leaf {
-
- /**
- * Constructs a Behavior node with default parameters. The default
- * values are as follows:
- *
- */
- public Behavior() {
- }
-
- /**
- * Initialize this behavior. Classes that extend Behavior must
- * provide their own initialize method.
- *
- * NOTE: Applications should not call this method. It is called
- * by the Java 3D behavior scheduler.
- */
- public abstract void initialize();
-
- /**
- * Process a stimulus meant for this behavior. This method is invoked
- * if the Behavior's wakeup criteria are satisfied and an active
- * ViewPlatform's
- * activation volume intersects with the Behavior's scheduling region.
- * Classes that extend Behavior must provide their own processStimulus
- * method.
- *
- * NOTE: Applications should not call this method. It is called
- * by the Java 3D behavior scheduler.
- * @param criteria an enumeration of triggered wakeup criteria for this
- * behavior
- */
- public abstract void processStimulus(Enumeration criteria);
-
- /**
- * Set the Behavior's scheduling region to the specified bounds.
- * This is used when the scheduling bounding leaf is set to null.
- * @param region the bounds that contains the Behavior's new scheduling
- * region
- */
- public void setSchedulingBounds(Bounds region) {
- ((BehaviorRetained)this.retained).setSchedulingBounds(region);
- }
-
- /**
- * Retrieves the Behavior node's scheduling bounds.
- * @return this Behavior's scheduling bounds information
- */
- public Bounds getSchedulingBounds() {
- return ((BehaviorRetained)this.retained).getSchedulingBounds();
- }
-
- /**
- * Set the Behavior's scheduling region to the specified bounding leaf.
- * When set to a value other than null, this overrides the scheduling
- * bounds object.
- * @param region the bounding leaf node used to specify the Behavior
- * node's new scheduling region
- */
- public void setSchedulingBoundingLeaf(BoundingLeaf region) {
- ((BehaviorRetained)this.retained).setSchedulingBoundingLeaf(region);
- }
-
- /**
- * Retrieves the Behavior node's scheduling bounding leaf.
- * @return this Behavior's scheduling bounding leaf information
- */
- public BoundingLeaf getSchedulingBoundingLeaf() {
- return ((BehaviorRetained)this.retained).getSchedulingBoundingLeaf();
- }
-
- /**
- * Creates the retained mode BehaviorRetained object that this
- * Behavior object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new BehaviorRetained();
- this.retained.setSource(this);
- }
-
- /**
- * Defines this behavior's wakeup criteria. This method
- * may only be called from a Behavior object's initialize
- * or processStimulus methods to (re)arm the next wakeup.
- * It should be the last thing done by those methods.
- * @param criteria the wakeup criteria for this behavior
- * @exception IllegalStateException if this method is called by
- * a method other than initialize or processStimulus
- */
- protected void wakeupOn(WakeupCondition criteria) {
- BehaviorRetained behavret = (BehaviorRetained) this.retained;
- synchronized (behavret) {
- if (!behavret.inCallback) {
- throw new IllegalStateException(J3dI18N.getString("Behavior0"));
- }
- }
- behavret.wakeupOn(criteria);
- }
-
- /**
- * Retrieves this behavior's current wakeup condition as set by
- * the wakeupOn method. If no wakeup condition is currently
- * active, null will be returned. In particular, this means that
- * null will be returned if Java 3D is executing this behavior's
- * processStimulus routine and wakeupOn has not yet been called to
- * re-arm the wakeup condition for next time.
- *
- * @return the current wakeup condition for this behavior
- *
- * @since Java 3D 1.3
- */
- protected WakeupCondition getWakeupCondition() {
- return ((BehaviorRetained)this.retained).getWakeupCondition();
- }
-
- /**
- * Posts the specified postId to the Behavior Scheduler. All behaviors
- * that have registered WakeupOnBehaviorPost with this postId, or a postId
- * of 0, and with this behavior, or a null behavior, will have that wakeup
- * condition met.
- *
- * This feature allows applications to send arbitrary events into the
- * behavior scheduler stream. It can be used as a notification scheme
- * for communicating events to behaviors in the system.
- *
- * @param postId the Id being posted
- *
- * @see WakeupOnBehaviorPost
- */
- public void postId(int postId){
- ((BehaviorRetained)this.retained).postId(postId);
- }
-
- /**
- * Enables or disables this Behavior. The default state is enabled.
- * @param state true or false to enable or disable this Behavior
- */
- public void setEnable(boolean state) {
- ((BehaviorRetained)this.retained).setEnable(state);
- }
-
- /**
- * Retrieves the state of the Behavior enable flag.
- * @return the Behavior enable state
- */
- public boolean getEnable() {
- return ((BehaviorRetained)this.retained).getEnable();
- }
-
- /**
- * Returns the number of scheduling intervals supported by this
- * implementation of Java 3D. The minimum number of supported
- * intervals must be at least 10. The default scheduling interval
- * for each behavior instance is set to
- * numSchedulingIntervals / 2.
- *
- * @return the number of supported scheduling intervals
- *
- * @since Java 3D 1.3
- */
- public static int getNumSchedulingIntervals() {
- return BehaviorRetained.NUM_SCHEDULING_INTERVALS;
- }
-
-
- /**
- * Sets the scheduling interval of this Behavior node to the
- * specified value.
- *
- * The scheduling interval defines a partial order of execution
- * for behaviors that wake up in response to the same wakeup
- * condition (that is, those behaviors that are processed at the
- * same "time"). Given a set of behaviors whose wakeup conditions
- * are satisfied at the same time, the behavior scheduler will
- * execute all behaviors in a lower scheduling interval before
- * executing any behavior in a higher scheduling interval. Within
- * a scheduling interval, behaviors can be executed in any order,
- * or in parallel. Note that this partial ordering is only
- * guaranteed for those behaviors that wake up at the same time in
- * response to the same wakeup condition, for example, the set of
- * behaviors that wake up every frame in response to a
- * WakeupOnElapsedFrames(0) wakeup condition.
- *
- * The default value is numSchedulingIntervals / 2.
- *
- * @param schedulingInterval the new scheduling interval
- *
- * @exception IllegalArgumentException if
- * schedulingInterval < 0 or
- * schedulingInterval >=
- * numSchedulingIntervals
- *
- * @since Java 3D 1.3
- */
- public void setSchedulingInterval(int schedulingInterval) {
- if (schedulingInterval < 0 ||
- schedulingInterval >= getNumSchedulingIntervals()) {
-
- throw new IllegalStateException(J3dI18N.getString("Behavior1"));
- }
-
- ((BehaviorRetained)this.retained).
- setSchedulingInterval(schedulingInterval);
- }
-
- /**
- * Retrieves the current scheduling interval of this Behavior
- * node.
- *
- * @return the current scheduling interval
- *
- * @since Java 3D 1.3
- */
- public int getSchedulingInterval() {
- return ((BehaviorRetained)this.retained).getSchedulingInterval();
- }
-
- /**
- * Returns the primary view associated with this behavior. This method
- * is useful with certain types of behaviors (e.g., Billboard, LOD) that
- * rely on per-View information and with behaviors in general in regards
- * to scheduling (the distance from the view platform determines the
- * active behaviors). The "primary" view is defined to be the first
- * View attached to a live ViewPlatform, if there is more than one active
- * View. So, for instance, Billboard behaviors would be oriented toward
- * this primary view, in the case of multiple active views into the same
- * scene graph.
- */
- protected View getView() {
- return ((BehaviorRetained)this.retained).getView();
- }
-
-
- /**
- * Copies all Behavior information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- super.duplicateAttributes(originalNode, forceDuplicate);
-
- BehaviorRetained attr = (BehaviorRetained) originalNode.retained;
- BehaviorRetained rt = (BehaviorRetained) retained;
-
- rt.setEnable(attr.getEnable());
- rt.setSchedulingBounds(attr.getSchedulingBounds());
- rt.setSchedulingInterval(attr.getSchedulingInterval());
- // will set to the correct one in updateNodeReferences
- rt.setSchedulingBoundingLeaf(attr.getSchedulingBoundingLeaf());
-
- }
-
-
- /**
- * Callback used to allow a node to check if any scene graph objects
- * referenced
- * by that node have been duplicated via a call to cloneTree.
- * This method is called by cloneTree after all nodes in
- * the sub-graph have been duplicated. The cloned Leaf node's method
- * will be called and the Leaf node can then look up any object references
- * by using the getNewObjectReference method found in the
- * NodeReferenceTable object. If a match is found, a
- * reference to the corresponding object in the newly cloned sub-graph
- * is returned. If no corresponding reference is found, either a
- * DanglingReferenceException is thrown or a reference to the original
- * object is returned depending on the value of the
- * allowDanglingReferences parameter passed in the
- * cloneTree call.
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneTree method.
- *
- * @param referenceTable a NodeReferenceTableObject that contains the
- * getNewObjectReference method needed to search for
- * new object instances.
- *
- * @see NodeReferenceTable
- * @see Node#cloneTree
- * @see DanglingReferenceException
- */
- @Override
- public void updateNodeReferences(NodeReferenceTable referenceTable) {
- super.updateNodeReferences(referenceTable);
-
- BehaviorRetained rt = (BehaviorRetained) retained;
- BoundingLeaf bl= rt.getSchedulingBoundingLeaf();
-
- // check for schedulingBoundingLeaf
- if (bl != null) {
- Object o = referenceTable.getNewObjectReference(bl);
- rt.setSchedulingBoundingLeaf((BoundingLeaf) o);
-
- }
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/BehaviorRetained.java b/src/classes/share/javax/media/j3d/BehaviorRetained.java
deleted file mode 100644
index b82b09d..0000000
--- a/src/classes/share/javax/media/j3d/BehaviorRetained.java
+++ /dev/null
@@ -1,525 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-/**
- * Behavior is an abstract class that contains the framework for all
- * behavioral components in Java 3D.
- */
-
-class BehaviorRetained extends LeafRetained {
- // These bitmasks are used to quickly tell what conditions this behavior
- // is waiting for. Currently BehaviorStructure only used 4 of them.
- static final int WAKEUP_ACTIVATE_INDEX = 0;
- static final int WAKEUP_DEACTIVATE_INDEX = 1;
- static final int WAKEUP_VP_ENTRY_INDEX = 2;
- static final int WAKEUP_VP_EXIT_INDEX = 3;
- static final int WAKEUP_TIME_INDEX = 4;
-
- static final int NUM_WAKEUPS = 5;
-
- static final int WAKEUP_ACTIVATE = 0x0001;
- static final int WAKEUP_DEACTIVATE = 0x0002;
- static final int WAKEUP_VP_ENTRY = 0x0004;
- static final int WAKEUP_VP_EXIT = 0x0008;
- static final int WAKEUP_TIME = 0x0010;
-
- /**
- * The number of scheduling intervals supported by this
- * implementation. This is fixed for a particular implementation
- * and must be at least 10.
- */
- static final int NUM_SCHEDULING_INTERVALS = 10;
-
- // different types of IndexedUnorderedSet that use in BehaviorStructure
- static final int BEHAIVORS_IN_BS_LIST = 0;
- static final int SCHEDULE_IN_BS_LIST = 1;
-
- // total number of different IndexedUnorderedSet types
- static final int TOTAL_INDEXED_UNORDER_SET_TYPES = 2;
-
- /**
- * The Boundary object defining the behavior's scheduling region.
- */
- Bounds schedulingRegion = null;
-
- /**
- * The bounding leaf reference
- */
- BoundingLeafRetained boundingLeaf = null;
-
- /**
- * The current wakeup condition.
- */
- WakeupCondition wakeupCondition = null;
-
- /**
- * This is the new WakeupCondition to be set in
- * initialize wakeupOn()
- */
- WakeupCondition newWakeupCondition = null;
-
- /**
- * The current view platform for this behavior; this value is
- * false until it comes into range of a view platform.
- */
- ViewPlatformRetained vp = null;
-
- /**
- * The current activation status for this behavior; this value
- * is false until it comes into range of a view platform.
- */
- boolean active = false;
-
- /**
- * Flag indicating whether the behavior is enabled.
- */
- boolean enable = true;
-
- /**
- * Current scheduling interval.
- */
- int schedulingInterval = NUM_SCHEDULING_INTERVALS / 2;
-
- /**
- * This is a flag that tells the behavior scheduler whether the
- * user-programmed process stimulus called wakeupOn, if it did
- * not, then the wakeupCondition will be set to null.
- */
- boolean conditionSet = false;
-
- /**
- * This is a flag that indicates whether we are in an initialize or
- * processStimulus callback. If wakeupOn is called for this behavior
- * when this flag is not set, an exception will be thrown.
- */
- boolean inCallback = false;
-
- /**
- * This is a flag that indicates whether we are in initialize
- * callback. If wakeupOn is called for this behavior when
- * this flag is true, then its
- * buildTree() will delay until insert nodes message
- * is get. This is because some localToVworld[] that wakeup
- * depends may not initialize when this behavior setLive().
- */
- boolean inInitCallback = false;
-
- /**
- * The transformed schedulingRegion
- */
- Bounds transformedRegion = null;
-
- // A bitmask that indicates that the scheduling region has changed.
- int isDirty = 0xffff;
-
- /**
- * A bitmask that represents all conditions that this behavior is waiting on.
- */
- int wakeupMask = 0;
-
- /**
- * An array of ints that count how many of each wakup is present
- */
- int[] wakeupArray = new int[NUM_WAKEUPS];
-
- // use to post message when bounds change, always point to this
- Object targets[] = new Object[1];
-
- BehaviorRetained() {
- this.nodeType = NodeRetained.BEHAVIOR;
- localBounds = new BoundingBox((Bounds)null);
- targets[0] = this;
- IndexedUnorderSet.init(this, TOTAL_INDEXED_UNORDER_SET_TYPES);
- }
-
- /**
- * Get the Behavior's scheduling region.
- * @return this Behavior's scheduling region information
- */
- Bounds getSchedulingBounds() {
- Bounds b = null;
-
- if (schedulingRegion != null) {
- b = (Bounds) schedulingRegion.clone();
- if (staticTransform != null) {
- Transform3D invTransform = staticTransform.getInvTransform();
- b.transform(invTransform);
- }
- }
- return b;
- }
-
- /**
- * Set the Behavior's scheduling region.
- * @param region a region that contains the Behavior's new scheduling
- * bounds
- */
- synchronized void setSchedulingBounds(Bounds region) {
-
- if (region != null) {
- schedulingRegion = (Bounds) region.clone();
- if (staticTransform != null) {
- schedulingRegion.transform(staticTransform.transform);
- }
- } else {
- schedulingRegion = null;
- }
-
- if (source != null && source.isLive()) {
- sendMessage(J3dMessage.REGION_BOUND_CHANGED);
- }
- }
-
- /**
- * Set the Sound's scheduling region to the specified Leaf node.
- */
- synchronized void setSchedulingBoundingLeaf(BoundingLeaf region) {
-
- if (source != null && source.isLive()) {
- if (boundingLeaf != null)
- boundingLeaf.mirrorBoundingLeaf.removeUser(this);
- }
-
- if (region != null) {
- boundingLeaf = (BoundingLeafRetained)region.retained;
- } else {
- boundingLeaf = null;
- }
-
- if (source != null && source.isLive()) {
- if (boundingLeaf != null)
- boundingLeaf.mirrorBoundingLeaf.addUser(this);
- sendMessage(J3dMessage.REGION_BOUND_CHANGED);
- }
- }
-
- /**
- * Enables or disables this Behavior. The default state is enabled.
- * @param state true or false to enable or disable this Behavior
- */
- void setEnable(boolean state) {
- if (enable != state) {
- enable = state;
- if (source != null && source.isLive()) {
- sendMessage(state ? J3dMessage.BEHAVIOR_ENABLE:
- J3dMessage.BEHAVIOR_DISABLE);
- }
- }
- }
-
-
- /**
- * Retrieves the state of the Behavior enable flag.
- * @return the Behavior enable state
- */
- boolean getEnable() {
- return enable;
- }
-
-
- /**
- * Sets the scheduling interval of this Behavior node to the
- * specified value.
- * @param schedulingInterval the new scheduling interval
- */
- void setSchedulingInterval(int schedulingInterval) {
-
- if ((source != null) && source.isLive()
- && !inCallback) {
- // avoid MT safe problem when user thread setting
- // this while behavior scheduling using this.
- sendMessage(J3dMessage.SCHEDULING_INTERVAL_CHANGED,
- new Integer(schedulingInterval));
- } else {
- // garantee this setting reflect in next frame
- this.schedulingInterval = schedulingInterval;
- }
- }
-
-
- /**
- * Retrieves the current scheduling interval of this Behavior
- * node.
- *
- * @return the current scheduling interval
- */
- int getSchedulingInterval() {
- return schedulingInterval;
- }
-
-
- /**
- * Get the Behavior's scheduling region
- */
- BoundingLeaf getSchedulingBoundingLeaf() {
- return (boundingLeaf != null ?
- (BoundingLeaf)boundingLeaf.source : null);
- }
-
- /**
- * This setLive routine first calls the superclass's method, then
- * it activates all canvases that are associated with the attached
- * view.
- */
- @Override
- synchronized void setLive(SetLiveState s) {
-
- super.doSetLive(s);
- if (inBackgroundGroup) {
- throw new
- IllegalSceneGraphException(J3dI18N.getString("BehaviorRetained0"));
- }
- if (inSharedGroup) {
- throw new
- IllegalSharingException(J3dI18N.getString("BehaviorRetained1"));
- }
-
- s.nodeList.add(this);
- s.behaviorNodes.add(this);
- s.notifyThreads |= J3dThread.UPDATE_BEHAVIOR;
- // process switch leaf
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(this, Targets.BEH_TARGETS);
- }
- switchState = s.switchStates.get(0);
-
- if (boundingLeaf != null) {
- boundingLeaf.mirrorBoundingLeaf.addUser(this);
- }
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(this, Targets.BEH_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
- super.markAsLive();
- }
-
- /**
- * This clearLive routine first calls the superclass's method, then
- * it deactivates all canvases that are associated with the attached
- * view.
- */
- @Override
- synchronized void clearLive(SetLiveState s) {
- super.clearLive(s);
- s.nodeList.add(this);
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(this, Targets.BEH_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
- s.notifyThreads |= J3dThread.UPDATE_BEHAVIOR;
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(this, Targets.BEH_TARGETS);
- }
- if (boundingLeaf != null) {
- boundingLeaf.mirrorBoundingLeaf.removeUser(this);
- }
- // BehaviorStructure removeBehavior() will do the
- // wakeupCondition.cleanTree() over there.
- }
-
- /**
- * This routine execute the user's initialize method
- */
- void executeInitialize() {
-
- synchronized (this) {
- boolean inCallbackSaved = inCallback;
- boolean inInitCallbackSaved = inInitCallback;
-
- inCallback = true;
- inInitCallback = true;
- try {
- ((Behavior)this.source).initialize();
- }
- catch (RuntimeException e) {
- System.err.println("Exception occurred during Behavior initialization:");
- e.printStackTrace();
- }
- catch (Error e) {
- // Issue 264 - catch Error
- System.err.println("Error occurred during Behavior initialization:");
- e.printStackTrace();
- }
- inCallback = inCallbackSaved;
- inInitCallback = inInitCallbackSaved;
- }
- }
-
- /**
- * Defines this behavior's wakeup criteria.
- * @param criteria The wakeup criterion for this object
- */
- void wakeupOn(WakeupCondition criteria) {
- // If not call by initialize(), buildTree will
- // delay until insertNodes in BehaviorStructure
- // Otherwise BehaviorScheduler will invoke
- // handleLastWakeupOn()
- if (criteria == null) {
- throw new NullPointerException(J3dI18N.getString("BehaviorRetained2"));
- }
-
- if (!inInitCallback) {
- conditionSet = true;
- wakeupCondition = criteria;
- } else {
- // delay setting wakeup condition in BehaviorStructure
- // activateBehaviors(). This is because there may have
- // previously wakeupCondition attach to it and
- // scheduling even after clearLive() due to message
- // delay processing. It is not MT safe to set it
- // in user thread.
- newWakeupCondition = criteria;
- }
-
- }
-
- // The above wakeupOn() just remember the reference
- // We only need to handle (and ignore the rest) the
- // last wakeupOn() condition set in the behavior.
- // This handle the case when multiple wakeupOn()
- // are invoked in the same processStimulus()
- void handleLastWakeupOn(WakeupCondition prevWakeupCond,
- BehaviorStructure bs) {
-
- if (bs == universe.behaviorStructure) {
- if (wakeupCondition == prevWakeupCond) {
- // reuse the same wakeupCondition
- wakeupCondition.resetTree();
- } else {
- if (prevWakeupCond != null) {
- prevWakeupCond.cleanTree(bs);
- }
- wakeupCondition.buildTree(null, 0, this);
- }
- } else {
- // No need to do prevWakeupCond.cleanTree(bs)
- // since removeBehavior() will do so
- }
- }
-
-
- /**
- * Returns this behavior's wakeup criteria.
- * @return criteria The wakeup criteria of this object
- */
- WakeupCondition getWakeupCondition() {
- return wakeupCondition;
- }
-
- /**
- * Post the specified Id. Behaviors use this method to cause sequential
- * scheduling of other behavior object.
- * @param postId The Id being posted
- */
-
- void postId(int postId){
- if (source != null && source.isLive()) {
- universe.behaviorStructure.handleBehaviorPost((Behavior) source, postId);
- }
- }
-
- protected View getView() {
- return (universe != null ?
- universe.getCurrentView() : null);
- }
-
- synchronized void updateTransformRegion(Bounds bound) {
- if (boundingLeaf == null) {
- updateTransformRegion();
- } else {
- if (bound == null) {
- transformedRegion = null;
- } else {
- transformedRegion = (Bounds) bound.clone();
- transformedRegion.transform(
- boundingLeaf.mirrorBoundingLeaf.getCurrentLocalToVworld());
- }
- }
- }
-
- synchronized void updateTransformRegion() {
- if (boundingLeaf == null ||
- !boundingLeaf.mirrorBoundingLeaf.switchState.currentSwitchOn) {
- if (schedulingRegion == null) {
- transformedRegion = null;
- } else {
- // use schedulingRegion
- if (transformedRegion != null) {
- transformedRegion.set(schedulingRegion);
- } else {
- transformedRegion = (Bounds) schedulingRegion.clone();
- }
- transformedRegion.transform(getCurrentLocalToVworld());
-
- }
- } else {
- // use boundingLeaf
- transformedRegion =
- boundingLeaf.mirrorBoundingLeaf.transformedRegion;
-
- }
- }
-
-
- // Note: This routine will only to update the object's
- // transformed region
- void updateBoundingLeaf(long refTime) {
- transformedRegion = boundingLeaf.mirrorBoundingLeaf.transformedRegion;
- }
-
-
- void addWakeupCondition() {}
-
- final void sendMessage(int mtype, Object arg) {
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = J3dThread.UPDATE_BEHAVIOR;
- createMessage.type = mtype;
- createMessage.universe = universe;
- createMessage.args[0] = targets;
- createMessage.args[1]= this;
- createMessage.args[2]= arg;
- VirtualUniverse.mc.processMessage(createMessage);
- }
-
- final void sendMessage(int mtype) {
- sendMessage(mtype, null);
- }
-
- @Override
- void mergeTransform(TransformGroupRetained xform) {
- super.mergeTransform(xform);
- if (schedulingRegion != null) {
- schedulingRegion.transform(xform.transform);
- }
- if (source instanceof DistanceLOD) {
- ((DistanceLOD)source).mergeTransform(xform);
- }
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BehaviorScheduler.java b/src/classes/share/javax/media/j3d/BehaviorScheduler.java
deleted file mode 100644
index 1a43a34..0000000
--- a/src/classes/share/javax/media/j3d/BehaviorScheduler.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.logging.Level;
-
-class BehaviorScheduler extends J3dThread {
-
- /**
- * The virtual universe that owns this BehaviorScheduler
- */
- VirtualUniverse univ = null;
-
- // reference to behaviourStructure processList
- UnorderList processList[];
-
- // reference to scheduleList;
- IndexedUnorderSet scheduleList;
-
- // reference to universe.behaviorStructure
- BehaviorStructure behaviorStructure;
-
- // A count for BehaviorScheduler start/stop
- int stopCount = -1;
-
- /**
- * These are used for start/stop BehaviorScheduler
- */
- long lastStartTime;
- long lastStopTime;
-
- // lock to ensure consistency of interval values read
- Object intervalTimeLock = new Object();
-
- /**
- * Some variables used to name threads correctly
- */
- private static int numInstances = 0;
- private int instanceNum = -1;
-
- private synchronized int newInstanceNum() {
- return (++numInstances);
- }
-
- @Override
- int getInstanceNum() {
- if (instanceNum == -1)
- instanceNum = newInstanceNum();
- return instanceNum;
- }
-
-
- BehaviorScheduler(ThreadGroup t, VirtualUniverse universe) {
- super(t);
- setName("J3D-BehaviorScheduler-" + getInstanceNum());
- this.univ = universe;
- behaviorStructure = universe.behaviorStructure;
- scheduleList = behaviorStructure.scheduleList;
- processList = behaviorStructure.processList;
- type = J3dThread.BEHAVIOR_SCHEDULER;
- }
-
- void stopBehaviorScheduler(long[] intervalTime) {
-
- stopCount = 2;
- VirtualUniverse.mc.sendRunMessage(univ, J3dThread.BEHAVIOR_SCHEDULER);
- while (!userStop ) {
- MasterControl.threadYield();
- }
- synchronized (intervalTimeLock) {
- intervalTime[0] = lastStartTime;
- intervalTime[1] = lastStopTime;
- }
- }
-
- void startBehaviorScheduler() {
- // don't allow scheduler start until intervalTime is read
- synchronized (intervalTimeLock) {
- stopCount = -1;
- userStop = false;
- VirtualUniverse.mc.setWork();
- }
- }
-
- void deactivate() {
- active = false;
- if (stopCount >= 0) {
- userStop = true;
- }
- }
-
- /**
- * The main loop for the Behavior Scheduler.
- * Main method for firing off vector of satisfied conditions that
- * are contained in the condMet vector. Method is synchronized
- * because it is modifying the current wakeup vectors in the
- * clean (emptying out satisfied conditions) and processStimulus
- * (adding conditions again if wakeupOn called) calls.
- */
- @Override
- void doWork(long referenceTime) {
- BehaviorRetained arr[];
- UnorderList list;
- int i, size, interval;
-
- lastStartTime = J3dClock.currentTimeMillis();
-
- if (stopCount >= 0) {
- VirtualUniverse.mc.sendRunMessage(univ, J3dThread.BEHAVIOR_SCHEDULER);
- if (--stopCount == 0) {
- userStop = true;
- }
- }
-
-
- for (interval = 0;
- interval < BehaviorRetained.NUM_SCHEDULING_INTERVALS;
- interval++) {
-
- list = processList[interval];
-
- if (list.isEmpty()) {
- continue;
- }
- arr = (BehaviorRetained []) list.toArray(false);
-
- size = list.arraySize();
-
- for (i = 0; i < size ; i++) {
- BehaviorRetained behavret = arr[i];
-
-
- synchronized (behavret) {
- Behavior behav = (Behavior) behavret.source;
-
- if (!behav.isLive() ||
- !behavret.conditionSet ||
- (behavret.wakeupCondition == null)) {
- continue;
- }
-
- if (behavret.wakeupCondition.trigEnum == null) {
- behavret.wakeupCondition.trigEnum =
- new WakeupCriteriaEnumerator(behavret.wakeupCondition,
- WakeupCondition.TRIGGERED_ELEMENTS);
- } else {
- behavret.wakeupCondition.trigEnum.reset(
- behavret.wakeupCondition,
- WakeupCondition.TRIGGERED_ELEMENTS);
- }
-
- // BehaviorRetained now cache the old
- // wakeupCondition in order to
- // reuse it without the heavyweight cleanTree()
- // behavret.wakeupCondition.cleanTree();
-
- behavret.conditionSet = false;
- WakeupCondition wakeupCond = behavret.wakeupCondition;
-
- synchronized (behavret) {
- behavret.inCallback = true;
- univ.inBehavior = true;
- try {
- behav.processStimulus(wakeupCond.trigEnum);
- }
- catch (RuntimeException e) {
- // Force behavior condition to be unset
- // Issue 21: don't call cleanTree here
- behavret.conditionSet = false;
- System.err.println("Exception occurred during Behavior execution:");
- e.printStackTrace();
- }
- catch (Error e) {
- // Force behavior condition to be unset
- // Fix for issue 264
- behavret.conditionSet = false;
- System.err.println("Error occurred during Behavior execution:");
- e.printStackTrace();
- }
- univ.inBehavior = false;
- behavret.inCallback = false;
- }
- // note that if the behavior wasn't reset, we need to make the
- // wakeupcondition equal to null
- if (behavret.conditionSet == false) {
- if (wakeupCond != null) {
- wakeupCond.cleanTree(behaviorStructure);
- }
- behavret.wakeupCondition = null;
- behavret.active = false;
- scheduleList.remove(behavret);
- } else {
- behavret.handleLastWakeupOn(wakeupCond,
- behaviorStructure);
- }
- }
- }
- list.clear();
- }
-
- behaviorStructure.handleAWTEvent();
- behaviorStructure.handleBehaviorPost();
- lastStopTime = J3dClock.currentTimeMillis();
-
- if (MasterControl.isStatsLoggable(Level.FINE)) {
- VirtualUniverse.mc.recordTime(MasterControl.TimeType.BEHAVIOR, (lastStopTime-lastStartTime)*1000000);
- }
- }
-
- void free() {
- behaviorStructure = null;
- getThreadData(null, null).thread = null;
- univ = null;
- for (int i=BehaviorRetained.NUM_SCHEDULING_INTERVALS-1;
- i >= 0; i--) {
- processList[i].clear();
- }
- scheduleList.clear();
- }
-}
diff --git a/src/classes/share/javax/media/j3d/BehaviorStructure.java b/src/classes/share/javax/media/j3d/BehaviorStructure.java
deleted file mode 100644
index dc10a13..0000000
--- a/src/classes/share/javax/media/j3d/BehaviorStructure.java
+++ /dev/null
@@ -1,1675 +0,0 @@
-/*
- * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.awt.AWTEvent;
-import java.awt.event.ComponentEvent;
-import java.awt.event.FocusEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.util.Arrays;
-
-import javax.vecmath.Point3d;
-import javax.vecmath.Vector3d;
-
-/**
- * A behavior structure is a object that organizes behaviors,
- * wakeup conditions, and other behavior scheduler entities.
- */
-
-class BehaviorStructure extends J3dStructure {
-
- /**
- * The list of behaviors
- */
- IndexedUnorderSet behaviors;
-
- /**
- * The list of view platforms
- */
- IndexedUnorderSet viewPlatforms;
-
- /**
- * An array of schedulable behaviors, use in
- * removeViewPlatform() to go through only active behaviors
- */
- IndexedUnorderSet scheduleList;
-
- /**
- * An array of process behaviors
- */
- UnorderList processList[] = new UnorderList[BehaviorRetained.NUM_SCHEDULING_INTERVALS];
-
- /**
- * A bounds used for getting a view platform scheduling BoundingSphere
- */
- // BoundingSphere tempSphere = new BoundingSphere();
- // BoundingSphere vpsphere = new BoundingSphere();
- Point3d vpCenter = new Point3d();
- Point3d vpTransCenter = new Point3d();
-
- /**
- * A list of bounds WakeupOnViewPlatformEntry objects that
- * have seen ViewPlatformEntry
- */
- WakeupIndexedList boundsEntryList;
-
- /**
- * A list of bounds WakeupOnViewPlatformExit objects that have
- * seen ViewPlatformEntry
- */
- WakeupIndexedList boundsExitList;
-
- /**
- * A list of WakeupOnSensorEntry objects that have seen a sensor
- */
- WakeupIndexedList currentSensorEntryList;
-
- /**
- * A list of WakeupOnSensorExit objects that have seen a sensor
- */
- WakeupIndexedList currentSensorExitList;
-
- /**
- * The lists of the WakeupCriterion objects that the
- * behavior scheduler keeps.
- */
- WakeupIndexedList wakeupOnAWTEvent;
- WakeupIndexedList wakeupOnActivation;
- WakeupIndexedList wakeupOnDeactivation;
- WakeupIndexedList wakeupOnBehaviorPost;
- WakeupIndexedList wakeupOnElapsedFrames;
- WakeupIndexedList wakeupOnViewPlatformEntry;
- WakeupIndexedList wakeupOnViewPlatformExit;
- WakeupIndexedList wakeupOnSensorEntry;
- WakeupIndexedList wakeupOnSensorExit;
-
- // Temporary array for processTransformChanged()
- UnorderList transformViewPlatformList = new UnorderList(ViewPlatformRetained.class);
-
-
- // The number of active wakeup condition in wakeupOnElapsedFrames
- int activeWakeupOnFrameCount = 0;
-
- // The number of active wakeup condition in wakeupOnSensorEntry/Exit
- int activeWakeupOnSensorCount = 0;
-
- /**
- * Buffers to hold events when user thread is in processStimulus()
- * while this event is receiving. This avoid any lost of event.
- * We did not remove individual element from the following list
- * (except clear()) so the order is still preserve.
- */
- UnorderList awtEventsBuffer = new UnorderList(AWTEvent.class);
-
- // Use generic integer array to avoid new Integer() for individual element
- int postIDBuffer[] = new int[10]; // size of default UnorderList
- int clonePostIDBuffer[] = new int[postIDBuffer.length];
-
- UnorderList behaviorPostBuffer = new UnorderList(Behavior.class);
-
- // temp values for transformed hotspot used in
- // wakeupOnSensorEntry/ExitupdateSensorsHotspot
- Transform3D sensorTransform = new Transform3D();
- Vector3d sensorLoc = new Vector3d();
- Point3d ptSensorLoc = new Point3d();
-
- // list of active physical environments
- UnorderList physicalEnvironments = new UnorderList(1, PhysicalEnvironment.class);
-
-
- // list of Behavior waiting to be add to behavior list and buildTree()
- UnorderList pendingBehaviors = new UnorderList(BehaviorRetained.class);
-
- // true if branch detach
- boolean branchDetach = false;
-
- // This is used to notify WakeupOnAWTEvent re-enable Canvas3D events
- long awtEventTimestamp = 1;
-
- // used to process transform messages
- boolean transformMsg = false;
- UpdateTargets targets = null;
-
- BehaviorStructure(VirtualUniverse u) {
- super(u, J3dThread.UPDATE_BEHAVIOR);
-
- for (int i=BehaviorRetained.NUM_SCHEDULING_INTERVALS-1;
- i >= 0; i--) {
- processList[i] = new UnorderList(BehaviorRetained.class);
- }
- behaviors = new IndexedUnorderSet(BehaviorRetained.class,
- BehaviorRetained.BEHAIVORS_IN_BS_LIST, u);
- viewPlatforms = new IndexedUnorderSet(ViewPlatformRetained.class,
- ViewPlatformRetained.VP_IN_BS_LIST, u);
- scheduleList = new IndexedUnorderSet(BehaviorRetained.class,
- BehaviorRetained.SCHEDULE_IN_BS_LIST, u);
- boundsEntryList = new WakeupIndexedList(WakeupOnViewPlatformEntry.class,
- WakeupOnViewPlatformEntry.BOUNDSENTRY_IN_BS_LIST, u);
- boundsExitList = new WakeupIndexedList(WakeupOnViewPlatformExit.class,
- WakeupOnViewPlatformExit.BOUNDSEXIT_IN_BS_LIST, u);
- currentSensorEntryList = new WakeupIndexedList(WakeupOnSensorEntry.class,
- WakeupOnSensorEntry.SENSORENTRY_IN_BS_LIST, u);
- currentSensorExitList = new WakeupIndexedList(WakeupOnSensorExit.class,
- WakeupOnSensorExit.SENSOREXIT_IN_BS_LIST, u);
- wakeupOnAWTEvent = new WakeupIndexedList(WakeupOnAWTEvent.class,
- WakeupOnAWTEvent.COND_IN_BS_LIST, u);
- wakeupOnActivation = new WakeupIndexedList(WakeupOnActivation.class,
- WakeupOnActivation.COND_IN_BS_LIST, u);
- wakeupOnDeactivation = new WakeupIndexedList(WakeupOnDeactivation.class,
- WakeupOnDeactivation.COND_IN_BS_LIST, u);
- wakeupOnBehaviorPost = new WakeupIndexedList(WakeupOnBehaviorPost.class,
- WakeupOnBehaviorPost.COND_IN_BS_LIST, u);
- wakeupOnElapsedFrames = new WakeupIndexedList(WakeupOnElapsedFrames.class,
- WakeupOnElapsedFrames.COND_IN_BS_LIST, u);
- wakeupOnViewPlatformEntry = new WakeupIndexedList(WakeupOnViewPlatformEntry.class,
- WakeupOnViewPlatformEntry.COND_IN_BS_LIST, u);
- wakeupOnViewPlatformExit = new WakeupIndexedList(WakeupOnViewPlatformExit.class,
- WakeupOnViewPlatformExit.COND_IN_BS_LIST, u);
- wakeupOnSensorEntry = new WakeupIndexedList(WakeupOnSensorEntry.class,
- WakeupOnSensorEntry.COND_IN_BS_LIST, u);
- wakeupOnSensorExit = new WakeupIndexedList(WakeupOnSensorExit.class,
- WakeupOnSensorExit.COND_IN_BS_LIST, u);
-
- }
-
- @Override
- void processMessages(long referenceTime) {
-
- J3dMessage[] messages = getMessages(referenceTime);
- int nMsg = getNumMessage();
- J3dMessage m;
-
- if (nMsg > 0) {
- for (int i=0; i 0) {
- // Wakeup render thread when there is pending wakeupOnElapsedFrames
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.BEHAVIOR_SCHEDULER|
- J3dThread.RENDER_THREAD);
-
- } else {
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.BEHAVIOR_SCHEDULER);
- }
- } else {
- checkSensorEntryExit();
- // we have to invoke checkSensorEntryExit() next time
- if (activeWakeupOnFrameCount > 0) {
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.UPDATE_BEHAVIOR|
- J3dThread.BEHAVIOR_SCHEDULER|
- J3dThread.RENDER_THREAD);
-
- } else {
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.UPDATE_BEHAVIOR|
- J3dThread.BEHAVIOR_SCHEDULER);
- }
- }
- }
-
- void insertNodes(Object[] nodes) {
- for (int i=0; i=0; i--) {
- behav = behavArr[i];
- behav.wakeupCondition = behav.newWakeupCondition;
- if (behav.wakeupCondition != null) {
- behav.wakeupCondition.buildTree(null, 0, behav);
- behav.conditionSet = true;
- behaviors.add(behav);
- behav.updateTransformRegion();
- addToScheduleList(behav);
- }
- }
- pendingBehaviors.clear();
- }
-
- void addViewPlatform(ViewPlatformRetained vp) {
- int i;
- BehaviorRetained behavArr[] = (BehaviorRetained []) behaviors.toArray(false);
-
- viewPlatforms.add(vp);
- vp.updateTransformRegion();
-
- if (!vp.isActiveViewPlatform()) {
- return;
- }
-
- // re-evaulate all behaviors to see if we need to put
- // more behaviors in scheduleList
-
- for (i=behaviors.arraySize()-1; i>=0; i--) {
- addToScheduleList(behavArr[i]);
- }
-
- // handle ViewPlatform Entry
- WakeupOnViewPlatformEntry wakeupOnViewPlatformEntryArr[] =
- (WakeupOnViewPlatformEntry []) wakeupOnViewPlatformEntry.toArray(false);
- WakeupOnViewPlatformEntry wentry;
-
- for (i=wakeupOnViewPlatformEntry.arraySize()-1; i >=0; i--) {
- wentry = wakeupOnViewPlatformEntryArr[i];
- if (!boundsEntryList.contains(wentry) &&
- wentry.transformedRegion.intersect(vp.center)) {
- boundsEntryList.add(wentry);
- wentry.triggeredVP = vp;
- wentry.setTriggered();
- }
- }
-
- // handle ViewPlatform Exit
- WakeupOnViewPlatformExit wakeupOnViewPlatformExitArr[] =
- (WakeupOnViewPlatformExit []) wakeupOnViewPlatformExit.toArray(false);
- WakeupOnViewPlatformExit wexit;
-
- for (i=wakeupOnViewPlatformExit.arraySize()-1; i >=0; i--) {
- wexit = wakeupOnViewPlatformExitArr[i];
- if (!boundsExitList.contains(wexit) &&
- wexit.transformedRegion.intersect(vp.center)) {
- wexit.triggeredVP = vp;
- boundsExitList.add(wexit);
- }
- }
-
- }
-
- @Override
- void removeNodes(J3dMessage m) {
- Object[] nodes = (Object[]) m.args[0];
- boolean behavRemove = false;
-
- for (int i=0; i= FocusEvent.FOCUS_FIRST && awtId <= FocusEvent.FOCUS_LAST) ||
- (eventMask & AWTEvent.FOCUS_EVENT_MASK) != 0) {
- focusEnable = true;
- }
- if ((awtId >= KeyEvent.KEY_FIRST && awtId <= KeyEvent.KEY_LAST) ||
- (eventMask & AWTEvent.KEY_EVENT_MASK) != 0) {
- keyEnable = true;
- }
- if ((awtId >= MouseEvent.MOUSE_FIRST) &&
- (awtId <= MouseEvent.MOUSE_LAST)) {
- if ((awtId == MouseEvent.MOUSE_DRAGGED) ||
- (awtId == MouseEvent.MOUSE_MOVED)) {
- mouseMotionEnable = true;
- }
- else if ((awtId == MouseEvent.MOUSE_ENTERED) ||
- (awtId == MouseEvent.MOUSE_EXITED) ||
- (awtId == MouseEvent.MOUSE_CLICKED) ||
- (awtId == MouseEvent.MOUSE_PRESSED) ||
- (awtId == MouseEvent.MOUSE_RELEASED) ) {
- mouseEnable = true;
- }
- else if (awtId == MouseEvent.MOUSE_WHEEL) {
- mouseWheelEnable = true;
- }
- } else {
- if ((eventMask & AWTEvent.MOUSE_EVENT_MASK) != 0) {
- mouseEnable = true;
- }
- if ((eventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0) {
- mouseMotionEnable = true;
- }
- if ((eventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0) {
- mouseWheelEnable = true;
- }
- }
- }
-
- if (!focusEnable && universe.enableFocus) {
- incTimestamp = true;
- universe.disableFocusEvents();
- }
- if (!keyEnable && universe.enableKey) {
- // key event use for toggle to fullscreen/window mode
- incTimestamp = true;
- universe.disableKeyEvents();
- }
- if (!mouseWheelEnable && universe.enableMouseWheel) {
- incTimestamp = true;
- universe.disableMouseWheelEvents();
- }
- if (!mouseMotionEnable && universe.enableMouseMotion) {
- incTimestamp = true;
- universe.disableMouseMotionEvents();
- }
- if (!mouseEnable && universe.enableMouse) {
- incTimestamp = true;
- universe.disableMouseEvents();
- }
- if (incTimestamp) {
- awtEventTimestamp++;
- }
- }
- }
-
- void removeViewPlatform(ViewPlatformRetained vp) {
- BehaviorRetained behav;
- int i;
-
- viewPlatforms.remove(vp);
-
- BehaviorRetained scheduleArr[] = (BehaviorRetained [])
- scheduleList.toArray(false);
-
- // handle Deactive
- for (i=scheduleList.arraySize()-1; i >=0 ; i--) {
- behav = scheduleArr[i];
- // This vp may contribute to the reason that
- // behavior is in schedule list
- if (!intersectVPRegion(behav.transformedRegion)) {
- removeFromScheduleList(behav);
- }
- }
-
- // handle ViewPlatform Entry
- WakeupOnViewPlatformEntry boundsEntryArr[] =
- (WakeupOnViewPlatformEntry []) boundsEntryList.toArray(false);
- WakeupOnViewPlatformEntry wentry;
- ViewPlatformRetained triggeredVP;
-
- for (i=boundsEntryList.arraySize()-1; i >=0; i--) {
- wentry = boundsEntryArr[i];
- // only this thread can modify wentry.transformedRegion, so
- // no need to getWithLock()
- triggeredVP = intersectVPCenter(wentry.transformedRegion);
- if (triggeredVP == null) {
- boundsEntryList.remove(wentry);
- }
- }
-
- // handle ViewPlatform Exit
- WakeupOnViewPlatformExit boundsExitArr[] =
- (WakeupOnViewPlatformExit []) boundsExitList.toArray(false);
- WakeupOnViewPlatformExit wexit;
-
- for (i=boundsExitList.arraySize()-1; i >=0; i--) {
- wexit = boundsExitArr[i];
- // only this thread can modify wentry.transformedRegion, so
- // no need to getWithLock()
- triggeredVP = intersectVPCenter(wexit.transformedRegion);
- if (triggeredVP == null) {
- boundsExitList.remove(wexit);
- wexit.setTriggered();
- }
- }
- }
-
- void removeBehavior(BehaviorRetained behav) {
- behaviors.remove(behav);
-
- if ((behav.wakeupCondition != null) &&
- (behav.wakeupCondition.behav != null)) {
- behav.wakeupCondition.cleanTree(this);
- if (behav.universe == universe) {
- behav.conditionSet = false;
- }
- }
-
- // cleanup boundsEntryList
- // since we didn't remove it on removeVPEntryCondition
- WakeupOnViewPlatformEntry boundsEntryArr[] =
- (WakeupOnViewPlatformEntry []) boundsEntryList.toArray(false);
- WakeupOnViewPlatformEntry wentry;
-
- for (int i=boundsEntryList.arraySize()-1; i>=0; i--) {
- wentry = boundsEntryArr[i];
- if (wentry.behav == behav) {
- boundsEntryList.remove(wentry);
- }
- }
-
- // cleanup boundsExitList
- // since we didn't remove it on removeVPExitCondition
- WakeupOnViewPlatformExit boundsExitArr[] =
- (WakeupOnViewPlatformExit []) boundsExitList.toArray(false);
- WakeupOnViewPlatformExit wexit;
-
- for (int i=boundsExitList.arraySize()-1; i>=0; i--) {
- wexit = boundsExitArr[i];
- if (wexit.behav == behav) {
- boundsExitList.remove(wexit);
- }
- }
-
-
- // cleanup currentSensorEntryList
- // since we didn't remove it on removeSensorEntryCondition
- WakeupOnSensorEntry currentSensorEntryArr[] =
- (WakeupOnSensorEntry []) currentSensorEntryList.toArray(false);
- WakeupOnSensorEntry sentry;
-
- for (int i=currentSensorEntryList.arraySize()-1; i>=0; i--) {
- sentry = currentSensorEntryArr[i];
- if (sentry.behav == behav) {
- currentSensorEntryList.remove(sentry);
- }
- }
-
-
- // cleanup currentSensorExitList
- // since we didn't remove it on removeSensorExitCondition
- WakeupOnSensorExit currentSensorExitArr[] =
- (WakeupOnSensorExit []) currentSensorExitList.toArray(false);
- WakeupOnSensorExit sexit;
-
- for (int i=currentSensorExitList.arraySize()-1; i>=0; i--) {
- sexit = currentSensorExitArr[i];
- if (sexit.behav == behav) {
- currentSensorExitList.remove(sexit);
- }
- }
- removeFromScheduleList(behav);
-
- }
-
-
- void handleAWTEvent(AWTEvent evt) {
- awtEventsBuffer.add(evt);
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.BEHAVIOR_SCHEDULER);
- }
-
- /**
- * This routine takes the awt event list and gives then to the awt event
- * conditions
- */
- void handleAWTEvent() {
- WakeupOnAWTEvent awtConds[] = (WakeupOnAWTEvent [])
- wakeupOnAWTEvent.toArray();
- AWTEvent events[];
- int eventSize = wakeupOnAWTEvent.arraySize();
- int awtBufferSize;
-
- synchronized (awtEventsBuffer) {
- events = (AWTEvent []) awtEventsBuffer.toArray();
- awtBufferSize = awtEventsBuffer.size();
- awtEventsBuffer.clear();
- }
- WakeupOnAWTEvent awtCond;
- AWTEvent evt;
- int id;
-
- for (int i=0; i < eventSize; i++) {
- awtCond = awtConds[i];
- for (int j=0; j < awtBufferSize; j++) {
- evt = events[j];
- id = evt.getID();
-
- if (awtCond.AwtId != 0) {
- if (awtCond.AwtId == id) {
- // XXXX: how do we clone this event (do we need to?)
- // Bug: 4181321
- awtCond.addAWTEvent(evt);
- }
- } else {
- if (id >= ComponentEvent.COMPONENT_FIRST &&
- id <= ComponentEvent.COMPONENT_LAST &&
- (awtCond.EventMask & AWTEvent.COMPONENT_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- else if (id >= FocusEvent.FOCUS_FIRST &&
- id <= FocusEvent.FOCUS_LAST &&
- (awtCond.EventMask & AWTEvent.FOCUS_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- else if (id >= KeyEvent.KEY_FIRST &&
- id <= KeyEvent.KEY_LAST &&
- (awtCond.EventMask & AWTEvent.KEY_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- else if ((id == MouseEvent.MOUSE_CLICKED ||
- id == MouseEvent.MOUSE_ENTERED ||
- id == MouseEvent.MOUSE_EXITED ||
- id == MouseEvent.MOUSE_PRESSED ||
- id == MouseEvent.MOUSE_RELEASED) &&
- (awtCond.EventMask & AWTEvent.MOUSE_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- else if ((id == MouseEvent.MOUSE_DRAGGED ||
- id == MouseEvent.MOUSE_MOVED) &&
- (awtCond.EventMask & AWTEvent.MOUSE_MOTION_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- else if ((id == MouseEvent.MOUSE_WHEEL) &&
- (awtCond.EventMask & AWTEvent.MOUSE_WHEEL_EVENT_MASK) != 0) {
- awtCond.addAWTEvent(evt);
- }
- }
- }
- }
-
-
-
- }
-
-
- void handleBehaviorPost(Behavior behav, int postid) {
-
- synchronized (behaviorPostBuffer) {
- int size = behaviorPostBuffer.size();
- if (postIDBuffer.length == size) {
- int oldbuffer[] = postIDBuffer;
- postIDBuffer = new int[size << 1];
- System.arraycopy(oldbuffer, 0, postIDBuffer, 0, size);
- }
- postIDBuffer[size] = postid;
- behaviorPostBuffer.add(behav);
- }
- VirtualUniverse.mc.sendRunMessage(universe, J3dThread.BEHAVIOR_SCHEDULER);
- }
-
- /**
- * This goes through all of the criteria waiting for Behavior Posts
- * and notifys them.
- */
- void handleBehaviorPost() {
- Behavior behav;
- int postid;
- WakeupOnBehaviorPost wakeup;
- WakeupOnBehaviorPost wakeupConds[] = (WakeupOnBehaviorPost [])
- wakeupOnBehaviorPost.toArray();
- Behavior behavArr[];
- int behavBufferSize;
-
- synchronized (behaviorPostBuffer) {
- behavArr = (Behavior []) behaviorPostBuffer.toArray();
- behavBufferSize = behaviorPostBuffer.size();
- if (clonePostIDBuffer.length < behavBufferSize) {
- clonePostIDBuffer = new int[behavBufferSize];
- }
- System.arraycopy(postIDBuffer, 0, clonePostIDBuffer, 0,
- behavBufferSize);
- behaviorPostBuffer.clear();
- }
-
- int size = wakeupOnBehaviorPost.arraySize();
- for (int i=0; i < size; i++) {
- wakeup = wakeupConds[i];
- for (int j=0; j < behavBufferSize; j++) {
- behav = behavArr[j];
- postid = clonePostIDBuffer[j];
- if ((wakeup.post == postid || wakeup.post == 0) &&
- (behav == wakeup.armingBehavior || wakeup.armingBehavior == null)) {
- wakeup.triggeringBehavior = behav;
- wakeup.triggeringPost = postid;
- wakeup.setTriggered();
- }
- }
- }
-
- }
-
- /**
- * This goes through all of the criteria waiting for Elapsed Frames
- * and notified them.
- */
- void incElapsedFrames() {
-
- WakeupOnElapsedFrames wakeupConds[] = (WakeupOnElapsedFrames [])
- wakeupOnElapsedFrames.toArray(true);
- int size = wakeupOnElapsedFrames.arraySize();
- int i = 0;
-
- while (i < size) {
- wakeupConds[i++].newFrame();
- }
-
- if ( size > 0) {
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.BEHAVIOR_SCHEDULER|J3dThread.UPDATE_BEHAVIOR);
- }
-
- if (branchDetach) {
- // Since this procedure may call by immediate mode user
- // thread, we can't just clear it in removeNodes()
- wakeupOnElapsedFrames.clearMirror();
- branchDetach = false;
- }
-
- }
-
- void removeVPEntryCondition(WakeupCondition w) {
- wakeupOnViewPlatformEntry.remove(w);
- // don't remove boundsEntryList, it is use next time
- // when addVPExitCondition invoke to determine whether to
- // trigger an event or not.
-
- }
-
- void addVPEntryCondition(WakeupOnViewPlatformEntry w) {
- boolean needTrigger = true;
-
- // see if the matching wakeupOnViewPlatformEntry
- // condition exists & do cleanup
- WakeupOnViewPlatformEntry boundsEntryArr[] =
- (WakeupOnViewPlatformEntry []) boundsEntryList.toArray(false);
- WakeupOnViewPlatformEntry wentry;
-
- for (int i=boundsEntryList.arraySize()-1; i>=0; i--) {
- wentry = boundsEntryArr[i];
- if ((wentry.behav == w.behav) &&
- (wentry.region.equals(w.region))) {
- boundsEntryList.remove(i);
- // Case where we wakeOr() both condition together.
- // we should avoid calling setTrigger() every time.
- needTrigger = false;
- break;
- }
- }
-
- wakeupOnViewPlatformEntry.add(w);
-
- ViewPlatformRetained triggeredVP = intersectVPCenter(w.transformedRegion);
- if (triggeredVP != null) {
- boundsEntryList.add(w);
- }
-
- // we always trigger bound is inside during initialize
- if (needTrigger && (triggeredVP != null)) {
- w.triggeredVP = triggeredVP;
- w.setTriggered();
- }
- }
-
- void removeVPExitCondition(WakeupOnViewPlatformExit w) {
- wakeupOnViewPlatformExit.remove(w);
- // don't remove boundsExitList, it is use next time
- // when addVPEntryCondition invoke to determine whether to
- // trigger an event or not.
- }
-
- void addVPExitCondition(WakeupOnViewPlatformExit w) {
- // Cleanup, since collideEntryList did not remove
- // its condition in removeVPEntryCondition
- boolean needTrigger = true;
- WakeupOnViewPlatformExit boundsExitArr[] =
- (WakeupOnViewPlatformExit []) boundsExitList.toArray(false);
- WakeupOnViewPlatformExit wexit;
- for (int i=boundsExitList.arraySize()-1; i>=0; i--) {
- wexit = boundsExitArr[i];
- if ((wexit.behav == w.behav) &&
- (wexit.region.equals(w.region))) {
- boundsExitList.remove(i);
- needTrigger = false;
- break;
- }
- }
-
- ViewPlatformRetained triggeredVP = intersectVPCenter(w.transformedRegion);
- wakeupOnViewPlatformExit.add(w);
-
- if (triggeredVP != null) {
- w.triggeredVP = triggeredVP;
- boundsExitList.add(w);
- }
-
- if (!needTrigger) {
- return;
- }
-
- // see if the matching wakeupOnViewPlatformEntry
- // condition exists
-
- WakeupOnViewPlatformEntry boundsEntryArr[] =
- (WakeupOnViewPlatformEntry []) boundsEntryList.toArray(false);
- WakeupOnViewPlatformEntry wentry;
-
- for (int i=boundsEntryList.arraySize()-1; i>=0; i--) {
- wentry = boundsEntryArr[i];
- if ((wentry.behav == w.behav) &&
- (wentry.region.equals(w.region))) {
- // Don't remove this since if user wakeupOr()
- // Entry and Exit condition together we may have trouble
- // boundsEntryList.remove(i);
- if (triggeredVP == null) {
- w.setTriggered();
- }
- break;
- }
- }
-
- }
-
-
- void removeSensorEntryCondition(WakeupOnSensorEntry w) {
- wakeupOnSensorEntry.remove(w);
- // don't remove currentSensorEntryList, it is use next time
- // when addSensorExitCondition invoke to determine whether to
- // trigger an event or not.
- }
-
- void addSensorEntryCondition(WakeupOnSensorEntry w) {
- boolean needTrigger = true;
-
- // see if the matching wakeupOnSensorEntry
- // condition exists
- WakeupOnSensorEntry sensorEntryArr[] =
- (WakeupOnSensorEntry []) currentSensorEntryList.toArray(false);
- WakeupOnSensorEntry wentry;
-
- for (int i=currentSensorEntryList.arraySize()-1; i>=0; i--) {
- wentry = sensorEntryArr[i];
- if ((wentry.behav == w.behav) &&
- (wentry.region.equals(w.region))) {
- currentSensorEntryList.remove(i);
- needTrigger = false;
- break;
- }
- }
-
- wakeupOnSensorEntry.add(w);
-
- w.updateTransformRegion();
- Sensor target = sensorIntersect(w.transformedRegion);
- if (target != null) {
- w.setTarget(target);
- currentSensorEntryList.add(w);
- }
-
- if (needTrigger && (target != null)) {
- w.setTriggered();
-
- }
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.UPDATE_BEHAVIOR);
- }
-
- void removeSensorExitCondition(WakeupOnSensorExit w) {
- wakeupOnSensorExit.remove(w);
- // don't remove currentSensorExitList, it is use next time
- // when addSensorEntryCondition invoke to determine whether to
- // trigger an event or not
- }
-
- void addSensorExitCondition(WakeupOnSensorExit w) {
- // Cleanup
- boolean needTrigger = true;
-
- WakeupOnSensorExit currentSensorExitArr[] =
- (WakeupOnSensorExit []) currentSensorExitList.toArray(false);
- WakeupOnSensorExit wexit;
- for (int i=currentSensorExitList.arraySize()-1; i>=0; i--) {
- wexit = currentSensorExitArr[i];
- if ((wexit.behav == w.behav) &&
- (wexit.region.equals(w.region))) {
- currentSensorExitList.remove(i);
- needTrigger = false;
- break;
- }
- }
-
- w.updateTransformRegion();
- Sensor target = sensorIntersect(w.transformedRegion);
- wakeupOnSensorExit.add(w);
-
- if (target != null) {
- w.setTarget(target);
- currentSensorExitList.add(w);
- }
-
- if (!needTrigger) {
- return;
- }
- // see if the matching wakeupOnSensorEntry
- // condition exists
- WakeupOnSensorEntry sensorEntryArr[] =
- (WakeupOnSensorEntry []) currentSensorEntryList.toArray(false);
- WakeupOnSensorEntry wentry;
-
- for (int i=currentSensorEntryList.arraySize()-1; i>=0; i--) {
- wentry = sensorEntryArr[i];
- if ((wentry.behav == w.behav) &&
- (wentry.region.equals(w.region))) {
- // No need to invoke currentSensorEntryList.remove(i);
- if (target == null) {
- w.setTriggered();
- }
- break;
- }
- }
- VirtualUniverse.mc.sendRunMessage(universe,
- J3dThread.UPDATE_BEHAVIOR);
- }
-
- void processConditionMet(BehaviorRetained behav,
- Boolean checkSchedulingRegion) {
-
- // Since we reuse wakeup condition, the old wakeupCondition
- // will not reactivate again while processStimulus is running
- // which may set another wakeupCondition.
- // Previously we don't reuse wakeupCondition and cleanTree()
- // everytime before calling processStimulus() so the flag
- // inCallback is not necessary to check.
- if (!behav.inCallback &&
- ((checkSchedulingRegion == Boolean.FALSE) ||
- behav.active)) {
- processList[behav.schedulingInterval].add(behav);
- } else {
- if (((behav.wakeupMask &
- BehaviorRetained.WAKEUP_TIME) != 0) &&
- (behav.source != null) &&
- (behav.source.isLive()) &&
- (behav.wakeupCondition != null)) {
- // need to add back wakeupOnElapsedTime condition
- // to TimerThread
- behav.wakeupCondition.reInsertElapseTimeCond();
- }
- }
- }
-
- final void processBehXformChanged(UnorderList arrList) {
- BehaviorRetained beh;
- Object[] nodes, nodesArr;
-
- int size = arrList.size();
- nodesArr = arrList.toArray(false);
-
- for (int i = 0; i < size; i++) {
- nodes = (Object[])nodesArr[i];
- for (int j=0; j 0) {
- ViewPlatformRetained vpArr[] = (ViewPlatformRetained [])
- transformViewPlatformList.toArray(false);
-
- int size = transformViewPlatformList.arraySize();
- for (i=0; i < size; i++) {
- processViewPlatformTransform(vpArr[i]);
- }
- transformViewPlatformList.clear();
- }
- }
-
-
- // assume behav.updateTransformRegion() invoke before
- final void processBehaviorTransform(BehaviorRetained behav) {
- if ((behav.wakeupMask & BehaviorRetained.WAKEUP_VP_ENTRY) != 0) {
- updateVPEntryTransformRegion(behav);
- }
-
- if ((behav.wakeupMask & BehaviorRetained.WAKEUP_VP_EXIT) != 0) {
- updateVPExitTransformRegion(behav);
- }
-
- if (behav.active) {
- if (!intersectVPRegion(behav.transformedRegion)) {
- removeFromScheduleList(behav);
- }
- } else {
- addToScheduleList(behav);
- }
- }
-
-
- void processViewPlatformTransform(ViewPlatformRetained vp) {
- int i;
- BehaviorRetained behav;
-
- vp.updateTransformRegion();
-
- if (!vp.isActiveViewPlatform()) {
- return;
- }
-
- BehaviorRetained behavArr[] = (BehaviorRetained []) behaviors.toArray(false);
-
- // re-evaulate all behaviors affected by this vp
- for (i=behaviors.arraySize()-1; i>=0; i--) {
- behav = behavArr[i];
- if (behav.active) {
- if (!intersectVPRegion(behav.transformedRegion)) {
- removeFromScheduleList(behav);
- }
- } else {
- addToScheduleList(behav);
- }
- }
-
- // handle wakeupOnViewPlatformEntry
- WakeupOnViewPlatformEntry wakeupOnViewPlatformEntryArr[] =
- (WakeupOnViewPlatformEntry []) wakeupOnViewPlatformEntry.toArray(false);
- WakeupOnViewPlatformEntry wentry;
- int idx;
- ViewPlatformRetained triggeredVP;
-
- for (i=wakeupOnViewPlatformEntry.arraySize()-1; i >=0; i--) {
- wentry = wakeupOnViewPlatformEntryArr[i];
- idx = boundsEntryList.indexOf(wentry);
- if (idx < 0) {
- if (wentry.transformedRegion.intersect(vp.center)) {
- boundsEntryList.add(wentry);
- wentry.triggeredVP = vp;
- wentry.setTriggered();
- }
- } else {
- triggeredVP = intersectVPCenter(wentry.transformedRegion);
- if (triggeredVP == null) {
- boundsEntryList.remove(idx);
- }
- }
- }
-
- // handle wakeupOnViewPlatformExit;
- WakeupOnViewPlatformExit wakeupOnViewPlatformExitArr[] =
- (WakeupOnViewPlatformExit []) wakeupOnViewPlatformExit.toArray(false);
- WakeupOnViewPlatformExit wexit;
-
- for (i=wakeupOnViewPlatformExit.arraySize()-1; i >=0; i--) {
- wexit = wakeupOnViewPlatformExitArr[i];
- idx = boundsExitList.indexOf(wexit);
- if (idx < 0) {
- if (wexit.transformedRegion.intersect(vp.center)) {
- wexit.triggeredVP = vp;
- boundsExitList.add(wexit);
-
- }
- } else {
- triggeredVP = intersectVPCenter(wexit.transformedRegion);
- if (triggeredVP == null) {
- boundsExitList.remove(idx);
- wexit.setTriggered();
- }
- }
- }
- }
-
- void updateVPEntryTransformRegion(BehaviorRetained behav) {
- WakeupOnViewPlatformEntry wakeupOnViewPlatformEntryArr[] =
- (WakeupOnViewPlatformEntry []) wakeupOnViewPlatformEntry.toArray(false);
- WakeupOnViewPlatformEntry wentry;
- ViewPlatformRetained triggeredVP;
-
- for (int i=wakeupOnViewPlatformEntry.arraySize()-1; i >=0; i--) {
- wentry = wakeupOnViewPlatformEntryArr[i];
- if (wentry.behav == behav) {
- wentry.updateTransformRegion(behav);
- int idx = boundsEntryList.indexOf(wentry);
-
- triggeredVP = intersectVPCenter(wentry.transformedRegion);
- if (triggeredVP != null) {
- if (idx < 0) {
- boundsEntryList.add(wentry);
- wentry.triggeredVP = triggeredVP;
- wentry.setTriggered();
- }
- } else {
- if (idx >=0) {
- boundsEntryList.remove(idx);
- }
- }
- }
-
- }
- }
-
-
-
- void updateVPExitTransformRegion(BehaviorRetained behav) {
- WakeupOnViewPlatformExit wakeupOnViewPlatformExitArr[] =
- (WakeupOnViewPlatformExit []) wakeupOnViewPlatformExit.toArray(false);
- WakeupOnViewPlatformExit wexit;
- ViewPlatformRetained triggeredVP;
-
- for (int i=wakeupOnViewPlatformExit.arraySize()-1; i >=0; i--) {
- wexit = wakeupOnViewPlatformExitArr[i];
- if (wexit.behav == behav) {
- wexit.updateTransformRegion(behav);
- wexit = wakeupOnViewPlatformExitArr[i];
- int idx = boundsExitList.indexOf(wexit);
- triggeredVP = intersectVPCenter(wexit.transformedRegion);
- if (triggeredVP != null) {
- if (idx < 0) {
- wexit.triggeredVP = triggeredVP;
- boundsExitList.add(wexit);
- }
- } else {
- if (idx >= 0) {
- boundsExitList.remove(idx);
- wexit.setTriggered();
- }
- }
- }
- }
- }
-
-
-void reEvaluatePhysicalEnvironments() {
- // we can't just add or remove from the list since
- // physicalEnvironment may be share by multiple view
- ViewPlatformRetained[] vpr = universe.getViewPlatformList();
-
- physicalEnvironments.clear();
-
- for (int i = vpr.length - 1; i >= 0; i--) {
- View[] views = vpr[i].getViewList();
- for (int j = views.length - 1; j >= 0; j--) {
- View v = views[j];
- if (!v.active)
- continue;
-
- if (!physicalEnvironments.contains(v.physicalEnvironment)) {
- physicalEnvironments.add(v.physicalEnvironment);
- }
- }
- }
-}
-
- void checkSensorEntryExit() {
- int i, idx;
- Sensor target;
-
- // handle WakeupOnSensorEntry
- WakeupOnSensorEntry wentry;
- WakeupOnSensorEntry wentryArr[] = (WakeupOnSensorEntry [])
- wakeupOnSensorEntry.toArray();
-
- for (i=wakeupOnSensorEntry.arraySize()-1; i>=0; i--) {
- wentry = wentryArr[i];
- idx = currentSensorEntryList.indexOf(wentry);
- wentry.updateTransformRegion();
- target = sensorIntersect(wentry.transformedRegion);
- if (target != null) {
- if (idx < 0) {
- currentSensorEntryList.add(wentry);
- wentry.setTarget(target);
- wentry.setTriggered();
- }
- } else {
- if (idx >= 0) {
- currentSensorEntryList.remove(idx);
- }
- }
- }
-
- // handle WakeupOnSensorExit
- WakeupOnSensorExit wexit;
- WakeupOnSensorExit wexitArr[] = (WakeupOnSensorExit [])
- wakeupOnSensorExit.toArray();
-
- for (i=wakeupOnSensorExit.arraySize()-1; i>=0; i--) {
- wexit = wexitArr[i];
- idx = currentSensorExitList.indexOf(wexit);
- wexit.updateTransformRegion();
- target = sensorIntersect(wexit.transformedRegion);
- if (target != null) {
- if (idx < 0) {
- currentSensorExitList.add(wexit);
- wexit.setTarget(target);
- }
- } else {
- if (idx >= 0) {
- currentSensorExitList.remove(idx);
- wexit.setTriggered();
- }
- }
- }
-
- }
-
-
-/**
- * return the Sensor that intersect with behregion or null
- */
-Sensor sensorIntersect(Bounds behregion) {
-
- if (behregion == null)
- return null;
-
- PhysicalEnvironment env[] = (PhysicalEnvironment [])
- physicalEnvironments.toArray(false);
- for (int i = physicalEnvironments.arraySize() - 1; i >= 0; i--) {
- if (env[i].activeViewRef <= 0)
- continue;
-
- Sensor[] sensors = env[i].getSensorList();
- if (sensors == null)
- continue;
-
- for (int j = env[i].users.size() - 1; j >= 0; j--) {
- View v = env[i].users.get(j);
- synchronized (sensors) {
- for (int k = sensors.length - 1; k >= 0; k--) {
- Sensor s = sensors[k];
- if (s == null)
- continue;
-
- v.getSensorToVworld(s, sensorTransform);
- sensorTransform.get(sensorLoc);
- ptSensorLoc.set(sensorLoc);
- if (behregion.intersect(ptSensorLoc)) {
- return s;
- }
- }
- }
- }
- }
- return null;
-}
-
-
- /**
- * return true if one of ViewPlatforms intersect behregion
- */
- final boolean intersectVPRegion(Bounds behregion) {
- if (behregion == null) {
- return false;
- }
-
- ViewPlatformRetained vp;
- ViewPlatformRetained vpLists[] = (ViewPlatformRetained [])
- viewPlatforms.toArray(false);
-
- for (int i=viewPlatforms.arraySize()- 1; i>=0; i--) {
- vp = vpLists[i];
- if (vp.isActiveViewPlatform() &&
- vp.schedSphere.intersect(behregion)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * return true if one of ViewPlatforms center intersect behregion
- */
- final ViewPlatformRetained intersectVPCenter(Bounds behregion) {
- if (behregion == null) {
- return null;
- }
-
- ViewPlatformRetained vp;
- ViewPlatformRetained vpLists[] = (ViewPlatformRetained [])
- viewPlatforms.toArray(false);
-
-
- for (int i=viewPlatforms.arraySize()- 1; i>=0; i--) {
- vp = vpLists[i];
- if (vp.isActiveViewPlatform() &&
- behregion.intersect(vp.center)) {
- return vp;
- }
- }
- return null;
- }
-
- void notifyDeactivationCondition(BehaviorRetained behav) {
- WakeupOnDeactivation wakeup;
- WakeupOnDeactivation wakeupConds[] = (WakeupOnDeactivation [])
- wakeupOnDeactivation.toArray(false);
-
- for (int i=wakeupOnDeactivation.arraySize()-1; i>=0; i--) {
- wakeup = wakeupConds[i];
- if (wakeup.behav == behav) {
- wakeup.setTriggered();
- }
- }
- }
-
- void notifyActivationCondition(BehaviorRetained behav) {
- WakeupOnActivation wakeup;
- WakeupOnActivation wakeupConds[] = (WakeupOnActivation [])
- wakeupOnActivation.toArray(false);
-
- for (int i=wakeupOnActivation.arraySize()-1; i>=0; i--) {
- wakeup = wakeupConds[i];
- if (wakeup.behav == behav) {
- wakeup.setTriggered();
- }
- }
- }
-
-
- void processSwitchChanged(J3dMessage m) {
-
- int i,j;
- UnorderList arrList;
- int size;
- Object[] nodes, nodesArr;
-
- UpdateTargets targets = (UpdateTargets)m.args[0];
- arrList = targets.targetList[Targets.VPF_TARGETS];
-
- if (arrList != null) {
- ViewPlatformRetained vp;
- size = arrList.size();
- nodesArr = arrList.toArray(false);
-
- for (j=0; j=0; i--) {
- vp = (ViewPlatformRetained) nodes[i];
- vp.processSwitchChanged();
- }
- }
- }
-
- arrList = targets.targetList[Targets.BEH_TARGETS];
-
- if (arrList != null) {
- BehaviorRetained behav;
- size = arrList.size();
- nodesArr = arrList.toArray(false);
-
- for (j=0; j=0; i--) {
- behav = (BehaviorRetained) nodes[i];
- if (behav.switchState.currentSwitchOn) {
- addToScheduleList(behav);
- } else {
- removeFromScheduleList(behav);
- }
- }
- }
- }
-
- arrList = targets.targetList[Targets.BLN_TARGETS];
- if (arrList != null) {
- size = arrList.size();
- nodesArr = arrList.toArray(false);
- Object[] objArr = (Object[])m.args[1];
- Object[] obj;
-
- for (int h=0; h=0; i--) {
-
- Object[] users = (Object[])obj[i];
- Object[] leafObj = new Object[1];
- for (j = 0; j < users.length; j++) {
- if (users[j] instanceof BehaviorRetained) {
- leafObj[0] = users[j];
- processTransformChanged(leafObj);
- }
- }
- }
- }
- }
- }
-
- void processBoundingLeafChanged(Object users[],
- Bounds bound) {
- Object leaf;
- BehaviorRetained behav;
-
- for (int i=users.length-1; i>=0; i--) {
- leaf = users[i];
- if (leaf instanceof BehaviorRetained) {
- behav = (BehaviorRetained) leaf;
- behav.updateTransformRegion(bound);
- processBehaviorTransform(behav);
- }
- }
- }
-
- final void removeFromScheduleList(BehaviorRetained behav) {
- if (behav.active) {
- if ((behav.wakeupMask &
- BehaviorRetained.WAKEUP_DEACTIVATE) != 0) {
- notifyDeactivationCondition(behav);
- }
- scheduleList.remove(behav);
- behav.active = false;
- if (behav.universe != universe) {
- J3dMessage m = new J3dMessage();
- m.threads = J3dThread.UPDATE_BEHAVIOR;
- m.type = J3dMessage.BEHAVIOR_REEVALUATE;
- m.universe = behav.universe;
- m.args[0] = behav;
- VirtualUniverse.mc.processMessage(m);
- }
- }
- }
-
- final void addToScheduleList(BehaviorRetained behav) {
-
- if (!behav.inCallback &&
- !behav.active &&
- behav.enable &&
- behav.switchState.currentSwitchOn &&
- (behav.wakeupCondition != null) &&
- ((Behavior) behav.source).isLive() &&
- intersectVPRegion(behav.transformedRegion)) {
-
- scheduleList.add(behav);
- behav.active = true;
- if ((behav.wakeupMask &
- BehaviorRetained.WAKEUP_ACTIVATE) != 0) {
- notifyActivationCondition(behav);
- }
-
- if (behav.wakeupCondition != null) {
- // This reset the conditionMet, otherwise
- // if conditionMet is true then WakeupCondition
- // will never post message to BehaviorStructure
- behav.wakeupCondition.conditionMet = false;
- }
- }
- }
-
- /**
- * This prevents wakeupCondition sent out message and sets
- * conditionMet to true, but the
- * BehaviorStructure/BehaviorScheduler is not fast enough to
- * process the message and reset conditionMet to false
- * when view deactivate/unregister.
- */
- void resetConditionMet() {
- resetConditionMet(wakeupOnAWTEvent);
- resetConditionMet(wakeupOnActivation);
- resetConditionMet(wakeupOnDeactivation);
- resetConditionMet(wakeupOnBehaviorPost);
- resetConditionMet(wakeupOnElapsedFrames);
- resetConditionMet(wakeupOnViewPlatformEntry);
- resetConditionMet(wakeupOnViewPlatformExit);
- resetConditionMet(wakeupOnSensorEntry);
- resetConditionMet(wakeupOnSensorExit);
- }
-
- static void resetConditionMet(WakeupIndexedList list) {
- WakeupCondition wakeups[] = (WakeupCondition []) list.toArray(false);
- int i = list.size()-1;
- while (i >= 0) {
- wakeups[i--].conditionMet = false;
- }
- }
-
- void reEvaluateWakeupCount() {
- WakeupOnElapsedFrames wakeupConds[] = (WakeupOnElapsedFrames [])
- wakeupOnElapsedFrames.toArray(true);
- int size = wakeupOnElapsedFrames.arraySize();
- int i = 0;
- WakeupOnElapsedFrames cond;
-
- activeWakeupOnFrameCount = 0;
-
- while (i < size) {
- cond = wakeupConds[i++];
- if (!cond.passive &&
- (cond.behav != null) &&
- cond.behav.enable) {
- activeWakeupOnFrameCount++;
- }
- }
-
-
- activeWakeupOnSensorCount = 0;
- WakeupOnSensorEntry wentry;
- WakeupOnSensorEntry wentryArr[] = (WakeupOnSensorEntry [])
- wakeupOnSensorEntry.toArray();
-
- for (i=wakeupOnSensorEntry.arraySize()-1; i>=0; i--) {
- wentry = wentryArr[i];
- if ((wentry.behav != null) &&
- (wentry.behav.enable)) {
- activeWakeupOnSensorCount++;
- }
- }
-
- WakeupOnSensorExit wexit;
- WakeupOnSensorExit wexitArr[] = (WakeupOnSensorExit [])
- wakeupOnSensorExit.toArray();
-
- for (i=wakeupOnSensorExit.arraySize()-1; i>=0; i--) {
- wexit = wexitArr[i];
- if ((wexit.behav != null) &&
- (wexit.behav.enable)) {
- activeWakeupOnSensorCount++;
- }
- }
-
- }
-
- @Override
- void cleanup() {
- behaviors.clear();
- viewPlatforms.clear();
- scheduleList.clear();
- boundsEntryList.clear();
- boundsExitList.clear();
- currentSensorEntryList.clear();
- currentSensorExitList.clear();
- wakeupOnAWTEvent.clear();
- wakeupOnActivation.clear();
- wakeupOnDeactivation.clear();
- wakeupOnBehaviorPost.clear();
- wakeupOnElapsedFrames.clear();
- wakeupOnViewPlatformEntry.clear();
- wakeupOnViewPlatformExit.clear();
- wakeupOnSensorEntry.clear();
- wakeupOnSensorExit.clear();
- }
-}
diff --git a/src/classes/share/javax/media/j3d/Billboard.java b/src/classes/share/javax/media/j3d/Billboard.java
deleted file mode 100644
index 0372062..0000000
--- a/src/classes/share/javax/media/j3d/Billboard.java
+++ /dev/null
@@ -1,675 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.Enumeration;
-
-import javax.vecmath.AxisAngle4d;
-import javax.vecmath.Point3d;
-import javax.vecmath.Point3f;
-import javax.vecmath.Vector3d;
-import javax.vecmath.Vector3f;
-
-/**
- * The Billboard behavior node operates on the TransformGroup node
- * to cause the local +z axis of the TransformGroup to point at
- * the viewer's eye position. This is done regardless of the transforms
- * above the specified TransformGroup node in the scene graph.
- *
- *
- * If the alignment mode is ROTATE_ABOUT_AXIS, the rotation will be
- * around the specified axis. If the alignment mode is
- * ROTATE_ABOUT_POINT, the rotation will be about the specified
- * point, with an additional rotation to align the +y axis of the
- * TransformGroup with the +y axis in the View.
- *
- *
- * Note that in a multiple View system, the alignment is done to
- * the primary View only.
- *
- *
- * Billboard nodes are ideal for drawing screen aligned-text or
- * for drawing roughly-symmetrical objects. A typical use might
- * consist of a quadrilateral that contains a texture of a tree.
- *
- * @see OrientedShape3D
- */
-public class Billboard extends Behavior {
- /**
- * Specifies that rotation should be about the specified axis.
- */
- public static final int ROTATE_ABOUT_AXIS = 0;
-
- /**
- * Specifies that rotation should be about the specified point and
- * that the children's Y-axis should match the view object's Y-axis.
- */
- public static final int ROTATE_ABOUT_POINT = 1;
-
- // Wakeup condition for Billboard node
- WakeupOnElapsedFrames wakeupFrame = new WakeupOnElapsedFrames(0, true);
-
-
- // Specifies the billboard's mode of operation. One of ROTATE_AXIAL,
- // ROTATE_POINT_VIEW, or ROTATE_POINT_WORLD.
- int mode = ROTATE_ABOUT_AXIS;
-
- // Axis about which to rotate.
- Vector3f axis = new Vector3f(0.0f, 1.0f, 0.0f);
- Point3f rotationPoint = new Point3f(0.0f, 0.0f, 1.0f);
- private Vector3d nAxis = new Vector3d(0.0, 1.0, 0.0); // normalized axis
-
- // TransformGroup to operate on.
- TransformGroup tg = null;
-
-
- // reused temporaries
- private Point3d viewPosition = new Point3d();
- private Point3d yUpPoint = new Point3d();
-
- private Vector3d eyeVec = new Vector3d();
- private Vector3d yUp = new Vector3d();
- private Vector3d zAxis = new Vector3d();
- private Vector3d yAxis = new Vector3d();
- private Vector3d vector = new Vector3d();
-
- private AxisAngle4d aa = new AxisAngle4d();
-
- static final double EPSILON = 1.0e-6;
-
- /**
- * Constructs a Billboard node with default parameters.
- * The default values are as follows:
- *
- */
- public Billboard() {
- nAxis.x = 0.0;
- nAxis.y = 1.0;
- nAxis.z = 0.0;
- }
-
-
- /**
- * Constructs a Billboard node with default parameters that operates
- * on the specified TransformGroup node.
- * The default alignment mode is ROTATE_ABOUT_AXIS rotation with the axis
- * pointing along the Y axis.
- * @param tg the TransformGroup node that this Billboard
- * node operates upon
- */
- public Billboard(TransformGroup tg) {
- this.tg = tg;
- nAxis.x = 0.0;
- nAxis.y = 1.0;
- nAxis.z = 0.0;
-
- }
-
-
- /**
- * Constructs a Billboard node with the specified axis and mode
- * that operates on the specified TransformGroup node.
- * The specified axis must not be parallel to the Z
- * axis--(0,0,z) for any value of z. It is not
- * possible for the +Z axis to point at the viewer's eye
- * position by rotating about itself. The target transform will
- * be set to the identity if the axis is (0,0,z).
- *
- * @param tg the TransformGroup node that this Billboard
- * node operates upon
- * @param mode alignment mode, one of ROTATE_ABOUT_AXIS or
- * ROTATE_ABOUT_POINT
- * @param axis the ray about which the billboard rotates
- */
- public Billboard(TransformGroup tg, int mode, Vector3f axis) {
- this.tg = tg;
- this.mode = mode;
- this.axis.set(axis);
- double invMag;
- invMag = 1.0/Math.sqrt(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
- nAxis.x = (double)axis.x*invMag;
- nAxis.y = (double)axis.y*invMag;
- nAxis.z = (double)axis.z*invMag;
-
- }
-
- /**
- * Constructs a Billboard node with the specified rotation point and mode
- * that operates on the specified TransformGroup node.
- * @param tg the TransformGroup node that this Billboard
- * node operates upon
- * @param mode alignment mode, one of ROTATE_ABOUT_AXIS or
- * ROTATE_ABOUT_POINT
- * @param point the position about which the billboard rotates
- */
- public Billboard(TransformGroup tg, int mode, Point3f point) {
- this.tg = tg;
- this.mode = mode;
- this.rotationPoint.set(point);
- }
-
- /**
- * Sets the alignment mode.
- * @param mode one of: ROTATE_ABOUT_AXIS or ROTATE_ABOUT_POINT
- */
- public void setAlignmentMode(int mode) {
- this.mode = mode;
- }
-
-
- /**
- * Gets the alignment mode.
- * @return one of: ROTATE_ABOUT_AXIS or ROTATE_ABOUT_POINT
- */
- public int getAlignmentMode() {
- return this.mode;
- }
-
-
- /**
- * Sets the alignment axis.
- * The specified axis must not be parallel to the Z
- * axis--(0,0,z) for any value of z. It is not
- * possible for the +Z axis to point at the viewer's eye
- * position by rotating about itself. The target transform will
- * be set to the identity if the axis is (0,0,z).
- *
- * @param axis the ray about which the billboard rotates
- */
- public void setAlignmentAxis(Vector3f axis) {
- this.axis.set(axis);
- double invMag;
- invMag = 1.0/Math.sqrt(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
- nAxis.x = (double)axis.x*invMag;
- nAxis.y = (double)axis.y*invMag;
- nAxis.z = (double)axis.z*invMag;
-
- }
-
-
- /**
- * Sets the alignment axis.
- * The specified axis must not be parallel to the Z
- * axis--(0,0,z) for any value of z. It is not
- * possible for the +Z axis to point at the viewer's eye
- * position by rotating about itself. The target transform will
- * be set to the identity if the axis is (0,0,z).
- *
- * @param x the x component of the ray about which the billboard rotates
- * @param y the y component of the ray about which the billboard rotates
- * @param z the z component of the ray about which the billboard rotates
- */
- public void setAlignmentAxis(float x, float y, float z) {
- this.axis.set(x, y, z);
- this.axis.set(axis);
- double invMag;
- invMag = 1.0/Math.sqrt(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z);
- nAxis.x = (double)axis.x*invMag;
- nAxis.y = (double)axis.y*invMag;
- nAxis.z = (double)axis.z*invMag;
-
- }
-
-
- /**
- * Gets the alignment axis and sets the parameter to this value.
- * @param axis the vector that will contain the ray about which
- * the billboard rotates
- */
- public void getAlignmentAxis(Vector3f axis) {
- axis.set(this.axis);
- }
-
- /**
- * Sets the rotation point.
- * @param point the point about which the billboard rotates
- */
- public void setRotationPoint(Point3f point) {
- this.rotationPoint.set(point);
- }
-
-
- /**
- * Sets the rotation point.
- * @param x the x component of the point about which the billboard rotates
- * @param y the y component of the point about which the billboard rotates
- * @param z the z component of the point about which the billboard rotates
- */
- public void setRotationPoint(float x, float y, float z) {
- this.rotationPoint.set(x, y, z);
- }
-
-
- /**
- * Gets the rotation point and sets the parameter to this value.
- * @param point the position the Billboard rotates about
- */
- public void getRotationPoint(Point3f point) {
- point.set(this.rotationPoint);
- }
- /**
- * Sets the tranformGroup for this Billboard object.
- * @param tg the transformGroup node which replaces the current
- * transformGroup node for this Billboard
- */
- public void setTarget(TransformGroup tg ) {
- this.tg = tg;
- }
-
- /**
- * Returns a copy of the transformGroup associated with this Billboard.
- * @return the TranformGroup for this Billboard
- */
- public TransformGroup getTarget() {
- return(tg);
- }
-
-
- /**
- * Initialize method that sets up initial wakeup criteria.
- */
- @Override
- public void initialize() {
- // Insert wakeup condition into queue
- wakeupOn(wakeupFrame);
- }
-
-
- /**
- * Process stimulus method that computes appropriate transform.
- * @param criteria an enumeration of the criteria that caused the
- * stimulus
- */
- @Override
- public void processStimulus(Enumeration criteria) {
- double angle = 0.0;
- double sign;
-
- if( tg == null ){
- wakeupOn(wakeupFrame);
- return;
- }
-
- // get viewplatforms's location in virutal world
- View v = this.getView();
- if( v == null ) {
- wakeupOn(wakeupFrame);
- return;
- }
- Canvas3D canvas = v.getCanvas3D(0);
- boolean status;
-
- Transform3D xform = new Transform3D();
- Transform3D bbXform = new Transform3D();
- Transform3D prevTransform = new Transform3D();
-
- ((TransformGroupRetained) tg.retained).getTransform(prevTransform);
-
- if (mode == ROTATE_ABOUT_AXIS ) { // rotate about axis
- canvas.getCenterEyeInImagePlate(viewPosition);
- canvas.getImagePlateToVworld(xform); // xform is imagePlateToLocal
- xform.transform(viewPosition);
-
- // get billboard's transform
-
- // since we are using getTransform() to get the transform
- // of the transformGroup, we need to use getLocalToVworld()
- // to get the localToVworld which includes the static transform
-
- ((NodeRetained)tg.retained).getLocalToVworld(xform);
-
- xform.invert(); // xform is now vWorldToLocal
-
- // transform the eye position into the billboard's coordinate system
- xform.transform(viewPosition);
-
- // eyeVec is a vector from the local origin to the eye pt in local
- eyeVec.set(viewPosition);
- eyeVec.normalize();
-
- // project the eye into the rotation plane
- status = projectToPlane(eyeVec, nAxis);
-
- // If the first project was successful ..
- if (status) {
- // project the z axis into the rotation plane
- zAxis.x = 0.0;
- zAxis.y = 0.0;
- zAxis.z = 1.0;
- status = projectToPlane(zAxis, nAxis);
- }
-
-
- ((TransformGroupRetained) tg.retained).getTransform(xform);
- if (status) {
- // compute the sign of the angle by checking if the cross product
- // of the two vectors is in the same direction as the normal axis
- vector.cross(eyeVec, zAxis);
- if (vector.dot(nAxis) > 0.0) {
- sign = 1.0;
- } else {
- sign = -1.0;
- }
-
- // compute the angle between the projected eye vector and the
- // projected z
- double dot = eyeVec.dot(zAxis);
-
- if (dot > 1.0f) {
- dot = 1.0f;
- } else if (dot < -1.0f) {
- dot = -1.0f;
- }
-
- angle = sign*Math.acos(dot);
-
- // use -angle because xform is to *undo* rotation by angle
- aa.x = nAxis.x;
- aa.y = nAxis.y;
- aa.z = nAxis.z;
- aa.angle = -angle;
- bbXform.set(aa);
- if( !prevTransform.epsilonEquals(bbXform, EPSILON)) {
- // Optimization for Billboard since it use passive
- // behavior
- // set the transform on the Billboard TG
- tg.setTransform(bbXform);
- }
- }
- else {
- bbXform.setIdentity();
- if (!prevTransform.epsilonEquals(bbXform, EPSILON)) {
- tg.setTransform(bbXform);
- }
- }
-
- } else { // rotate about point
- // Need to rotate Z axis to point to eye, and Y axis to be
- // parallel to view platform Y axis, rotating around rotation pt
-
- Transform3D zRotate = new Transform3D();
-
- // get the eye point
- canvas.getCenterEyeInImagePlate(viewPosition);
-
- // derive the yUp point
- yUpPoint.set(viewPosition);
- yUpPoint.y += 0.01; // one cm in Physical space
-
- // transform the points to the Billboard's space
- canvas.getImagePlateToVworld(xform); // xform is ImagePlateToVworld
-
- xform.transform(viewPosition);
- xform.transform(yUpPoint);
-
- // get billboard's transform
-
- // since we are using getTransform() to get the transform
- // of the transformGroup, we need to use getLocalToVworld()
- // to get the localToVworld which includes the static transform
-
- ((NodeRetained)tg.retained).getLocalToVworld(xform);
-
- xform.invert(); // xform is vWorldToLocal
-
- // transfom points to local coord sys
- xform.transform(viewPosition);
- xform.transform(yUpPoint);
-
- // Make a vector from viewPostion to 0,0,0 in the BB coord sys
- eyeVec.set(viewPosition);
- eyeVec.normalize();
-
- // create a yUp vector
- yUp.set(yUpPoint);
- yUp.sub(viewPosition);
- yUp.normalize();
-
-
- // find the plane to rotate z
- zAxis.x = 0.0;
- zAxis.y = 0.0;
- zAxis.z = 1.0;
-
- // rotation axis is cross product of eyeVec and zAxis
- vector.cross(eyeVec, zAxis); // vector is cross product
-
- // if cross product is non-zero, vector is rotation axis and
- // rotation angle is acos(eyeVec.dot(zAxis)));
- double length = vector.length();
-
- if (length > 0.0001) {
- double dot = eyeVec.dot(zAxis);
-
- if (dot > 1.0f) {
- dot = 1.0f;
- } else if (dot < -1.0f) {
- dot = -1.0f;
- }
-
- angle = Math.acos(dot);
- aa.x = vector.x;
- aa.y = vector.y;
- aa.z = vector.z;
- aa.angle = -angle;
- zRotate.set(aa);
- } else {
- // no rotation needed, set to identity (scale = 1.0)
- zRotate.set(1.0);
- }
-
- // Transform the yAxis by zRotate
- yAxis.x = 0.0;
- yAxis.y = 1.0;
- yAxis.z = 0.0;
- zRotate.transform(yAxis);
-
- // project the yAxis onto the plane perp to the eyeVec
- status = projectToPlane(yAxis, eyeVec);
-
- if (status) {
- // project the yUp onto the plane perp to the eyeVec
- status = projectToPlane(yUp, eyeVec);
- }
-
- ((TransformGroupRetained) tg.retained).getTransform(xform);
- if (status) {
- // rotation angle is acos(yUp.dot(yAxis));
- double dot = yUp.dot(yAxis);
-
- // Fix numerical error, otherwise acos return NULL
- if (dot > 1.0f) {
- dot = 1.0f;
- } else if (dot < -1.0f) {
- dot = -1.0f;
- }
-
- angle = Math.acos(dot);
-
- // check the sign by looking a the cross product vs the eyeVec
- vector.cross(yUp, yAxis); // vector is cross product
- if (eyeVec.dot(vector) < 0) {
- angle *= -1;
- }
- aa.x = eyeVec.x;
- aa.y = eyeVec.y;
- aa.z = eyeVec.z;
- aa.angle = -angle;
-
- xform.set(aa); // xform is now yRotate
-
- // rotate around the rotation point
- vector.x = rotationPoint.x;
- vector.y = rotationPoint.y;
- vector.z = rotationPoint.z; // vector to translate to RP
- bbXform.set(vector); // translate to RP
- bbXform.mul(xform); // yRotate
- bbXform.mul(zRotate); // zRotate
- vector.scale(-1.0); // vector to translate back
- xform.set(vector); // xform to translate back
- bbXform.mul(xform); // translate back
-
-
- if (!prevTransform.epsilonEquals(bbXform, EPSILON)) {
- // set the transform on the Billboard TG
- tg.setTransform(bbXform);
- }
- }
- else {
- bbXform.setIdentity();
- if (!prevTransform.epsilonEquals(bbXform, EPSILON)) {
- tg.setTransform(bbXform);
- }
- }
- }
-
- // Insert wakeup condition into queue
- wakeupOn(wakeupFrame);
-}
-
-private boolean projectToPlane(Vector3d projVec, Vector3d planeVec) {
- double dis = planeVec.dot(projVec);
- projVec.x = projVec.x - planeVec.x*dis;
- projVec.y = projVec.y - planeVec.y*dis;
- projVec.z = projVec.z - planeVec.z*dis;
-
- double length = projVec.length();
-
- if (length < EPSILON) {
- return false;
- }
- projVec.scale(1 / length);
- return true;
-}
-
- /**
- * Creates a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- Billboard b = new Billboard();
- b.duplicateNode(this, forceDuplicate);
- return b;
- }
-
-
- /**
- * Copies all Billboard information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- super.duplicateAttributes(originalNode, forceDuplicate);
-
- Billboard bb = (Billboard) originalNode;
-
- setAlignmentMode(bb.getAlignmentMode());
-
- Vector3f v = new Vector3f();
- bb.getAlignmentAxis(v);
- setAlignmentAxis(v);
-
- Point3f p = new Point3f();
- bb.getRotationPoint(p);
- setRotationPoint(p);
-
- // this will be updated by updateNodeReferences() later
- setTarget(bb.getTarget());
- }
-
-
- /**
- * Callback used to allow a node to check if any scene graph objects
- * referenced
- * by that node have been duplicated via a call to cloneTree.
- * This method is called by cloneTree after all nodes in
- * the sub-graph have been duplicated. The cloned Leaf node's method
- * will be called and the Leaf node can then look up any object references
- * by using the getNewObjectReference method found in the
- * NodeReferenceTable object. If a match is found, a
- * reference to the corresponding object in the newly cloned sub-graph
- * is returned. If no corresponding reference is found, either a
- * DanglingReferenceException is thrown or a reference to the original
- * object is returned depending on the value of the
- * allowDanglingReferences parameter passed in the
- * cloneTree call.
- *
- * NOTE: Applications should not call this method directly.
- * It should only be called by the cloneTree method.
- *
- * @param referenceTable a NodeReferenceTableObject that contains the
- * getNewObjectReference method needed to search for
- * new object instances.
- * @see NodeReferenceTable
- * @see Node#cloneTree
- * @see DanglingReferenceException
- */
- @Override
- public void updateNodeReferences(NodeReferenceTable referenceTable) {
- super.updateNodeReferences(referenceTable);
-
- // check for new TransformGroup
- TransformGroup g = getTarget();
- if (g != null) {
- setTarget((TransformGroup) referenceTable.getNewObjectReference(g));
- }
- }
-}
-
diff --git a/src/classes/share/javax/media/j3d/BoundingBox.java b/src/classes/share/javax/media/j3d/BoundingBox.java
deleted file mode 100644
index 304e43b..0000000
--- a/src/classes/share/javax/media/j3d/BoundingBox.java
+++ /dev/null
@@ -1,1904 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Point3d;
-import javax.vecmath.Point4d;
-import javax.vecmath.Vector3d;
-import javax.vecmath.Vector4d;
-
-/**
- * This class defines an axis aligned bounding box which is used for
- * bounding regions.
- *
- */
-
-public class BoundingBox extends Bounds {
-
-/**
- * The corner of the bounding box with the numerically smallest values.
- */
-final Point3d lower;
-
-/**
- * The corner of the bounding box with the numerically largest values.
- */
-final Point3d upper;
- private static final double EPS = 1.0E-8;
-
-/**
- * Constructs and initializes a BoundingBox given min,max in x,y,z.
- * @param lower the "small" corner
- * @param upper the "large" corner
- */
-public BoundingBox(Point3d lower, Point3d upper) {
- boundId = BOUNDING_BOX;
- this.lower = new Point3d(lower);
- this.upper = new Point3d(upper);
- updateBoundsStates();
-}
-
-/**
- * Constructs and initializes a 2X bounding box about the origin. The lower
- * corner is initialized to (-1.0d, -1.0d, -1.0d) and the upper corner is
- * initialized to (1.0d, 1.0d, 1.0d).
- */
-public BoundingBox() {
- boundId = BOUNDING_BOX;
- lower = new Point3d(-1.0d, -1.0d, -1.0d);
- upper = new Point3d( 1.0d, 1.0d, 1.0d);
- boundsIsEmpty = false;
- boundsIsInfinite = false;
-}
-
-/**
- * Constructs a BoundingBox from a bounding object.
- * @param boundsObject a bounds object
- */
-public BoundingBox(Bounds boundsObject) {
- boundId = BOUNDING_BOX;
- lower = new Point3d();
- upper = new Point3d();
-
- if (boundsObject == null || boundsObject.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if (boundsObject.boundsIsInfinite) {
- setInfiniteBounds();
- return;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
-
- lower.set(box.lower);
- upper.set(box.upper);
- }
- else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
-
- lower.set(sphere.center.x - sphere.radius,
- sphere.center.y - sphere.radius,
- sphere.center.z - sphere.radius);
-
- upper.set(sphere.center.x + sphere.radius,
- sphere.center.y + sphere.radius,
- sphere.center.z + sphere.radius);
- }
- else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- if( polytope.nVerts < 1 ) { // handle degenerate case
- lower.set(-1.0d, -1.0d, -1.0d);
- upper.set( 1.0d, 1.0d, 1.0d);
- } else {
- lower.set(polytope.verts[0]);
- upper.set(polytope.verts[0]);
-
- for(int i=1;i upper.x )
- upper.x = polytope.verts[i].x;
- if( polytope.verts[i].y > upper.y )
- upper.y = polytope.verts[i].y;
- if( polytope.verts[i].z > upper.z )
- upper.z = polytope.verts[i].z;
- }
- }
-
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox0"));
- }
-
- updateBoundsStates();
- }
-
-/**
- * Constructs a BoundingBox from an array of bounding objects.
- * @param bounds an array of bounding objects
- */
-public BoundingBox(Bounds[] bounds) {
- boundId = BOUNDING_BOX;
- upper = new Point3d();
- lower = new Point3d();
-
- if (bounds == null || bounds.length <= 0) {
- setEmptyBounds();
- return;
- }
-
- int i = 0;
- // find first non empty bounds object
- while ((i < bounds.length) && ((bounds[i] == null) || bounds[i].boundsIsEmpty)) {
- i++;
- }
-
- if (i >= bounds.length) {
- // all bounds objects were empty
- setEmptyBounds();
- return;
- }
-
- this.set(bounds[i++]);
- if(boundsIsInfinite)
- return;
-
- for(;i box.lower.x) lower.x = box.lower.x;
- if( lower.y > box.lower.y) lower.y = box.lower.y;
- if( lower.z > box.lower.z) lower.z = box.lower.z;
- if( upper.x < box.upper.x) upper.x = box.upper.x;
- if( upper.y < box.upper.y) upper.y = box.upper.y;
- if( upper.z < box.upper.z) upper.z = box.upper.z;
-
- }
- else if(bounds[i].boundId == BOUNDING_SPHERE) {
- BoundingSphere sphere = (BoundingSphere)bounds[i];
- if( lower.x > (sphere.center.x - sphere.radius))
- lower.x = sphere.center.x - sphere.radius;
- if( lower.y > (sphere.center.y - sphere.radius))
- lower.y = sphere.center.y - sphere.radius;
- if( lower.z > (sphere.center.z - sphere.radius))
- lower.z = sphere.center.z - sphere.radius;
- if( upper.x < (sphere.center.x + sphere.radius))
- upper.x = sphere.center.x + sphere.radius;
- if( upper.y < (sphere.center.y + sphere.radius))
- upper.y = sphere.center.y + sphere.radius;
- if( upper.z < (sphere.center.z + sphere.radius))
- upper.z = sphere.center.z + sphere.radius;
- }
- else if(bounds[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)bounds[i];
-
- for(i=0;i upper.x )
- upper.x = polytope.verts[i].x;
- if( polytope.verts[i].y > upper.y )
- upper.y = polytope.verts[i].y;
- if( polytope.verts[i].z > upper.z )
- upper.z = polytope.verts[i].z;
- }
- }
- else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox1"));
- }
- }
- updateBoundsStates();
- }
-
-/**
- * Gets the lower corner of this bounding box.
- * @param p1 a Point to receive the lower corner of the bounding box
- */
-public void getLower(Point3d p1) {
- p1.set(lower);
-}
-
-/**
- * Sets the lower corner of this bounding box.
- * @param xmin minimum x value of bounding box
- * @param ymin minimum y value of bounding box
- * @param zmin minimum z value of bounding box
- */
-public void setLower(double xmin, double ymin, double zmin) {
- lower.set(xmin, ymin, zmin);
- updateBoundsStates();
-}
-
-/**
- * Sets the lower corner of this bounding box.
- * @param p1 a Point defining the new lower corner of the bounding box
- */
-public void setLower(Point3d p1) {
- lower.set(p1);
- updateBoundsStates();
-}
-
-/**
- * Gets the upper corner of this bounding box.
- * @param p1 a Point to receive the upper corner of the bounding box
- */
-public void getUpper(Point3d p1) {
- p1.set(upper);
-}
-
-/**
- * Sets the upper corner of this bounding box.
- * @param xmax max x value of bounding box
- * @param ymax max y value of bounding box
- * @param zmax max z value of bounding box
- */
-public void setUpper(double xmax, double ymax, double zmax) {
- upper.set(xmax, ymax, zmax);
- updateBoundsStates();
-}
-
-/**
- * Sets the upper corner of this bounding box.
- * @param p1 a Point defining the new upper corner of the bounding box
- */
-public void setUpper(Point3d p1) {
- upper.set(p1);
- updateBoundsStates();
-}
-
- /**
- * Sets the the value of this BoundingBox
- * @param boundsObject another bounds object
- */
- @Override
- public void set(Bounds boundsObject) {
- int i;
-
- if (boundsObject == null || boundsObject.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if (boundsObject.boundsIsInfinite) {
- setInfiniteBounds();
- return;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
-
- lower.x = box.lower.x;
- lower.y = box.lower.y;
- lower.z = box.lower.z;
- upper.x = box.upper.x;
- upper.y = box.upper.y;
- upper.z = box.upper.z;
-
- } else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- lower.x = sphere.center.x - sphere.radius;
- lower.y = sphere.center.y - sphere.radius;
- lower.z = sphere.center.z - sphere.radius;
- upper.x = sphere.center.x + sphere.radius;
- upper.y = sphere.center.y + sphere.radius;
- upper.z = sphere.center.z + sphere.radius;
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- lower.x = upper.x = polytope.verts[0].x;
- lower.y = upper.y = polytope.verts[0].y;
- lower.z = upper.z = polytope.verts[0].z;
-
- for(i=1;i upper.x ) upper.x = polytope.verts[i].x;
- if( polytope.verts[i].y > upper.y ) upper.y = polytope.verts[i].y;
- if( polytope.verts[i].z > upper.z ) upper.z = polytope.verts[i].z;
- }
-
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox0"));
- }
-
- updateBoundsStates();
- }
-
-
- /**
- * Creates a copy of this bounding box.
- * @return a new bounding box
- */
- @Override
- public Object clone() {
- return new BoundingBox(this.lower, this.upper);
- }
-
-
- /**
- * Indicates whether the specified bounds object is
- * equal to this BoundingBox object. They are equal if the
- * specified bounds object is an instance of
- * BoundingBox and all of the data
- * members of bounds are equal to the corresponding
- * data members in this BoundingBox.
- * @param bounds the object with which the comparison is made.
- * @return true if this BoundingBox is equal to bounds;
- * otherwise false
- *
- * @since Java 3D 1.2
- */
- @Override
- public boolean equals(Object bounds) {
- try {
- BoundingBox box = (BoundingBox)bounds;
- return (lower.equals(box.lower) &&
- upper.equals(box.upper));
- }
- catch (NullPointerException e) {
- return false;
- }
- catch (ClassCastException e) {
- return false;
- }
- }
-
-
- /**
- * Returns a hash code value for this BoundingBox object
- * based on the data values in this object. Two different
- * BoundingBox objects with identical data values (i.e.,
- * BoundingBox.equals returns true) will return the same hash
- * code value. Two BoundingBox objects with different data
- * members may return the same hash code value, although this is
- * not likely.
- * @return a hash code value for this BoundingBox object.
- *
- * @since Java 3D 1.2
- */
- @Override
- public int hashCode() {
- long bits = 1L;
- bits = J3dHash.mixDoubleBits(bits, lower.x);
- bits = J3dHash.mixDoubleBits(bits, lower.y);
- bits = J3dHash.mixDoubleBits(bits, lower.z);
- bits = J3dHash.mixDoubleBits(bits, upper.x);
- bits = J3dHash.mixDoubleBits(bits, upper.y);
- bits = J3dHash.mixDoubleBits(bits, upper.z);
- return J3dHash.finish(bits);
- }
-
-
- /**
- * Combines this bounding box with a bounding object so that the
- * resulting bounding box encloses the original bounding box and the
- * specified bounds object.
- * @param boundsObject another bounds object
- */
- @Override
- public void combine(Bounds boundsObject) {
-
- if((boundsObject == null) || (boundsObject.boundsIsEmpty)
- || (boundsIsInfinite))
- return;
-
- if((boundsIsEmpty) || (boundsObject.boundsIsInfinite)) {
- this.set(boundsObject);
- return;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
-
- if( lower.x > box.lower.x) lower.x = box.lower.x;
- if( lower.y > box.lower.y) lower.y = box.lower.y;
- if( lower.z > box.lower.z) lower.z = box.lower.z;
- if( upper.x < box.upper.x) upper.x = box.upper.x;
- if( upper.y < box.upper.y) upper.y = box.upper.y;
- if( upper.z < box.upper.z) upper.z = box.upper.z;
-
- }
- else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- if( lower.x > (sphere.center.x - sphere.radius))
- lower.x = sphere.center.x - sphere.radius;
- if( lower.y > (sphere.center.y - sphere.radius))
- lower.y = sphere.center.y - sphere.radius;
- if( lower.z > (sphere.center.z - sphere.radius))
- lower.z = sphere.center.z - sphere.radius;
- if( upper.x < (sphere.center.x + sphere.radius))
- upper.x = sphere.center.x + sphere.radius;
- if( upper.y < (sphere.center.y + sphere.radius))
- upper.y = sphere.center.y + sphere.radius;
- if( upper.z < (sphere.center.z + sphere.radius))
- upper.z = sphere.center.z + sphere.radius;
-
- }
- else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- int i;
- for(i=1;i upper.x ) upper.x = polytope.verts[i].x;
- if( polytope.verts[i].y > upper.y ) upper.y = polytope.verts[i].y;
- if( polytope.verts[i].z > upper.z ) upper.z = polytope.verts[i].z;
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox3"));
- }
-
- updateBoundsStates();
- }
-
- /**
- * Combines this bounding box with an array of bounding objects
- * so that the resulting bounding box encloses the original bounding
- * box and the array of bounding objects.
- * @param bounds an array of bounds objects
- */
- @Override
- public void combine(Bounds[] bounds) {
- int i=0;
-
- if( (bounds == null) || (bounds.length <= 0)
- || (boundsIsInfinite))
- return;
-
- // find first non empty bounds object
- while( (i= bounds.length)
- return; // no non empty bounds so do not modify current bounds
-
- if(boundsIsEmpty)
- this.set(bounds[i++]);
-
- if(boundsIsInfinite)
- return;
-
- for(;i box.lower.x) lower.x = box.lower.x;
- if( lower.y > box.lower.y) lower.y = box.lower.y;
- if( lower.z > box.lower.z) lower.z = box.lower.z;
- if( upper.x < box.upper.x) upper.x = box.upper.x;
- if( upper.y < box.upper.y) upper.y = box.upper.y;
- if( upper.z < box.upper.z) upper.z = box.upper.z;
- }
- else if( bounds[i].boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)bounds[i];
- if( lower.x > (sphere.center.x - sphere.radius))
- lower.x = sphere.center.x - sphere.radius;
- if( lower.y > (sphere.center.y - sphere.radius))
- lower.y = sphere.center.y - sphere.radius;
- if( lower.z > (sphere.center.z - sphere.radius))
- lower.z = sphere.center.z - sphere.radius;
- if( upper.x < (sphere.center.x + sphere.radius))
- upper.x = sphere.center.x + sphere.radius;
- if( upper.y < (sphere.center.y + sphere.radius))
- upper.y = sphere.center.y + sphere.radius;
- if( upper.z < (sphere.center.z + sphere.radius))
- upper.z = sphere.center.z + sphere.radius;
- }
- else if(bounds[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)bounds[i];
- for(i=1;i upper.x ) upper.x = polytope.verts[i].x;
- if( polytope.verts[i].y > upper.y ) upper.y = polytope.verts[i].y;
- if( polytope.verts[i].z > upper.z ) upper.z = polytope.verts[i].z;
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox4"));
- }
- }
-
- updateBoundsStates();
- }
-
- /**
- * Combines this bounding box with a point so that the resulting
- * bounding box encloses the original bounding box and the point.
- * @param point a 3d point in space
- */
- @Override
- public void combine(Point3d point) {
-
- if( boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty) {
- upper.x = lower.x = point.x;
- upper.y = lower.y = point.y;
- upper.z = lower.z = point.z;
- } else {
- if( point.x > upper.x) upper.x = point.x;
- if( point.y > upper.y) upper.y = point.y;
- if( point.z > upper.z) upper.z = point.z;
-
- if( point.x < lower.x) lower.x = point.x;
- if( point.y < lower.y) lower.y = point.y;
- if( point.z < lower.z) lower.z = point.z;
- }
-
- updateBoundsStates();
- }
-
- /**
- * Combines this bounding box with an array of points so that the
- * resulting bounding box encloses the original bounding box and the
- * array of points.
- * @param points an array of 3d points in space
- */
- @Override
- public void combine(Point3d[] points) {
-
- int i;
-
- if( boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty) {
- this.setUpper(points[0]);
- this.setLower(points[0]);
- }
-
- for(i=0;i upper.x) upper.x = points[i].x;
- if( points[i].y > upper.y) upper.y = points[i].y;
- if( points[i].z > upper.z) upper.z = points[i].z;
-
- if( points[i].x < lower.x) lower.x = points[i].x;
- if( points[i].y < lower.y) lower.y = points[i].y;
- if( points[i].z < lower.z) lower.z = points[i].z;
- }
-
- updateBoundsStates();
- }
-
- /**
- * Modifies the bounding box so that it bounds the volume
- * generated by transforming the given bounding object.
- * @param boundsObject the bounding object to be transformed
- * @param matrix a transformation matrix
- */
- @Override
- public void transform( Bounds boundsObject, Transform3D matrix) {
-
- if (boundsObject == null || boundsObject.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if (boundsObject.boundsIsInfinite) {
- setInfiniteBounds();
- return;
- }
-
- if(boundsObject.boundId == BOUNDING_BOX){
- this.set(boundsObject);
- this.transform(matrix);
- }
- else if(boundsObject.boundId == BOUNDING_SPHERE) {
- BoundingSphere tmpSphere = new BoundingSphere(boundsObject);
- tmpSphere.transform(matrix);
- this.set(tmpSphere);
- }
- else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope tmpPolytope = new BoundingPolytope(boundsObject);
- tmpPolytope.transform(matrix);
- this.set(tmpPolytope);
- }
- else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox5"));
- }
- }
-
- /**
- * Transforms this bounding box by the given matrix.
- * @param matrix a transformation matrix
- */
- @Override
- public void transform(Transform3D matrix) {
-
- if (boundsIsInfinite)
- return;
-
- Point3d tmpP3d = new Point3d();
-
- double ux, uy, uz, lx, ly, lz;
- ux = upper.x; uy = upper.y; uz = upper.z;
- lx = lower.x; ly = lower.y; lz = lower.z;
-
- tmpP3d.set(ux, uy, uz);
- matrix.transform( tmpP3d );
- upper.x = tmpP3d.x;
- upper.y = tmpP3d.y;
- upper.z = tmpP3d.z;
- lower.x = tmpP3d.x;
- lower.y = tmpP3d.y;
- lower.z = tmpP3d.z;
-
- tmpP3d.set(lx, uy, uz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(lx, ly, uz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(ux, ly, uz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(lx, uy, lz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(ux, uy, lz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(lx, ly, lz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- tmpP3d.set(ux, ly, lz);
- matrix.transform( tmpP3d );
- if ( tmpP3d.x > upper.x ) upper.x = tmpP3d.x;
- if ( tmpP3d.y > upper.y ) upper.y = tmpP3d.y;
- if ( tmpP3d.z > upper.z ) upper.z = tmpP3d.z;
- if ( tmpP3d.x < lower.x ) lower.x = tmpP3d.x;
- if ( tmpP3d.y < lower.y ) lower.y = tmpP3d.y;
- if ( tmpP3d.z < lower.z ) lower.z = tmpP3d.z;
-
- }
-
- /**
- * Test for intersection with a ray.
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @param position3 a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Point3d origin, Vector3d direction, Point4d position ) {
- double t1,t2,tmp,tnear,tfar,invDir,invMag;
- double dirx, diry, dirz;
-
- /*
- System.err.println("BoundingBox.intersect(p,d,p) called\n");
- System.err.println("bounds = " + lower + " -> " + upper);
- */
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = origin.x;
- position.y = origin.y;
- position.z = origin.z;
- position.w = 0.0;
- return true;
- }
-
- double dirLen = direction.x*direction.x + direction.y*direction.y +
- direction.z*direction.z;
-
- // Handle zero length direction vector.
- if(dirLen == 0.0)
- return intersect(origin, position);
-
- invMag = 1.0/Math.sqrt(dirLen);
- dirx = direction.x*invMag;
- diry = direction.y*invMag;
- dirz = direction.z*invMag;
-
- /*
- System.err.println("dir = " + dirx + ", " + diry + ", " + dirz);
- System.err.println("origin = " + origin);
- */
-
- // initialize tnear and tfar to handle dir.? == 0 cases
- tnear = -Double.MAX_VALUE;
- tfar = Double.MAX_VALUE;
-
- if(dirx == 0.0) {
- //System.err.println("dirx == 0.0");
- if (origin.x < lower.x || origin.x > upper.x ) {
- //System.err.println( "parallel to x plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/dirx;
- t1 = (lower.x-origin.x)*invDir;
- t2 = (upper.x-origin.x)*invDir;
-
- //System.err.println("x t1 = " + t1 + " t2 = " + t2);
- if( t1 > t2) {
- tnear = t2;
- tfar = t1;
- }else {
- tnear = t1;
- tfar = t2;
- }
- if( tfar < 0.0 ) {
- //System.err.println( "x failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("x tnear = " + tnear + " tfar = " + tfar);
- }
- // y
- if (diry == 0.0) {
- //System.err.println("diry == 0.0");
- if( origin.y < lower.y || origin.y > upper.y ){
- //System.err.println( "parallel to y plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/diry;
- //System.err.println("invDir = " + invDir);
- t1 = (lower.y-origin.y)*invDir;
- t2 = (upper.y-origin.y)*invDir;
-
- if( t1 > t2) {
- tmp = t1;
- t1 = t2;
- t2 = tmp;
- }
- //System.err.println("y t1 = " + t1 + " t2 = " + t2);
- if( t1 > tnear) tnear = t1;
- if( t2 < tfar ) tfar = t2;
-
- if( (tfar < 0.0) || (tnear > tfar)){
- //System.err.println( "y failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("y tnear = " + tnear + " tfar = " + tfar);
- }
-
- // z
- if (dirz == 0.0) {
- //System.err.println("dirz == 0.0");
- if( origin.z < lower.z || origin.z > upper.z ) {
- //System.err.println( "parallel to z plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/dirz;
- t1 = (lower.z-origin.z)*invDir;
- t2 = (upper.z-origin.z)*invDir;
-
- if( t1 > t2) {
- tmp = t1;
- t1 = t2;
- t2 = tmp;
- }
- //System.err.println("z t1 = " + t1 + " t2 = " + t2);
- if( t1 > tnear) tnear = t1;
- if( t2 < tfar ) tfar = t2;
-
- if( (tfar < 0.0) || (tnear > tfar)){
- //System.err.println( "z failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("z tnear = " + tnear + " tfar = " + tfar);
- }
-
- if((tnear < 0.0) && (tfar >= 0.0)) {
- // origin is inside the BBox.
- position.x = origin.x + dirx*tfar;
- position.y = origin.y + diry*tfar;
- position.z = origin.z + dirz*tfar;
- position.w = tfar;
- }
- else {
- position.x = origin.x + dirx*tnear;
- position.y = origin.y + diry*tnear;
- position.z = origin.z + dirz*tnear;
- position.w = tnear;
- }
-
- return true;
-
- }
-
-
- /**
- * Test for intersection with a point.
- * @param point the pick point
- * @param position a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Point3d point, Point4d position ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = point.x;
- position.y = point.y;
- position.z = point.z;
- position.w = 0.0;
- return true;
- }
-
- if( point.x <= upper.x && point.x >= lower.x &&
- point.y <= upper.y && point.y >= lower.y &&
- point.z <= upper.z && point.z >= lower.z) {
- position.x = point.x;
- position.y = point.y;
- position.z = point.z;
- position.w = 0.0;
- return true;
- } else
- return false;
-
- }
-
- /**
- * Test for intersection with a segment.
- * @param start a point defining the start of the line segment
- * @param end a point defining the end of the line segment
- * @param position a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect( Point3d start, Point3d end, Point4d position ) {
- double t1,t2,tmp,tnear,tfar,invDir,invMag;
- double dirx, diry, dirz;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = start.x;
- position.y = start.y;
- position.z = start.z;
- position.w = 0.0;
- return true;
- }
-
- dirx = end.x - start.x;
- diry = end.y - start.y;
- dirz = end.z - start.z;
-
- double dirLen = dirx*dirx + diry*diry + dirz*dirz;
-
- // Optimization : Handle zero length direction vector.
- if(dirLen == 0.0)
- return intersect(start, position);
-
- dirLen = Math.sqrt(dirLen);
- // System.err.println("dirLen is " + dirLen);
- invMag = 1.0/dirLen;
- dirx = dirx*invMag;
- diry = diry*invMag;
- dirz = dirz*invMag;
-
- /*
- System.err.println("dir = " + dir);
- System.err.println("start = " + start);
- System.err.println("lower = " + lower);
- System.err.println("upper = " + upper);
- */
-
- // initialize tnear and tfar to handle dir.? == 0 cases
- tnear = -Double.MAX_VALUE;
- tfar = Double.MAX_VALUE;
-
- if(dirx == 0.0) {
- //System.err.println("dirx == 0.0");
- if (start.x < lower.x || start.x > upper.x ) {
- //System.err.println( "parallel to x plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/dirx;
- t1 = (lower.x-start.x)*invDir;
- t2 = (upper.x-start.x)*invDir;
-
- //System.err.println("x t1 = " + t1 + " t2 = " + t2);
- if( t1 > t2) {
- tnear = t2;
- tfar = t1;
- }else {
- tnear = t1;
- tfar = t2;
- }
- if( tfar < 0.0 ) {
- //System.err.println( "x failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("x tnear = " + tnear + " tfar = " + tfar);
- }
- // y
- if (diry == 0.0) {
- //System.err.println("diry == 0.0");
- if( start.y < lower.y || start.y > upper.y ){
- //System.err.println( "parallel to y plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/diry;
- //System.err.println("invDir = " + invDir);
- t1 = (lower.y-start.y)*invDir;
- t2 = (upper.y-start.y)*invDir;
-
- if( t1 > t2) {
- tmp = t1;
- t1 = t2;
- t2 = tmp;
- }
- //System.err.println("y t1 = " + t1 + " t2 = " + t2);
- if( t1 > tnear) tnear = t1;
- if( t2 < tfar ) tfar = t2;
-
- if( (tfar < 0.0) || (tnear > tfar)){
- //System.err.println( "y failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("y tnear = " + tnear + " tfar = " + tfar);
- }
-
- // z
- if (dirz == 0.0) {
- //System.err.println("dirz == 0.0");
- if( start.z < lower.z || start.z > upper.z ) {
- //System.err.println( "parallel to z plane and outside");
- return false;
- }
- } else {
- invDir = 1.0/dirz;
- t1 = (lower.z-start.z)*invDir;
- t2 = (upper.z-start.z)*invDir;
-
- if( t1 > t2) {
- tmp = t1;
- t1 = t2;
- t2 = tmp;
- }
- //System.err.println("z t1 = " + t1 + " t2 = " + t2);
- if( t1 > tnear) tnear = t1;
- if( t2 < tfar ) tfar = t2;
-
- if( (tfar < 0.0) || (tnear > tfar)){
- //System.err.println( "z failed: tnear="+tnear+" tfar="+tfar);
- return false;
- }
- //System.err.println("z tnear = " + tnear + " tfar = " + tfar);
- }
-
- if((tnear < 0.0) && (tfar >= 0.0)) {
- // origin is inside the BBox.
- position.x = start.x + dirx*tfar;
- position.y = start.y + diry*tfar;
- position.z = start.z + dirz*tfar;
- position.w = tfar;
- }
- else {
- if(tnear>dirLen) {
- // Segment is behind BBox.
- /*
- System.err.println("PickSegment : intersected postion : " + position
- + " tnear " + tnear + " tfar " + tfar );
- */
- return false;
- }
- position.x = start.x + dirx*tnear;
- position.y = start.y + diry*tnear;
- position.z = start.z + dirz*tnear;
-
- position.w = tnear;
- }
-
- /*
- System.err.println("tnear = " + tnear + " tfar = " + tfar + " w " +
- position.w);
- System.err.println("lower = " + lower);
- System.err.println("upper = " + upper + "\n");
- */
- return true;
-
- }
-
- /**
- * Test for intersection with a ray.
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d origin, Vector3d direction ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- return true;
- }
-
- Point3d p=new Point3d();
- return intersect( origin, direction, p );
- }
-
- /**
- * A protected intersect method that returns the point of intersection.
- * Used by Picking methods to sort or return closest picked item.
- */
- boolean intersect(Point3d origin, Vector3d direction, Point3d intersect ) {
- double theta=0.0;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- intersect.x = origin.x;
- intersect.y = origin.y;
- intersect.z = origin.z;
- return true;
- }
-
- if (direction.x > 0.0 )
- theta = Math.max( theta, (lower.x - origin.x)/direction.x );
- if (direction.x < 0.0 )
- theta = Math.max( theta, (upper.x - origin.x)/direction.x );
- if (direction.y > 0.0 )
- theta = Math.max( theta, (lower.y - origin.y)/direction.y );
- if (direction.y < 0.0 )
- theta = Math.max( theta, (upper.y - origin.y)/direction.y );
- if (direction.z > 0.0 )
- theta = Math.max( theta, (lower.z - origin.z)/direction.z );
- if (direction.z < 0.0 )
- theta = Math.max( theta, (upper.z - origin.z)/direction.z );
-
- intersect.x = origin.x + theta*direction.x;
- intersect.y = origin.y + theta*direction.y;
- intersect.z = origin.z + theta*direction.z;
-
- if (intersect.x < (lower.x-EPS)) return false;
- if (intersect.x > (upper.x+EPS)) return false;
- if (intersect.y < (lower.y-EPS)) return false;
- if (intersect.y > (upper.y+EPS)) return false;
- if (intersect.z < (lower.z-EPS)) return false;
- if (intersect.z > (upper.z+EPS)) return false;
-
- return true;
-
- }
-
- /**
- * Test for intersection with a point.
- * @param point a point defining a position in 3-space
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d point ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
- if( boundsIsInfinite ) {
- return true;
- }
-
- if( point.x <= upper.x && point.x >= lower.x &&
- point.y <= upper.y && point.y >= lower.y &&
- point.z <= upper.z && point.z >= lower.z)
- return true;
- else
- return false;
- }
- /**
- * Tests whether the bounding box is empty. A bounding box is
- * empty if it is null (either by construction or as the result of
- * a null intersection) or if its volume is negative. A bounding box
- * with a volume of zero is not empty.
- * @return true if the bounding box is empty; otherwise, it returns false
- */
- @Override
- public boolean isEmpty() {
-
- return boundsIsEmpty;
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Bounds boundsObject, Point4d position) {
- return intersect(boundsObject);
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds boundsObject) {
-
- if( boundsObject == null ) {
- return false;
- }
-
- if( boundsIsEmpty || boundsObject.boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite || boundsObject.boundsIsInfinite ) {
- return true;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
- // both boxes are axis aligned
- if( upper.x > box.lower.x && box.upper.x > lower.x &&
- upper.y > box.lower.y && box.upper.y > lower.y &&
- upper.z > box.lower.z && box.upper.z > lower.z )
- return true;
- else
- return false;
- } else if( boundsObject.boundId == BOUNDING_SPHERE) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- double rad_sq = sphere.radius*sphere.radius;
- double dis = 0.0;
-
- if( sphere.center.x < lower.x )
- dis = (sphere.center.x-lower.x)*(sphere.center.x-lower.x);
- else
- if( sphere.center.x > upper.x )
- dis = (sphere.center.x-upper.x)*(sphere.center.x-upper.x);
-
- if( sphere.center.y < lower.y )
- dis += (sphere.center.y-lower.y)*(sphere.center.y-lower.y);
- else
- if( sphere.center.y > upper.y )
- dis += (sphere.center.y-upper.y)*(sphere.center.y-upper.y);
-
- if( sphere.center.z < lower.z )
- dis += (sphere.center.z-lower.z)*(sphere.center.z-lower.z);
- else
- if( sphere.center.z > upper.z )
- dis += (sphere.center.z-upper.z)*(sphere.center.z-upper.z);
-
- if( dis <= rad_sq )
- return true;
- else
- return false;
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- // intersect an axis aligned box with a polytope
- return intersect_ptope_abox ( (BoundingPolytope)boundsObject, this );
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox6"));
- }
-
- }
-
- /**
- * Test for intersection with an array of bounds objects.
- * @param boundsObjects an array of bounding objects
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds[] boundsObjects) {
-
- int i;
-
- if( boundsObjects == null || boundsObjects.length <= 0 ) {
- return false;
- }
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- for(i = 0; i < boundsObjects.length; i++){
- if( boundsObjects[i] == null || boundsObjects[i].boundsIsEmpty) ;
- else if( boundsIsInfinite || boundsObjects[i].boundsIsInfinite ) {
- return true; // We're done here.
- }
- else if( boundsObjects[i].boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObjects[i];
- // both boxes are axis aligned
- if( upper.x > box.lower.x && box.upper.x > lower.x &&
- upper.y > box.lower.y && box.upper.y > lower.y &&
- upper.z > box.lower.z && box.upper.z > lower.z )
- return true;
- }
- else if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObjects[i];
- double rad_sq = sphere.radius*sphere.radius;
- double dis = 0.0;
-
- if( sphere.center.x < lower.x )
- dis = (sphere.center.x-lower.x)*(sphere.center.x-lower.x);
- else
- if( sphere.center.x > upper.x )
- dis = (sphere.center.x-upper.x)*(sphere.center.x-upper.x);
-
- if( sphere.center.y < lower.y )
- dis += (sphere.center.y-lower.y)*(sphere.center.y-lower.y);
- else
- if( sphere.center.y > upper.y )
- dis += (sphere.center.y-upper.y)*(sphere.center.y-upper.y);
-
- if( sphere.center.z < lower.z )
- dis += (sphere.center.z-lower.z)*(sphere.center.z-lower.z);
- else
- if( sphere.center.z > upper.z )
- dis += (sphere.center.z-upper.z)*(sphere.center.z-upper.z);
-
- if( dis <= rad_sq )
- return true;
-
- }
- else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- if( intersect_ptope_abox ( (BoundingPolytope)boundsObjects[i], this ))
- return true;
- }
- else {
- // System.err.println("intersect ?? ");
- }
- }
-
- return false;
- }
-
- /**
- * Test for intersection with another bounding box.
- * @param boundsObject another bounding object
- * @param newBoundBox the new bounding box which is the intersection of
- * the boundsObject and this BoundingBox
- * @return true or false indicating if an intersection occured
- */
- public boolean intersect(Bounds boundsObject, BoundingBox newBoundBox) {
-
- if((boundsObject == null) || boundsIsEmpty || boundsObject.boundsIsEmpty ) {
- newBoundBox.set((Bounds)null);
- return false;
- }
-
-
- if(boundsIsInfinite && (!boundsObject.boundsIsInfinite)) {
- newBoundBox.set(boundsObject);
- return true;
- }
- else if((!boundsIsInfinite) && boundsObject.boundsIsInfinite) {
- newBoundBox.set(this);
- return true;
- }
- else if(boundsIsInfinite && boundsObject.boundsIsInfinite) {
- newBoundBox.set(this);
- return true;
- }
- else if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
- // both boxes are axis aligned
- if( upper.x > box.lower.x && box.upper.x > lower.x &&
- upper.y > box.lower.y && box.upper.y > lower.y &&
- upper.z > box.lower.z && box.upper.z > lower.z ){
-
-
- if(upper.x > box.upper.x)
- newBoundBox.upper.x = box.upper.x;
- else
- newBoundBox.upper.x = upper.x;
-
- if(upper.y > box.upper.y)
- newBoundBox.upper.y = box.upper.y;
- else
- newBoundBox.upper.y = upper.y;
-
- if(upper.z > box.upper.z)
- newBoundBox.upper.z = box.upper.z;
- else
- newBoundBox.upper.z = upper.z;
-
- if(lower.x < box.lower.x)
- newBoundBox.lower.x = box.lower.x;
- else
- newBoundBox.lower.x = lower.x;
-
- if(lower.y < box.lower.y)
- newBoundBox.lower.y = box.lower.y;
- else
- newBoundBox.lower.y = lower.y;
-
- if(lower.z < box.lower.z)
- newBoundBox.lower.z = box.lower.z;
- else
- newBoundBox.lower.z = lower.z;
-
- newBoundBox.updateBoundsStates();
- return true;
- } else {
- // Negative volume.
- newBoundBox.set((Bounds)null);
- return false;
- }
- }
- else if( boundsObject.boundId == BOUNDING_SPHERE) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- if( this.intersect( sphere) ) {
- BoundingBox sbox = new BoundingBox( sphere );
- this.intersect( sbox, newBoundBox );
- return true;
- } else {
- // Negative volume.
- newBoundBox.set((Bounds)null);
- return false;
- }
-
- // System.err.println("intersect Sphere ");
- }
- else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- if( this.intersect( polytope)) {
- BoundingBox pbox = new BoundingBox( polytope); // convert polytope to box
- this.intersect( pbox, newBoundBox );
- return true;
- } else {
- // Negative volume.
- newBoundBox.set((Bounds)null);
- return false;
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox7"));
- }
- }
-
- /**
- * Test for intersection with an array of bounds objects.
- * @param boundsObjects an array of bounds objects
- * @param newBoundBox the new bounding box which is the intersection of
- * the boundsObject and this BoundingBox
- * @return true or false indicating if an intersection occured
- */
- public boolean intersect(Bounds[] boundsObjects, BoundingBox newBoundBox) {
-
- if( boundsObjects == null || boundsObjects.length <= 0 || boundsIsEmpty ) {
- // Negative volume.
- newBoundBox.set((Bounds)null);
- return false;
- }
-
- int i=0;
- // find first non null bounds object
- while( boundsObjects[i] == null && i < boundsObjects.length) {
- i++;
- }
-
- if( i >= boundsObjects.length ) { // all bounds objects were empty
- // Negative volume.
- newBoundBox.set((Bounds)null);
- return false;
- }
-
-
- boolean status = false;
- BoundingBox tbox = new BoundingBox();
-
- for(;i box.lower.x && box.upper.x > lower.x &&
- upper.y > box.lower.y && box.upper.y > lower.y &&
- upper.z > box.lower.z && box.upper.z > lower.z ){
-
- if(upper.x > box.upper.x)
- newBoundBox.upper.x = box.upper.x;
- else
- newBoundBox.upper.x = upper.x;
-
- if(upper.y > box.upper.y)
- newBoundBox.upper.y = box.upper.y;
- else
- newBoundBox.upper.y = upper.y;
-
- if(upper.z > box.upper.z)
- newBoundBox.upper.z = box.upper.z;
- else
- newBoundBox.upper.z = upper.z;
-
- if(lower.x < box.lower.x)
- newBoundBox.lower.x = box.lower.x;
- else
- newBoundBox.lower.x = lower.x;
-
- if(lower.y < box.lower.y)
- newBoundBox.lower.y = box.lower.y;
- else
- newBoundBox.lower.y = lower.y;
-
- if(lower.z < box.lower.z)
- newBoundBox.lower.z = box.lower.z;
- else
- newBoundBox.lower.z = lower.z;
- status = true;
- newBoundBox.updateBoundsStates();
- }
- }
- else if( boundsObjects[i].boundId == BOUNDING_SPHERE) {
- BoundingSphere sphere = (BoundingSphere)boundsObjects[i];
- if( this.intersect(sphere)) {
- BoundingBox sbox = new BoundingBox( sphere ); // convert sphere to box
- this.intersect(sbox,tbox); // insersect two boxes
- if( status ) {
- newBoundBox.combine( tbox );
- } else {
- newBoundBox.set( tbox );
- status = true;
- }
- }
-
- }
- else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- if( this.intersect( polytope)) {
- BoundingBox pbox = new BoundingBox( polytope ); // convert polytope to box
- this.intersect(pbox,tbox); // insersect two boxes
- if ( status ) {
- newBoundBox.combine( tbox );
- } else {
- newBoundBox.set( tbox );
- status = true;
- }
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox6"));
- }
-
- if(newBoundBox.boundsIsInfinite)
- break; // We're done.
- }
- if( status == false ) {
- // Negative volume.
- newBoundBox.set((Bounds)null);
- }
- return status;
- }
-
-
- /**
- * Finds closest bounding object that intersects this bounding box.
- * @param boundsObjects an array of bounds objects
- * @return closest bounding object
- */
- @Override
- public Bounds closestIntersection( Bounds[] boundsObjects) {
-
- if( boundsObjects == null || boundsObjects.length <= 0 ) {
- return null;
- }
-
- if( boundsIsEmpty ) {
- return null;
- }
-
- Point3d centroid = getCenter();
-
- double dis;
- double cenX = 0.0, cenY = 0.0, cenZ = 0.0;
- boolean contains = false;
- boolean inside;
- boolean intersect = false;
- double smallest_distance = Double.MAX_VALUE;
- int i,j,index=0;
-
- for(i = 0; i < boundsObjects.length; i++){
- if( boundsObjects[i] == null ) ;
-
- else if( this.intersect( boundsObjects[i])) {
- intersect = true;
- if( boundsObjects[i].boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObjects[i];
- cenX = (box.upper.x+box.lower.x)/2.0;
- cenY = (box.upper.y+box.lower.y)/2.0;
- cenZ = (box.upper.z+box.lower.z)/2.0;
- dis = Math.sqrt( (centroid.x-cenX)*(centroid.x-cenX) +
- (centroid.y-cenY)*(centroid.y-cenY) +
- (centroid.z-cenZ)*(centroid.z-cenZ) );
- inside = false;
-
- if( lower.x <= box.lower.x &&
- lower.y <= box.lower.y &&
- lower.z <= box.lower.z &&
- upper.x >= box.upper.x &&
- upper.y >= box.upper.y &&
- upper.z >= box.upper.z ) { // box is contained
- inside = true;
- }
- if( inside ) {
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
-
- }
- else if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObjects[i];
- dis = Math.sqrt( (centroid.x-sphere.center.x)*
- (centroid.x-sphere.center.x) +
- (centroid.y-sphere.center.y)*
- (centroid.y-sphere.center.y) +
- (centroid.z-sphere.center.z)*
- (centroid.z-sphere.center.z) );
-
- inside = false;
-
- // sphere sphere.center is inside box
- if(sphere.center.x <= upper.x && sphere.center.x >= lower.x &&
- sphere.center.y <= upper.y && sphere.center.y >= lower.y &&
- sphere.center.z <= upper.z && sphere.center.z >= lower.z ) {
- // check if sphere intersects any side
- if (sphere.center.x - lower.x >= sphere.radius &&
- upper.x - sphere.center.x >= sphere.radius &&
- sphere.center.y - lower.y >= sphere.radius &&
- upper.y - sphere.center.y >= sphere.radius &&
- sphere.center.z - lower.z >= sphere.radius &&
- upper.z - sphere.center.z >= sphere.radius ) {
- // contains the sphere
- inside = true;
- }
- }
- if (inside ) {
- // initialize smallest_distance for the first containment
- if( !contains ){
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- }
- else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope =
- (BoundingPolytope)boundsObjects[i];
- dis = Math.sqrt( (centroid.x-polytope.centroid.x)*
- (centroid.x-polytope.centroid.x) +
- (centroid.y-polytope.centroid.y)*
- (centroid.y-polytope.centroid.y) +
- (centroid.z-polytope.centroid.z)*
- (centroid.z-polytope.centroid.z) );
- inside = true;
- for(j=0;j upper.x ||
- polytope.verts[j].y > upper.y ||
- polytope.verts[j].z > upper.z ) { // box contains polytope
- inside = false;
-
- }
-
- }
- if( inside ) {
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
-
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingBox9"));
- }
- }
- }
-
- if ( intersect )
- return boundsObjects[index];
- else
- return null;
- }
-
- /**
- * Tests for intersection of box and frustum.
- * @param frustum
- * @return true if they intersect
- */
- boolean intersect(CachedFrustum frustum ) {
-
- if (boundsIsEmpty)
- return false;
-
- if(boundsIsInfinite)
- return true;
-
- // System.err.println("intersect frustum with box="+this.toString());
- // System.err.println("frustum "+frustum.toString());
- // check if box and bounding box of frustum intersect
- if ((upper.x < frustum.lower.x) ||
- (lower.x > frustum.upper.x) ||
- (upper.y < frustum.lower.y) ||
- (lower.y > frustum.upper.y) ||
- (upper.z < frustum.lower.z) ||
- (lower.z > frustum.upper.z) ) {
-
- // System.err.println("*** box and bounding box of frustum do not intersect");
- return false;
- }
-
- // check if all box points out any frustum plane
- int i = 5;
- while (i>=0){
- Vector4d vc = frustum.clipPlanes[i--];
- if ((( upper.x*vc.x + upper.y*vc.y +
- upper.z*vc.z + vc.w ) < 0.0 ) &&
- (( upper.x*vc.x + lower.y*vc.y +
- upper.z*vc.z + vc.w ) < 0.0 ) &&
- (( upper.x*vc.x + lower.y*vc.y +
- lower.z*vc.z + vc.w ) < 0.0 ) &&
- (( upper.x*vc.x + upper.y*vc.y +
- lower.z*vc.z + vc.w ) < 0.0 ) &&
- (( lower.x*vc.x + upper.y*vc.y +
- upper.z*vc.z + vc.w ) < 0.0 ) &&
- (( lower.x*vc.x + lower.y*vc.y +
- upper.z*vc.z + vc.w ) < 0.0 ) &&
- (( lower.x*vc.x + lower.y*vc.y +
- lower.z*vc.z + vc.w ) < 0.0 ) &&
- (( lower.x*vc.x + upper.y*vc.y +
- lower.z*vc.z + vc.w ) < 0.0 )) {
- // all corners outside this frustum plane
- // System.err.println("*** all corners outside this frustum plane");
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Returns a string representation of this class.
- */
- @Override
- public String toString() {
- return new String( "Bounding box: Lower="+lower.x+" "+
- lower.y+" "+lower.z+" Upper="+upper.x+" "+
- upper.y+" "+upper.z );
- }
-
-private void setEmptyBounds() {
- lower.set( 1.0d, 1.0d, 1.0d);
- upper.set(-1.0d, -1.0d, -1.0d);
- boundsIsInfinite = false;
- boundsIsEmpty = true;
-}
-
-private void setInfiniteBounds() {
- lower.set(Double.NEGATIVE_INFINITY,
- Double.NEGATIVE_INFINITY,
- Double.NEGATIVE_INFINITY);
- upper.set(Double.POSITIVE_INFINITY,
- Double.POSITIVE_INFINITY,
- Double.POSITIVE_INFINITY);
-
- boundsIsInfinite = true;
- boundsIsEmpty = false;
-}
-
- private void updateBoundsStates() {
- if((lower.x == Double.NEGATIVE_INFINITY) &&
- (lower.y == Double.NEGATIVE_INFINITY) &&
- (lower.z == Double.NEGATIVE_INFINITY) &&
- (upper.x == Double.POSITIVE_INFINITY) &&
- (upper.y == Double.POSITIVE_INFINITY) &&
- (upper.z == Double.POSITIVE_INFINITY)) {
- boundsIsEmpty = false;
- boundsIsInfinite = true;
- return;
- }
-
- if (Double.isNaN(lower.x + lower.y + lower.z + upper.x + upper.y + upper.z)) {
- boundsIsEmpty = true;
- boundsIsInfinite = false;
- return;
- }
- else {
- boundsIsInfinite = false;
- if( lower.x > upper.x ||
- lower.y > upper.y ||
- lower.z > upper.z ) {
- boundsIsEmpty = true;
- } else {
- boundsIsEmpty = false;
- }
- }
- }
-
-// For a infinite bounds. What is the centroid ?
-@Override
-Point3d getCenter() {
- Point3d cent = new Point3d();
- cent.add(upper, lower);
- cent.scale(0.5d);
- return cent;
-}
-
-@Override
-public void getCenter(Point3d center) {
- center.add(lower, upper);
- center.scale(0.5d);
-}
-
- void translate(BoundingBox bbox, Vector3d value) {
- if (bbox == null || bbox.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if (bbox.boundsIsInfinite) {
- setInfiniteBounds();
- return;
- }
-
- lower.x = bbox.lower.x + value.x;
- lower.y = bbox.lower.y + value.y;
- lower.z = bbox.lower.z + value.z;
- upper.x = bbox.upper.x + value.x;
- upper.y = bbox.upper.y + value.y;
- upper.z = bbox.upper.z + value.z;
- }
-
-
- /**
- * if the passed the "region" is same type as this object
- * then do a copy, otherwise clone the Bounds and
- * return
- */
- @Override
- Bounds copy(Bounds r) {
- if (r != null && this.boundId == r.boundId) {
- BoundingBox region = (BoundingBox) r;
- region.lower.x = lower.x;
- region.lower.y = lower.y;
- region.lower.z = lower.z;
- region.upper.x = upper.x;
- region.upper.y = upper.y;
- region.upper.z = upper.z;
- region.boundsIsEmpty = boundsIsEmpty;
- region.boundsIsInfinite = boundsIsInfinite;
- return region;
- }
- else {
- return (Bounds) this.clone();
- }
- }
-
- @Override
- int getPickType() {
- return PickShape.PICKBOUNDINGBOX;
- }
-}
-
diff --git a/src/classes/share/javax/media/j3d/BoundingLeaf.java b/src/classes/share/javax/media/j3d/BoundingLeaf.java
deleted file mode 100644
index 3037abe..0000000
--- a/src/classes/share/javax/media/j3d/BoundingLeaf.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-/**
- * The BoundingLeaf node defines a bounding region object that can be
- * referenced by other nodes to define a region of influence
- * (Fog and Light nodes), an application region (Background, Clip,
- * and Soundscape nodes), or a scheduling region (Sound and
- * Behavior nodes). The bounding region is defined in the local
- * coordinate system of the BoundingLeaf node. A reference to a
- * BoundingLeaf node can be used in place
- * of a locally defined bounds object for any of the aforementioned regions.
- *
- * This allows an application to specify a bounding region in one coordinate system
- * (the local coordinate system of the BoundingLeaf node) other than the local
- * coordinate system of the node that references the bounds. For an example of how
- * this might be used, consider a closed room with a number of track lights. Each
- * light can move independent of the other lights and, as such, needs its own local
- * coordinate system. However, the bounding volume is used by all the lights in the
- * boundary of the room, which doesn't move when the lights move. In this example,
- * the BoundingLeaf node allows the bounding region to be defined in the local
- * coordinate system of the room, rather than in the local coordinate system of a
- * particular light. All lights can then share this single bounding volume.
- */
-public class BoundingLeaf extends Leaf {
- /**
- * Specifies that this BoundingLeaf node allows read access to its
- * bounding region object.
- */
- public static final int
- ALLOW_REGION_READ = CapabilityBits.BOUNDING_LEAF_ALLOW_REGION_READ;
-
- /**
- * Specifies that this BoundingLeaf node allows write access to its
- * bounding region object.
- */
- public static final int
- ALLOW_REGION_WRITE = CapabilityBits.BOUNDING_LEAF_ALLOW_REGION_WRITE;
-
- // Array for setting default read capabilities
- private static final int[] readCapabilities = {
- ALLOW_REGION_READ
- };
-
- /**
- * Constructs a BoundingLeaf node with a null (empty) bounding region.
- */
- public BoundingLeaf() {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((BoundingLeafRetained)this.retained).createBoundingLeaf();
- }
-
- /**
- * Constructs a BoundingLeaf node with the specified bounding region.
- * @param region the bounding region of this leaf node
- */
- public BoundingLeaf(Bounds region) {
- // set default read capabilities
- setDefaultReadCapabilities(readCapabilities);
-
- ((BoundingLeafRetained)this.retained).createBoundingLeaf();
- ((BoundingLeafRetained)this.retained).initRegion(region);
- }
-
- /**
- * Sets this BoundingLeaf node's bounding region.
- * @param region the bounding region of this leaf node
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public void setRegion(Bounds region) {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_REGION_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("BoundingLeaf0"));
-
- if (isLive())
- ((BoundingLeafRetained)this.retained).setRegion(region);
- else
- ((BoundingLeafRetained)this.retained).initRegion(region);
- }
-
- /**
- * Retrieves this BoundingLeaf's bounding region.
- * @return the bounding region of this leaf node
- * @exception CapabilityNotSetException if appropriate capability is
- * not set and this object is part of live or compiled scene graph
- */
- public Bounds getRegion() {
- if (isLiveOrCompiled())
- if(!this.getCapability(ALLOW_REGION_READ))
- throw new CapabilityNotSetException(J3dI18N.getString("BoundingLeaf1"));
-
- return ((BoundingLeafRetained)this.retained).getRegion();
- }
-
- /**
- * Creates the BoundingLeafRetained object that this
- * BoundingLeaf object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new BoundingLeafRetained();
- this.retained.setSource(this);
- }
-
- /**
- * Used to create a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
- BoundingLeaf bl = new BoundingLeaf();
- bl.duplicateNode(this, forceDuplicate);
- return bl;
- }
-
-
-
- /**
- * Copies all BoundingLeaf information from
- * originalNode into
- * the current node. This method is called from the
- * cloneNode method which is, in turn, called by the
- * cloneTree method.
- *
- * @param originalNode the original node to duplicate.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @exception RestrictedAccessException if this object is part of a live
- * or compiled scenegraph.
- *
- * @see Node#duplicateNode
- * @see Node#cloneTree
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- void duplicateAttributes(Node originalNode, boolean forceDuplicate) {
- super.duplicateAttributes(originalNode, forceDuplicate);
-
- ((BoundingLeafRetained) retained).initRegion(
- ((BoundingLeafRetained) originalNode.retained).getRegion());
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/BoundingLeafRetained.java b/src/classes/share/javax/media/j3d/BoundingLeafRetained.java
deleted file mode 100644
index 309922f..0000000
--- a/src/classes/share/javax/media/j3d/BoundingLeafRetained.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-
-/**
- * The BoundingLeaf node defines a bounding region object that can be
- * referenced by other nodes to define a region of influence, an
- * application region, or a scheduling region.
- */
-class BoundingLeafRetained extends LeafRetained {
- // Statics used when something in the boundingleaf changes
- static final int REGION_CHANGED = 0x0001;
- static final Integer REGION_CHANGED_MESSAGE = new Integer(REGION_CHANGED);
-
- // The bounding region object defined by this node
- Bounds region = null;
-
-
- // For the mirror object, this region is the transformed region
- // (the region of the original bounding leaf object transformed
- // by the cache transform)
- Bounds transformedRegion = null;
-
- BoundingLeafRetained mirrorBoundingLeaf;
-
- // A list of Objects that refer, directly or indirectly, to this
- // bounding leaf object
- ArrayList users = new ArrayList();
-
- // Target threads to be notified when light changes
- int targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
- J3dThread.UPDATE_RENDER;
-
-
- // Target threads for tranform change
- int transformTargetThreads =
- J3dThread.UPDATE_RENDERING_ENVIRONMENT | J3dThread.UPDATE_GEOMETRY;
-
- BoundingLeafRetained() {
- this.nodeType = NodeRetained.BOUNDINGLEAF;
- }
-
- void createBoundingLeaf() {
- this.nodeType = NodeRetained.BOUNDINGLEAF;
- mirrorBoundingLeaf = new BoundingLeafRetained();
- }
-
- /**
- * Initialize the bounding region
- */
- void initRegion(Bounds region) {
- if (region != null) {
- this.region = (Bounds) region.clone();
- }
- else {
- this.region = null;
- }
- if (staticTransform != null) {
- this.region.transform(staticTransform.transform);
- }
- }
-
- /**
- * Set the bounding region
- */
- void setRegion(Bounds region) {
- initRegion(region);
- J3dMessage createMessage = new J3dMessage();
- createMessage.threads = mirrorBoundingLeaf.targetThreads;
- createMessage.type = J3dMessage.BOUNDINGLEAF_CHANGED;
- createMessage.universe = universe;
- createMessage.args[0] = this;
- createMessage.args[1]= REGION_CHANGED_MESSAGE;
- if (region != null) {
- createMessage.args[2] = (Bounds)(region.clone());
- } else {
- createMessage.args[2] = null;
- }
- createMessage.args[3] = mirrorBoundingLeaf.users.toArray();
- VirtualUniverse.mc.processMessage(createMessage);
- }
-
-
- /**
- * Get the bounding region
- */
- Bounds getRegion() {
- Bounds b = null;
- if (this.region != null) {
- b = (Bounds) this.region.clone();
- if (staticTransform != null) {
- Transform3D invTransform = staticTransform.getInvTransform();
- b.transform(invTransform);
- }
- }
- return b;
- }
-
-
- @Override
- void setLive(SetLiveState s) {
- super.doSetLive(s);
-
- if (inBackgroundGroup) {
- throw new
- IllegalSceneGraphException(J3dI18N.getString("BoundingLeafRetained0"));
- }
-
- if (inSharedGroup) {
- throw new
- IllegalSharingException(J3dI18N.getString("BoundingLeafRetained1"));
- }
-
-
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(mirrorBoundingLeaf,
- Targets.BLN_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
- mirrorBoundingLeaf.localToVworld = new Transform3D[1][];
- mirrorBoundingLeaf.localToVworldIndex = new int[1][];
- mirrorBoundingLeaf.localToVworld[0] = this.localToVworld[0];
- mirrorBoundingLeaf.localToVworldIndex[0] = this.localToVworldIndex[0];
- mirrorBoundingLeaf.parent = parent;
- if (region != null) {
- mirrorBoundingLeaf.region = (Bounds)region.clone();
- mirrorBoundingLeaf.transformedRegion = (Bounds)region.clone();
- mirrorBoundingLeaf.transformedRegion.transform(
- mirrorBoundingLeaf.getCurrentLocalToVworld());
- } else {
- mirrorBoundingLeaf.region = null;
- mirrorBoundingLeaf.transformedRegion = null;
- }
- // process switch leaf
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(mirrorBoundingLeaf,
- Targets.BLN_TARGETS);
- }
- mirrorBoundingLeaf.switchState = s.switchStates.get(0);
- super.markAsLive();
- }
-
-
- /** Update the "component" field of the mirror object with the
- * given "value"
- */
- synchronized void updateImmediateMirrorObject(Object[] objs) {
-
- int component = ((Integer)objs[1]).intValue();
- Bounds b = ((Bounds)objs[2]);
- Transform3D t;
-
- if ((component & REGION_CHANGED) != 0) {
- mirrorBoundingLeaf.region = b;
- if (b != null) {
- mirrorBoundingLeaf.transformedRegion = (Bounds)b.clone();
- t = mirrorBoundingLeaf.getCurrentLocalToVworld();
- mirrorBoundingLeaf.transformedRegion.transform(b, t);
- }
- else {
- mirrorBoundingLeaf.transformedRegion = null;
- }
-
- }
- }
-
- /**
- * Add a user to the list of users.
- * There is no if (node.source.isLive()) check since
- * mirror objects are the users of the mirror bounding leaf
- * and they do not have a source.
- */
- synchronized void addUser(LeafRetained node) {
- users.add(node);
- if (node.nodeType == NodeRetained.BACKGROUND ||
- node.nodeType == NodeRetained.CLIP ||
- node.nodeType == NodeRetained.ALTERNATEAPPEARANCE ||
- node instanceof FogRetained ||
- node instanceof LightRetained) {
- transformTargetThreads |= J3dThread.UPDATE_RENDER;
- }
- else if (node instanceof BehaviorRetained) {
- transformTargetThreads |= J3dThread.UPDATE_BEHAVIOR;
- targetThreads |= J3dThread.UPDATE_BEHAVIOR;
- }
- else if (node instanceof SoundRetained ||
- node.nodeType == NodeRetained.SOUNDSCAPE) {
- transformTargetThreads |= J3dThread.UPDATE_SOUND;
- }
-
- }
-
- /**
- * Remove user from the list of users.
- * There is no if (node.source.isLive()) check since
- * mirror objects are the users of the mirror bounding leaf
- * and they do not have a source.
- */
- synchronized void removeUser(LeafRetained u) {
- int i;
- users.remove(users.indexOf(u));
- // For now reconstruct the transform target threads from scratch
- transformTargetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT;
- targetThreads = J3dThread.UPDATE_RENDERING_ENVIRONMENT |
- J3dThread.UPDATE_RENDER;
-
- for (i =0; i < users.size(); i++) {
- LeafRetained node = (LeafRetained)users.get(i);
- if (node.nodeType == NodeRetained.BACKGROUND ||
- node.nodeType == NodeRetained.CLIP ||
- node.nodeType == NodeRetained.ALTERNATEAPPEARANCE ||
- node instanceof FogRetained ||
- node instanceof LightRetained) {
- transformTargetThreads |= J3dThread.UPDATE_RENDER;
- }
- else if (node.nodeType == NodeRetained.BEHAVIOR) {
- transformTargetThreads |= J3dThread.UPDATE_BEHAVIOR;
- targetThreads |= J3dThread.UPDATE_BEHAVIOR;
- }
- else if (node instanceof SoundRetained ||
- node.nodeType == NodeRetained.SOUNDSCAPE) {
- transformTargetThreads |= J3dThread.UPDATE_SOUND;
- }
- }
- }
-
-
- // This function is called on the mirror bounding leaf
- void updateImmediateTransformChange() {
- Transform3D t;
- t = getCurrentLocalToVworld();
- if (region != null) {
- transformedRegion.transform(region, t);
- }
- }
-
- @Override
- void clearLive(SetLiveState s) {
- super.clearLive();
- if (s.switchTargets != null &&
- s.switchTargets[0] != null) {
- s.switchTargets[0].addNode(mirrorBoundingLeaf,
- Targets.BLN_TARGETS);
- }
- if (s.transformTargets != null && s.transformTargets[0] != null) {
- s.transformTargets[0].addNode(mirrorBoundingLeaf,
- Targets.BLN_TARGETS);
- s.notifyThreads |= J3dThread.UPDATE_TRANSFORM;
- }
- }
-
- @Override
- void mergeTransform(TransformGroupRetained xform) {
- super.mergeTransform(xform);
- region.transform(xform.transform);
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/BoundingPolytope.java b/src/classes/share/javax/media/j3d/BoundingPolytope.java
deleted file mode 100644
index 37d47c0..0000000
--- a/src/classes/share/javax/media/j3d/BoundingPolytope.java
+++ /dev/null
@@ -1,1783 +0,0 @@
-/*
- * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Point3d;
-import javax.vecmath.Point4d;
-import javax.vecmath.Vector3d;
-import javax.vecmath.Vector4d;
-
-/**
- * A BoundingPolytope defines a polyhedral bounding region using the
- * intersection of four or more half spaces. The region defined by a
- * BoundingPolytope is always convex and must be closed.
- *
- * Each plane in the BoundingPolytope specifies a half-space defined
- * by the equation:
- *
- * Ax + By + Cz + D <= 0
- *
- * where A, B, C, D are the parameters that specify the plane. The
- * parameters are passed in the x, y, z, and w fields, respectively,
- * of a Vector4d object. The intersection of the set of half-spaces
- * corresponding to the planes in this BoundingPolytope defines the
- * bounding region.
- */
-
-public class BoundingPolytope extends Bounds {
-
- /**
- * An array of bounding planes.
- */
- Vector4d[] planes;
- double[] mag; // magnitude of plane vector
- double[] pDotN; // point on plane dotted with normal
- Point3d[] verts; // vertices of polytope
- int nVerts; // number of verts in polytope
- Point3d centroid = new Point3d(); // centroid of polytope
-
- Point3d boxVerts[];
- boolean allocBoxVerts = false;
-
- /**
- * Constructs a BoundingPolytope using the specified planes.
- * @param planes a set of planes defining the polytope.
- * @exception IllegalArgumentException if the length of the
- * specified array of planes is less than 4.
- */
- public BoundingPolytope(Vector4d[] planes) {
- if (planes.length < 4) {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope11"));
- }
-
- boundId = BOUNDING_POLYTOPE;
- int i;
- double invMag;
- this.planes = new Vector4d[planes.length];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
-
- for(i=0;i
- * planes[0] : x <= 1 (1,0,0,-1)
- * planes[1] : -x <= 1 (-1,0,0,-1)
- * planes[2] : y <= 1 (0,1,0,-1)
- * planes[3] : -y <= 1 (0,-1,0,-1)
- * planes[4] : z <= 1 (0,0,1,-1)
- * planes[5] : -z <= 1 (0,0,-1,-1)
- *
- */
- public BoundingPolytope() {
- boundId = BOUNDING_POLYTOPE;
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -1.0 );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, -1.0 );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -1.0 );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, -1.0 );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -1.0 );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, -1.0 );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
-
- computeAllVerts(); // XXXX: lazy evaluate
- }
-
-
- /**
- * Constructs a BoundingPolytope from the specified bounds object.
- * The new polytope will circumscribe the region specified by the
- * input bounds.
- * @param boundsObject the bounds object from which this polytope
- * is constructed.
- */
- public BoundingPolytope(Bounds boundsObject ) {
- int i;
-
- boundId = BOUNDING_POLYTOPE;
-
- if( boundsObject == null ) {
- boundsIsEmpty = true;
- boundsIsInfinite = false;
- initEmptyPolytope();
- computeAllVerts(); // XXXX: lazy evaluate
- return;
- }
-
- boundsIsEmpty = boundsObject.boundsIsEmpty;
- boundsIsInfinite = boundsObject.boundsIsInfinite;
-
- if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -(sphere.center.x+sphere.radius) );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, sphere.center.x-sphere.radius );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -(sphere.center.y+sphere.radius) );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, sphere.center.y-sphere.radius );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -(sphere.center.z+sphere.radius) );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, sphere.center.z-sphere.radius );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
- computeAllVerts(); // XXXX: lazy evaluate
-
- } else if( boundsObject.boundId == BOUNDING_BOX ){
- BoundingBox box = (BoundingBox)boundsObject;
- planes = new Vector4d[6];
- pDotN = new double[planes.length];
- mag = new double[planes.length];
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -box.upper.x );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, box.lower.x );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -box.upper.y );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, box.lower.y );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -box.upper.z );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, box.lower.z );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
- computeAllVerts(); // XXXX: lazy evaluate
-
- } else if( boundsObject.boundId == BOUNDING_POLYTOPE ) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- planes = new Vector4d[polytope.planes.length];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
- nVerts = polytope.nVerts;
- verts = new Point3d[nVerts];
- for(i=0;i= boundsObjects.length ) { // all bounds objects were empty
- boundsIsEmpty = true;
- boundsIsInfinite = false;
- initEmptyPolytope();
- computeAllVerts(); // XXXX: lazy evaluate
- return;
- }
-
- boundsIsEmpty = boundsObjects[i].boundsIsEmpty;
- boundsIsInfinite = boundsObjects[i].boundsIsInfinite;
-
- if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObjects[i];
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -(sphere.center.x+sphere.radius) );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, sphere.center.x-sphere.radius );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -(sphere.center.y+sphere.radius) );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, sphere.center.y-sphere.radius );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -(sphere.center.z+sphere.radius) );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, sphere.center.z-sphere.radius );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
-
- computeAllVerts(); // XXXX: lazy evaluate
- } else if( boundsObjects[i].boundId == BOUNDING_BOX ){
- BoundingBox box = (BoundingBox)boundsObjects[i];
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -box.upper.x );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, box.lower.x );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -box.upper.y );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, box.lower.y );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -box.upper.z );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, box.lower.z );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
-
- computeAllVerts(); // XXXX: lazy evaluate
- } else if( boundsObjects[i].boundId == BOUNDING_POLYTOPE ) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- planes = new Vector4d[polytope.planes.length];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
- nVerts = polytope.nVerts;
- verts = new Point3d[nVerts];
- for(i=0;i 0.0) planes[i].w = -newD;
- if( (newD = ux + ly + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
- if( (newD = ux + ly + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
-
- if( (newD = lx + uy + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
- if( (newD = lx + uy + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
- if( (newD = lx + ly + uz ) + planes[i].w > 0.0) planes[i].w = -newD;
- if( (newD = lx + ly + lz ) + planes[i].w > 0.0) planes[i].w = -newD;
- }
-
- boundsIsEmpty = boundsObject.boundsIsEmpty;
- boundsIsInfinite = boundsObject.boundsIsInfinite;
- computeAllVerts(); // XXXX: lazy evaluate
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- if( planes.length != polytope.planes.length) {
- planes = new Vector4d[polytope.planes.length];
- for(k=0;kbounds object is
- * equal to this BoundingPolytope object. They are equal if the
- * specified bounds object is an instance of
- * BoundingPolytope and all of the data
- * members of bounds are equal to the corresponding
- * data members in this BoundingPolytope.
- * @param bounds the object with which the comparison is made.
- * @return true if this BoundingPolytope is equal to bounds;
- * otherwise false
- *
- * @since Java 3D 1.2
- */
- @Override
- public boolean equals(Object bounds) {
- try {
- BoundingPolytope polytope = (BoundingPolytope)bounds;
- if (planes.length != polytope.planes.length)
- return false;
- for (int i = 0; i < planes.length; i++)
- if (!planes[i].equals(polytope.planes[i]))
- return false;
-
- return true;
- }
- catch (NullPointerException e) {
- return false;
- }
- catch (ClassCastException e) {
- return false;
- }
- }
-
-
- /**
- * Returns a hash code value for this BoundingPolytope object
- * based on the data values in this object. Two different
- * BoundingPolytope objects with identical data values (i.e.,
- * BoundingPolytope.equals returns true) will return the same hash
- * code value. Two BoundingPolytope objects with different data
- * members may return the same hash code value, although this is
- * not likely.
- * @return a hash code value for this BoundingPolytope object.
- *
- * @since Java 3D 1.2
- */
- @Override
- public int hashCode() {
- long bits = 1L;
-
- for (int i = 0; i < planes.length; i++) {
- bits = J3dHash.mixDoubleBits(bits, planes[i].x);
- bits = J3dHash.mixDoubleBits(bits, planes[i].y);
- bits = J3dHash.mixDoubleBits(bits, planes[i].z);
- bits = J3dHash.mixDoubleBits(bits, planes[i].w);
- }
-
- return J3dHash.finish(bits);
- }
-
-
- /**
- * Combines this bounding polytope with a bounding object so that the
- * resulting bounding polytope encloses the original bounding polytope and the
- * given bounds object.
- * @param boundsObject another bounds object
- */
- @Override
- public void combine(Bounds boundsObject) {
- BoundingSphere sphere;
-
- if((boundsObject == null) || (boundsObject.boundsIsEmpty)
- || (boundsIsInfinite))
- return;
-
-
- if((boundsIsEmpty) || (boundsObject.boundsIsInfinite)) {
- this.set(boundsObject);
- return;
- }
-
- boundsIsEmpty = boundsObject.boundsIsEmpty;
- boundsIsInfinite = boundsObject.boundsIsInfinite;
-
- if( boundsObject.boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObject;
- int i;
- double dis;
- for(i = 0; i < planes.length; i++){
- dis = sphere.radius+ sphere.center.x*planes[i].x +
- sphere.center.y*planes[i].y + sphere.center.z *
- planes[i].z + planes[i].w;
- if( dis > 0.0 ) {
- planes[i].w += -dis;
- }
- }
- } else if( boundsObject instanceof BoundingBox){
- BoundingBox b = (BoundingBox)boundsObject;
- if( !allocBoxVerts){
- boxVerts = new Point3d[8];
- for(int j=0;j<8;j++)boxVerts[j] = new Point3d();
- allocBoxVerts = true;
- }
- boxVerts[0].set(b.lower.x, b.lower.y, b.lower.z );
- boxVerts[1].set(b.lower.x, b.upper.y, b.lower.z );
- boxVerts[2].set(b.upper.x, b.lower.y, b.lower.z );
- boxVerts[3].set(b.upper.x, b.upper.y, b.lower.z );
- boxVerts[4].set(b.lower.x, b.lower.y, b.upper.z );
- boxVerts[5].set(b.lower.x, b.upper.y, b.upper.z );
- boxVerts[6].set(b.upper.x, b.lower.y, b.upper.z );
- boxVerts[7].set(b.upper.x, b.upper.y, b.upper.z );
- this.combine(boxVerts);
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- this.combine(polytope.verts);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope3"));
- }
-
- computeAllVerts();
- }
-
- /**
- * Combines this bounding polytope with an array of bounding objects so that the
- * resulting bounding polytope encloses the original bounding polytope and the
- * given array of bounds object.
- * @param boundsObjects an array of bounds objects
- */
- @Override
- public void combine(Bounds[] boundsObjects) {
- int i=0;
- double dis;
-
- if( (boundsObjects == null) || (boundsObjects.length <= 0)
- || (boundsIsInfinite))
- return;
-
- // find first non empty bounds object
- while( (i= boundsObjects.length)
- return; // no non empty bounds so do not modify current bounds
-
- if(boundsIsEmpty)
- this.set(boundsObjects[i++]);
-
- if(boundsIsInfinite)
- return;
-
- for(;i 0.0 ) {
- planes[j].w += -dis;
- }
- }
- } else if( boundsObjects[i].boundId == BOUNDING_BOX){
- BoundingBox b = (BoundingBox)boundsObjects[i];
- if( !allocBoxVerts){
- boxVerts = new Point3d[8];
- for(int j=0;j<8;j++)boxVerts[j] = new Point3d();
- allocBoxVerts = true;
- }
- boxVerts[0].set(b.lower.x, b.lower.y, b.lower.z );
- boxVerts[1].set(b.lower.x, b.upper.y, b.lower.z );
- boxVerts[2].set(b.upper.x, b.lower.y, b.lower.z );
- boxVerts[3].set(b.upper.x, b.upper.y, b.lower.z );
- boxVerts[4].set(b.lower.x, b.lower.y, b.upper.z );
- boxVerts[5].set(b.lower.x, b.upper.y, b.upper.z );
- boxVerts[6].set(b.upper.x, b.lower.y, b.upper.z );
- boxVerts[7].set(b.upper.x, b.upper.y, b.upper.z );
- this.combine(boxVerts);
-
- } else if(boundsObjects[i] instanceof BoundingPolytope) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- this.combine(polytope.verts);
-
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope4"));
- }
-
- computeAllVerts();
- }
- }
-
- /**
- * Combines this bounding polytope with a point.
- * @param point a 3d point in space
- */
- @Override
- public void combine(Point3d point) {
- int i;
- double dis;
-
- if(boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty ){
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
- nVerts = 1;
- verts = new Point3d[nVerts];
- verts[0] = new Point3d( point.x, point.y, point.z);
-
- for(i=0;i 0.0 ) {
- planes[i].w += -dis;
- }
- }
- computeAllVerts();
- }
- }
-
- /**
- * Combines this bounding polytope with an array of points.
- * @param points an array of 3d points in space
- */
- @Override
- public void combine(Point3d[] points) {
- int i,j;
- double dis;
-
- if( boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty ){
- planes = new Vector4d[6];
- mag = new double[planes.length];
- pDotN = new double[planes.length];
- nVerts = points.length;
- verts = new Point3d[nVerts];
- verts[0] = new Point3d( points[0].x, points[0].y, points[0].z);
-
- for(i=0;i 0.0 ) {
- planes[i].w += -dis;
- }
- }
- }
-
- computeAllVerts();
- }
-
- /**
- * Modifies the bounding polytope so that it bounds the volume
- * generated by transforming the given bounding object.
- * @param boundsObject the bounding object to be transformed
- * @param matrix a transformation matrix
- */
- @Override
- public void transform( Bounds boundsObject, Transform3D matrix) {
-
- if( boundsObject == null || boundsObject.boundsIsEmpty) {
- boundsIsEmpty = true;
- boundsIsInfinite = false;
- computeAllVerts();
- return;
- }
-
- if(boundsObject.boundsIsInfinite) {
- this.set(boundsObject);
- return;
- }
-
- if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = new BoundingSphere(boundsObject);
- sphere.transform(matrix);
- this.set(sphere);
- } else if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = new BoundingBox(boundsObject);
- box.transform(matrix);
- this.set(box);
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = new BoundingPolytope(boundsObject);
- polytope.transform(matrix);
- this.set(polytope);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope5"));
- }
- }
-
- /**
- * Transforms this bounding polytope by the given transformation matrix.
- * @param matrix a transformation matrix
- */
- @Override
- public void transform( Transform3D matrix) {
-
- if(boundsIsInfinite)
- return;
-
- int i;
- double invMag;
- Transform3D invTrans = new Transform3D(matrix);
-
- invTrans.invert();
- invTrans.transpose();
-
- for(i = 0; i < planes.length; i++){
- planes[i].x = planes[i].x * mag[i];
- planes[i].y = planes[i].y * mag[i];
- planes[i].z = planes[i].z * mag[i];
- planes[i].w = planes[i].w * mag[i];
- invTrans.transform( planes[i] );
- }
-
- for(i=0;i= 0.0) { // plane is behind origin
-
- x = origin.x + dx*t; // compute intersection point
- y = origin.y + dy*t;
- z = origin.z + dz*t;
-
- if( pointInPolytope(x,y,z) ) {
- intersectPoint.x = x;
- intersectPoint.y = y;
- intersectPoint.z = z;
- return true; // ray intersects a face of polytope
- }
- }
- }
- }
-
- return false;
- }
-
- /**
- * Test for intersection with a ray
- * @param origin is a the starting point of the ray
- * @param direction is the direction of the ray
- * @param position is a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Point3d origin, Vector3d direction, Point4d position ) {
- double t,v0,vd,x,y,z,invMag;
- double dx, dy, dz;
- int i;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = origin.x;
- position.y = origin.y;
- position.z = origin.z;
- position.w = 0.0;
- return true;
- }
-
- invMag = 1.0/Math.sqrt(direction.x*direction.x + direction.y*
- direction.y + direction.z*direction.z);
- dx = direction.x*invMag;
- dy = direction.y*invMag;
- dz = direction.z*invMag;
-
- for(i=0;i 0.0 )
- return false;
-
- }
- return true;
-
- }
-
- /**
- * Test for intersection with a segment
- * @param start is a point defining the start of the line segment
- * @param end is a point defining the end of the line segment
- * @param position is a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect( Point3d start, Point3d end, Point4d position ) {
- double t,v0,vd,x,y,z;
- int i;
-
- //System.err.println("line segment intersect : planes.length " + planes.length);
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = start.x;
- position.y = start.y;
- position.z = start.z;
- position.w = 0.0;
- return true;
- }
-
- Point3d direction = new Point3d();
-
- direction.x = end.x - start.x;
- direction.y = end.y - start.y;
- direction.z = end.z - start.z;
-
- for(i=0;i= 0.0) { // plane is behind start
-
- x = start.x + direction.x*t; // compute intersection point
- y = start.y + direction.y*t;
- z = start.z + direction.z*t;
- // System.err.println("t="+t+" point="+x+" "+y+" "+z);
-
- if( pointInPolytope(x,y,z) ) {
- // if((t*t) > (end.x-start.x)*(end.x-start.x) +
- // (end.y-start.y)*(end.y-start.y) +
- // (end.z-start.z)*(end.z-start.z)) {
- if(t <= 1.0) {
- position.x = x;
- position.y = y;
- position.z = z;
- position.w = t;
- return true; // ray intersects a face of polytope
- }
- }
- }
- }
- }
-
- return false;
-
- }
-
- /**
- * Test for intersection with a ray.
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d origin, Vector3d direction ) {
-
- // compute intersection point of ray and each plane then test if point is in polytope
-
- double t,v0,vd,x,y,z;
- int i;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- return true;
- }
-
- for(i=0;i= 0.0) { // plane is behind origin
-
- x = origin.x + direction.x*t; // compute intersection point
- y = origin.y + direction.y*t;
- z = origin.z + direction.z*t;
-
- if( pointInPolytope(x,y,z) ) {
- return true; // ray intersects a face of polytope
- } else {
- // System.err.println("point outside polytope");
- }
- }
- }
- }
-
- return false;
-
- }
-
- /**
- * Tests whether the bounding polytope is empty. A bounding polytope is
- * empty if it is null (either by construction or as the result of
- * a null intersection) or if its volume is negative. A bounding polytope
- * with a volume of zero is not empty.
- * @return true if the bounding polytope is empty;
- * otherwise, it returns false
- */
- @Override
- public boolean isEmpty() {
- // if nVerts > 0 after computeAllVerts(), that means
- // there is some intersection between 3 planes.
- return (boundsIsEmpty || (nVerts <= 0));
- }
-
- /**
- * Test for intersection with a point.
- * @param point a Point defining a position in 3-space
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d point ) {
-
- int i;
- if( boundsIsEmpty ) {
- return false;
- }
- if( boundsIsInfinite ) {
- return true;
- }
-
- for(i = 0; i < this.planes.length; i++){
- if(( point.x*this.planes[i].x +
- point.y*this.planes[i].y +
- point.z*this.planes[i].z + planes[i].w ) > 0.0 )
- return false;
-
- }
- return true;
- }
-
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Bounds boundsObject, Point4d position) {
- return intersect(boundsObject);
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds boundsObject) {
-
- if( boundsObject == null ) {
- return false;
- }
-
- if( boundsIsEmpty || boundsObject.boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite || boundsObject.boundsIsInfinite ) {
- return true;
- }
-
- if( boundsObject.boundId == BOUNDING_SPHERE ) {
- return intersect_ptope_sphere( this, (BoundingSphere)boundsObject);
- } else if( boundsObject.boundId == BOUNDING_BOX){
- return intersect_ptope_abox( this, (BoundingBox)boundsObject);
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- return intersect_ptope_ptope( this, (BoundingPolytope)boundsObject);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope6"));
- }
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObjects an array of bounding objects
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds[] boundsObjects) {
-
- double distsq, radsq;
- BoundingSphere sphere;
- int i;
- if( boundsObjects == null || boundsObjects.length <= 0 ) {
- return false;
- }
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- for(i = 0; i < boundsObjects.length; i++){
- if( boundsObjects[i] == null || boundsObjects[i].boundsIsEmpty) ;
- else if( boundsIsInfinite || boundsObjects[i].boundsIsInfinite ) {
- return true; // We're done here.
- }
- if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObjects[i];
- radsq = sphere.radius;
- radsq *= radsq;
- distsq = sphere.center.distanceSquared(sphere.center);
- if (distsq < radsq) {
- return true;
- }
- } else if(boundsObjects[i].boundId == BOUNDING_BOX){
- if( this.intersect(boundsObjects[i])) return true;
- } else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- if( this.intersect(boundsObjects[i])) return true;
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingPolytope7"));
- }
- }
-
- return false;
- }
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @param newBoundPolytope the new bounding polytope, which is the intersection of
- * the boundsObject and this BoundingPolytope
- * @return true or false indicating if an intersection occured
- */
- public boolean intersect(Bounds boundsObject, BoundingPolytope newBoundPolytope) {
- int i;
-
- if((boundsObject == null) || boundsIsEmpty || boundsObject.boundsIsEmpty ) {
- newBoundPolytope.boundsIsEmpty = true;
- newBoundPolytope.boundsIsInfinite = false;
- newBoundPolytope.computeAllVerts();
- return false;
- }
- if(boundsIsInfinite && (!boundsObject.boundsIsInfinite)) {
- newBoundPolytope.set(boundsObject);
- return true;
- }
- else if((!boundsIsInfinite) && boundsObject.boundsIsInfinite) {
- newBoundPolytope.set(this);
- return true;
- }
- else if(boundsIsInfinite && boundsObject.boundsIsInfinite) {
- newBoundPolytope.set(this);
- return true;
- }
-
-
- BoundingBox tbox = new BoundingBox(); // convert sphere to box
-
- if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- if( this.intersect( sphere)) {
- BoundingBox sbox = new BoundingBox( sphere ); // convert sphere to box
- BoundingBox pbox = new BoundingBox( this ); // convert polytope to box
- pbox.intersect(sbox, tbox); // insersect two boxes
- newBoundPolytope.set( tbox );
- return true;
- }
- } else if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
- if( this.intersect( box)) {
- BoundingBox pbox = new BoundingBox( this ); // convert polytope to box
- pbox.intersect(box, tbox); // insersect two boxes
- newBoundPolytope.set( tbox );
- return true;
- }
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- if( this.intersect( polytope)) {
- Vector4d newPlanes[] = new Vector4d[planes.length + polytope.planes.length];
- for(i=0;i= boundsObjects.length ) { // all bounds objects were empty
- newBoundingPolytope.boundsIsEmpty = true;
- newBoundingPolytope.boundsIsInfinite = false;
- newBoundingPolytope.computeAllVerts();
- return false;
- }
-
- boolean status = false;
- BoundingBox tbox = new BoundingBox(); // convert sphere to box
-
- for(i=0;i 0.0 ) { // check if sphere center in polytope
- disToPlane = sphere.center.x*planes[j].x +
- sphere.center.y*planes[j].y +
- sphere.center.z*planes[j].z + planes[j].w;
-
- // check if distance from center to plane is larger than radius
- if( disToPlane > sphere.radius ) inside = false;
- }
- }
- if( inside) { // contains the sphere
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if( boundsObjects[i] instanceof BoundingBox){
- BoundingBox box = (BoundingBox)boundsObjects[i];
- cenX = (box.upper.x+box.lower.x)/2.0;
- cenY = (box.upper.y+box.lower.y)/2.0;
- cenZ = (box.upper.z+box.lower.z)/2.0;
- dis = Math.sqrt( (centroid.x-cenX)*(centroid.x-cenX) +
- (centroid.y-cenY)*(centroid.y-cenY) +
- (centroid.z-cenZ)*(centroid.z-cenZ) );
- inside = true;
- if( !pointInPolytope( box.upper.x, box.upper.y, box.upper.z ) ) inside = false;
- if( !pointInPolytope( box.upper.x, box.upper.y, box.lower.z ) ) inside = false;
- if( !pointInPolytope( box.upper.x, box.lower.y, box.upper.z ) ) inside = false;
- if( !pointInPolytope( box.upper.x, box.lower.y, box.lower.z ) ) inside = false;
- if( !pointInPolytope( box.lower.x, box.upper.y, box.upper.z ) ) inside = false;
- if( !pointInPolytope( box.lower.x, box.upper.y, box.lower.z ) ) inside = false;
- if( !pointInPolytope( box.lower.x, box.lower.y, box.upper.z ) ) inside = false;
- if( !pointInPolytope( box.lower.x, box.lower.y, box.lower.z ) ) inside = false;
-
- if( inside ) { // contains box
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
-
- } else if(boundsObjects[i] instanceof BoundingPolytope) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- dis = Math.sqrt( (centroid.x-polytope.centroid.x)*(centroid.x-polytope.centroid.x) +
- (centroid.y-polytope.centroid.y)*(centroid.y-polytope.centroid.y) +
- (centroid.z-polytope.centroid.z)*(centroid.z-polytope.centroid.z) );
- inside = true;
- for(j=0;j= verts.length) {
- Point3d newVerts[] = new Point3d[nVerts << 1];
- for(int i=0;i EPSILON ) {
- return false;
- }
-
- }
- return true;
- }
-
- private void checkBoundsIsEmpty() {
- boundsIsEmpty = (planes.length < 4);
- }
-
- private void initEmptyPolytope() {
- planes = new Vector4d[6];
- pDotN = new double[6];
- mag = new double[6];
- verts = new Point3d[planes.length*planes.length];
- nVerts = 0;
-
- planes[0] = new Vector4d( 1.0, 0.0, 0.0, -1.0 );
- planes[1] = new Vector4d(-1.0, 0.0, 0.0, -1.0 );
- planes[2] = new Vector4d( 0.0, 1.0, 0.0, -1.0 );
- planes[3] = new Vector4d( 0.0,-1.0, 0.0, -1.0 );
- planes[4] = new Vector4d( 0.0, 0.0, 1.0, -1.0 );
- planes[5] = new Vector4d( 0.0, 0.0,-1.0, -1.0 );
- mag[0] = 1.0;
- mag[1] = 1.0;
- mag[2] = 1.0;
- mag[3] = 1.0;
- mag[4] = 1.0;
- mag[5] = 1.0;
-
- checkBoundsIsEmpty();
- }
-
- @Override
- Point3d getCenter() {
- return centroid;
- }
-
-@Override
-public void getCenter(Point3d center) {
- center.set(centroid);
-}
-
- /**
- * if the passed the "region" is same type as this object
- * then do a copy, otherwise clone the Bounds and
- * return
- */
- @Override
- Bounds copy(Bounds r) {
- int i, k;
-
- if (r != null && this.boundId == r.boundId) {
- BoundingPolytope region = (BoundingPolytope) r;
- if( region.planes.length !=planes.length) {
- region.planes = new Vector4d[planes.length];
-
- for(k=0;k< region.planes.length;k++)
- region.planes[k] = new Vector4d();
-
- region.mag = new double[planes.length];
- region.pDotN = new double[planes.length];
- region.verts = new Point3d[nVerts];
- region.nVerts = nVerts;
- for(k=0;k rad_sq) {
- dis = Math.sqrt( dis_sq);
- radius = (radius + dis)*.5;
- oldc_to_new_c = dis - radius;
- t = oldc_to_new_c/dis;
- center.x = center.x + (polytope.verts[i].x - center.x)*t;
- center.y = center.y + (polytope.verts[i].y - center.y)*t;
- center.z = center.z + (polytope.verts[i].z - center.z)*t;
- }
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere0"));
- }
-
- updateBoundsStates();
- }
-
-/**
- * Constructs and initializes a BoundingSphere from an array of bounding
- * objects.
- * @param boundsObjects an array of bounds objects
- */
-public BoundingSphere(Bounds[] boundsObjects) {
- boundId = BOUNDING_SPHERE;
- center = new Point3d();
-
- if (boundsObjects == null || boundsObjects.length <= 0) {
- setEmptyBounds();
- return;
- }
-
- // find first non empty bounds object
- int i = 0;
- while( boundsObjects[i] == null && i < boundsObjects.length) {
- i++;
- }
-
- if (i >= boundsObjects.length) { // all bounds objects were empty
- setEmptyBounds();
- return;
- }
-
- this.set(boundsObjects[i++]);
- if(boundsIsInfinite)
- return;
-
- Point3d[] boxVerts = null;
- for(;i sphere.radius) {
- if( (dis+sphere.radius) > radius) {
- d1 = .5*(radius-sphere.radius+dis);
- t = d1/dis;
- radius = d1+sphere.radius;
- center.x = sphere.center.x + (center.x-sphere.center.x)*t;
- center.y = sphere.center.y + (center.y-sphere.center.y)*t;
- center.z = sphere.center.z + (center.z-sphere.center.z)*t;
- }
- }else {
- if( (dis+radius) <= sphere.radius) {
- center.x = sphere.center.x;
- center.y = sphere.center.y;
- center.z = sphere.center.z;
- radius = sphere.radius;
- }else {
- d1 = .5*(sphere.radius-radius+dis);
- t = d1/dis;
- radius = d1+radius;
- center.x = center.x + (sphere.center.x-center.x)*t;
- center.y = center.y + (sphere.center.y-center.y)*t;
- center.z = center.z + (sphere.center.z-center.z)*t;
- }
- }
- }
- else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- this.combine(polytope.verts);
-
- }
- else {
- if( boundsObjects[i] != null )
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere0"));
- }
- }
- updateBoundsStates();
- }
-
- /**
- * Returns the radius of this bounding sphere as a double.
- * @return the radius of the bounding sphere
- */
- public double getRadius() {
- return radius;
- }
-
- /**
- * Sets the radius of this bounding sphere from a double.
- * @param r the new radius for the bounding sphere
- */
- public void setRadius(double r) {
- radius = r;
- updateBoundsStates();
- }
-
-/**
- * Returns the position of this bounding sphere as a point.
- * @param center a Point to receive the center of the bounding sphere
- */
-@Override
-public void getCenter(Point3d center) {
- center.set(this.center);
-}
-
-/**
- * Sets the position of this bounding sphere from a point.
- * @param center a Point defining the new center of the bounding sphere
- */
-public void setCenter(Point3d center) {
- this.center.set(center);
- updateBoundsStates();
-}
-
- /**
- * Sets the value of this BoundingSphere.
- * @param boundsObject another bounds object
- */
- @Override
- public void set(Bounds boundsObject){
- int i;
-
- if (boundsObject == null || boundsObject.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if( boundsObject.boundsIsInfinite ) {
- setInfiniteBounds();
- return;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
- center.x = (box.upper.x + box.lower.x )/2.0;
- center.y = (box.upper.y + box.lower.y )/2.0;
- center.z = (box.upper.z + box.lower.z )/2.0;
- radius = 0.5*Math.sqrt((box.upper.x-box.lower.x)*
- (box.upper.x-box.lower.x)+
- (box.upper.y-box.lower.y)*
- (box.upper.y-box.lower.y)+
- (box.upper.z-box.lower.z)*
- (box.upper.z-box.lower.z));
- } else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- radius = sphere.radius;
- center.x = sphere.center.x;
- center.y = sphere.center.y;
- center.z = sphere.center.z;
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- double t,dis,dis_sq,rad_sq,oldc_to_new_c;
- center.x = polytope.centroid.x;
- center.y = polytope.centroid.y;
- center.z = polytope.centroid.z;
- radius = Math.sqrt((polytope.verts[0].x - center.x)*
- (polytope.verts[0].x - center.x) +
- (polytope.verts[0].y - center.y)*
- (polytope.verts[0].y - center.y) +
- (polytope.verts[0].z - center.z)*
- (polytope.verts[0].z - center.z));
-
- for(i=1;i rad_sq) { // point is outside sphere
- dis = Math.sqrt( dis_sq);
- radius = (radius + dis)*.5;
- oldc_to_new_c = dis - radius;
- t = oldc_to_new_c/dis;
- center.x = center.x + (polytope.verts[i].x - center.x)*t;
- center.y = center.y + (polytope.verts[i].y - center.y)*t;
- center.z = center.z + (polytope.verts[i].z - center.z)*t;
- }
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere2"));
- }
- updateBoundsStates();
- }
-
- /**
- * Creates a copy of the bounding sphere.
- * @return a BoundingSphere
- */
- @Override
- public Object clone() {
- return new BoundingSphere(this.center, this.radius);
- }
-
-
- /**
- * Indicates whether the specified bounds object is
- * equal to this BoundingSphere object. They are equal if the
- * specified bounds object is an instance of
- * BoundingSphere and all of the data
- * members of bounds are equal to the corresponding
- * data members in this BoundingSphere.
- * @param bounds the object with which the comparison is made.
- * @return true if this BoundingSphere is equal to bounds;
- * otherwise false
- *
- * @since Java 3D 1.2
- */
- @Override
- public boolean equals(Object bounds) {
- try {
- BoundingSphere sphere = (BoundingSphere)bounds;
- return (center.equals(sphere.center) &&
- radius == sphere.radius);
- }
- catch (NullPointerException e) {
- return false;
- }
- catch (ClassCastException e) {
- return false;
- }
- }
-
-
- /**
- * Returns a hash code value for this BoundingSphere object
- * based on the data values in this object. Two different
- * BoundingSphere objects with identical data values (i.e.,
- * BoundingSphere.equals returns true) will return the same hash
- * code value. Two BoundingSphere objects with different data
- * members may return the same hash code value, although this is
- * not likely.
- * @return a hash code value for this BoundingSphere object.
- *
- * @since Java 3D 1.2
- */
- @Override
- public int hashCode() {
- long bits = 1L;
- bits = J3dHash.mixDoubleBits(bits, radius);
- bits = J3dHash.mixDoubleBits(bits, center.x);
- bits = J3dHash.mixDoubleBits(bits, center.y);
- bits = J3dHash.mixDoubleBits(bits, center.z);
- return J3dHash.finish(bits);
- }
-
-
- /**
- * Combines this bounding sphere with a bounding object so that the
- * resulting bounding sphere encloses the original bounding sphere and the
- * given bounds object.
- * @param boundsObject another bounds object
- */
- @Override
- public void combine(Bounds boundsObject) {
- double t,dis,d1,u,l,x,y,z,oldc_to_new_c;
- BoundingSphere sphere;
-
- if((boundsObject == null) || (boundsObject.boundsIsEmpty)
- || (boundsIsInfinite))
- return;
-
- if((boundsIsEmpty) || (boundsObject.boundsIsInfinite)) {
- this.set(boundsObject);
- return;
- }
-
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox b = (BoundingBox)boundsObject;
-
- // start with point furthest from sphere
- u = b.upper.x-center.x;
- l = b.lower.x-center.x;
- if( u*u > l*l)
- x = b.upper.x;
- else
- x = b.lower.x;
-
- u = b.upper.y-center.y;
- l = b.lower.y-center.y;
- if( u*u > l*l)
- y = b.upper.y;
- else
- y = b.lower.y;
-
- u = b.upper.z-center.z;
- l = b.lower.z-center.z;
- if( u*u > l*l)
- z = b.upper.z;
- else
- z = b.lower.z;
-
- dis = Math.sqrt( (x - center.x)*(x - center.x) +
- (y - center.y)*(y - center.y) +
- (z - center.z)*(z - center.z) );
-
- if( dis > radius) {
- radius = (dis + radius)*.5;
- oldc_to_new_c = dis - radius;
- center.x = (radius*center.x + oldc_to_new_c*x)/dis;
- center.y = (radius*center.y + oldc_to_new_c*y)/dis;
- center.z = (radius*center.z + oldc_to_new_c*z)/dis;
- combinePoint( b.upper.x, b.upper.y, b.upper.z);
- combinePoint( b.upper.x, b.upper.y, b.lower.z);
- combinePoint( b.upper.x, b.lower.y, b.upper.z);
- combinePoint( b.upper.x, b.lower.y, b.lower.z);
- combinePoint( b.lower.x, b.upper.y, b.upper.z);
- combinePoint( b.lower.x, b.upper.y, b.lower.z);
- combinePoint( b.lower.x, b.lower.y, b.upper.z);
- combinePoint( b.lower.x, b.lower.y, b.lower.z);
- }
- } else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObject;
- dis = Math.sqrt( (center.x - sphere.center.x)*
- (center.x - sphere.center.x) +
- (center.y - sphere.center.y)*
- (center.y - sphere.center.y) +
- (center.z - sphere.center.z)*
- (center.z - sphere.center.z) );
- if( radius > sphere.radius) {
- if( (dis+sphere.radius) > radius) {
- d1 = .5*(radius-sphere.radius+dis);
- t = d1/dis;
- radius = d1+sphere.radius;
- center.x = sphere.center.x + (center.x-sphere.center.x)*t;
- center.y = sphere.center.y + (center.y-sphere.center.y)*t;
- center.z = sphere.center.z + (center.z-sphere.center.z)*t;
- }
- }else {
- if( (dis+radius) <= sphere.radius) {
- center.x = sphere.center.x;
- center.y = sphere.center.y;
- center.z = sphere.center.z;
- radius = sphere.radius;
- }else {
- d1 = .5*(sphere.radius-radius+dis);
- t = d1/dis;
- radius = d1+radius;
- center.x = center.x + (sphere.center.x-center.x)*t;
- center.y = center.y + (sphere.center.y-center.y)*t;
- center.z = center.z + (sphere.center.z-center.z)*t;
- }
- }
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- this.combine(polytope.verts);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere3"));
- }
- updateBoundsStates();
- }
-
- private void combinePoint( double x, double y, double z) {
- double dis,oldc_to_new_c;
- dis = Math.sqrt( (x - center.x)*(x - center.x) +
- (y - center.y)*(y - center.y) +
- (z - center.z)*(z - center.z) );
-
- if( dis > radius) {
- radius = (dis + radius)*.5;
- oldc_to_new_c = dis - radius;
- center.x = (radius*center.x + oldc_to_new_c*x)/dis;
- center.y = (radius*center.y + oldc_to_new_c*y)/dis;
- center.z = (radius*center.z + oldc_to_new_c*z)/dis;
- }
- }
-
- /**
- * Combines this bounding sphere with an array of bounding objects so that the
- * resulting bounding sphere encloses the original bounding sphere and the
- * given array of bounds object.
- * @param boundsObjects an array of bounds objects
- */
- @Override
- public void combine(Bounds[] boundsObjects) {
- BoundingSphere sphere;
- BoundingBox b;
- BoundingPolytope polytope;
- double t,dis,d1,u,l,x,y,z,oldc_to_new_c;
- int i=0;
-
-
- if((boundsObjects == null) || (boundsObjects.length <= 0)
- || (boundsIsInfinite))
- return;
-
- // find first non empty bounds object
- while((i= boundsObjects.length)
- return; // no non empty bounds so do not modify current bounds
-
- if( boundsIsEmpty)
- this.set(boundsObjects[i++]);
-
- if(boundsIsInfinite)
- return;
-
- for(;i l*l)
- x = b.upper.x;
- else
- x = b.lower.x;
-
- u = b.upper.y-center.y;
- l = b.lower.y-center.y;
- if( u*u > l*l)
- y = b.upper.y;
- else
- y = b.lower.y;
-
- u = b.upper.z-center.z;
- l = b.lower.z-center.z;
- if( u*u > l*l)
- z = b.upper.z;
- else
- z = b.lower.z;
-
- dis = Math.sqrt( (x - center.x)*(x - center.x) +
- (y - center.y)*(y - center.y) +
- (z - center.z)*(z - center.z) );
-
- if( dis > radius) {
- radius = (dis + radius)*.5;
- oldc_to_new_c = dis - radius;
- center.x = (radius*center.x + oldc_to_new_c*x)/dis;
- center.y = (radius*center.y + oldc_to_new_c*y)/dis;
- center.z = (radius*center.z + oldc_to_new_c*z)/dis;
- combinePoint( b.upper.x, b.upper.y, b.upper.z);
- combinePoint( b.upper.x, b.upper.y, b.lower.z);
- combinePoint( b.upper.x, b.lower.y, b.upper.z);
- combinePoint( b.upper.x, b.lower.y, b.lower.z);
- combinePoint( b.lower.x, b.upper.y, b.upper.z);
- combinePoint( b.lower.x, b.upper.y, b.lower.z);
- combinePoint( b.lower.x, b.lower.y, b.upper.z);
- combinePoint( b.lower.x, b.lower.y, b.lower.z);
- }
- } else if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObjects[i];
- dis = Math.sqrt( (center.x - sphere.center.x)*
- (center.x - sphere.center.x) +
- (center.y - sphere.center.y)*
- (center.y - sphere.center.y) +
- (center.z - sphere.center.z)*
- (center.z - sphere.center.z) );
- if( radius > sphere.radius) {
- if( (dis+sphere.radius) > radius) {
- d1 = .5*(radius-sphere.radius+dis);
- t = d1/dis;
- radius = d1+sphere.radius;
- center.x = sphere.center.x + (center.x-sphere.center.x)*t;
- center.y = sphere.center.y + (center.y-sphere.center.y)*t;
- center.z = sphere.center.z + (center.z-sphere.center.z)*t;
- }
- }else {
- if( (dis+radius) <= sphere.radius) {
- center.x = sphere.center.x;
- center.y = sphere.center.y;
- center.z = sphere.center.z;
- radius = sphere.radius;
- }else {
- d1 = .5*(sphere.radius-radius+dis);
- t = d1/dis;
- radius = d1+radius;
- center.x = center.x + (sphere.center.x-center.x)*t;
- center.y = center.y + (sphere.center.y-center.y)*t;
- center.z = center.z + (sphere.center.z-center.z)*t;
- }
- }
- } else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- polytope = (BoundingPolytope)boundsObjects[i];
- this.combine(polytope.verts);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere4"));
- }
- }
-
- updateBoundsStates();
- }
-
- /**
- * Combines this bounding sphere with a point.
- * @param point a 3D point in space
- */
- @Override
- public void combine(Point3d point) {
- double dis,oldc_to_new_c;
-
- if( boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty) {
- radius = 0.0;
- center.x = point.x;
- center.y = point.y;
- center.z = point.z;
- } else {
- dis = Math.sqrt( (point.x - center.x)*(point.x - center.x) +
- (point.y - center.y)*(point.y - center.y) +
- (point.z - center.z)*(point.z - center.z) );
-
- if( dis > radius) {
- radius = (dis + radius)*.5;
- oldc_to_new_c = dis - radius;
- center.x = (radius*center.x + oldc_to_new_c*point.x)/dis;
- center.y = (radius*center.y + oldc_to_new_c*point.y)/dis;
- center.z = (radius*center.z + oldc_to_new_c*point.z)/dis;
- }
- }
-
- updateBoundsStates();
- }
-
- /**
- * Combines this bounding sphere with an array of points.
- * @param points an array of 3D points in space
- */
- @Override
- public void combine(Point3d[] points) {
- int i;
- double dis,dis_sq,rad_sq,oldc_to_new_c;
-
- if( boundsIsInfinite) {
- return;
- }
-
- if( boundsIsEmpty ) {
- center.x = points[0].x;
- center.y = points[0].y;
- center.z = points[0].z;
- radius = 0.0;
- }
-
- for(i=0;i rad_sq) {
- dis = Math.sqrt( dis_sq);
- radius = (radius + dis)*.5;
- oldc_to_new_c = dis - radius;
- center.x = (radius*center.x + oldc_to_new_c*points[i].x)/dis;
- center.y = (radius*center.y + oldc_to_new_c*points[i].y)/dis;
- center.z = (radius*center.z + oldc_to_new_c*points[i].z)/dis;
- }
- }
-
- updateBoundsStates();
- }
-
-
- /**
- * Modifies the bounding sphere so that it bounds the volume
- * generated by transforming the given bounding object.
- * @param boundsObject the bounding object to be transformed
- * @param matrix a transformation matrix
- */
- @Override
- public void transform( Bounds boundsObject, Transform3D matrix) {
- if (boundsObject == null || boundsObject.boundsIsEmpty) {
- setEmptyBounds();
- return;
- }
-
- if (boundsObject.boundsIsInfinite) {
- setInfiniteBounds();
- return;
- }
-
- if (boundsObject.boundId == BOUNDING_BOX) {
- BoundingBox tmpBox = new BoundingBox(boundsObject);
- tmpBox.transform(matrix);
- this.set(tmpBox);
- }
- else if (boundsObject.boundId == BOUNDING_SPHERE) {
- this.set(boundsObject);
- this.transform(matrix);
- }
- else if (boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope tmpPolytope = new BoundingPolytope(boundsObject);
- tmpPolytope.transform(matrix);
- this.set(tmpPolytope);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere5"));
- }
- }
-
- /**
- * Transforms this bounding sphere by the given matrix.
- */
- @Override
- public void transform( Transform3D trans) {
- double scale;
-
- if(boundsIsInfinite)
- return;
-
- trans.transform(center);
- scale = trans.getDistanceScale();
- radius = radius * scale;
- if (Double.isNaN(radius)) {
- setEmptyBounds();
- return;
- }
- }
-
- /**
- * Test for intersection with a ray
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @param position3 a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Point3d origin, Vector3d direction, Point4d position ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = origin.x;
- position.y = origin.y;
- position.z = origin.z;
- position.w = 0.0;
- return true;
- }
-
- double l2oc,rad2,tca,t2hc,t,invMag;
- Vector3d dir = new Vector3d(); // normalized direction of ray
- Point3d oc = new Point3d(); // vector from sphere center to ray origin
-
- oc.x = center.x - origin.x;
- oc.y = center.y - origin.y;
- oc.z = center.z - origin.z;
-
- l2oc = oc.x*oc.x + oc.y*oc.y + oc.z*oc.z; // center to origin squared
-
- rad2 = radius*radius;
- if( l2oc < rad2 ){
- // System.err.println("ray origin inside sphere" );
- return true; // ray origin inside sphere
- }
-
- invMag = 1.0/Math.sqrt(direction.x*direction.x +
- direction.y*direction.y +
- direction.z*direction.z);
- dir.x = direction.x*invMag;
- dir.y = direction.y*invMag;
- dir.z = direction.z*invMag;
- tca = oc.x*dir.x + oc.y*dir.y + oc.z*dir.z;
-
- if( tca <= 0.0 ) {
- // System.err.println("ray points away from sphere" );
- return false; // ray points away from sphere
- }
-
- t2hc = rad2 - l2oc + tca*tca;
-
- if( t2hc > 0.0 ){
- t = tca - Math.sqrt(t2hc);
- // System.err.println("ray hits sphere:"+this.toString()+" t="+t+" direction="+dir );
- position.x = origin.x + dir.x*t;
- position.y = origin.y + dir.y*t;
- position.z = origin.z + dir.z*t;
- position.w = t;
- return true; // ray hits sphere
- }else {
- // System.err.println("ray does not hit sphere" );
- return false;
- }
-
- }
-
- /**
- * Test for intersection with a point
- * @param point the pick point
- * @param position a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Point3d point, Point4d position ) {
- double x,y,z,dist;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = point.x;
- position.y = point.y;
- position.z = point.z;
- position.w = 0.0;
- return true;
- }
-
- x = point.x - center.x;
- y = point.y - center.y;
- z = point.z - center.z;
-
- dist = x*x + y*y + z*z;
- if( dist > radius*radius)
- return false;
- else {
- position.x = point.x;
- position.y = point.y;
- position.z = point.z;
- position.w = Math.sqrt(dist);
- return true;
- }
-
- }
-
- /**
- * Test for intersection with a segment
- * @param start a point defining the start of the line segment
- * @param end a point defining the end of the line segment
- * @param position a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect( Point3d start, Point3d end, Point4d position ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- position.x = start.x;
- position.y = start.y;
- position.z = start.z;
- position.w = 0.0;
- return true;
- }
-
- double l2oc,rad2,tca,t2hc,invMag,t;
- Vector3d dir = new Vector3d(); // normalized direction of ray
- Point3d oc = new Point3d(); // vector from sphere center to ray origin
- Vector3d direction = new Vector3d();
-
- oc.x = center.x - start.x;
- oc.y = center.y - start.y;
- oc.z = center.z - start.z;
- direction.x = end.x - start.x;
- direction.y = end.y - start.y;
- direction.z = end.z - start.z;
- invMag = 1.0/Math.sqrt( direction.x*direction.x +
- direction.y*direction.y +
- direction.z*direction.z);
- dir.x = direction.x*invMag;
- dir.y = direction.y*invMag;
- dir.z = direction.z*invMag;
-
-
- l2oc = oc.x*oc.x + oc.y*oc.y + oc.z*oc.z; // center to origin squared
-
- rad2 = radius*radius;
- if( l2oc < rad2 ){
- // System.err.println("ray origin inside sphere" );
- return true; // ray origin inside sphere
- }
-
- tca = oc.x*dir.x + oc.y*dir.y + oc.z*dir.z;
-
- if( tca <= 0.0 ) {
- // System.err.println("ray points away from sphere" );
- return false; // ray points away from sphere
- }
-
- t2hc = rad2 - l2oc + tca*tca;
-
- if( t2hc > 0.0 ){
- t = tca - Math.sqrt(t2hc);
- if( t*t <= ((end.x-start.x)*(end.x-start.x)+
- (end.y-start.y)*(end.y-start.y)+
- (end.z-start.z)*(end.z-start.z))){
-
- position.x = start.x + dir.x*t;
- position.y = start.y + dir.x*t;
- position.z = start.z + dir.x*t;
- position.w = t;
- return true; // segment hits sphere
- }
- }
- return false;
- }
-
- /**
- * Test for intersection with a ray.
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d origin, Vector3d direction ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- return true;
- }
-
- double l2oc,rad2,tca,t2hc,mag;
- Vector3d dir = new Vector3d(); // normalized direction of ray
- Point3d oc = new Point3d(); // vector from sphere center to ray origin
-
- oc.x = center.x - origin.x;
- oc.y = center.y - origin.y;
- oc.z = center.z - origin.z;
-
- l2oc = oc.x*oc.x + oc.y*oc.y + oc.z*oc.z; // center to origin squared
-
- rad2 = radius*radius;
- if( l2oc < rad2 ){
- // System.err.println("ray origin inside sphere" );
- return true; // ray origin inside sphere
- }
-
- mag = Math.sqrt(direction.x*direction.x +
- direction.y*direction.y +
- direction.z*direction.z);
- dir.x = direction.x/mag;
- dir.y = direction.y/mag;
- dir.z = direction.z/mag;
- tca = oc.x*dir.x + oc.y*dir.y + oc.z*dir.z;
-
- if( tca <= 0.0 ) {
- // System.err.println("ray points away from sphere" );
- return false; // ray points away from sphere
- }
-
- t2hc = rad2 - l2oc + tca*tca;
-
- if( t2hc > 0.0 ){
- // System.err.println("ray hits sphere" );
- return true; // ray hits sphere
- }else {
- // System.err.println("ray does not hit sphere" );
- return false;
- }
- }
-
-
- /**
- * Returns the position of the intersect point if the ray intersects with
- * the sphere.
- *
- */
- boolean intersect(Point3d origin, Vector3d direction, Point3d intersectPoint ) {
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite ) {
- intersectPoint.x = origin.x;
- intersectPoint.y = origin.y;
- intersectPoint.z = origin.z;
- return true;
- }
-
- double l2oc,rad2,tca,t2hc,mag,t;
- Point3d dir = new Point3d(); // normalized direction of ray
- Point3d oc = new Point3d(); // vector from sphere center to ray origin
-
- oc.x = center.x - origin.x; // XXXX: check if this method is still needed
- oc.y = center.y - origin.y;
- oc.z = center.z - origin.z;
-
- l2oc = oc.x*oc.x + oc.y*oc.y + oc.z*oc.z; // center to origin squared
-
- rad2 = radius*radius;
- if( l2oc < rad2 ){
- // System.err.println("ray origin inside sphere" );
- return true; // ray origin inside sphere
- }
-
- mag = Math.sqrt(direction.x*direction.x +
- direction.y*direction.y +
- direction.z*direction.z);
- dir.x = direction.x/mag;
- dir.y = direction.y/mag;
- dir.z = direction.z/mag;
- tca = oc.x*dir.x + oc.y*dir.y + oc.z*dir.z;
-
- if( tca <= 0.0 ) {
- // System.err.println("ray points away from sphere" );
- return false; // ray points away from sphere
- }
-
- t2hc = rad2 - l2oc + tca*tca;
-
- if( t2hc > 0.0 ){
- t = tca - Math.sqrt(t2hc);
- intersectPoint.x = origin.x + direction.x*t;
- intersectPoint.y = origin.y + direction.y*t;
- intersectPoint.z = origin.z + direction.z*t;
- // System.err.println("ray hits sphere" );
- return true; // ray hits sphere
- }else {
- // System.err.println("ray does not hit sphere" );
- return false;
- }
- }
-
-
- /**
- * Test for intersection with a point.
- * @param point a point defining a position in 3-space
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Point3d point ) {
- double x,y,z,dist;
-
- if( boundsIsEmpty ) {
- return false;
- }
- if( boundsIsInfinite ) {
- return true;
- }
-
- x = point.x - center.x;
- y = point.y - center.y;
- z = point.z - center.z;
-
- dist = x*x + y*y + z*z;
- if( dist > radius*radius)
- return false;
- else
- return true;
-
- }
-
- /**
- * Tests whether the bounding sphere is empty. A bounding sphere is
- * empty if it is null (either by construction or as the result of
- * a null intersection) or if its volume is negative. A bounding sphere
- * with a volume of zero is not empty.
- * @return true if the bounding sphere is empty;
- * otherwise, it returns false
- */
- @Override
- public boolean isEmpty() {
- return boundsIsEmpty;
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- boolean intersect(Bounds boundsObject, Point4d position) {
- return intersect(boundsObject);
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds boundsObject) {
- double distsq, radsq;
- BoundingSphere sphere;
-
- if( boundsObject == null ) {
- return false;
- }
-
- if( boundsIsEmpty || boundsObject.boundsIsEmpty ) {
- return false;
- }
-
- if( boundsIsInfinite || boundsObject.boundsIsInfinite ) {
- return true;
- }
-
- if( boundsObject.boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObject;
- double dis = 0.0;
- double rad_sq = radius*radius;
-
- // find the corner closest to the center of sphere
-
- if( center.x < box.lower.x )
- dis = (center.x-box.lower.x)*(center.x-box.lower.x);
- else
- if( center.x > box.upper.x )
- dis = (center.x-box.upper.x)*(center.x-box.upper.x);
-
- if( center.y < box.lower.y )
- dis += (center.y-box.lower.y)*(center.y-box.lower.y);
- else
- if( center.y > box.upper.y )
- dis += (center.y-box.upper.y)*(center.y-box.upper.y);
-
- if( center.z < box.lower.z )
- dis += (center.z-box.lower.z)*(center.z-box.lower.z);
- else
- if( center.z > box.upper.z )
- dis += (center.z-box.upper.z)*(center.z-box.upper.z);
-
- return ( dis <= rad_sq );
- } else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObject;
- radsq = radius + sphere.radius;
- radsq *= radsq;
- distsq = center.distanceSquared(sphere.center);
- return (distsq <= radsq);
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- return intersect_ptope_sphere( (BoundingPolytope)boundsObject, this);
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere6"));
- }
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObjects an array of bounding objects
- * @return true or false indicating if an intersection occured
- */
- @Override
- public boolean intersect(Bounds[] boundsObjects) {
- double distsq, radsq;
- BoundingSphere sphere;
- int i;
-
- if( boundsObjects == null || boundsObjects.length <= 0 ) {
- return false;
- }
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- for(i = 0; i < boundsObjects.length; i++){
- if( boundsObjects[i] == null || boundsObjects[i].boundsIsEmpty);
- else if( boundsIsInfinite || boundsObjects[i].boundsIsInfinite ) {
- return true; // We're done here.
- } else if( boundsObjects[i].boundId == BOUNDING_BOX){
- if( this.intersect( boundsObjects[i])) return true;
- } else if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- sphere = (BoundingSphere)boundsObjects[i];
- radsq = radius + sphere.radius;
- radsq *= radsq;
- distsq = center.distanceSquared(sphere.center);
- if (distsq <= radsq) {
- return true;
- }
- } else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- if( this.intersect( boundsObjects[i])) return true;
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere7"));
- }
- }
-
- return false;
-
- }
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @param newBoundSphere the new bounding sphere which is the intersection of
- * the boundsObject and this BoundingSphere
- * @return true or false indicating if an intersection occured
- */
- public boolean intersect(Bounds boundsObject, BoundingSphere newBoundSphere) {
-
- if (boundsObject == null || boundsIsEmpty || boundsObject.boundsIsEmpty) {
- newBoundSphere.set(null);
- return false;
- }
-
- if (boundsIsInfinite && !boundsObject.boundsIsInfinite) {
- newBoundSphere.set(boundsObject);
- return true;
- }
-
- if (boundsObject.boundsIsInfinite) {
- newBoundSphere.set(this);
- return true;
- }
-
- if(boundsObject.boundId == BOUNDING_BOX){
- BoundingBox tbox = new BoundingBox();
- BoundingBox box = (BoundingBox)boundsObject;
- if( this.intersect( box) ){
- BoundingBox sbox = new BoundingBox( this ); // convert sphere to box
- sbox.intersect(box, tbox); // insersect two boxes
- newBoundSphere.set( tbox ); // set sphere to the intersection of 2 boxes
- return true;
- } else {
- newBoundSphere.set(null);
- return false;
- }
- } else if( boundsObject.boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObject;
- double dis,t,d2;
- dis = Math.sqrt( (center.x-sphere.center.x)*(center.x-sphere.center.x) +
- (center.y-sphere.center.y)*(center.y-sphere.center.y) +
- (center.z-sphere.center.z)*(center.z-sphere.center.z) );
- if ( dis > radius+sphere.radius) {
- newBoundSphere.set(null);
- return false;
- } else if( dis+radius <= sphere.radius ) { // this sphere is contained within boundsObject
- newBoundSphere.center.x = center.x;
- newBoundSphere.center.y = center.y;
- newBoundSphere.center.z = center.z;
- newBoundSphere.radius = radius;
- } else if( dis+sphere.radius <= radius ) { // boundsObject is containted within this sphere
- newBoundSphere.center.x = sphere.center.x;
- newBoundSphere.center.y = sphere.center.y;
- newBoundSphere.center.z = sphere.center.z;
- newBoundSphere.radius = sphere.radius;
- } else {
- // distance from this center to center of overlapped volume
- d2 = (dis*dis + radius*radius - sphere.radius*sphere.radius)/(2.0*dis);
- newBoundSphere.radius = Math.sqrt( radius*radius - d2*d2);
- t = d2/dis;
- newBoundSphere.center.x = center.x + (sphere.center.x - center.x)*t;
- newBoundSphere.center.y = center.y + (sphere.center.y - center.y)*t;
- newBoundSphere.center.z = center.z + (sphere.center.z - center.z)*t;
- }
-
- newBoundSphere.updateBoundsStates();
- return true;
-
- } else if(boundsObject.boundId == BOUNDING_POLYTOPE) {
- BoundingBox tbox = new BoundingBox();
-
- BoundingPolytope polytope = (BoundingPolytope)boundsObject;
- if( this.intersect( polytope) ){
- BoundingBox sbox = new BoundingBox( this ); // convert sphere to box
- BoundingBox pbox = new BoundingBox( polytope ); // convert polytope to box
- sbox.intersect(pbox,tbox); // insersect two boxes
- newBoundSphere.set( tbox ); // set sphere to the intersection of 2 boxesf
- return true;
- } else {
- newBoundSphere.set(null);
- return false;
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere8"));
- }
- }
-
- /**
- * Test for intersection with an array of bounds objects.
- * @param boundsObjects an array of bounds objects
- * @param newBoundSphere the new bounding sphere which is the intersection of
- * the boundsObject and this BoundingSphere
- * @return true or false indicating if an intersection occured
- */
- public boolean intersect(Bounds[] boundsObjects, BoundingSphere newBoundSphere) {
-
- if (boundsObjects == null || boundsObjects.length <= 0 || boundsIsEmpty) {
- newBoundSphere.set(null);
- return false;
- }
-
- int i=0;
-
- // find first non null bounds object
- while( boundsObjects[i] == null && i < boundsObjects.length) {
- i++;
- }
-
- if (i >= boundsObjects.length) { // all bounds objects were empty
- newBoundSphere.set(null);
- return false;
- }
-
- boolean status = false;
- double newRadius;
- Point3d newCenter = new Point3d();
- BoundingBox tbox = new BoundingBox();
-
- for(i=0;i radius+sphere.radius) {
- } else if( dis+radius <= sphere.radius ) { // this sphere is contained within boundsObject
- if( status ) {
- newBoundSphere.combine( this );
- } else {
- newBoundSphere.center.x = center.x;
- newBoundSphere.center.y = center.y;
- newBoundSphere.center.z = center.z;
- newBoundSphere.radius = radius;
- status = true;
- newBoundSphere.updateBoundsStates();
- }
- } else if( dis+sphere.radius <= radius ) { // boundsObject is containted within this sphere
- if( status ) {
- newBoundSphere.combine( sphere );
- } else {
- newBoundSphere.center.x = center.x;
- newBoundSphere.center.y = center.y;
- newBoundSphere.center.z = center.z;
- newBoundSphere.radius = sphere.radius;
- status = true;
- newBoundSphere.updateBoundsStates();
- }
- } else {
- // distance from this center to center of overlapped volume
- d2 = (dis*dis + radius*radius - sphere.radius*sphere.radius)/(2.0*dis);
- newRadius = Math.sqrt( radius*radius - d2*d2);
- t = d2/dis;
- newCenter.x = center.x + (sphere.center.x - center.x)*t;
- newCenter.y = center.y + (sphere.center.y - center.y)*t;
- newCenter.z = center.z + (sphere.center.z - center.z)*t;
- if( status ) {
- BoundingSphere newSphere = new BoundingSphere( newCenter,
- newRadius );
- newBoundSphere.combine( newSphere );
- } else {
- newBoundSphere.setRadius( newRadius );
- newBoundSphere.setCenter( newCenter );
- status = true;
- }
- }
-
- } else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- if( this.intersect( polytope) ){
- BoundingBox sbox = new BoundingBox( this ); // convert sphere to box
- BoundingBox pbox = new BoundingBox( polytope ); // convert polytope to box
- sbox.intersect(pbox, tbox); // insersect two boxes
- if( status ) {
- newBoundSphere.combine( tbox );
- } else {
- newBoundSphere.set( tbox ); // set sphere to the intersection of 2 boxesf
- status = true;
- }
- }
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere9"));
- }
- }
- if (status == false)
- newBoundSphere.set(null);
- return status;
- }
-
- /**
- * Finds closest bounding object that intersects this bounding sphere.
- * @param boundsObjects an array of bounds objects
- * @return closest bounding object
- */
- @Override
- public Bounds closestIntersection( Bounds[] boundsObjects) {
-
- if( boundsObjects == null || boundsObjects.length <= 0 ) {
- return null;
- }
-
- if( boundsIsEmpty ) {
- return null;
- }
-
- double dis,far_dis,pdist,x,y,z,rad_sq;
- double cenX = 0.0, cenY = 0.0, cenZ = 0.0;
- boolean contains = false;
- boolean inside;
- boolean intersect = false;
- double smallest_distance = Double.MAX_VALUE;
- int i,j,index=0;
-
-
- for(i = 0; i < boundsObjects.length; i++){
- if( boundsObjects[i] == null ) ;
-
- else if( this.intersect( boundsObjects[i])) {
- intersect = true;
- if(boundsObjects[i].boundId == BOUNDING_BOX){
- BoundingBox box = (BoundingBox)boundsObjects[i];
- cenX = (box.upper.x+box.lower.x)/2.0;
- cenY = (box.upper.y+box.lower.y)/2.0;
- cenZ = (box.upper.z+box.lower.z)/2.0;
- dis = Math.sqrt( (center.x-cenX)*(center.x-cenX) +
- (center.y-cenY)*(center.y-cenY) +
- (center.z-cenZ)*(center.z-cenZ) );
- if( (center.x-box.lower.x)*(center.x-box.lower.x) >
- (center.x-box.upper.x)*(center.x-box.upper.x) )
- far_dis = (center.x-box.lower.x)*(center.x-box.lower.x);
- else
- far_dis = (center.x-box.upper.x)*(center.x-box.upper.x);
-
- if( (center.y-box.lower.y)*(center.y-box.lower.y) >
- (center.y-box.upper.y)*(center.y-box.upper.y) )
- far_dis += (center.y-box.lower.y)*(center.y-box.lower.y);
- else
- far_dis += (center.y-box.upper.y)*(center.y-box.upper.y);
-
- if( (center.z-box.lower.z)*(center.z-box.lower.z) >
- (center.z-box.upper.z)*(center.z-box.upper.z) )
- far_dis += (center.z-box.lower.z)*(center.z-box.lower.z);
- else
- far_dis += (center.z-box.upper.z)*(center.z-box.upper.z);
-
- rad_sq = radius * radius;
- if( far_dis <= rad_sq ) { // contains box
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if( boundsObjects[i].boundId == BOUNDING_SPHERE ) {
- BoundingSphere sphere = (BoundingSphere)boundsObjects[i];
- dis = Math.sqrt( (center.x-sphere.center.x)*(center.x-sphere.center.x) +
- (center.y-sphere.center.y)*(center.y-sphere.center.y) +
- (center.z-sphere.center.z)*(center.z-sphere.center.z) );
- if( (dis+sphere.radius) <= radius) { // contains the sphere
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
-
- } else if(boundsObjects[i].boundId == BOUNDING_POLYTOPE) {
- BoundingPolytope polytope = (BoundingPolytope)boundsObjects[i];
- dis = Math.sqrt( (center.x-polytope.centroid.x)*(center.x-polytope.centroid.x) +
- (center.y-polytope.centroid.y)*(center.y-polytope.centroid.y) +
- (center.z-polytope.centroid.z)*(center.z-polytope.centroid.z) );
- inside = true;
- for(j=0;j radius*radius)
- inside=false;
- }
- if( inside ) {
- if( !contains ){ // initialize smallest_distance for the first containment
- index = i;
- smallest_distance = dis;
- contains = true;
- } else{
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
- } else if (!contains) {
- if( dis < smallest_distance){
- index = i;
- smallest_distance = dis;
- }
- }
-
- } else {
- throw new IllegalArgumentException(J3dI18N.getString("BoundingSphere10"));
- }
- }
- }
-
- if ( intersect )
- return boundsObjects[index];
- else
- return null;
-
- }
-
-
- /**
- * Intersects this bounding sphere with preprocessed frustum.
- * @return true if the bounding sphere and frustum intersect.
- */
- boolean intersect(CachedFrustum frustum) {
- int i;
- double dist;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if(boundsIsInfinite)
- return true;
-
- for (i=0; i<6; i++) {
- dist = frustum.clipPlanes[i].x*center.x + frustum.clipPlanes[i].y*center.y +
- frustum.clipPlanes[i].z*center.z + frustum.clipPlanes[i].w;
- if (dist < 0.0 && (dist + radius) < 0.0) {
- return(false);
- }
- }
- return true;
- }
-
- /**
- * This intersects this bounding sphere with 6 frustum plane equations
- * @return returns true if the bounding sphere and frustum intersect.
- */
- boolean intersect(Vector4d[] planes) {
- int i;
- double dist;
-
- if( boundsIsEmpty ) {
- return false;
- }
-
- if(boundsIsInfinite)
- return true;
-
- for (i=0; i<6; i++) {
- dist = planes[i].x*center.x + planes[i].y*center.y +
- planes[i].z*center.z + planes[i].w;
- if (dist < 0.0 && (dist + radius) < 0.0) {
- //System.err.println("Tossing " + i + " " + dist + " " + radius);
- return(false);
- }
- }
- return true;
- }
-
- /**
- * Returns a string representation of this class.
- */
- @Override
- public String toString() {
- return new String( "Center="+center+" Radius="+radius);
- }
-
-private void setEmptyBounds() {
- center.set(0.0d, 0.0d, 0.0d);
- radius = -1.0;
- boundsIsInfinite = false;
- boundsIsEmpty = true;
-}
-
-private void setInfiniteBounds() {
- center.set(0.0d, 0.0d, 0.0d);
- radius = Double.POSITIVE_INFINITY;
- boundsIsEmpty = false;
- boundsIsInfinite = true;
-}
-
- private void updateBoundsStates() {
-
- if (Double.isNaN(radius + center.x + center.y + center.z)) {
- boundsIsEmpty = true;
- boundsIsInfinite = false;
- return;
- }
-
- if(radius == Double.POSITIVE_INFINITY) {
- boundsIsEmpty = false;
- boundsIsInfinite = true;
- }
- else {
- boundsIsInfinite = false;
- if( radius < 0.0 ) {
- boundsIsEmpty = true;
- } else {
- boundsIsEmpty = false;
- }
- }
- }
-
- @Override
- Point3d getCenter() {
- return center;
- }
-
- /**
- * if the passed the "region" is same type as this object
- * then do a copy, otherwise clone the Bounds and
- * return
- */
- @Override
- Bounds copy(Bounds r) {
- if (r != null && this.boundId == r.boundId) {
- BoundingSphere region = (BoundingSphere)r;
- region.radius = radius;
- region.center.x = center.x;
- region.center.y = center.y;
- region.center.z = center.z;
- region.boundsIsEmpty = boundsIsEmpty;
- region.boundsIsInfinite = boundsIsInfinite;
- return region;
- }
- else {
- return (Bounds) this.clone();
- }
- }
-
- @Override
- int getPickType() {
- return PickShape.PICKBOUNDINGSPHERE;
- }
-}
-
-
-
-
diff --git a/src/classes/share/javax/media/j3d/Bounds.java b/src/classes/share/javax/media/j3d/Bounds.java
deleted file mode 100644
index 9672859..0000000
--- a/src/classes/share/javax/media/j3d/Bounds.java
+++ /dev/null
@@ -1,673 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import javax.vecmath.Matrix3d;
-import javax.vecmath.Point3d;
-import javax.vecmath.Point4d;
-import javax.vecmath.Vector3d;
-import javax.vecmath.Vector4d;
-
-/**
- * The abstract base class for bounds objects. Bounds objects define
- * a convex, closed volume that is used for various intersection and
- * culling operations.
- */
-
-public abstract class Bounds extends Object implements Cloneable {
- static final double EPSILON = .000001;
- static final boolean debug = false;
-
- static final int BOUNDING_BOX = 0x1;
- static final int BOUNDING_SPHERE = 0x2;
- static final int BOUNDING_POLYTOPE = 0x4;
-
- boolean boundsIsEmpty = false;
- boolean boundsIsInfinite = false;
- int boundId = 0;
-
- /**
- * Constructs a new Bounds object.
- */
- public Bounds() {
- }
-
-
- /**
- * Makes a copy of a bounds object.
- */
- @Override
- public abstract Object clone();
-
-
- /**
- * Indicates whether the specified bounds object is
- * equal to this Bounds object. They are equal if both the
- * specified bounds object and this Bounds are
- * instances of the same Bounds subclass and all of the data
- * members of bounds are equal to the corresponding
- * data members in this Bounds.
- * @param bounds the object with which the comparison is made.
- * @return true if this Bounds object is equal to bounds;
- * otherwise false
- *
- * @since Java 3D 1.2
- */
- @Override
- public abstract boolean equals(Object bounds);
-
-
- /**
- * Returns a hash code for this Bounds object based on the
- * data values in this object. Two different Bounds objects of
- * the same type with identical data values (i.e., Bounds.equals
- * returns true) will return the same hash code. Two Bounds
- * objects with different data members may return the same hash code
- * value, although this is not likely.
- * @return a hash code for this Bounds object.
- *
- * @since Java 3D 1.2
- */
- @Override
- public abstract int hashCode();
-
-
- /**
- * Test for intersection with a ray.
- * @param origin the starting point of the ray
- * @param direction the direction of the ray
- * @return true or false indicating if an intersection occured
- */
- public abstract boolean intersect( Point3d origin, Vector3d direction );
-
- /**
- * Test for intersection with a point.
- * @param point a point defining a position in 3-space
- * @return true or false indicating if an intersection occured
- */
- public abstract boolean intersect( Point3d point );
-
- /**
- * Test for intersection with a ray
- * @param origin is a the starting point of the ray
- * @param direction is the direction of the ray
- * @param position is a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- abstract boolean intersect( Point3d origin, Vector3d direction, Point4d position );
-
- /**
- * Test for intersection with a point
- * @param point is a point defining a position in 3-space
- * @param position is a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- abstract boolean intersect( Point3d point, Point4d position);
-
- /**
- * Test for intersection with a segment
- * @param start is a point defining the start of the line segment
- * @param end is a point defining the end of the line segment
- * @param position is a point defining the location of the pick w= distance to pick
- * @return true or false indicating if an intersection occured
- */
- abstract boolean intersect( Point3d start, Point3d end, Point4d position );
-
- /**
- * Test for intersection with another bounds object
- *
- * Test for intersection with another bounds object
- * @param boundsObject is another bounds object
- * @return true or false indicating if an intersection occured
- */
- abstract boolean intersect( Bounds boundsObject, Point4d position );
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObject another bounds object
- * @return true or false indicating if an intersection occurred
- */
- public abstract boolean intersect( Bounds boundsObject );
-
- /**
- * Test for intersection with another bounds object.
- * @param boundsObjects an array of bounding objects
- * @return true or false indicating if an intersection occured
- */
- public abstract boolean intersect( Bounds[] boundsObjects );
-
-
- /**
- * Finds closest bounding object that intersects this bounding object.
- * @param boundsObjects an array of bounds objects
- * @return closest bounding object
- */
- public abstract Bounds closestIntersection( Bounds[] boundsObjects);
-
-/**
- * Returns the center of the bounds
- * @return bounds center
- */
-abstract Point3d getCenter();
-
-/**
- * Gets the centroid of this bounding region.
- * @param center a Point to receive the centroid of the bounding region
- */
-public abstract void getCenter(Point3d center);
-
- /**
- * Combines this bounding object with a bounding object so that the
- * resulting bounding object encloses the original bounding object and the
- * given bounds object.
- * @param boundsObject another bounds object
- */
- public abstract void combine( Bounds boundsObject );
-
-
- /**
- * Combines this bounding object with an array of bounding objects so that the
- * resulting bounding object encloses the original bounding object and the
- * given array of bounds object.
- * @param boundsObjects an array of bounds objects
- */
- public abstract void combine( Bounds[] boundsObjects);
-
- /**
- * Combines this bounding object with a point.
- * @param point a 3d point in space
- */
- public abstract void combine( Point3d point);
-
- /**
- * Combines this bounding object with an array of points.
- * @param points an array of 3d points in space
- */
- public abstract void combine( Point3d[] points);
-
- /**
- * Transforms this bounding object by the given matrix.
- * @param trans the transformation matrix
- */
- public abstract void transform(Transform3D trans);
-
- /**
- * Modifies the bounding object so that it bounds the volume
- * generated by transforming the given bounding object.
- * @param bounds the bounding object to be transformed
- * @param trans the transformation matrix
- */
- public abstract void transform( Bounds bounds, Transform3D trans);
-
- /**
- * Tests whether the bounds is empty. A bounds is
- * empty if it is null (either by construction or as the result of
- * a null intersection) or if its volume is negative. A bounds
- * with a volume of zero is not empty.
- * @return true if the bounds is empty; otherwise, it returns false
- */
- public abstract boolean isEmpty();
-
- /**
- * Sets the value of this Bounds object.
- * @param boundsObject another bounds object.
- */
- public abstract void set( Bounds boundsObject);
-
-
- abstract Bounds copy(Bounds region);
-
-
- private void test_point(Vector4d[] planes, Point3d new_point) {
- for (int i = 0; i < planes.length; i++){
- double dist = (new_point.x*planes[i].x + new_point.y*planes[i].y +
- new_point.z*planes[i].z + planes[i].w ) ;
- if (dist > EPSILON ){
- System.err.println("new point is outside of" +
- " plane["+i+"] dist = " + dist);
- }
- }
- }
-
- /**
- * computes the closest point from the given point to a set of planes
- * (polytope)
- * @param g the point
- * @param planes array of bounding planes
- * @param new_point point on planes closest g
- */
- boolean closest_point( Point3d g, Vector4d[] planes, Point3d new_point ) {
-
- double t,s,dist,w;
- boolean converged, inside, firstPoint, firstInside;
- int i,count;
- double ab,ac,bc,ad,bd,cd,aa,bb,cc;
- double b1,b2,b3,d1,d2,d3,y1,y2,y3;
- double h11,h12,h13,h22,h23,h33;
- double l12,l13,l23;
- Point3d n = new Point3d();
- Point3d p = new Point3d();
- Vector3d delta = null;
-
- // These are temporary until the solve code is working
-
-
- /*
- * The algorithm:
- * We want to find the point "n", closest to "g", while still within
- * the the polytope defined by "planes". We find the solution by
- * minimizing the value for a "penalty function";
- *
- * f = distance(n,g)^2 + sum for each i: w(distance(n, planes[i]))
- *
- * Where "w" is a weighting which indicates how much more important
- * it is to be close to the planes than it is to be close to "g".
- *
- * We minimize this function by taking it's derivitive, and then
- * solving for the value of n when the derivitive equals 0.
- *
- * For the 1D case with a single plane (a,b,c,d), x = n.x and g = g.x,
- * this looks like:
- *
- * f(x) = (x - g) ^ 2 + w(ax + d)^2
- * f'(x) = 2x -2g + 2waax + 2wad
- *
- * (note aa = a^2) setting f'(x) = 0 gives:
- *
- * (1 + waa)x = g - wad
- *
- * Note that the solution is just outside the plane [a, d]. With the
- * correct choice of w, this should be inside of the EPSILON tolerance
- * outside the planes.
- *
- * Extending to 3D gives the matrix solution:
- *
- * | (1 + waa) wab wac |
- * H = | wab (1 + wbb) wbc |
- * | wac wbc (1 + wcc) |
- *
- * b = [g.x - wad, g.y - wbd, g.z - wcd]
- *
- * H * n = b
- *
- * n = b * H.inverse()
- *
- * The implementation speeds this process up by recognizing that
- * H is symmetric, so that it can be decomposed into three matrices:
- *
- * H = L * D * L.transpose()
- *
- * 1.0 0.0 0.0 d1 0.0 0.0
- * L = l12 1.0 0.0 D = 0.0 d2 0.0
- * l13 l23 1.0 0.0 0.0 d3
- *
- * n can then be derived by back-substitution, where the original
- * problem is decomposed as:
- *
- * H * n = b
- * L * D * L.transpose() * n = b
- * L * D * y = b; L.transpose() * n = y
- *
- * We can then multiply out the terms of L * D and solve for y, and
- * then use y to solve for n.
- */
-
- w=100.0 / EPSILON; // must be large enough to ensure that solution
- // is within EPSILON of planes
-
- count = 0;
- p.set(g);
-
- if (debug) {
- System.err.println("closest_point():\nincoming g="+" "+g.x+" "+g.y+
- " "+g.z);
- }
-
- converged = false;
- firstPoint = true;
- firstInside = false;
-
- Vector4d pln;
-
- while( !converged ) {
- if (debug) {
- System.err.println("start: p="+" "+p.x+" "+p.y+" "+p.z);
- }
-
- // test the current point against the planes, for each
- // plane that is violated, add it's contribution to the
- // penalty function
- inside = true;
- aa=0.0; bb=0.0; cc=0.0;
- ab=0.0; ac=0.0; bc=0.0; ad=0.0; bd=0.0; cd=0.0;
- for(i = 0; i < planes.length; i++){
- pln = planes[i];
- dist = (p.x*pln.x + p.y*pln.y +
- p.z*pln.z + pln.w ) ;
- // if point is outside or within EPSILON of the boundary, add
- // the plane to the penalty matrix. We do this even if the
- // point is already inside the polytope to prevent numerical
- // instablity in cases where the point is just outside the
- // boundary of several planes of the polytope
- if (dist > -EPSILON ){
- aa = aa + pln.x * pln.x;
- bb = bb + pln.y * pln.y;
- cc = cc + pln.z * pln.z;
- ab = ab + pln.x * pln.y;
- ac = ac + pln.x * pln.z;
- bc = bc + pln.y * pln.z;
- ad = ad + pln.x * pln.w;
- bd = bd + pln.y * pln.w;
- cd = cd + pln.z * pln.w;
- }
- // If the point is inside if dist is <= EPSILON
- if (dist > EPSILON ){
- inside = false;
- if (debug) {
- System.err.println("point outside plane["+i+"]=("+
- pln.x+ ","+pln.y+",\n\t"+pln.z+
- ","+ pln.w+")\ndist = " + dist);
- }
- }
- }
- // see if we are done
- if (inside) {
- if (debug) {
- System.err.println("p is inside");
- }
- if (firstPoint) {
- firstInside = true;
- }
- new_point.set(p);
- converged = true;
- } else { // solve for a closer point
- firstPoint = false;
-
- // this is the upper right corner of H, which is all we
- // need to do the decomposition since the matrix is symetric
- h11 = 1.0 + aa * w;
- h12 = ab * w;
- h13 = ac * w;
- h22 = 1.0 + bb * w;
- h23 = bc * w;
- h33 = 1.0 + cc * w;
-
- if (debug) {
- System.err.println(" hessin= ");
- System.err.println(h11+" "+h12+" "+h13);
- System.err.println(" "+h22+" "+h23);
- System.err.println(" "+h33);
- }
-
- // these are the constant terms
- b1 = g.x - w * ad;
- b2 = g.y - w * bd;
- b3 = g.z - w * cd;
-
- if (debug) {
- System.err.println(" b1,b2,b3 = "+b1+" "+b2+" " +b3);
- }
-
- // solve, d1, d2, d3 actually 1/dx, which is more useful
- d1 = 1/h11;
- l12 = d1 * h12;
- l13 = d1 * h13;
- s = h22-l12*h12;
- d2 = 1/s;
- t = h23-h12*l13;
- l23 = d2 * t;
- d3 = 1/(h33 - h13*l13 - t*l23);
-
- if (debug) {
- System.err.println(" l12,l13,l23 "+l12+" "+l13+" "+l23);
- System.err.println(" d1,d2,d3 "+ d1+" "+d2+" "+d3);
- }
-
- // we have L and D, now solve for y
- y1 = d1 * b1;
- y2 = d2 * (b2 - h12*y1);
- y3 = d3 * (b3 - h13*y1 - t*y2);
-
- if (debug) {
- System.err.println(" y1,y2,y3 = "+y1+" "+y2+" "+y3);
- }
-
- // we have y, solve for n
- n.z = y3;
- n.y = (y2 - l23*n.z);
- n.x = (y1 - l13*n.z - l12*n.y);
-
- if (debug) {
- System.err.println("new point = " + n.x+" " + n.y+" " +
- n.z);
- test_point(planes, n);
-
- if (delta == null) delta = new Vector3d();
- delta.sub(n, p);
- delta.normalize();
- System.err.println("p->n direction: " + delta);
- Matrix3d hMatrix = new Matrix3d();
- // check using the the javax.vecmath routine
- hMatrix.m00 = h11;
- hMatrix.m01 = h12;
- hMatrix.m02 = h13;
- hMatrix.m10 = h12; // h21 = h12
- hMatrix.m11 = h22;
- hMatrix.m12 = h23;
- hMatrix.m20 = h13; // h31 = h13
- hMatrix.m21 = h23; // h32 = h22
- hMatrix.m22 = h33;
- hMatrix.invert();
- Point3d check = new Point3d(b1, b2, b3);
- hMatrix.transform(check);
-
- System.err.println("check point = " + check.x+" " +
- check.y+" " + check.z);
- }
-
- // see if we have converged yet
- dist = (p.x-n.x)*(p.x-n.x) + (p.y-n.y)*(p.y-n.y) +
- (p.z-n.z)*(p.z-n.z);
-
- if (debug) {
- System.err.println("p->n distance =" + dist );
- }
-
- if( dist < EPSILON) { // close enough
- converged = true;
- new_point.set(n);
- } else {
- p.set(n);
- count++;
- if(count > 4 ){ // watch for cycling between two minimums
- new_point.set(n);
- converged = true;
- }
- }
- }
- }
- if (debug) {
- System.err.println("returning pnt ("+new_point.x+" "+
- new_point.y+" "+new_point.z+")");
-
- if(firstInside) System.err.println("input point inside polytope ");
- }
- return firstInside;
- }
-
- boolean intersect_ptope_sphere( BoundingPolytope polyTope,
- BoundingSphere sphere) {
- Point3d p = new Point3d();
- boolean inside;
-
-
- if (debug) {
- System.err.println("ptope_sphere intersect sphere ="+sphere);
- }
- inside = closest_point( sphere.center, polyTope.planes, p );
- if (debug) {
- System.err.println("ptope sphere intersect point ="+p);
- }
- if (!inside){
- // if distance between polytope and sphere center is greater than
- // radius then no intersection
- if (p.distanceSquared( sphere.center) >
- sphere.radius*sphere.radius){
- if (debug) {
- System.err.println("ptope_sphere returns false");
- }
- return false;
- } else {
- if (debug) {
- System.err.println("ptope_sphere returns true");
- }
- return true;
- }
- } else {
- if (debug) {
- System.err.println("ptope_sphere returns true");
- }
- return true;
- }
- }
-
- boolean intersect_ptope_abox( BoundingPolytope polyTope, BoundingBox box) {
- Vector4d planes[] = new Vector4d[6];
-
- if (debug) {
- System.err.println("ptope_abox, box = " + box);
- }
- planes[0] = new Vector4d( -1.0, 0.0, 0.0, box.lower.x);
- planes[1] = new Vector4d( 1.0, 0.0, 0.0,-box.upper.x);
- planes[2] = new Vector4d( 0.0,-1.0, 0.0, box.lower.y);
- planes[3] = new Vector4d( 0.0, 1.0, 0.0,-box.upper.y);
- planes[4] = new Vector4d( 0.0, 0.0,-1.0, box.lower.z);
- planes[5] = new Vector4d( 0.0, 0.0, 1.0,-box.upper.z);
-
-
- BoundingPolytope pbox = new BoundingPolytope( planes);
-
- boolean result = intersect_ptope_ptope( polyTope, pbox );
- if (debug) {
- System.err.println("ptope_abox returns " + result);
- }
- return(result);
- }
-
-
- boolean intersect_ptope_ptope( BoundingPolytope poly1,
- BoundingPolytope poly2) {
- boolean intersect;
- Point3d p = new Point3d();
- Point3d g = new Point3d();
- Point3d gnew = new Point3d();
- Point3d pnew = new Point3d();
-
- intersect = false;
-
- p.x = 0.0;
- p.y = 0.0;
- p.z = 0.0;
-
- // start from an arbitrary point on poly1
- closest_point( p, poly1.planes, g);
-
- // get the closest points on each polytope
- if (debug) {
- System.err.println("ptope_ptope: first g = "+g);
- }
- intersect = closest_point( g, poly2.planes, p);
-
- if (intersect) {
- return true;
- }
-
- if (debug) {
- System.err.println("first p = "+p+"\n");
- }
- intersect = closest_point( p, poly1.planes, gnew);
- if (debug) {
- System.err.println("gnew = "+gnew+" intersect="+intersect);
- }
-
- // loop until the closest points on the two polytopes are not changing
-
- double prevDist = p.distanceSquared(g);
- double dist;
-
- while( !intersect ) {
-
- dist = p.distanceSquared(gnew);
-
- if (dist < prevDist) {
- g.set(gnew);
- intersect = closest_point( g, poly2.planes, pnew );
- if (debug) {
- System.err.println("pnew = "+pnew+" intersect="+intersect);
- }
- } else {
- g.set(gnew);
- break;
- }
- prevDist = dist;
- dist = pnew.distanceSquared(g);
-
- if (dist < prevDist) {
- p.set(pnew);
- if( !intersect ) {
- intersect = closest_point( p, poly1.planes, gnew );
- if (debug) {
- System.err.println("gnew = "+gnew+" intersect="+
- intersect);
- }
- }
- } else {
- p.set(pnew);
- break;
- }
- prevDist = dist;
- }
-
- if (debug) {
- System.err.println("gnew="+" "+gnew.x+" "+gnew.y+" "+gnew.z);
- System.err.println("pnew="+" "+pnew.x+" "+pnew.y+" "+pnew.z);
- }
- return intersect;
- }
-
-
- synchronized void setWithLock(Bounds b) {
- this.set(b);
- }
-
- synchronized void getWithLock(Bounds b) {
- b.set(this);
- }
-
- // Return one of Pick Bounds type define in PickShape
- abstract int getPickType();
-}
diff --git a/src/classes/share/javax/media/j3d/BranchGroup.java b/src/classes/share/javax/media/j3d/BranchGroup.java
deleted file mode 100644
index 41fc93a..0000000
--- a/src/classes/share/javax/media/j3d/BranchGroup.java
+++ /dev/null
@@ -1,580 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-
-/**
- * The BranchGroup serves as a pointer to the root of a
- * scene graph branch; BranchGroup objects are the only objects that
- * can be inserted into a Locale's set of objects. A subgraph, rooted
- * by a BranchGroup node can be thought of as a compile unit. The
- * following things may be done with BranchGroup:
- *
- *
A BranchGroup may be compiled by calling its compile method. This causes the
- * entire subgraph to be compiled. If any BranchGroup nodes are contained within the
- * subgraph, they are compiled as well (along with their descendants).
- *
- *
A BranchGroup may be inserted into a virtual universe by attaching it to a
- * Locale. The entire subgraph is then said to be live.
- *
- *
A BranchGroup that is contained within another subgraph may be reparented or
- * detached at run time if the appropriate capabilities are set.
- *
- * Note that that if a BranchGroup is included in another subgraph, as a child of
- * some other group node, it may not be attached to a Locale.
- */
-
-public class BranchGroup extends Group {
-
- /**
- * For BranchGroup nodes, specifies that this BranchGroup allows detaching
- * from its parent.
- */
- public static final int
- ALLOW_DETACH = CapabilityBits.BRANCH_GROUP_ALLOW_DETACH;
-
- /**
- * Constructs and initializes a new BranchGroup node object.
- */
- public BranchGroup() {
- }
-
- /**
- * Creates the retained mode BranchGroupRetained object that this
- * BranchGroup component object will point to.
- */
- @Override
- void createRetained() {
- this.retained = new BranchGroupRetained();
- this.retained.setSource(this);
- }
-
-
- /**
- * Compiles the source BranchGroup associated with this object and
- * creates and caches a compiled scene graph.
- * @exception SceneGraphCycleException if there is a cycle in the
- * scene graph
- * @exception RestrictedAccessException if the method is called
- * when this object is part of a live scene graph.
- */
- public void compile() {
- if (isLive()) {
- throw new RestrictedAccessException(
- J3dI18N.getString("BranchGroup0"));
- }
-
- if (isCompiled() == false) {
- // will throw SceneGraphCycleException if there is a cycle
- // in the scene graph
- checkForCycle();
-
- ((BranchGroupRetained)this.retained).compile();
- }
- }
-
- /**
- * Detaches this BranchGroup from its parent.
- */
- public void detach() {
- Group parent;
-
- if (isLiveOrCompiled()) {
- if(!this.getCapability(ALLOW_DETACH))
- throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup1"));
-
- if (((BranchGroupRetained)this.retained).parent != null) {
- parent = (Group)((BranchGroupRetained)this.retained).parent.source;
- if(!parent.getCapability(Group.ALLOW_CHILDREN_WRITE))
- throw new CapabilityNotSetException(J3dI18N.getString("BranchGroup2"));
- }
- }
-
- ((BranchGroupRetained)this.retained).detach();
- }
-
-
- void validateModeFlagAndPickShape(int mode, int flags, PickShape pickShape) {
-
- if(isLive()==false) {
- throw new IllegalStateException(J3dI18N.getString("BranchGroup3"));
- }
-
- if((mode != PickInfo.PICK_BOUNDS) && (mode != PickInfo.PICK_GEOMETRY)) {
-
- throw new IllegalArgumentException(J3dI18N.getString("BranchGroup4"));
- }
-
- if((pickShape instanceof PickPoint) && (mode == PickInfo.PICK_GEOMETRY)) {
- throw new IllegalArgumentException(J3dI18N.getString("BranchGroup5"));
- }
-
- if(((flags & PickInfo.CLOSEST_GEOM_INFO) != 0) &&
- ((flags & PickInfo.ALL_GEOM_INFO) != 0)) {
- throw new IllegalArgumentException(J3dI18N.getString("BranchGroup6"));
- }
-
- if((mode == PickInfo.PICK_BOUNDS) &&
- (((flags & (PickInfo.CLOSEST_GEOM_INFO |
- PickInfo.ALL_GEOM_INFO |
- PickInfo.CLOSEST_DISTANCE |
- PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) {
-
- throw new IllegalArgumentException(J3dI18N.getString("BranchGroup7"));
- }
-
- if((pickShape instanceof PickBounds) &&
- (((flags & (PickInfo.CLOSEST_GEOM_INFO |
- PickInfo.ALL_GEOM_INFO |
- PickInfo.CLOSEST_DISTANCE |
- PickInfo.CLOSEST_INTERSECTION_POINT)) != 0))) {
-
- throw new IllegalArgumentException(J3dI18N.getString("BranchGroup8"));
- }
-
- }
-
- /**
- * Returns an array referencing all the items that are pickable below this
- * BranchGroup that intersect with PickShape.
- * The resultant array is unordered.
- *
- * @param pickShape the PickShape object
- *
- * @see SceneGraphPath
- * @see Locale#pickAll
- * @see PickShape
- * @exception IllegalStateException if BranchGroup is not live.
- *
- */
- public SceneGraphPath[] pickAll( PickShape pickShape ) {
-
- if(isLive()==false)
- throw new IllegalStateException(J3dI18N.getString("BranchGroup3"));
-
- return ((BranchGroupRetained)this.retained).pickAll(pickShape);
-
- }
-
- /**
- * Returns an array unsorted references to all the PickInfo objects that are
- * pickable below this BranchGroup that intersect with PickShape.
- * The accuracy of the pick is set by the pick mode. The mode include :
- * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
- * is specified via a masked variable, flags, indicating which components are
- * present in each returned PickInfo object.
- *
- * @param mode picking mode, one of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.
- *
- * @param flags a mask indicating which components are present in each PickInfo object.
- * This is specified as one or more individual bits that are bitwise "OR"ed together to
- * describe the PickInfo data. The flags include :
- *
- * PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath.
- * PickInfo.NODE - request for computed intersected Node.
- * PickInfo.LOCAL_TO_VWORLD - request for computed local to virtual world transform.
- * PickInfo.CLOSEST_INTERSECTION_POINT - request for closest intersection point.
- * PickInfo.CLOSEST_DISTANCE - request for the distance of closest intersection.
- * PickInfo.CLOSEST_GEOM_INFO - request for only the closest intersection geometry information.
- * PickInfo.ALL_GEOM_INFO - request for all intersection geometry information.
- *
- *
- * @param pickShape the description of this picking volume or area.
- *
- * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
- * ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
- * is set to PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
- * nor PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is PickBounds
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalStateException if BranchGroup is not live.
- *
- * @exception CapabilityNotSetException if the mode is
- * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
- * is not set in any Geometry objects referred to by any shape
- * node whose bounds intersects the PickShape.
- *
- * @exception CapabilityNotSetException if flags contains any of
- * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
- * or ALL_GEOM_INFO, and the capability bits that control reading of
- * coordinate data are not set in any GeometryArray object referred
- * to by any shape node that intersects the PickShape.
- * The capability bits that must be set to avoid this exception are as follows :
- *
Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
- * (in addition to one of the above)
- *
- *
- * @see Locale#pickAll(int,int,javax.media.j3d.PickShape)
- * @see PickInfo
- *
- * @since Java 3D 1.4
- *
- */
-
- public PickInfo[] pickAll( int mode, int flags, PickShape pickShape ) {
-
- validateModeFlagAndPickShape(mode, flags, pickShape);
- return ((BranchGroupRetained)this.retained).pickAll(mode, flags, pickShape);
-
- }
-
-
- /**
- * Returns a sorted array of references to all the Pickable items that
- * intersect with the pickShape. Element [0] references the item closest
- * to origin of PickShape successive array elements are further
- * from the origin
- *
- * Note: If pickShape is of type PickBounds, the resulting array
- * is unordered.
- * @param pickShape the PickShape object
- *
- * @see SceneGraphPath
- * @see Locale#pickAllSorted
- * @see PickShape
- * @exception IllegalStateException if BranchGroup is not live.
- *
- */
- public SceneGraphPath[] pickAllSorted( PickShape pickShape ) {
-
- if(isLive()==false)
- throw new IllegalStateException(J3dI18N.getString("BranchGroup3"));
-
- return ((BranchGroupRetained)this.retained).pickAllSorted(pickShape);
-
- }
-
-
- /**
- * Returns a sorted array of PickInfo references to all the pickable
- * items that intersect with the pickShape. Element [0] references
- * the item closest to origin of PickShape successive array
- * elements are further from the origin
- * The accuracy of the pick is set by the pick mode. The mode include :
- * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
- * is specified via a masked variable, flags, indicating which components are
- * present in each returned PickInfo object.
- *
- * @param mode picking mode, one of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.
- *
- * @param flags a mask indicating which components are present in each PickInfo object.
- * This is specified as one or more individual bits that are bitwise "OR"ed together to
- * describe the PickInfo data. The flags include :
- *
- * PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath.
- * PickInfo.NODE - request for computed intersected Node.
- * PickInfo.LOCAL_TO_VWORLD - request for computed local to virtual world transform.
- * PickInfo.CLOSEST_INTERSECTION_POINT - request for closest intersection point.
- * PickInfo.CLOSEST_DISTANCE - request for the distance of closest intersection.
- * PickInfo.CLOSEST_GEOM_INFO - request for only the closest intersection geometry information.
- * PickInfo.ALL_GEOM_INFO - request for all intersection geometry information.
- *
- *
- * @param pickShape the description of this picking volume or area.
- *
- * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
- * ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
- * is set to PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
- * nor PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is PickBounds
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalStateException if BranchGroup is not live.
- *
- * @exception CapabilityNotSetException if the mode is
- * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
- * is not set in any Geometry objects referred to by any shape
- * node whose bounds intersects the PickShape.
- *
- * @exception CapabilityNotSetException if flags contains any of
- * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
- * or ALL_GEOM_INFO, and the capability bits that control reading of
- * coordinate data are not set in any GeometryArray object referred
- * to by any shape node that intersects the PickShape.
- * The capability bits that must be set to avoid this exception are as follows :
- *
Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
- * (in addition to one of the above)
- *
- *
- * @see Locale#pickAllSorted(int,int,javax.media.j3d.PickShape)
- * @see PickInfo
- *
- * @since Java 3D 1.4
- *
- */
- public PickInfo[] pickAllSorted( int mode, int flags, PickShape pickShape ) {
-
- validateModeFlagAndPickShape(mode, flags, pickShape);
- return ((BranchGroupRetained)this.retained).pickAllSorted(mode, flags, pickShape);
-
- }
-
- /**
- * Returns a SceneGraphPath that references the pickable item
- * closest to the origin of pickShape.
- *
- * Note: If pickShape is of type PickBounds, the return is any pickable node
- * below this BranchGroup.
- * @param pickShape the PickShape object
- *
- * @see SceneGraphPath
- * @see Locale#pickClosest
- * @see PickShape
- * @exception IllegalStateException if BranchGroup is not live.
- *
- */
- public SceneGraphPath pickClosest( PickShape pickShape ) {
-
- if(isLive()==false)
- throw new IllegalStateException(J3dI18N.getString("BranchGroup3"));
-
- return ((BranchGroupRetained)this.retained).pickClosest(pickShape);
-
- }
-
- /**
- * Returns a PickInfo which references the pickable item
- * which is closest to the origin of pickShape.
- * The accuracy of the pick is set by the pick mode. The mode include :
- * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
- * is specified via a masked variable, flags, indicating which components are
- * present in each returned PickInfo object.
- *
- * @param mode picking mode, one of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.
- *
- * @param flags a mask indicating which components are present in each PickInfo object.
- * This is specified as one or more individual bits that are bitwise "OR"ed together to
- * describe the PickInfo data. The flags include :
- *
- * PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath.
- * PickInfo.NODE - request for computed intersected Node.
- * PickInfo.LOCAL_TO_VWORLD - request for computed local to virtual world transform.
- * PickInfo.CLOSEST_INTERSECTION_POINT - request for closest intersection point.
- * PickInfo.CLOSEST_DISTANCE - request for the distance of closest intersection.
- * PickInfo.CLOSEST_GEOM_INFO - request for only the closest intersection geometry information.
- * PickInfo.ALL_GEOM_INFO - request for all intersection geometry information.
- *
- *
- * @param pickShape the description of this picking volume or area.
- *
- * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
- * ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
- * is set to PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
- * nor PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is PickBounds
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalStateException if BranchGroup is not live.
- *
- * @exception CapabilityNotSetException if the mode is
- * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
- * is not set in any Geometry objects referred to by any shape
- * node whose bounds intersects the PickShape.
- *
- * @exception CapabilityNotSetException if flags contains any of
- * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
- * or ALL_GEOM_INFO, and the capability bits that control reading of
- * coordinate data are not set in any GeometryArray object referred
- * to by any shape node that intersects the PickShape.
- * The capability bits that must be set to avoid this exception are as follows :
- *
Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
- * (in addition to one of the above)
- *
- *
- * @see Locale#pickClosest(int,int,javax.media.j3d.PickShape)
- * @see PickInfo
- *
- * @since Java 3D 1.4
- *
- */
- public PickInfo pickClosest( int mode, int flags, PickShape pickShape ) {
-
- validateModeFlagAndPickShape(mode, flags, pickShape);
- return ((BranchGroupRetained)this.retained).pickClosest(mode, flags, pickShape);
-
- }
-
-
- /**
- * Returns a reference to any item that is Pickable below this BranchGroup that
- * intersects with pickShape.
- * @param pickShape the PickShape object
- *
- * @see SceneGraphPath
- * @see Locale#pickAny
- * @see PickShape
- * @exception IllegalStateException if BranchGroup is not live.
- *
- */
- public SceneGraphPath pickAny( PickShape pickShape ) {
-
- if(isLive()==false)
- throw new IllegalStateException(J3dI18N.getString("BranchGroup3"));
-
- return ((BranchGroupRetained)this.retained).pickAny(pickShape);
-
- }
-
- /**
- * Returns a PickInfo which references the pickable item below this
- * BranchGroup that intersects with pickShape.
- * The accuracy of the pick is set by the pick mode. The mode include :
- * PickInfo.PICK_BOUNDS and PickInfo.PICK_GEOMETRY. The amount of information returned
- * is specified via a masked variable, flags, indicating which components are
- * present in each returned PickInfo object.
- *
- * @param mode picking mode, one of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY.
- *
- * @param flags a mask indicating which components are present in each PickInfo object.
- * This is specified as one or more individual bits that are bitwise "OR"ed together to
- * describe the PickInfo data. The flags include :
- *
- * PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath.
- * PickInfo.NODE - request for computed intersected Node.
- * PickInfo.LOCAL_TO_VWORLD - request for computed local to virtual world transform.
- * PickInfo.CLOSEST_INTERSECTION_POINT - request for closest intersection point.
- * PickInfo.CLOSEST_DISTANCE - request for the distance of closest intersection.
- * PickInfo.CLOSEST_GEOM_INFO - request for only the closest intersection geometry information.
- * PickInfo.ALL_GEOM_INFO - request for all intersection geometry information.
- *
- *
- * @param pickShape the description of this picking volume or area.
- *
- * @exception IllegalArgumentException if flags contains both CLOSEST_GEOM_INFO and
- * ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is a PickPoint and pick mode
- * is set to PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is neither PICK_BOUNDS
- * nor PICK_GEOMETRY.
- *
- * @exception IllegalArgumentException if pick mode is PICK_BOUNDS
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalArgumentException if pickShape is PickBounds
- * and flags includes any of CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE,
- * CLOSEST_GEOM_INFO or ALL_GEOM_INFO.
- *
- * @exception IllegalStateException if BranchGroup is not live.
- *
- * @exception CapabilityNotSetException if the mode is
- * PICK_GEOMETRY and the Geometry.ALLOW_INTERSECT capability bit
- * is not set in any Geometry objects referred to by any shape
- * node whose bounds intersects the PickShape.
- *
- * @exception CapabilityNotSetException if flags contains any of
- * CLOSEST_INTERSECTION_POINT, CLOSEST_DISTANCE, CLOSEST_GEOM_INFO
- * or ALL_GEOM_INFO, and the capability bits that control reading of
- * coordinate data are not set in any GeometryArray object referred
- * to by any shape node that intersects the PickShape.
- * The capability bits that must be set to avoid this exception are as follows :
- *
Indexed geometry : IndexedGeometryArray.ALLOW_COORDINATE_INDEX_READ
- * (in addition to one of the above)
- *
- *
- * @see Locale#pickAny(int,int,javax.media.j3d.PickShape)
- * @see PickInfo
- *
- * @since Java 3D 1.4
- *
- */
- public PickInfo pickAny( int mode, int flags, PickShape pickShape ) {
-
- validateModeFlagAndPickShape(mode, flags, pickShape);
- return ((BranchGroupRetained)this.retained).pickAny(mode, flags, pickShape);
-
- }
-
- /**
- * Creates a new instance of the node. This routine is called
- * by cloneTree to duplicate the current node.
- * @param forceDuplicate when set to true, causes the
- * duplicateOnCloneTree flag to be ignored. When
- * false, the value of each node's
- * duplicateOnCloneTree variable determines whether
- * NodeComponent data is duplicated or copied.
- *
- * @see Node#cloneTree
- * @see Node#cloneNode
- * @see Node#duplicateNode
- * @see NodeComponent#setDuplicateOnCloneTree
- */
- @Override
- public Node cloneNode(boolean forceDuplicate) {
-
- BranchGroup bg = new BranchGroup();
- bg.duplicateNode(this, forceDuplicate);
- return bg;
-
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/BranchGroupRetained.java b/src/classes/share/javax/media/j3d/BranchGroupRetained.java
deleted file mode 100644
index 47372d0..0000000
--- a/src/classes/share/javax/media/j3d/BranchGroupRetained.java
+++ /dev/null
@@ -1,377 +0,0 @@
-/*
- * Copyright 1996-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-import java.util.ArrayList;
-
-/**
- * The BranchGroup node provides the ability to insert a branch of
- * a scene graph into the virtual world.
- */
-
-class BranchGroupRetained extends GroupRetained {
-
- // This boolean is used in a moveTo operation to get transforms to update
- boolean isDirty = false;
-
- // This boolean is used when the BG is inserted into the scene
- boolean isNew = false;
-
- /**
- * True, if this branchGroup is directly attached to the locale
- */
- boolean attachedToLocale = false;
-
-
- BranchGroupRetained() {
- this.nodeType = NodeRetained.BRANCHGROUP;
- }
-
- /**
- * This sets the current locale.
- */
- void setLocale(Locale loc) {
- locale = loc;
- }
-
- /**
- * This gets the current locale
- */
- @Override
- Locale getLocale() {
- return locale;
- }
-
- /**
- * Detaches this BranchGroup from its parent.
- */
- void detach() {
- dirtyBoundsCache();
- if (universe != null) {
- universe.resetWaitMCFlag();
- synchronized (universe.sceneGraphLock) {
- boolean isLive = source.isLive();
- if (isLive) {
- notifySceneGraphChanged(true);
- }
- GroupRetained oldParent = (GroupRetained)parent;
- do_detach();
- universe.setLiveState.clear();
- if (isLive) {
- if (oldParent==null) {
- universe.notifyStructureChangeListeners(false,locale,(BranchGroup)this.source);
- } else {
- universe.notifyStructureChangeListeners(false,oldParent.source, (BranchGroup)this.source);
- }
- }
- }
- universe.waitForMC();
- } else { // Not live yet, just do it.
- this.do_detach();
- if (universe != null) {
- synchronized (universe.sceneGraphLock) {
- universe.setLiveState.clear();
- }
- }
- }
- }
-
- // The method that does the work once the lock is acquired.
- void do_detach() {
- if (attachedToLocale) {
- locale.doRemoveBranchGraph((BranchGroup)this.source, null, 0);
- } else if (parent != null) {
- GroupRetained g = (GroupRetained)parent;
- g.doRemoveChild(g.children.indexOf(this), null, 0);
- }
- }
-
- @Override
- void setNodeData(SetLiveState s) {
- // super.setNodeData will set branchGroupPaths
- // based on s.parentBranchGroupPaths, we need to
- // set it earlier in order to undo the effect.
- s.parentBranchGroupPaths = branchGroupPaths;
-
- super.setNodeData(s);
-
- if (!inSharedGroup) {
- setAuxData(s, 0, 0);
- } else {
- // For inSharedGroup case.
- int j, hkIndex;
- for(j=0; j= 0) {
- setAuxData(s, j, hkIndex);
-
- } else {
- // XXXX: change this to an assertion exception
- MasterControl.getCoreLogger().severe("Can't Find matching hashKey in setNodeData.");
- }
- }
- }
- }
-
-
- @Override
- void setAuxData(SetLiveState s, int index, int hkIndex) {
- super.setAuxData(s, index, hkIndex);
-
- BranchGroupRetained path[] = s.branchGroupPaths.get(index);
- BranchGroupRetained clonePath[] = new BranchGroupRetained[path.length + 1];
- System.arraycopy(path, 0, clonePath, 0, path.length);
- clonePath[path.length] = this;
- s.branchGroupPaths.set(index, clonePath);
- branchGroupPaths.add(hkIndex, clonePath);
- }
-
-
- /**
- * remove the localToVworld transform for this node.
- */
- @Override
- void removeNodeData(SetLiveState s) {
-
- if((!inSharedGroup) || (s.keys.length == localToVworld.length)) {
- // restore to default and avoid calling clear()
- // that may clear parent reference branchGroupPaths
- branchGroupPaths = new ArrayList(1);
- }
- else {
- int i, index;
- // Must be in reverse, to preserve right indexing.
- for (i = s.keys.length-1; i >= 0; i--) {
- index = s.keys[i].equals(localToVworldKeys, 0, localToVworldKeys.length);
- if(index >= 0) {
- branchGroupPaths.remove(index);
- }
- }
- // Set it back to its parent localToVworld data. This is b/c the parent has
- // changed it localToVworld data arrays.
- }
- super.removeNodeData(s);
- }
-
- @Override
- void setLive(SetLiveState s) {
- // recursively call child
- super.doSetLive(s);
- super.markAsLive();
- }
-
-
- // Top level compile call
- void compile() {
-
- if (source.isCompiled() || VirtualUniverse.mc.disableCompile)
- return;
-
- if (J3dDebug.devPhase && J3dDebug.debug) {
- J3dDebug.doDebug(J3dDebug.compileState, J3dDebug.LEVEL_3,
- "BranchGroupRetained.compile()....\n");
- }
-
- CompileState compState = new CompileState();
-
- isRoot = true;
-
- compile(compState);
- merge(compState);
-
- if (J3dDebug.devPhase && J3dDebug.debug) {
- if (J3dDebug.doDebug(J3dDebug.compileState, J3dDebug.LEVEL_3)) {
- compState.printStats();
- }
- if (J3dDebug.doDebug(J3dDebug.compileState, J3dDebug.LEVEL_5)) {
- this.traverse(false, 1);
- System.err.println();
- }
- }
- }
-
- @Override
- void compile(CompileState compState) {
- // if this branch group is previously compiled, don't
- // go any further. Mark the keepTG flag for now. Static
- // transform doesn't go beyond previously compiled group.
-
- if (mergeFlag == SceneGraphObjectRetained.MERGE_DONE) {
- compState.keepTG = true;
- return;
- }
-
- super.compile(compState);
-
- // don't remove this node because user can do pickAll on this node
- // without any capabilities set
- mergeFlag = SceneGraphObjectRetained.DONT_MERGE;
- }
-
- SceneGraphPath[] pickAll(PickShape pickShape) {
-
- PickInfo[] pickInfoArr = pickAll(PickInfo.PICK_BOUNDS,
- PickInfo.SCENEGRAPHPATH, pickShape);
-
- if(pickInfoArr == null) {
- return null;
- }
-
- SceneGraphPath[] sgpArr = new SceneGraphPath[pickInfoArr.length];
- for( int i=0; i upper.x) upper.x = verts[i].x; // xmax
- if( verts[i].x < lower.x) lower.x = verts[i].x; // xmin
-
- if( verts[i].y > upper.y) upper.y = verts[i].y; // ymay
- if( verts[i].y < lower.y) lower.y = verts[i].y; // ymin
-
- if( verts[i].z > upper.z) upper.z = verts[i].z; // zmaz
- if( verts[i].z < lower.z) lower.z = verts[i].z; // zmin
-
- center.x += verts[i].x;
- center.y += verts[i].y;
- center.z += verts[i].z;
- }
-
- center.x = center.x*0.125;
- center.y = center.y*0.125;
- center.z = center.z*0.125;
-
- }
-
- private void computeVertex( int a, int b, int c, Point3d vert) {
- double det;
-
- det = clipPlanes[a].x*clipPlanes[b].y*clipPlanes[c].z + clipPlanes[a].y*clipPlanes[b].z*clipPlanes[c].x +
- clipPlanes[a].z*clipPlanes[b].x*clipPlanes[c].y - clipPlanes[a].z*clipPlanes[b].y*clipPlanes[c].x -
- clipPlanes[a].y*clipPlanes[b].x*clipPlanes[c].z - clipPlanes[a].x*clipPlanes[b].z*clipPlanes[c].y;
-
-
- if( det*det < EPSILON ){
- // System.err.println("************** Two planes are parallel : det = " + det);
- return; // two planes are parallel
- }
-
- det = 1.0/det;
-
- vert.x = (clipPlanes[b].y*clipPlanes[c].z - clipPlanes[b].z*clipPlanes[c].y) * -clipPlanes[a].w;
- vert.y = (clipPlanes[b].z*clipPlanes[c].x - clipPlanes[b].x*clipPlanes[c].z) * -clipPlanes[a].w;
- vert.z = (clipPlanes[b].x*clipPlanes[c].y - clipPlanes[b].y*clipPlanes[c].x) * -clipPlanes[a].w;
-
- vert.x += (clipPlanes[c].y*clipPlanes[a].z - clipPlanes[c].z*clipPlanes[a].y) * -clipPlanes[b].w;
- vert.y += (clipPlanes[c].z*clipPlanes[a].x - clipPlanes[c].x*clipPlanes[a].z) * -clipPlanes[b].w;
- vert.z += (clipPlanes[c].x*clipPlanes[a].y - clipPlanes[c].y*clipPlanes[a].x) * -clipPlanes[b].w;
-
- vert.x += (clipPlanes[a].y*clipPlanes[b].z - clipPlanes[a].z*clipPlanes[b].y) * -clipPlanes[c].w;
- vert.y += (clipPlanes[a].z*clipPlanes[b].x - clipPlanes[a].x*clipPlanes[b].z) * -clipPlanes[c].w;
- vert.z += (clipPlanes[a].x*clipPlanes[b].y - clipPlanes[a].y*clipPlanes[b].x) * -clipPlanes[c].w;
-
- vert.x = vert.x*det;
- vert.y = vert.y*det;
- vert.z = vert.z*det;
-
- }
-
-}
diff --git a/src/classes/share/javax/media/j3d/CachedTargets.java b/src/classes/share/javax/media/j3d/CachedTargets.java
deleted file mode 100644
index 0723d4c..0000000
--- a/src/classes/share/javax/media/j3d/CachedTargets.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- */
-
-package javax.media.j3d;
-
-class CachedTargets {
- // cached targets, used by J3d threads
-
- // 0 - Data type is GeometryAtom.
- // 1 - Data type is Light, Fog, Background, ModelClip, AlternateAppearance,
- // Clip
- // 2 - Data type is BehaviorRetained.
- // 3 - Data type is Sound or Soundscape
- // 4 - Data type is ViewPlatformRetained.
- // 5 - Data type is BoundingLeafRetained.
- // 6 - Data type is GroupRetained.
-
- // Order of index is as above.
- // The handling of BoundingLeaf isn't optimize. Target threads should be
- // more specific.
-
- static String typeString[] = {
- "GEO_TARGETS",
- "ENV_TARGETS",
- "BEH_TARGETS",
- "SND_TARGETS",
- "VPF_TARGETS",
- "BLN_TARGETS",
- "GRP_TARGETS",
- };
-
- static int updateTargetThreads[] = {
- // GEO
- J3dThread.UPDATE_TRANSFORM | J3dThread.UPDATE_RENDER |
- J3dThread.UPDATE_GEOMETRY,
-
- // ENV
- J3dThread.UPDATE_RENDER | J3dThread.UPDATE_RENDERING_ENVIRONMENT,
-
- // BEH
- J3dThread.UPDATE_BEHAVIOR,
-
- // SND
- J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER,
-
- // VPF
- J3dThread.UPDATE_RENDER | J3dThread.UPDATE_BEHAVIOR |
- J3dThread.UPDATE_SOUND | J3dThread.SOUND_SCHEDULER,
-
- // BLN
- J3dThread.UPDATE_RENDER | J3dThread.UPDATE_RENDERING_ENVIRONMENT |
- J3dThread.UPDATE_BEHAVIOR | J3dThread.UPDATE_SOUND,
-
- // GRP
- J3dThread.UPDATE_TRANSFORM | J3dThread.UPDATE_GEOMETRY
- };
-
-
- NnuId targetArr[][] = new NnuId[Targets.MAX_NODELIST][];
-
- int computeTargetThreads() {
- int targetThreads = 0;
-
- for (int i=0; i < Targets.MAX_NODELIST; i++) {
- if (targetArr[i] != null) {
- targetThreads |= updateTargetThreads[i];
- }
- }
- return targetThreads;
- }
-
- void copy( CachedTargets ct ) {
-
- for(int i=0; i
- * 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
- * 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
- * off-screen rendering.
- * On-screen Canvas3Ds are added to AWT or Swing Container objects
- * like any other canvas. Java 3D automatically and continuously
- * renders to all on-screen canvases that are attached to an active
- * View object. On-screen Canvas3Ds can be either single or double
- * buffered and they can be either stereo or monoscopic.
- *
- * Off-screen Canvas3Ds must not be added to any Container. Java 3D
- * renders to off-screen canvases in response to the
- * renderOffScreenBuffer method. Off-screen Canvas3Ds
- * are single buffered. However, on many systems, the actual
- * rendering is done to an off-screen hardware buffer or to a 3D
- * library-specific buffer and only copied to the off-screen buffer of
- * 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
- * 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
- * exception.
- *
- * 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
- * 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
- * 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
- * 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
- * when the windowEyepointPolicy is RELATIVE_TO_FIELD_OF_VIEW or
- * 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
- * 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
- * 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
- * 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
- * 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,
- * rendering the right and left eye for stereo viewing becomes the
- * 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
- * attached to a live ViewPlatform object).
- *
- * Other Canvas3D methods related to immediate mode rendering are:
- *
- *
- * getGraphicsContext3D retrieves the immediate-mode
- * 3D graphics context associated with this Canvas3D. It creates a
- * new graphics context if one does not already exist.
- *
- * getGraphics2D retrieves the
- * 2D graphics object associated with this Canvas3D. It creates a
- * new 2D graphics object if one does not already exist.
- *
- * swap synchronizes and swaps buffers on a
- * double-buffered canvas for this Canvas3D object. This method
- * should only be called if the Java 3D renderer has been stopped.
- * In the normal case, the renderer automatically swaps
- * the buffer.
- *
- *
- *
- * 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
- * graph into the canvas.
- *
- *
- * Canvas3D methods related to mixed mode rendering are:
- *
- *
- *
- * preRender called by the Java 3D rendering loop after
- * clearing the canvas and before any rendering has been done for
- * this frame.
- *
- * postRender called by the Java 3D rendering loop after
- * completing all rendering to the canvas for this frame and before
- * the buffer swap.
- *
- * postSwap called by the Java 3D rendering loop after
- * completing all rendering to the canvas, and all other canvases
- * associated with this view, for this frame following the
- * buffer swap.
- *
- * renderField called by the Java 3D rendering loop
- * during the execution of the rendering loop. It is called once
- * for each field (i.e., once per frame on a mono system or once
- * each for the right eye and left eye on a two-pass stereo system.
- *
- *
- * 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,
- * executed for each Canvas3D, is as follows:
- *
- * clear canvas (both eyes)
- * call preRender() // user-supplied method
- * set left eye view
- * render opaque scene graph objects
- * call renderField(FIELD_LEFT) // user-supplied method
- * render transparent scene graph objects
- * set right eye view
- * render opaque scene graph objects again
- * call renderField(FIELD_RIGHT) // user-supplied method
- * render transparent scene graph objects again
- * call postRender() // user-supplied method
- * synchronize and swap buffers
- * call postSwap() // user-supplied method
- *
- *
- * The basic Java 3D monoscopic rendering loop 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
- * methods.
- * Updates to live Geometry, Texture, and ImageComponent objects
- * in the scene graph are not allowed from any of these callback
- * methods.
- *
- *
- * Serialization
- *
- * Canvas3D does not support serialization. An attempt to
- * serialize a Canvas3D object will result in an
- * UnsupportedOperationException being thrown.
- *
- *
- * Additional Information
- *
- * For more information, see the
- * Introduction to the Java 3D API and
- * View Model
- * documents.
- *
- * @see Screen3D
- * @see View
- * @see GraphicsContext3D
- */
-public class Canvas3D extends Canvas {
- /**
- * Specifies the left field of a field-sequential stereo rendering loop.
- * A left field always precedes a right field.
- */
- public static final int FIELD_LEFT = 0;
-
- /**
- * Specifies the right field of a field-sequential stereo rendering loop.
- * A right field always follows a left field.
- */
- public static final int FIELD_RIGHT = 1;
-
- /**
- * Specifies a single-field rendering loop.
- */
- 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;
- static final int POINTATTRS_DIRTY = 0x04;
- static final int MATERIAL_DIRTY = 0x08;
- static final int TRANSPARENCYATTRS_DIRTY = 0x10;
- static final int COLORINGATTRS_DIRTY = 0x20;
-
- // Values for lightbin, env set, texture, texture setting etc.
- static final int LIGHTBIN_DIRTY = 0x40;
- static final int LIGHTENABLES_DIRTY = 0x80;
- static final int AMBIENTLIGHT_DIRTY = 0x100;
- static final int ATTRIBUTEBIN_DIRTY = 0x200;
- static final int TEXTUREBIN_DIRTY = 0x400;
- 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 VIEW_MATRIX_DIRTY = 0x8000;
- // static final int SHADER_DIRTY = 0x10000; Not ready for this yet -- JADA
-
- //
- // Flag that indicates whether this Canvas3D is an off-screen Canvas3D
- //
- boolean offScreen = false;
-
- //
- // Issue 131: Flag that indicates whether this Canvas3D is a manually
- // rendered Canvas3D (versus an automatically rendered Canvas3D).
- //
- // NOTE: manualRendering only applies to off-screen Canvas3Ds at this time.
- // We have no plans to ever change this, but if we do, it might be necessary
- // to determine which, if any, of the uses of "manualRendering" should be
- // changed to "manualRendering&&offScreen"
- //
- boolean manualRendering = false;
-
- // user specified offScreen Canvas location
- Point offScreenCanvasLoc;
-
- // user specified offScreen Canvas dimension
- Dimension offScreenCanvasSize;
-
- //
- // Flag that indicates whether off-screen rendering is in progress or not
- //
- volatile boolean offScreenRendering = false;
-
- //
- // Flag that indicates we are waiting for an off-screen buffer to be
- // created or destroyed by the Renderer.
- //
- volatile boolean offScreenBufferPending = false;
-
- //
- // ImageComponent used for off-screen rendering
- //
- ImageComponent2D offScreenBuffer = null;
-
- // flag that indicates whether this canvas will use shared context
- boolean useSharedCtx = true;
-
- //
- // Read-only flag that indicates whether stereo is supported for this
- // canvas. This is always false for off-screen canvases.
- //
- boolean stereoAvailable;
-
- //
- // Flag to enable stereo rendering, if allowed by the
- // stereoAvailable flag.
- //
- boolean stereoEnable = true;
-
- //
- // This flag is set when stereo mode is both enabled and
- // available. Code that looks at stereo mode should use this
- // flag.
- //
- boolean useStereo;
-
- // Indicate whether it is left or right stereo pass currently
- boolean rightStereoPass = false;
-
- //
- // Specifies how Java 3D generates monoscopic view
- // (LEFT_EYE_VIEW, RIGHT_EYE_VIEW, or CYCLOPEAN_EYE_VIEW).
- //
- int monoscopicViewPolicy = View.CYCLOPEAN_EYE_VIEW;
-
- // User requested stencil size
- int requestedStencilSize;
-
- // Actual stencil size return for this canvas
- int actualStencilSize;
-
- // True if stencil buffer is available for user
- boolean userStencilAvailable;
-
- // True if stencil buffer is available for system ( decal )
- boolean systemStencilAvailable;
-
- //
- // Read-only flag that indicates whether double buffering is supported
- // for this canvas. This is always false for off-screen canvases.
- //
- boolean doubleBufferAvailable;
-
- //
- // Flag to enable double buffered rendering, if allowed by the
- // doubleBufferAvailable flag.
- //
- boolean doubleBufferEnable = true;
-
- //
- // This flag is set when doubleBuffering is both enabled and
- // available Code that enables or disables double buffering should
- // use this flag.
- //
- boolean useDoubleBuffer;
-
- //
- // Read-only flag that indicates whether scene antialiasing
- // is supported for this canvas.
- //
- boolean sceneAntialiasingAvailable;
- boolean sceneAntialiasingMultiSamplesAvailable;
-
- // Use to see whether antialiasing is already set
- private boolean antialiasingSet = false;
-
- //
- // Read-only flag that indicates the size of the texture color
- // table for this canvas. A value of 0 indicates that the texture
- // color table is not supported.
- //
- int textureColorTableSize;
-
- // number of active/enabled texture unit
- int numActiveTexUnit = 0;
-
- // index iof last enabled texture unit
- int lastActiveTexUnit = -1;
-
- // True if shadingLanguage is supported, otherwise false.
- boolean shadingLanguageGLSL = false;
-
- // Query properties
- J3dQueryProps queryProps;
-
- // Flag indicating a fatal rendering error of some sort
- private boolean fatalError = false;
-
- //
- // The positions of the manual left and right eyes in image-plate
- // coordinates.
- // By default, we will use the center of the screen for X and Y values
- // (X values are adjusted for default eye separation), and
- // 0.4572 meters (18 inches) for the Z value.
- // These match defaults elsewhere in the system.
- //
- Point3d leftManualEyeInImagePlate = new Point3d(0.142, 0.135, 0.4572);
- Point3d rightManualEyeInImagePlate = new Point3d(0.208, 0.135, 0.4572);
-
- //
- // View that is attached to this Canvas3D.
- //
- View view = null;
-
- // View waiting to be set
- View pendingView;
-
- //
- // 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
- // false during checkForCompaction in renderBin
- boolean raIsVisible = false;
-
- RenderAtom ra = null;
-
- // Stereo related field has changed.
- static final int STEREO_DIRTY = 0x01;
- // MonoscopicViewPolicy field has changed.
- static final int MONOSCOPIC_VIEW_POLICY_DIRTY = 0x02;
- // 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;
-
- // Canvas Background changed (this may affect doInfinite flag)
- static final int BACKGROUND_DIRTY = 0x10;
-
- // 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 |
- MONOSCOPIC_VIEW_POLICY_DIRTY |
- EYE_IN_IMAGE_PLATE_DIRTY |
- MOVED_OR_RESIZED_DIRTY |
- BACKGROUND_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
- // instance of CanvasViewCache (due to the fix for Issue 109), they
- // need separate dirty bits. Array element 0 is used for the Renderer and
- // element 1 is used for the RenderBin.
- static final int RENDERER_DIRTY_IDX = 0;
- static final int RENDER_BIN_DIRTY_IDX = 1;
- int[] cvDirtyMask = new int[2];
-
- // This boolean informs the J3DGraphics2DImpl that the window is resized
- boolean resizeGraphics2D = true;
- //
- // This boolean allows an application to start and stop the render
- // loop on this canvas.
- //
- volatile boolean isRunning = true;
-
- // This is used by MasterControl only. MC relay on this in a
- // single loop to set renderer thread. During this time,
- // the isRunningStatus can't change by user thread.
- volatile boolean isRunningStatus = true;
-
- // This is true when the canvas is ready to be rendered into
- boolean active = false;
-
- // This is true when the canvas is visible
- boolean visible = false;
-
- // This is true if context need to recreate
- boolean ctxReset = true;
-
- // The Screen3D that corresponds to this Canvas3D
- Screen3D screen = null;
-
- // Flag to indicate that image is render completely
- // so swap is valid.
- boolean imageReady = false;
-
- // The 3D Graphics context used for immediate mode rendering
- // into this canvas.
- GraphicsContext3D graphicsContext3D = null;
- boolean waiting = false;
- boolean swapDone = false;
-
- GraphicsConfiguration graphicsConfiguration;
-
- // The Java 3D Graphics2D object used for Java2D/AWT rendering
- // into this Canvas3D
- J3DGraphics2DImpl graphics2D = null;
-
- // Lock used to synchronize the creation of the 2D and 3D
- // graphics context objects
- Object gfxCreationLock = new Object();
-
- // The source of the currently loaded localToVWorld for this Canvas3D
- // (used to only update the model matrix when it changes)
- // Transform3D localToVWorldSrc = null;
-
- // The current vworldToEc Transform
- Transform3D vworldToEc = new Transform3D();
-
- // The view transform (VPC to EC) for the current eye.
- // NOTE that this is *read-only*
- Transform3D vpcToEc;
-
- // Opaque object representing the underlying drawable (window). This
- // is defined by the Pipeline.
- Drawable drawable = null;
-
- // graphicsConfigTable is a static hashtable which allows getBestConfiguration()
- // in NativeConfigTemplate3D to map a GraphicsConfiguration to the pointer
- // to the actual GLXFBConfig that glXChooseFBConfig() returns. The Canvas3D
- // doesn't exist at the time getBestConfiguration() is called, and
- // X11GraphicsConfig neither maintains this pointer nor provides a public
- // constructor to allow Java 3D to extend it.
- static Hashtable graphicsConfigTable =
- new Hashtable();
-
- // 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;
-
- // This is the id for the underlying graphics context structure.
- Context ctx = null;
-
- // since the ctx id can be the same as the previous one,
- // we need to keep a time stamp to differentiate the contexts with the
- // same id
- volatile long ctxTimeStamp = 0;
-
- // The current context setting for local eye lighting
- boolean ctxEyeLightingEnable = false;
-
- // 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();
-
- // This MaterialRetained Object refelects the current state of this canvas.
- // It is used to optimize setting of attributes at render time.
- MaterialRetained currentMaterial = new MaterialRetained();
-
- /**
- * The object used for View Frustum Culling
- */
- CachedFrustum viewFrustum = new CachedFrustum();
-
- /**
- * The RenderBin bundle references used to decide what the underlying
- * context contains.
- */
- LightBin lightBin = null;
- EnvironmentSet environmentSet = null;
- AttributeBin attributeBin = null;
- ShaderBin shaderBin = null;
- RenderMolecule renderMolecule = null;
- PolygonAttributesRetained polygonAttributes = null;
- LineAttributesRetained lineAttributes = null;
- PointAttributesRetained pointAttributes = null;
- MaterialRetained material = null;
- boolean enableLighting = false;
- TransparencyAttributesRetained transparency = null;
- ColoringAttributesRetained coloringAttributes = null;
- Transform3D modelMatrix = null;
- Transform3D projTrans = null;
- TextureBin textureBin = null;
-
-
- /**
- * cached RenderBin states for lazy native states update
- */
- LightRetained lights[] = null;
- int frameCount[] = null;
- long enableMask = -1;
- FogRetained fog = null;
- ModelClipRetained modelClip = null;
- Color3f sceneAmbient = new Color3f();
- TextureUnitStateRetained[] texUnitState = null;
-
- /**
- * These cached values are only used in Pure Immediate and Mixed Mode rendering
- */
- TextureRetained texture = null;
- TextureAttributesRetained texAttrs = null;
- TexCoordGenerationRetained texCoordGeneration = null;
- RenderingAttributesRetained renderingAttrs = null;
- AppearanceRetained appearance = null;
-
- ShaderProgramRetained shaderProgram = null;
-
- // only used in Mixed Mode rendering
- Object appHandle = null;
-
- /**
- * Dirty bit to determine if the NodeComponent needs to be re-sent
- * down to the underlying API
- */
- int canvasDirty = 0xffff;
-
- // True when either one of dirtyRenderMoleculeList,
- // dirtyDlistPerRinfoList, dirtyRenderAtomList size > 0
- boolean dirtyDisplayList = false;
-
-ArrayList dirtyRenderMoleculeList = new ArrayList();
-ArrayList dirtyRenderAtomList = new ArrayList();
-// List of (Rm, rInfo) pair of individual dlists that need to be rebuilt
-ArrayList