From 7de355f4569f3b41b22e98a85f031e8dc39e5c3a Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Sat, 31 Dec 2011 14:49:22 -0800 Subject: j3dutils: remove trailing whitespace from all files Signed-off-by: Harvey Harrison --- .../com/sun/j3d/audioengines/AudioEngine.java | 38 +- .../com/sun/j3d/audioengines/AudioEngine3D.java | 72 +- .../com/sun/j3d/audioengines/AudioEngine3DL2.java | 32 +- .../sun/j3d/audioengines/AudioEngineThread.java | 16 +- .../com/sun/j3d/audioengines/AuralParameters.java | 28 +- .../share/com/sun/j3d/audioengines/Sample.java | 60 +- .../audioengines/javasound/JSAuralParameters.java | 6 +- .../sun/j3d/audioengines/javasound/JSChannel.java | 52 +- .../com/sun/j3d/audioengines/javasound/JSClip.java | 28 +- .../javasound/JSDirectionalSample.java | 156 ++-- .../audioengines/javasound/JSPositionalSample.java | 218 +++--- .../sun/j3d/audioengines/javasound/JSSample.java | 86 +-- .../sun/j3d/audioengines/javasound/JSThread.java | 36 +- .../j3d/audioengines/javasound/JavaSoundMixer.java | 132 ++-- .../share/com/sun/j3d/exp/swing/JCanvas3D.java | 14 +- .../com/sun/j3d/internal/ByteBufferWrapper.java | 18 +- .../share/com/sun/j3d/internal/Distance.java | 50 +- .../com/sun/j3d/internal/FloatBufferWrapper.java | 2 +- .../sun/j3d/loaders/IncorrectFormatException.java | 2 +- src/classes/share/com/sun/j3d/loaders/Loader.java | 8 +- .../share/com/sun/j3d/loaders/LoaderBase.java | 20 +- src/classes/share/com/sun/j3d/loaders/Scene.java | 10 +- .../share/com/sun/j3d/loaders/SceneBase.java | 30 +- .../com/sun/j3d/loaders/lw3d/DebugOutput.java | 4 +- .../com/sun/j3d/loaders/lw3d/EnvelopeHandler.java | 2 +- .../j3d/loaders/lw3d/FloatValueInterpolator.java | 20 +- .../com/sun/j3d/loaders/lw3d/ImageScaler.java | 14 +- .../com/sun/j3d/loaders/lw3d/J3dLwoParser.java | 44 +- .../com/sun/j3d/loaders/lw3d/LWOBFileReader.java | 2 +- .../lw3d/LightIntensityPathInterpolator.java | 10 +- .../share/com/sun/j3d/loaders/lw3d/Lw3dLoader.java | 64 +- .../com/sun/j3d/loaders/lw3d/LwLightObject.java | 6 +- .../share/com/sun/j3d/loaders/lw3d/LwoParser.java | 30 +- .../share/com/sun/j3d/loaders/lw3d/LwoSurface.java | 10 +- .../share/com/sun/j3d/loaders/lw3d/LwoTexture.java | 26 +- .../com/sun/j3d/loaders/lw3d/LwsBackground.java | 14 +- .../share/com/sun/j3d/loaders/lw3d/LwsCamera.java | 20 +- .../com/sun/j3d/loaders/lw3d/LwsEnvelope.java | 12 +- .../com/sun/j3d/loaders/lw3d/LwsEnvelopeFrame.java | 8 +- .../loaders/lw3d/LwsEnvelopeLightIntensity.java | 12 +- .../share/com/sun/j3d/loaders/lw3d/LwsFog.java | 10 +- .../share/com/sun/j3d/loaders/lw3d/LwsFrame.java | 94 +-- .../share/com/sun/j3d/loaders/lw3d/LwsLight.java | 36 +- .../share/com/sun/j3d/loaders/lw3d/LwsMotion.java | 74 +- .../share/com/sun/j3d/loaders/lw3d/LwsObject.java | 46 +- .../com/sun/j3d/loaders/lw3d/ParserObject.java | 10 +- .../com/sun/j3d/loaders/lw3d/SequenceLine.java | 36 +- .../com/sun/j3d/loaders/lw3d/SequenceReader.java | 16 +- .../com/sun/j3d/loaders/lw3d/ShapeHolder.java | 34 +- .../j3d/loaders/lw3d/SwitchPathInterpolator.java | 14 +- .../com/sun/j3d/loaders/lw3d/TargaReader.java | 2 +- .../com/sun/j3d/loaders/lw3d/TextfileParser.java | 20 +- .../j3d/loaders/objectfile/DefaultMaterials.java | 2 +- .../com/sun/j3d/loaders/objectfile/ObjectFile.java | 30 +- .../loaders/objectfile/ObjectFileMaterials.java | 6 +- .../j3d/loaders/objectfile/ObjectFileParser.java | 2 +- .../com/sun/j3d/loaders/objectfile/RgbFile.java | 4 +- .../share/com/sun/j3d/utils/applet/JMainFrame.java | 4 +- .../share/com/sun/j3d/utils/applet/MainFrame.java | 28 +- .../sun/j3d/utils/audio/DistanceAttenuation.java | 8 +- .../behaviors/interpolators/CubicSplineCurve.java | 48 +- .../interpolators/CubicSplineSegment.java | 202 +++--- .../interpolators/KBCubicSplineCurve.java | 52 +- .../interpolators/KBCubicSplineSegment.java | 220 +++--- .../utils/behaviors/interpolators/KBKeyFrame.java | 42 +- .../KBRotPosScaleSplinePathInterpolator.java | 76 +- .../interpolators/KBSplinePathInterpolator.java | 60 +- .../RotPosScaleTCBSplinePathInterpolator.java | 68 +- .../utils/behaviors/interpolators/TCBKeyFrame.java | 40 +- .../interpolators/TCBSplinePathInterpolator.java | 66 +- .../j3d/utils/behaviors/keyboard/KeyNavigator.java | 4 +- .../behaviors/keyboard/KeyNavigatorBehavior.java | 4 +- .../j3d/utils/behaviors/mouse/MouseBehavior.java | 40 +- .../sun/j3d/utils/behaviors/mouse/MouseRotate.java | 48 +- .../j3d/utils/behaviors/mouse/MouseTranslate.java | 48 +- .../j3d/utils/behaviors/mouse/MouseWheelZoom.java | 60 +- .../sun/j3d/utils/behaviors/mouse/MouseZoom.java | 44 +- .../sun/j3d/utils/behaviors/picking/Intersect.java | 564 +++++++-------- .../utils/behaviors/picking/PickMouseBehavior.java | 18 +- .../j3d/utils/behaviors/picking/PickObject.java | 268 +++---- .../behaviors/picking/PickRotateBehavior.java | 32 +- .../behaviors/picking/PickTranslateBehavior.java | 32 +- .../utils/behaviors/picking/PickZoomBehavior.java | 40 +- .../behaviors/sensor/Mouse6DPointerBehavior.java | 12 +- .../j3d/utils/behaviors/sensor/SensorBeamEcho.java | 8 +- .../behaviors/sensor/SensorButtonListener.java | 10 +- .../j3d/utils/behaviors/sensor/SensorEvent.java | 12 +- .../utils/behaviors/sensor/SensorEventAgent.java | 34 +- .../utils/behaviors/sensor/SensorGnomonEcho.java | 8 +- .../utils/behaviors/sensor/SensorInputAdaptor.java | 2 +- .../utils/behaviors/sensor/SensorReadListener.java | 4 +- .../sun/j3d/utils/behaviors/vp/OrbitBehavior.java | 154 ++-- .../behaviors/vp/ViewPlatformAWTBehavior.java | 60 +- .../utils/behaviors/vp/ViewPlatformBehavior.java | 10 +- .../j3d/utils/behaviors/vp/WandViewBehavior.java | 314 ++++---- .../sun/j3d/utils/compression/CommandStream.java | 16 +- .../utils/compression/CompressedGeometryFile.java | 38 +- .../j3d/utils/compression/CompressionStream.java | 42 +- .../utils/compression/CompressionStreamColor.java | 16 +- .../compression/CompressionStreamElement.java | 12 +- .../utils/compression/CompressionStreamNormal.java | 70 +- .../utils/compression/CompressionStreamVertex.java | 14 +- .../j3d/utils/compression/GeometryCompressor.java | 18 +- .../com/sun/j3d/utils/compression/HuffmanNode.java | 2 +- .../sun/j3d/utils/compression/HuffmanTable.java | 12 +- .../com/sun/j3d/utils/compression/MeshBuffer.java | 4 +- .../share/com/sun/j3d/utils/geometry/Box.java | 64 +- .../com/sun/j3d/utils/geometry/ColorCube.java | 4 +- .../share/com/sun/j3d/utils/geometry/Cone.java | 22 +- .../share/com/sun/j3d/utils/geometry/Cylinder.java | 30 +- .../share/com/sun/j3d/utils/geometry/EarClip.java | 2 +- .../com/sun/j3d/utils/geometry/EdgeTable.java | 2 +- .../com/sun/j3d/utils/geometry/GeomBuffer.java | 98 +-- .../com/sun/j3d/utils/geometry/GeometryInfo.java | 476 ++++++------ .../j3d/utils/geometry/GeometryInfoGenerator.java | 36 +- .../sun/j3d/utils/geometry/NormalGenerator.java | 46 +- .../com/sun/j3d/utils/geometry/Primitive.java | 36 +- .../share/com/sun/j3d/utils/geometry/Quadrics.java | 200 +++--- .../share/com/sun/j3d/utils/geometry/Sphere.java | 80 +-- .../share/com/sun/j3d/utils/geometry/Text2D.java | 74 +- .../utils/geometry/compression/CommandStream.java | 16 +- .../compression/CompressedGeometryData.java | 8 +- .../compression/CompressedGeometryFile.java | 46 +- .../compression/CompressedGeometryRetained.java | 8 +- .../geometry/compression/CompressionStream.java | 44 +- .../compression/CompressionStreamColor.java | 16 +- .../compression/CompressionStreamElement.java | 12 +- .../compression/CompressionStreamNormal.java | 70 +- .../compression/CompressionStreamVertex.java | 14 +- .../geometry/compression/GeneralizedStrip.java | 32 +- .../compression/GeneralizedStripFlags.java | 2 +- .../compression/GeneralizedVertexList.java | 16 +- .../geometry/compression/GeometryCompressor.java | 18 +- .../geometry/compression/GeometryDecompressor.java | 34 +- .../compression/GeometryDecompressorShape3D.java | 30 +- .../utils/geometry/compression/HuffmanNode.java | 2 +- .../utils/geometry/compression/HuffmanTable.java | 12 +- .../j3d/utils/geometry/compression/MeshBuffer.java | 4 +- .../com/sun/j3d/utils/image/TextureLoader.java | 154 ++-- .../com/sun/j3d/utils/pickfast/PickCanvas.java | 42 +- .../sun/j3d/utils/pickfast/PickIntersection.java | 264 +++---- .../share/com/sun/j3d/utils/pickfast/PickTool.java | 166 ++--- .../pickfast/behaviors/PickMouseBehavior.java | 30 +- .../pickfast/behaviors/PickRotateBehavior.java | 24 +- .../pickfast/behaviors/PickTranslateBehavior.java | 26 +- .../utils/pickfast/behaviors/PickZoomBehavior.java | 26 +- .../com/sun/j3d/utils/picking/PickCanvas.java | 40 +- .../sun/j3d/utils/picking/PickIntersection.java | 230 +++--- .../com/sun/j3d/utils/picking/PickResult.java | 794 ++++++++++----------- .../share/com/sun/j3d/utils/picking/PickTool.java | 194 ++--- .../utils/picking/behaviors/PickMouseBehavior.java | 30 +- .../picking/behaviors/PickRotateBehavior.java | 26 +- .../picking/behaviors/PickTranslateBehavior.java | 28 +- .../utils/picking/behaviors/PickZoomBehavior.java | 28 +- .../utils/scenegraph/io/SceneGraphFileReader.java | 34 +- .../utils/scenegraph/io/SceneGraphFileWriter.java | 24 +- .../sun/j3d/utils/scenegraph/io/SceneGraphIO.java | 10 +- .../io/SceneGraphObjectReferenceControl.java | 2 +- .../scenegraph/io/SceneGraphStateProvider.java | 12 +- .../scenegraph/io/SceneGraphStreamReader.java | 16 +- .../scenegraph/io/SceneGraphStreamWriter.java | 10 +- .../utils/scenegraph/io/retained/Controller.java | 276 +++---- .../scenegraph/io/retained/J3fInputStream.java | 36 +- .../scenegraph/io/retained/J3fOutputStream.java | 36 +- .../io/retained/PositionInputStream.java | 18 +- .../io/retained/PositionOutputStream.java | 16 +- .../io/retained/RandomAccessFileControl.java | 154 ++-- .../scenegraph/io/retained/StreamControl.java | 42 +- .../utils/scenegraph/io/retained/SymbolTable.java | 270 +++---- .../scenegraph/io/retained/SymbolTableData.java | 24 +- .../KBRotPosScaleSplinePathInterpolatorState.java | 18 +- .../RotPosScaleTCBSplinePathInterpolatorState.java | 18 +- .../state/com/sun/j3d/utils/geometry/BoxState.java | 18 +- .../com/sun/j3d/utils/geometry/ColorCubeState.java | 18 +- .../com/sun/j3d/utils/geometry/ConeState.java | 22 +- .../com/sun/j3d/utils/geometry/CylinderState.java | 20 +- .../com/sun/j3d/utils/geometry/PrimitiveState.java | 14 +- .../com/sun/j3d/utils/geometry/SphereState.java | 22 +- .../com/sun/j3d/utils/geometry/Text2DState.java | 16 +- .../sun/j3d/utils/image/ImageComponent2DURL.java | 32 +- .../j3d/utils/image/ImageComponent2DURLState.java | 22 +- .../j3d/utils/universe/PlatformGeometryState.java | 2 +- .../j3d/utils/universe/SimpleUniverseState.java | 72 +- .../sun/j3d/utils/universe/ViewerAvatarState.java | 2 +- .../io/state/javax/media/j3d/AlphaState.java | 8 +- .../javax/media/j3d/AlternateAppearanceState.java | 28 +- .../state/javax/media/j3d/AmbientLightState.java | 2 +- .../io/state/javax/media/j3d/AppearanceState.java | 26 +- .../javax/media/j3d/AuralAttributesState.java | 24 +- .../javax/media/j3d/BackgroundSoundState.java | 8 +- .../io/state/javax/media/j3d/BehaviorState.java | 18 +- .../io/state/javax/media/j3d/BillboardState.java | 30 +- .../state/javax/media/j3d/BoundingLeafState.java | 10 +- .../io/state/javax/media/j3d/BranchGroupState.java | 2 +- .../io/state/javax/media/j3d/ClipState.java | 12 +- .../javax/media/j3d/ColorInterpolatorState.java | 22 +- .../javax/media/j3d/ColoringAttributesState.java | 10 +- .../javax/media/j3d/CompressedGeometryState.java | 30 +- .../io/state/javax/media/j3d/ConeSoundState.java | 28 +- .../io/state/javax/media/j3d/DecalGroupState.java | 2 +- .../javax/media/j3d/DepthComponentFloatState.java | 6 +- .../javax/media/j3d/DepthComponentIntState.java | 6 +- .../javax/media/j3d/DepthComponentNativeState.java | 8 +- .../javax/media/j3d/DirectionalLightState.java | 4 +- .../io/state/javax/media/j3d/DistanceLODState.java | 30 +- .../state/javax/media/j3d/ExponentialFogState.java | 12 +- .../io/state/javax/media/j3d/FogState.java | 18 +- .../state/javax/media/j3d/GeometryArrayState.java | 56 +- .../io/state/javax/media/j3d/GeometryState.java | 2 +- .../javax/media/j3d/GeometryStripArrayState.java | 8 +- .../io/state/javax/media/j3d/GroupState.java | 28 +- .../javax/media/j3d/ImageComponent2DState.java | 16 +- .../javax/media/j3d/ImageComponent3DState.java | 14 +- .../state/javax/media/j3d/ImageComponentState.java | 132 ++-- .../javax/media/j3d/IndexedGeometryArrayState.java | 22 +- .../media/j3d/IndexedGeometryStripArrayState.java | 8 +- .../javax/media/j3d/IndexedLineArrayState.java | 14 +- .../media/j3d/IndexedLineStripArrayState.java | 8 +- .../javax/media/j3d/IndexedPointArrayState.java | 14 +- .../javax/media/j3d/IndexedQuadArrayState.java | 14 +- .../javax/media/j3d/IndexedTriangleArrayState.java | 14 +- .../media/j3d/IndexedTriangleFanArrayState.java | 14 +- .../media/j3d/IndexedTriangleStripArrayState.java | 14 +- .../state/javax/media/j3d/InterpolatorState.java | 8 +- .../io/state/javax/media/j3d/LODState.java | 18 +- .../io/state/javax/media/j3d/LeafState.java | 2 +- .../io/state/javax/media/j3d/LightState.java | 14 +- .../io/state/javax/media/j3d/LineArrayState.java | 6 +- .../state/javax/media/j3d/LineAttributesState.java | 10 +- .../state/javax/media/j3d/LineStripArrayState.java | 6 +- .../io/state/javax/media/j3d/LinearFogState.java | 12 +- .../io/state/javax/media/j3d/LinkState.java | 14 +- .../io/state/javax/media/j3d/MaterialState.java | 12 +- .../io/state/javax/media/j3d/ModelClipState.java | 40 +- .../io/state/javax/media/j3d/MorphState.java | 22 +- .../state/javax/media/j3d/NodeComponentState.java | 12 +- .../io/state/javax/media/j3d/NodeState.java | 14 +- .../javax/media/j3d/NullSceneGraphObjectState.java | 18 +- .../state/javax/media/j3d/OrderedGroupState.java | 2 +- .../javax/media/j3d/OrientedShape3DState.java | 22 +- .../javax/media/j3d/PathInterpolatorState.java | 6 +- .../javax/media/j3d/PointAttributesState.java | 10 +- .../io/state/javax/media/j3d/PointLightState.java | 4 +- .../io/state/javax/media/j3d/PointSoundState.java | 22 +- .../javax/media/j3d/PolygonAttributesState.java | 10 +- .../javax/media/j3d/PositionInterpolatorState.java | 8 +- .../media/j3d/PositionPathInterpolatorState.java | 12 +- .../io/state/javax/media/j3d/QuadArrayState.java | 10 +- .../io/state/javax/media/j3d/RasterState.java | 12 +- .../javax/media/j3d/RenderingAttributesState.java | 10 +- .../media/j3d/RotPosPathInterpolatorState.java | 14 +- .../j3d/RotPosScalePathInterpolatorState.java | 16 +- .../javax/media/j3d/RotationInterpolatorState.java | 10 +- .../media/j3d/RotationPathInterpolatorState.java | 14 +- .../javax/media/j3d/ScaleInterpolatorState.java | 14 +- .../javax/media/j3d/SceneGraphObjectState.java | 118 +-- .../io/state/javax/media/j3d/Shape3DState.java | 22 +- .../io/state/javax/media/j3d/SharedGroupState.java | 2 +- .../io/state/javax/media/j3d/SoundState.java | 24 +- .../io/state/javax/media/j3d/SoundscapeState.java | 18 +- .../io/state/javax/media/j3d/SpotLightState.java | 4 +- .../io/state/javax/media/j3d/SwitchState.java | 12 +- .../media/j3d/SwitchValueInterpolatorState.java | 20 +- .../javax/media/j3d/TexCoordGenerationState.java | 10 +- .../io/state/javax/media/j3d/Texture2DState.java | 8 +- .../io/state/javax/media/j3d/Texture3DState.java | 18 +- .../javax/media/j3d/TextureAttributesState.java | 16 +- .../io/state/javax/media/j3d/TextureState.java | 34 +- .../javax/media/j3d/TextureUnitStateState.java | 20 +- .../state/javax/media/j3d/TransformGroupState.java | 14 +- .../media/j3d/TransformInterpolatorState.java | 6 +- .../media/j3d/TransparencyAttributesState.java | 10 +- .../media/j3d/TransparencyInterpolatorState.java | 18 +- .../state/javax/media/j3d/TriangleArrayState.java | 12 +- .../javax/media/j3d/TriangleFanArrayState.java | 10 +- .../javax/media/j3d/TriangleStripArrayState.java | 14 +- .../state/javax/media/j3d/ViewPlatformState.java | 14 +- .../transparency/SimpleDistanceComparator.java | 14 +- .../transparency/TransparencySortController.java | 6 +- .../transparency/TransparencySortGeom.java | 10 +- .../share/com/sun/j3d/utils/timer/J3DTimer.java | 6 +- .../com/sun/j3d/utils/universe/ConfigCommand.java | 8 +- .../sun/j3d/utils/universe/ConfigContainer.java | 122 ++-- .../com/sun/j3d/utils/universe/ConfigObject.java | 38 +- .../sun/j3d/utils/universe/ConfigPhysicalBody.java | 2 +- .../utils/universe/ConfigPhysicalEnvironment.java | 8 +- .../com/sun/j3d/utils/universe/ConfigScreen.java | 6 +- .../com/sun/j3d/utils/universe/ConfigSensor.java | 8 +- .../sun/j3d/utils/universe/ConfigSexpression.java | 24 +- .../com/sun/j3d/utils/universe/ConfigView.java | 16 +- .../sun/j3d/utils/universe/ConfigViewPlatform.java | 8 +- .../utils/universe/ConfigViewPlatformBehavior.java | 4 +- .../sun/j3d/utils/universe/ConfiguredUniverse.java | 36 +- .../com/sun/j3d/utils/universe/SimpleUniverse.java | 28 +- .../share/com/sun/j3d/utils/universe/ViewInfo.java | 194 ++--- .../share/com/sun/j3d/utils/universe/Viewer.java | 66 +- .../sun/j3d/utils/universe/ViewingPlatform.java | 22 +- 297 files changed, 5972 insertions(+), 5972 deletions(-) diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java index 8f3b66a..431f2a5 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine.java @@ -67,7 +67,7 @@ public abstract class AudioEngine implements AudioDevice { * HEADPHONE, MONO_SPEAKER, STEREO_SPEAKERS */ int audioPlaybackType = HEADPHONES; - + /* * Distance from center ear (midpoint between ears) to physical speaker. * Default reflects distance for headphones. @@ -75,8 +75,8 @@ public abstract class AudioEngine implements AudioDevice { * distance from the listener and that */ float distanceToSpeaker = 0.0f; - - /* + + /* * Angle between the vector from center ear parallel to head coordiate * Z axis and the vector from the center ear to the speaker. * For two speakers it is assumed that the speakers are placed at the @@ -115,14 +115,14 @@ public abstract class AudioEngine implements AudioDevice { */ public abstract boolean close(); - /* + /* * Audio Playback Methods - */ + */ /** * Set Type of Audio Playback physical transducer(s) sound is output to. * Valid types are HEADPHONE, MONO_SPEAKER, STEREO_SPEAKERS * @param type of audio output device - */ + */ public void setAudioPlaybackType(int type) { audioPlaybackType = type; } @@ -130,7 +130,7 @@ public abstract class AudioEngine implements AudioDevice { /** * Get Type of Audio Playback Output Device * returns audio playback type to which sound is currently output - */ + */ public int getAudioPlaybackType() { return audioPlaybackType; } @@ -138,7 +138,7 @@ public abstract class AudioEngine implements AudioDevice { /** * Set Distance from the Center Ear to a Speaker * @param distance from the center ear and to the speaker - */ + */ public void setCenterEarToSpeaker(float distance) { distanceToSpeaker = distance; } @@ -146,32 +146,32 @@ public abstract class AudioEngine implements AudioDevice { /** * Get Distance from Ear to Speaker * returns value set as distance from listener's ear to speaker - */ + */ public float getCenterEarToSpeaker() { return distanceToSpeaker; } - + /** * Set Angle Offset To Speaker - * @param angle in radian between head coordinate Z axis and vector to speaker */ + * @param angle in radian between head coordinate Z axis and vector to speaker */ public void setAngleOffsetToSpeaker(float angle) { angleOffsetToSpeaker = angle; - } - + } + /** * Get Angle Offset To Speaker * returns value set as angle between vector to speaker and Z head axis - */ + */ public float getAngleOffsetToSpeaker() { return angleOffsetToSpeaker; - } + } /** * Query total number of channels available for sound rendering * for this audio device. * returns number of maximum sound channels you can run with this - * library/device-driver. - */ + * library/device-driver. + */ public int getTotalChannels() { // this method should be overridden by a device specific implementation return (totalChannels); @@ -181,7 +181,7 @@ public abstract class AudioEngine implements AudioDevice { * Query number of channels currently available for use by the * returns number of sound channels currently available (number * not being used by active sounds. - */ + */ public int getChannelsAvailable() { return (channelsAvailable); } @@ -192,7 +192,7 @@ public abstract class AudioEngine implements AudioDevice { * @param sound refenence to sound node that query to be performed on * returns number of sound channels used by a specific Sound node * @deprecated This method is now part of the Sound class - */ + */ public int getChannelsUsedForSound(Sound sound) { if (sound != null) return sound.getNumberOfChannelsUsed(); diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java index 461a564..ce135af 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3D.java @@ -51,11 +51,11 @@ import java.util.ArrayList; /** * The AudioEngine3D Class defines an audio output device that generates - * sound 'image' from high-level sound parameters passed to it during + * sound 'image' from high-level sound parameters passed to it during * scene graph. * *

- * The methods in this class are meant to be optionally overridden by an + * The methods in this class are meant to be optionally overridden by an * extended class. This extended class would provice device specific code. * *

@@ -72,12 +72,12 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D /* * Identifiers of sample associated with sound source * This array grows as the AudioDevice3D implementation requires it larger. - */ + */ protected ArrayList samples = new ArrayList(64); /** * Current View sound is being rendered - */ + */ protected View currentView = (View)null; /* @@ -89,14 +89,14 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * Construct a new AudioEngine with the specified PhysicalEnvironment. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public AudioEngine3D(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); } /* * - * Methods that affect AudioEngine3D fields that are NOT associated + * Methods that affect AudioEngine3D fields that are NOT associated * with a specific sound sample * */ @@ -131,7 +131,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @param soundType denotes type of sound: Background, Point or Cone * @param soundData descrition of sound source data * @return index into sample vector of Sample object for sound - */ + */ public int prepareSound(int soundType, MediaContainer soundData) { // This method must be overridden by device specific implementation return Sample.NULL_SAMPLE; @@ -141,7 +141,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * Clear Sound. * Removes/clears associated sound data with this sound source node * @param index device specific reference number to device driver sample - */ + */ public abstract void clearSound(int index); /** @@ -170,7 +170,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public abstract int stopSample(int index); /** - * Update sample. + * Update sample. * Implies that some parameters affecting rendering have been modified. * @param index device specific reference number to device driver sample */ @@ -178,29 +178,29 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public abstract void updateSample(int index); /** - * Mute sample. + * Mute sample. * @param index device specific reference number to device driver sample */ public abstract void muteSample(int index); /** - * Unmute sample. + * Unmute sample. * @param index device specific reference number to device driver sample */ public abstract void unmuteSample(int index); /** - * Pause sample. + * Pause sample. * @param index device specific reference number to device driver sample */ public abstract void pauseSample(int index); /** - * Unpause sample. + * Unpause sample. * @param index device specific reference number to device driver sample */ public abstract void unpauseSample(int index); - + /* * * Methods that affect fields associated with the sound sample @@ -208,25 +208,25 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * */ /** - * Set gain scale factor applied to sample. + * Set gain scale factor applied to sample. * @param index device specific reference number to device driver sample * @param scaleFactor floating point multiplier applied to sample amplitude */ public void setSampleGain(int index, float scaleFactor) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setGain(scaleFactor); return; } - /** + /** * Set number of times sample is looped. * @param index device specific reference number to device driver sample * @param count number of times sample is repeated */ public void setLoop(int index, int count) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setLoopCount(count); return; } @@ -238,7 +238,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public void setPosition(int index, Point3d position) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setPosition(position); return; } @@ -252,12 +252,12 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * thru which ellipses pass * @param backAttenuationScaleFactor gain scale factors */ - public void setDistanceGain(int index, + public void setDistanceGain(int index, double[] frontDistance, float[] frontAttenuationScaleFactor, double[] backDistance, float[] backAttenuationScaleFactor) { Sample sample = (Sample)getSample(index); - if (sample != null) - sample.setDistanceGain(frontDistance, frontAttenuationScaleFactor, + if (sample != null) + sample.setDistanceGain(frontDistance, frontAttenuationScaleFactor, backDistance, backAttenuationScaleFactor); return; } @@ -269,7 +269,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public void setDirection(int index, Vector3d direction) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) sample.setDirection(direction); return; } @@ -285,11 +285,11 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @param filterCutoff array containing filter cutoff frequencies. * The filter values for each tuples can be set to Sound.NO_FILTER. */ - public void setAngularAttenuation(int index, int filterType, + public void setAngularAttenuation(int index, int filterType, double[] angle, float[] attenuationScaleFactor, float[] filterCutoff) { Sample sample = (Sample)getSample(index); - if (sample != null) - sample.setAngularAttenuation(filterType, angle, + if (sample != null) + sample.setAngularAttenuation(filterType, angle, attenuationScaleFactor, filterCutoff); return; } @@ -315,7 +315,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D } /** - * Set reverberation delay time for current aural attribute applied to + * Set reverberation delay time for current aural attribute applied to * all samples. * @param reverbDelay amount of time in millisecond between each * iteration of reverb processing. @@ -326,7 +326,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D } /** - * Set reverberation order for current aural attribute applied to all + * Set reverberation order for current aural attribute applied to all * samples. * @param reverbOrder number of times reverb process loop is iterated. */ @@ -341,14 +341,14 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * to all sample based on distance between listener and sound. * @param dist is an attenuation array of distance and low-pass filter values. */ - public void setDistanceFilter(int filterType, + public void setDistanceFilter(int filterType, double[] dist, float[] filterCutoff) { attribs.setDistanceFilter(filterType, dist, filterCutoff); return; } /** - * Set frequency scale factor for current aural attribute applied to all + * Set frequency scale factor for current aural attribute applied to all * samples. * @param scaleFactor frequency scale factor applied to samples normal * playback rate. @@ -358,7 +358,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D return; } /** - * Set velocity scale factor for current aural attribute applied to all + * Set velocity scale factor for current aural attribute applied to all * samples when Doppler is calculated. * @param scaleFactor scale factor applied to postional samples' * listener-to-soundSource velocity. @@ -377,7 +377,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public int getNumberOfChannelsUsed(int index) { // This method must be overridden by device specific implementation Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getNumberOfChannelsUsed()); else return 0; @@ -396,7 +396,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D public int getNumberOfChannelsUsed(int index, boolean muteFlag) { // This method must be overridden by device specific implementation Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getNumberOfChannelsUsed()); else return 0; @@ -409,7 +409,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public long getSampleDuration(int index) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getDuration()); else return 0L; @@ -422,7 +422,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D */ public long getStartTime(int index) { Sample sample = (Sample)getSample(index); - if (sample != null) + if (sample != null) return (sample.getStartTime()); else return 0L; @@ -450,7 +450,7 @@ public abstract class AudioEngine3D extends AudioEngine implements AudioDevice3D * @return reference to sample; returns null if index out of range. * * @since Java 3D 1.2.1 - */ + */ public Sample getSample(int index) { synchronized(samples) { if ((index >= 0) && (index < samples.size())) { diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java index 2e847c0..33e84f0 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngine3DL2.java @@ -51,11 +51,11 @@ import java.util.ArrayList; /** * The AudioEngine3DL2 Class defines an audio output device that generates - * sound 'image' from high-level sound parameters passed to it during + * sound 'image' from high-level sound parameters passed to it during * scene graph. * *

- * The methods in this class are meant to be optionally overridden by an + * The methods in this class are meant to be optionally overridden by an * extended class. This extended class would provice device specific code. * *

@@ -73,14 +73,14 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Construct a new AudioEngine3DL2 with the specified PhysicalEnvironment. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public AudioEngine3DL2(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); } /* * - * Methods that affect AudioEngine3DLD fields that are NOT associated + * Methods that affect AudioEngine3DLD fields that are NOT associated * with a specific sound sample * */ @@ -105,7 +105,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Set overall gain control of all sounds playing on the audio device. * @param scaleFactor scale factor applied to calculated amplitudes for * all sounds playing on this device - */ + */ public abstract void setGain(float scaleFactor); /* @@ -123,7 +123,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * Changes (scales) the playback rate of a sound independent of * Doppler rate changes. * @param index device specific reference to device driver sample - * @param scaleFactor non-negative factor applied to calculated + * @param scaleFactor non-negative factor applied to calculated * amplitudes for all sounds playing on this device * @see Sound#setRateScaleFactor */ @@ -151,7 +151,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * This parameter, along with the early reflection coefficient, defines * the reflective/absorptive characteristic of the surfaces in the * current listening region. - * @param coefficient late reflection attenuation factor + * @param coefficient late reflection attenuation factor * @see AuralAttributes#setReverbCoefficient */ public void setReverbCoefficient(float coefficient) { @@ -160,14 +160,14 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi } - /** + /** * 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. + * in milliseconds. * @param reflectionDelay time between each order of early reflection * @see AuralAttributes#setReflectionDelay - */ + */ public void setReflectionDelay(float reflectionDelay) { attribs.reflectionDelay = reflectionDelay; return; @@ -188,7 +188,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * 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 + * below this value. Thus, defining a different reverb decay curve for * frequencies above the cutoff value. * @param frequencyCutoff value of frequencies in Hertz above which a * low-pass filter is applied. @@ -204,7 +204,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * 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. - * @param diffusion percentage expressed within the range of 0.0 and 1.0 + * @param diffusion percentage expressed within the range of 0.0 and 1.0 * @see AuralAttributes#setDiffusion */ public void setDiffusion(float diffusion) { @@ -214,12 +214,12 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi /** * Set reverb density. - * This defines the modal density (also referred to as 'spectral + * 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. * @param density reverb density expressed as a percentage, - * within the range of 0.0 and 1.0 + * within the range of 0.0 and 1.0 * @see AuralAttributes#setDensity */ public void setDensity(float density) { @@ -253,7 +253,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * There is no corresponding Core AuralAttributes method at this time. * @param index device specific reference to device driver sample * @param frequencyCutoff value of frequencies in Hertz above which a - * low-pass filter is applied. + * low-pass filter is applied. */ public void setObstructionFilter(int index, float frequencyCutoff) { @@ -288,7 +288,7 @@ public abstract class AudioEngine3DL2 extends AudioEngine3D implements AudioDevi * There is no corresponding Core AuralAttributes method at this time. * @param index device specific reference to device driver sample * @param frequencyCutoff value of frequencies in Hertz above which a - * low-pass filter is applied. + * low-pass filter is applied. */ public void setOcclusionFilter(int index, float frequencyCutoff) { Sample sample = (Sample)getSample(index); diff --git a/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java b/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java index a8dc4bd..2c8c899 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java +++ b/src/classes/share/com/sun/j3d/audioengines/AudioEngineThread.java @@ -52,7 +52,7 @@ import javax.media.j3d.*; /** * The Thread Class extended for Audio Device engines that must process - * calls dynamically, in 'real-time" to asynchronously change engine + * calls dynamically, in 'real-time" to asynchronously change engine * parameters. * *

@@ -69,9 +69,9 @@ public class AudioEngineThread extends Thread { if (debugFlag) System.out.println(message); } - + /** - * The classification types. + * The classification types. */ protected static final int WORK_THREAD = 0x01; protected static final int UPDATE_THREAD = 0x02; @@ -82,13 +82,13 @@ public class AudioEngineThread extends Thread { protected static final int WAIT = 0; /** - * This runMonitor action notifies MasterControl that this thread + * This runMonitor action notifies MasterControl that this thread * has completed and wait. */ protected static final int NOTIFY_AND_WAIT = 1; /** - * This runMonitor action tells the thread to run N number of + * This runMonitor action tells the thread to run N number of * iterations. */ protected static final int RUN = 2; @@ -199,7 +199,7 @@ public class AudioEngineThread extends Thread { } } - /** + /** * This causes the threads run method to exit. */ public void finish() { @@ -259,7 +259,7 @@ public class AudioEngineThread extends Thread { public void shutdown() { } - + // default resource clean up method public void cleanup() { active = false; @@ -270,6 +270,6 @@ public class AudioEngineThread extends Thread { args = null; userStop = false; referenceTime = 0; - + } } diff --git a/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java b/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java index 38efbc6..75aa190 100644 --- a/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java +++ b/src/classes/share/com/sun/j3d/audioengines/AuralParameters.java @@ -76,8 +76,8 @@ public class AuralParameters /* * @since Java 3D 1.3 */ - public float reverbCoefficient = 1.0f; - public float reflectionDelay = 20.0f; + public float reverbCoefficient = 1.0f; + public float reflectionDelay = 20.0f; public float decayTime = 1000.0f; public float decayFrequencyCutoff = 5000.0f; public float diffusion = 1.0f; // 100% @@ -85,7 +85,7 @@ public class AuralParameters /** * Construct a new AuralParameters object - */ + */ public AuralParameters() { frequencyScaleFactor = 1.0f; velocityScaleFactor = 0.0f; @@ -104,20 +104,20 @@ public class AuralParameters density = 1.0f; // 100% } - public void setDistanceFilter(int filterType, double[] distance, + public void setDistanceFilter(int filterType, double[] distance, float[] filterCutoff) { boolean error = false; boolean allocate = false; int attenuationLength = 0; if (distance == null || filterCutoff == null) { error = true; - } + } else { attenuationLength = distance.length; if (attenuationLength == 0 || filterType == NO_FILTERING) { error = true; } - } + } if (error) { this.filterType = NO_FILTERING; this.filterDistance = null; @@ -141,10 +141,10 @@ public class AuralParameters this.filterDistance = new double[attenuationLength]; this.filterCutoff = new float[attenuationLength]; } - System.arraycopy(distance, 0, this.filterDistance, 0, - attenuationLength); - System.arraycopy(filterCutoff, 0, this.filterCutoff, 0, - attenuationLength); + System.arraycopy(distance, 0, this.filterDistance, 0, + attenuationLength); + System.arraycopy(filterCutoff, 0, this.filterCutoff, 0, + attenuationLength); if (debugFlag) { debugPrint("setDistanceFilter arrays = "); @@ -176,9 +176,9 @@ public class AuralParameters if (attenuationLength > filterDistance.length) attenuationLength = filterDistance.length; System.arraycopy(this.filterDistance, 0, distance, 0, - attenuationLength); + attenuationLength); System.arraycopy(this.filterCutoff, 0, filterCutoff, 0, - attenuationLength); + attenuationLength); return; } @@ -188,10 +188,10 @@ public class AuralParameters /** * Debug print method for Sound nodes - */ + */ protected void debugPrint(String message) { if (debugFlag) System.out.println(message); } - + } diff --git a/src/classes/share/com/sun/j3d/audioengines/Sample.java b/src/classes/share/com/sun/j3d/audioengines/Sample.java index e0dc0ea..3cd092b 100644 --- a/src/classes/share/com/sun/j3d/audioengines/Sample.java +++ b/src/classes/share/com/sun/j3d/audioengines/Sample.java @@ -76,28 +76,28 @@ public class Sample { /** * sound data associated with sound source - */ + */ protected MediaContainer soundData = null; /** * sound data associated with sound source - */ + */ protected int soundType = -1; /** * Overall Scale Factor applied to sound gain. - */ + */ protected float gain = 1.0f; // Valid values are >= 0.0. /** * Overall Scale Factor applied to sound. * @since Java 3D 1.3 - */ + */ protected float rateScaleFactor = 1.0f; // Valid values are >= 0.0. /** * Number of times sound is looped/repeated during play - */ + */ protected int loopCount = 0; // Range from 0 to POSITIVE_INFINITY(-1) @@ -131,13 +131,13 @@ public class Sample { /* * Pairs of distances and gain scale factors that define piecewise linear * gain attenuation between each pair. - */ - protected double[] attenuationDistance = null; + */ + protected double[] attenuationDistance = null; protected float[] attenuationGain = null;; /** * dirty flags denoting what has changed since last rendering - */ + */ protected int dirtyFlags = 0xFFFF; /* @@ -154,7 +154,7 @@ public class Sample { * Pairs of distances and gain scale factors that define piecewise linear * gain BACK attenuation between each pair. * These are used for defining elliptical attenuation regions. - */ + */ protected double[] backAttenuationDistance = null; protected float[] backAttenuationGain = null; @@ -173,10 +173,10 @@ public class Sample { * 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 + * For now the only supported filterType will be LOW_PASS frequency * cutoff. * At some time full FIR filtering will be supported. - */ + */ public static final int NO_FILTERING = -1; public static final int LOW_PASS = 1; @@ -188,22 +188,22 @@ public class Sample { * For now the only type of filtering supported is a low-pass filter * defined by a frequency cutoff value. * @since Java 3D 1.3 - */ + */ protected float obstructionGain = 1.0f; // scale factor protected int obstructionFilterType = NO_FILTERING; protected float obstructionFilterCutoff = Sound.NO_FILTER; protected float occlusionGain = 1.0f; // scale factor protected int occlusionFilterType = NO_FILTERING; - protected float occlusionFilterCutoff = Sound.NO_FILTER; + protected float occlusionFilterCutoff = Sound.NO_FILTER; /* * Construct a new audio device Sample object - */ + */ public Sample() { if (debugFlag) debugPrintln("Sample constructor"); } - + public long getDuration() { return 0; } @@ -266,11 +266,11 @@ public class Sample { } public void setLoopCount(int count) { - loopCount = count; + loopCount = count; } public int getLoopCount() { - return loopCount; + return loopCount; } @@ -283,7 +283,7 @@ public class Sample { public void setDistanceGain( - double[] frontDistance, float[] frontAttenuationScaleFactor, + double[] frontDistance, float[] frontAttenuationScaleFactor, double[] backDistance, float[] backAttenuationScaleFactor) { if (frontDistance != null) { int size = frontDistance.length; @@ -325,7 +325,7 @@ public class Sample { // TODO: no get method for Direction - public void setAngularAttenuation(int filterType, double[] angle, + public void setAngularAttenuation(int filterType, double[] angle, float[] attenuationScaleFactor, float[] filterCutoff) { if (angle != null) { int size = angle.length; @@ -357,7 +357,7 @@ public class Sample { /* * Set Rate ScaleFactor * @since Java 3D 1.3 - */ + */ public void setRateScaleFactor(float scaleFactor) { rateScaleFactor = scaleFactor; } @@ -365,7 +365,7 @@ public class Sample { /* * Get Rate ScaleFactor * @since Java 3D 1.3 - */ + */ public float getRateScaleFactor() { return rateScaleFactor; } @@ -374,7 +374,7 @@ public class Sample { /* * Set Obstruction Gain * @since Java 3D 1.3 - */ + */ public void setObstructionGain(float scaleFactor) { obstructionGain = scaleFactor; } @@ -382,7 +382,7 @@ public class Sample { /* * Get Obstruction Gain * @since Java 3D 1.3 - */ + */ public float getObstructionGain() { return obstructionGain; } @@ -390,7 +390,7 @@ public class Sample { /* * Set Obstruction Filter Cutoff Frequency * @since Java 3D 1.3 - */ + */ public void setObstructionFilter(float cutoffFrequency) { obstructionFilterType = LOW_PASS; obstructionFilterCutoff = cutoffFrequency; @@ -402,7 +402,7 @@ public class Sample { /* * Set Occlusion Gain * @since Java 3D 1.3 - */ + */ public void setOcclusionGain(float scaleFactor) { occlusionGain = scaleFactor; } @@ -410,7 +410,7 @@ public class Sample { /* * Get Occlusion Gain * @since Java 3D 1.3 - */ + */ public float getOcclusionGain() { return occlusionGain; } @@ -418,7 +418,7 @@ public class Sample { /* * Set Occlusion Filter Cutoff Frequency * @since Java 3D 1.3 - */ + */ public void setOcclusionFilter(float cutoffFrequency) { occlusionFilterType = LOW_PASS; occlusionFilterCutoff = cutoffFrequency; @@ -431,14 +431,14 @@ public class Sample { * Clears/re-initialize fields associated with sample data * for this sound, * and frees any device specific data associated with this sample. - */ + */ public void clear() { if (debugFlag) debugPrintln("Sample.clear() entered"); soundData = (MediaContainer)null; soundType = NULL_SAMPLE; gain = 1.0f; - loopCount = 0; + loopCount = 0; duration = DURATION_UNKNOWN; numberOfChannels = 0; vworldXfrm.setIdentity(); @@ -462,7 +462,7 @@ public class Sample { angularFilterCutoff[0] = Sound.NO_FILTER; angularFilterCutoff[1] = Sound.NO_FILTER; } - obstructionGain = 1.0f; + obstructionGain = 1.0f; obstructionFilterType = NO_FILTERING; obstructionFilterCutoff = Sound.NO_FILTER; occlusionGain = 1.0f; diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java index 8f56c82..7d16146 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSAuralParameters.java @@ -56,13 +56,13 @@ public class JSAuralParameters extends com.sun.j3d.audioengines.AuralParameters /** * Reverb Parameters - * + * * dirty flag checked and cleared by render() - */ + */ static int REFLECTION_COEFF_CHANGED = 1; static int REVERB_DELAY_CHANGED = 2; static int REVERB_ORDER_CHANGED = 4; - + int reverbDirty = 0xFFFF; int lastReverbSpeed = 0; // TODO: NOT used yet boolean reverbFlag = false; // previously refered to as reverbOn diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java index af3b6f8..2f07e40 100644 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSChannel.java @@ -81,7 +81,7 @@ class JSChannel { /** * Debug print mechanism for Sound nodes - */ + */ static final boolean debugFlag = false; static void debugPrint(String message) { @@ -113,7 +113,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error initAudioInputStream "); debugPrintln("input stream given is null"); - } + } this.inputStream = null; return null; } @@ -140,7 +140,7 @@ class JSChannel { /****** // QUESTION: HOW do I figure out the data type of the file/url/inputStream???? if (ais instanceof AudioMidiInputStream || - ais instanceof AudioRmfInputStream ) + ais instanceof AudioRmfInputStream ) // QUESTION: can non-cached MIDI files ever be supported ? *******/ return ais; @@ -156,7 +156,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error initAudioInputStream "); debugPrintln("URL given is null"); - } + } this.url = null; return null; } @@ -179,7 +179,7 @@ class JSChannel { inputStream = null; return ais; } // initAudioInputStream - + AudioInputStream reinitAudioInputStream(URL path) { /***** @@ -187,7 +187,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("URL given is null"); - } + } return null; } try { @@ -199,7 +199,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("get stream failed"); - } + } e.printStackTrace(); return null; } @@ -217,7 +217,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("InputStream given is null"); - } + } return null; } try { @@ -234,7 +234,7 @@ class JSChannel { if (debugFlag) { debugPrint("JSChannel: Internal Error reinitAudioInputStream "); debugPrintln("get stream failed"); - } + } e.printStackTrace(); return null; } @@ -259,11 +259,11 @@ class JSChannel { if (debugFlag) debugPrintln("JSChannel:getDuration"); - if (ais == null || audioFormat == null ) { - if (debugFlag) - debugPrintln("JSChannel: Internal Error getDuration"); + if (ais == null || audioFormat == null ) { + if (debugFlag) + debugPrintln("JSChannel: Internal Error getDuration"); return (long)Sample.DURATION_UNKNOWN; - } + } // Otherwise we'll assume that we can calculate this duration // get "duration" of audio stream (wave file) @@ -280,7 +280,7 @@ class JSChannel { debugPrintln(" rate in Frames = " + rateInFrames); if (numFrames <= 0) return (long)Sample.DURATION_UNKNOWN; - long duration = (long)((float)numFrames/rateInFrames); + long duration = (long)((float)numFrames/rateInFrames); if (debugFlag) debugPrintln(" duration(based on ais) = " + duration); return duration; @@ -289,7 +289,7 @@ class JSChannel { /** * Start TWO Samples */ - boolean startSamples(int loopCount, float leftGain, float rightGain, + boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay) { if (debugFlag) debugPrint("JSChannel: startSamples must be overridden"); @@ -354,10 +354,10 @@ class JSChannel { void scaleSampleRate(float scaleFactor) { /** * Change rate for Doppler affect or pitch shifting. - * Engine maximum sample rate is 48kHz so clamp to that + * Engine maximum sample rate is 48kHz so clamp to that * max value. */ - if (debugFlag) + if (debugFlag) debugPrintln("JSChannel: scaleSampleRate"); if (ais == null) { if (debugFlag) { @@ -366,7 +366,7 @@ class JSChannel { } return; } - + AudioFormat audioFormat = ais.getFormat(); float rate = audioFormat.getSampleRate(); @@ -380,7 +380,7 @@ class JSChannel { // need to set FloatControl.Type(SAMPLE_RATE) to new value somehow... if (debugFlag) { - debugPrintln("JSChannel: scaleSampleRate: new rate = " + + debugPrintln("JSChannel: scaleSampleRate: new rate = " + rate * scaleFactor); debugPrintln(" >>>>>>>>>>>>>>> using scaleFactor = " + scaleFactor); @@ -397,14 +397,14 @@ class JSChannel { } int pauseSample() { - /** + /** * Pause playing a sample - */ + */ // TODO: Notify thread return 0; - } + } - int unpauseSamples() { + int unpauseSamples() { /** * Resume playing samples */ @@ -412,10 +412,10 @@ class JSChannel { return 0; } - int unpauseSample() { - /** + int unpauseSample() { + /** * Resume playing a sample - */ + */ // TODO: Notify thread return 0; } diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java index 740c0b1..b533592 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSClip.java @@ -56,7 +56,7 @@ import java.net.*; import java.io.*; import java.io.InputStream; import javax.sound.sampled.*; - + /** * The JSClip Class defines an audio output methods that call JavaSound * Hae mixer methods. @@ -86,7 +86,7 @@ class JSClip extends JSChannel { debugPrintln("JSClip: initDataLine(" + ais + ")"); try { - if (debugFlag) + if (debugFlag) debugPrintln("JSClip: loadSample - try getting new line "); /* * From the AudioInputStream fetch information about the format @@ -104,7 +104,7 @@ class JSClip extends JSChannel { AudioFormat tmp = new AudioFormat( - AudioFormat.Encoding.PCM_SIGNED, + AudioFormat.Encoding.PCM_SIGNED, audioFormat.getSampleRate(), audioFormat.getSampleSizeInBits() * 2, audioFormat.getChannels(), @@ -115,7 +115,7 @@ class JSClip extends JSChannel { audioFormat = tmp; } - /* + /* * ask JavaSound for outline with a format suitable for our * AudioInputStream. In order to ask for a line, a Info object * with the desired properties must be constructed. @@ -134,7 +134,7 @@ class JSClip extends JSChannel { // TODO: JSClip can't be a listener (do we need to do this in the thread?) if (debugFlag) debugPrintln("JSClip: addLineListener for clip"); - line.addLineListener(this); + line.addLineListener(this); ******/ if (debugFlag) @@ -169,7 +169,7 @@ class JSClip extends JSChannel { * actual Java Sound start methods called are as immediate (without * delay between as possible. */ - boolean startSamples(int loopCount, float leftGain, float rightGain, + boolean startSamples(int loopCount, float leftGain, float rightGain, int leftDelay, int rightDelay) { // loop count is ignored for Stream and MIDI // TODO: loop count isn't implemented for MIDI yet @@ -178,10 +178,10 @@ class JSClip extends JSChannel { if (debugFlag) { debugPrint("JSClip: startSamples "); debugPrintln("start stream for Left called with "); - debugPrintln(" gain = " + leftGain + + debugPrintln(" gain = " + leftGain + " delay = " + leftDelay); debugPrintln("start stream for Right called with "); - debugPrintln(" gain = " + rightGain + + debugPrintln(" gain = " + rightGain + " delay = " + rightDelay); } @@ -218,7 +218,7 @@ for now just care about the left return false; } ************/ - + // we know that were processing TWO channels double ZERO_EPS = 0.0039; // approx 1/256 - twice MIDI precision double leftVolume = (double)leftGain; @@ -226,10 +226,10 @@ for now just care about the left // TODO: if not reading/writing done for Clips then I can't do // stereo trick (reading mono file and write to stereo buffer) - // Save time sound started, only in left + // Save time sound started, only in left startTime = System.currentTimeMillis(); if (debugFlag) - debugPrintln("*****start Stream with new start time " + + debugPrintln("*****start Stream with new start time " + startTime); try { // QUESTION: Offset clip is done how??? @@ -242,7 +242,7 @@ set reverb boolean reverbLeft = false; // off; reverb has it own channel boolean reverbRight = reverbLeft; - if (leftDelay < rightDelay) { + if (leftDelay < rightDelay) { XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); XXXX audioRightStream.start(rightVolume, panRight, reverbRight); } @@ -265,7 +265,7 @@ XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); return false; } - if (debugFlag) + if (debugFlag) debugPrintln("JSClip: startSamples returns"); return true; } // end of startSamples @@ -275,7 +275,7 @@ XXXX audioLeftStream.start(leftVolume, panLeft, reverbLeft); * This method is called specifically for BackgroundSounds. * There is exactly ONE sample (mono or stereo) associated with * this type of sound. Consequently, delay is not applicable. - * Since the sound has no auralAttributes applied to it reverb + * Since the sound has no auralAttributes applied to it reverb * is not applied to the sample. */ boolean startSample(int loopCount, float gain, int delay) { diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java index 9191bba..276cd57 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSDirectionalSample.java @@ -56,7 +56,7 @@ import com.sun.j3d.audioengines.*; import javax.vecmath.*; /** - * The PostionalSample Class defines the data and methods associated with a + * The PostionalSample Class defines the data and methods associated with a * PointSound sample played through the AudioDevice. */ @@ -67,7 +67,7 @@ class JSDirectionalSample extends JSPositionalSample public JSDirectionalSample() { super(); - if (debugFlag) + if (debugFlag) debugPrintln("JSDirectionalSample constructor"); } @@ -91,21 +91,21 @@ class JSDirectionalSample extends JSPositionalSample /* *********************************** - * + * * Intersect ray to head with Ellipse - * + * * ***********************************/ /* * An ellipse is defined using: * (1) the ConeSound's direction vector as the major axis of the ellipse; * (2) the max parameter (a front distance attenuation value) along the - * cone's position axis; and + * cone's position axis; and * (3) the min parameter (a back distance attenuation value) along the * cone's negative axis - * This method calculates the distance from the sound source to the + * This method calculates the distance from the sound source to the * Intersection of the Ellipse with the ray from the sound source to the * listener's head. - * This method returns the resulting distance. + * This method returns the resulting distance. * If an error occurs, -1.0 is returned. * * A calculation are done in 'Cone' space: @@ -121,7 +121,7 @@ class JSDirectionalSample extends JSPositionalSample * H'(x,y) = (cos @, sin @) * | H | * where @ is the angle between the X-axis and the ray to H. * Using the equation of the line thru the origin and H', and the - * equation of ellipse defined with min and max, find the + * equation of ellipse defined with min and max, find the * intersection by solving for x and then y. * * (I) The equation of the line thru the origin and H', and the @@ -164,9 +164,9 @@ class JSDirectionalSample extends JSPositionalSample * x**2 | -------------- + -------------------------------- | = 1 * | [(max+min)]**2 min*max | * - * | | + * | | * | 1 | - * | | + * | | * x**2 = | --------------------------------------- | * | | 4 [sin @/cos @]**2 | | * | | -------------- + ---------------- | | @@ -177,7 +177,7 @@ class JSDirectionalSample extends JSPositionalSample * * Then solve for y by plugging x into Eq.(I). * - * Return the distance from the origin in Cone space to this intersection + * Return the distance from the origin in Cone space to this intersection * point: square_root(x**2 + y**2). * */ @@ -226,9 +226,9 @@ class JSDirectionalSample extends JSPositionalSample debugPrint( " X = " + x ); /* * Solve for y, given the result for x: - * | H'(y) | | sin @ | + * | H'(y) | | sin @ | * y = | ----- | x = | ----- | x - * | H'(x) | | cos @ | + * | H'(x) | | cos @ | */ double y = tangent * x; if (debugFlag) @@ -245,13 +245,13 @@ class JSDirectionalSample extends JSPositionalSample } /* ***************** - * + * * Find Factor - * + * * *****************/ /* * Interpolates the correct attenuation scale factor given a 'distance' - * value. This version used both front and back attenuation distance + * value. This version used both front and back attenuation distance * and scale factor arrays (if non-null) in its calculation of the * the distance attenuation. * If the back attenuation arrays are null then this executes the @@ -259,13 +259,13 @@ class JSDirectionalSample extends JSPositionalSample * This method finds the intesection of the ray from the sound source * to the center-ear, with the ellipses defined by the two sets (front * and back) of distance attenuation arrays. - * This method looks at pairs of intersection distance values to find + * This method looks at pairs of intersection distance values to find * which pair the input distance argument is between: * [intersectionDistance[index] and intersectionDistance[index+1] * The index is used to get factorArray[index] and factorArray[index+1]. * Then the ratio of the 'distance' between this pair of intersection * values is used to scale the two found factorArray values proportionally. - */ + */ float findFactor(double distanceToHead, double[] maxDistanceArray, float[] maxFactorArray, double[] minDistanceArray, float[] minFactorArray) { @@ -311,12 +311,12 @@ class JSDirectionalSample extends JSPositionalSample */ if (distanceToHead >= maxDistanceArray[largestIndex]) { if (debugFlag) - debugPrint(" findFactor: distance > " + + debugPrint(" findFactor: distance > " + maxDistanceArray[largestIndex]); if (debugFlag) - debugPrint(" maxDistanceArray length = " + + debugPrint(" maxDistanceArray length = " + maxDistanceArray.length); - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + maxFactorArray[largestIndex] + " ******"); return maxFactorArray[largestIndex]; @@ -330,12 +330,12 @@ class JSDirectionalSample extends JSPositionalSample if (debugFlag) debugPrint(" findFactor: distance < " + maxDistanceArray[0]); - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + minFactorArray[0] + " ******"); return minFactorArray[0]; } - + /* * distanceToHead is between points within attenuation arrays. * Use binary halfing of distance attenuation arrays. @@ -350,11 +350,11 @@ class JSDirectionalSample extends JSPositionalSample boolean intersectionOnEllipse = false; int factorIndex = -1; - /* + /* * Using binary halving to find the two index values in the - * front and back distance arrays that the distanceToHead + * front and back distance arrays that the distanceToHead * parameter (from sound source position to head) fails between. - * Changing the the current low and high index values + * Changing the the current low and high index values * calculate the intesection of ellipses (defined by this * min/max distance values) with the ray (sound source to * head). Put the resulting value into the distanceArray. @@ -388,12 +388,12 @@ class JSDirectionalSample extends JSPositionalSample * Error in ellipse intersection calculation. Use * average of max/min difference for intersection value. */ - distanceArray[lowIndex] = (minDistanceArray[lowIndex] + + distanceArray[lowIndex] = (minDistanceArray[lowIndex] + maxDistanceArray[lowIndex])*0.5; if (internalErrors) debugPrint( "Internal Error in intersectEllipse; use " + - distanceArray[lowIndex] + + distanceArray[lowIndex] + " for intersection value " ); // Rather than aborting, just use average and go on... intersectionCalculated[lowIndex] = true; @@ -416,7 +416,7 @@ class JSDirectionalSample extends JSPositionalSample if (internalErrors) debugPrint( "Internal Error in intersectEllipse; use " + - distanceArray[highIndex] + + distanceArray[highIndex] + " for intersection value " ); // Rather than aborting, just use average and go on... intersectionCalculated[highIndex] = true; @@ -429,10 +429,10 @@ class JSDirectionalSample extends JSPositionalSample * return factor value directly from array */ if (distanceArray[lowIndex] >= distanceToHead) { - if ((lowIndex != 0) && + if ((lowIndex != 0) && (distanceToHead < distanceArray[lowIndex])) { if (internalErrors) - debugPrint( + debugPrint( "Internal Error: binary halving in " + "findFactor failed; distance < low " + "index value"); @@ -447,7 +447,7 @@ class JSDirectionalSample extends JSPositionalSample break; } else if (distanceArray[highIndex] <= distanceToHead) { - if ((highIndex != largestIndex) && + if ((highIndex != largestIndex) && (distanceToHead > distanceArray[highIndex])) { if (internalErrors) debugPrint( @@ -479,31 +479,31 @@ class JSDirectionalSample extends JSPositionalSample /* * First check to see if distanceToHead is beyond min or max * ellipses, or on an ellipse. - * If so, factor is calculated using the distance Ratio + * If so, factor is calculated using the distance Ratio * (distanceToHead - min) / (max-min) - * where max = maxDistanceArray[factorIndex], and + * where max = maxDistanceArray[factorIndex], and * min = minDistanceArray[factorIndex] */ if (intersectionOnEllipse && factorIndex >= 0) { - if (debugFlag) { + if (debugFlag) { debugPrint( " ratio calculated using factorIndex " + factorIndex); debugPrint( " d.A. max pair for factorIndex " + - maxDistanceArray[factorIndex] + ", " + + maxDistanceArray[factorIndex] + ", " + maxFactorArray[factorIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[factorIndex] + ", " + + minDistanceArray[factorIndex] + ", " + minFactorArray[factorIndex]); } returnValue = ( - ( (distanceArray[factorIndex] - + ( (distanceArray[factorIndex] - minDistanceArray[factorIndex]) / - (maxDistanceArray[factorIndex] - + (maxDistanceArray[factorIndex] - minDistanceArray[factorIndex]) ) * - (maxFactorArray[factorIndex] - + (maxFactorArray[factorIndex] - minFactorArray[factorIndex]) ) + minFactorArray[factorIndex] ; - if (debugFlag) + if (debugFlag) debugPrint(" findFactor returns ****** " + returnValue + " ******"); return (float)returnValue; @@ -515,22 +515,22 @@ class JSDirectionalSample extends JSPositionalSample * the other by highIndex min/max factor arrays. Then the * distance Ratio (defined above) is applied, using these * two factor values, to get the final return value. - */ + */ double highFactorValue = 1.0; double lowFactorValue = 0.0; - highFactorValue = + highFactorValue = ( ((distanceArray[highIndex] - minDistanceArray[highIndex]) / (maxDistanceArray[highIndex]-minDistanceArray[highIndex])) * (maxFactorArray[highIndex] - minFactorArray[highIndex]) ) + minFactorArray[highIndex] ; - if (debugFlag) { + if (debugFlag) { debugPrint( " highFactorValue calculated w/ highIndex " + highIndex); debugPrint( " d.A. max pair for highIndex " + - maxDistanceArray[highIndex] + ", " + + maxDistanceArray[highIndex] + ", " + maxFactorArray[highIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[highIndex] + ", " + + minDistanceArray[highIndex] + ", " + minFactorArray[highIndex]); debugPrint( " highFactorValue " + highFactorValue); } @@ -539,14 +539,14 @@ class JSDirectionalSample extends JSPositionalSample (maxDistanceArray[lowIndex] - minDistanceArray[lowIndex])) * (maxFactorArray[lowIndex] - minFactorArray[lowIndex]) ) + minFactorArray[lowIndex] ; - if (debugFlag) { + if (debugFlag) { debugPrint( " lowFactorValue calculated w/ lowIndex " + lowIndex); debugPrint( " d.A. max pair for lowIndex " + - maxDistanceArray[lowIndex] + ", " + + maxDistanceArray[lowIndex] + ", " + maxFactorArray[lowIndex]); debugPrint( " d.A. min pair for lowIndex " + - minDistanceArray[lowIndex] + ", " + + minDistanceArray[lowIndex] + ", " + minFactorArray[lowIndex]); debugPrint( " lowFactorValue " + lowFactorValue); } @@ -560,7 +560,7 @@ class JSDirectionalSample extends JSPositionalSample * attenuation value between lowIndex and highIndex * gives linearly interpolationed attenuation value */ - if (debugFlag) { + if (debugFlag) { debugPrint( " ratio calculated using distanceArray" + lowIndex + ", highIndex " + highIndex); debugPrint( " calculated pair for lowIndex " + @@ -568,27 +568,27 @@ class JSDirectionalSample extends JSPositionalSample debugPrint( " calculated pair for highIndex " + distanceArray[highIndex]+", "+ highFactorValue ); } - + returnValue = ( ( (distanceToHead - distanceArray[lowIndex]) / (distanceArray[highIndex] - distanceArray[lowIndex]) ) * (highFactorValue - lowFactorValue) ) + factorArray[lowIndex] ; - if (debugFlag) - debugPrint(" findFactor returns ******" + + if (debugFlag) + debugPrint(" findFactor returns ******" + returnValue + " ******"); return (float)returnValue; - } + } } /** - * CalculateDistanceAttenuation - * - * Simply calls ConeSound specific 'findFactor()' with + * CalculateDistanceAttenuation + * + * Simply calls ConeSound specific 'findFactor()' with * both front and back attenuation linear distance and gain scale factor - * arrays. - */ + * arrays. + */ float calculateDistanceAttenuation(float distance) { float factor = findFactor(distance, this.attenuationDistance, this.attenuationGain, this.backAttenuationDistance, @@ -599,11 +599,11 @@ class JSDirectionalSample extends JSPositionalSample return factor; } /** - * CalculateAngularGain - * - * Simply calls generic (for PointSound) 'findFactor()' with + * CalculateAngularGain + * + * Simply calls generic (for PointSound) 'findFactor()' with * a single set of angular attenuation distance and gain scalefactor arrays. - */ + */ float calculateAngularGain() { float angle = findAngularOffset(); float factor = findFactor(angle, this.angularDistance, this.angularGain); @@ -611,14 +611,14 @@ class JSDirectionalSample extends JSPositionalSample return 1.0f; else return factor; - } + } /* ***************** - * + * * Find Angular Offset - * + * * *****************/ - /* + /* * Calculates the angle from the sound's direction axis and the ray from * the sound origin to the listener'center ear. * For Cone Sounds this value is the arc cosine of dot-product between @@ -627,7 +627,7 @@ class JSDirectionalSample extends JSPositionalSample * Center ear position is in Virtual World coordinates. * Assumes that calculation done in VWorld Space... * Assumes that xformPosition is already calculated... - */ + */ float findAngularOffset() { Vector3f unitToEar = new Vector3f(); Vector3f unitDirection = new Vector3f(); @@ -635,10 +635,10 @@ class JSDirectionalSample extends JSPositionalSample Point3f xformCenterEar = centerEars[currentIndex]; float dotProduct; float angle; - /* + /* * TODO: (Question) is assumption that xformed values available O.K. * TODO: (Performance) save this angular offset and only recalculate - * if centerEar or sound position have changed. + * if centerEar or sound position have changed. */ unitToEar.x = xformCenterEar.x - xformPosition.x; unitToEar.y = xformCenterEar.y - xformPosition.y; @@ -653,11 +653,11 @@ class JSDirectionalSample extends JSPositionalSample } /************ - * + * * Calculate Filter - * + * * *****************/ - /* + /* * Calculates the low-pass cutoff frequency filter value applied to the * a sound based on both: * Distance Filter (from Aural Attributes) based on distance @@ -667,7 +667,7 @@ class JSDirectionalSample extends JSPositionalSample * vector between the sounds position and center ear. * The lowest of these two filter is used. * This filter value is stored into the sample's filterFreq field. - */ + */ void calculateFilter(float distance, AuralParameters attribs) { // setting filter cutoff freq to 44.1kHz which, in this // implementation, is the same as not performing filtering @@ -690,7 +690,7 @@ class JSDirectionalSample extends JSPositionalSample } // Calculate angle from direction axis towards listener - float angle = findAngularOffset(); + float angle = findAngularOffset(); distanceFilter = findFactor((double)angle, angularDistance, angularFilterCutoff); if (distanceFilter < 0.0f) @@ -702,10 +702,10 @@ class JSDirectionalSample extends JSPositionalSample distanceFilterFound = false; distanceFilter = -1.0f; } - + if (debugFlag) debugPrint(" calculateFilter arrayLength = " + arrayLength); - + // Angular filter of directional sound sources. arrayLength = angularDistance.length; filterType = angularFilterType; @@ -720,7 +720,7 @@ class JSDirectionalSample extends JSPositionalSample else { angularFilterFound = false; angularFilter = -1.0f; - } + } filterFlag = distanceFilterFound || angularFilterFound; if (distanceFilter < 0.0f) diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java index 9bbc5ae..20a9682 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSPositionalSample.java @@ -56,12 +56,12 @@ import javax.vecmath.*; import com.sun.j3d.audioengines.*; /** - * The PostionalSample Class defines the data and methods associated with a + * The PostionalSample Class defines the data and methods associated with a * PointSound sample played thru the AudioDevice. */ class JSPositionalSample extends JSSample -{ +{ // maintain fields for stereo channel rendering float leftGain = 1.0f; // scale factor @@ -79,18 +79,18 @@ class JSPositionalSample extends JSSample * are allocated, one each for the left and right channels, played at * a different (delayed) time and with a different gain value. */ - int secondIndex = NULL_SAMPLE; + int secondIndex = NULL_SAMPLE; /** * A third sample for control of reverb of the stream/clip is openned * and maintained for all directional/positional sounds. - * For now, even if no aural attributes (using reverb) are active, - * a reverb channel is always started with the other two. A sound could + * For now, even if no aural attributes (using reverb) are active, + * a reverb channel is always started with the other two. A sound could * be started without reverb and then reverb added later, but since there * is no way to offset properly into all sounds (considering non-cached * and nconsistent rate-changes during playing) this third sound is * always allocated and started. */ - int reverbIndex = NULL_SAMPLE; + int reverbIndex = NULL_SAMPLE; /** * Save ear positions transformed into VirtualWorld coords from Head coords @@ -118,13 +118,13 @@ class JSPositionalSample extends JSSample * sound was last processed. * Process delta distance and time as part of Doppler calculations. */ - static int MAX_DISTANCES = 4; - int numDistances = 0; + static int MAX_DISTANCES = 4; + int numDistances = 0; // TODO: time is based on changes to position!!! only // TODO: must shap shot when either Position OR ear changes!!! // TODO: must grab all changes to VIEW parameters (could change ear)!!! // not just when pointer to View changes!! - long[] times = new long[MAX_DISTANCES]; + long[] times = new long[MAX_DISTANCES]; Point3f[] positions = new Point3f[MAX_DISTANCES]; // xformed sound source positions Point3f[] centerEars = new Point3f[MAX_DISTANCES]; // xformed center ear positions /* @@ -134,14 +134,14 @@ class JSPositionalSample extends JSSample int firstIndex = 0; int lastIndex = 0; int currentIndex = 0; - + /* * Allow changes in Doppler rate only small incremental values otherwise * you hear skips in the pitch of a sound during playback. * When playback is faster, allow delta changes: - * (diff in Factor for octave (1.0))/(12 1/2-steps))*(1/4) of half-step + * (diff in Factor for octave (1.0))/(12 1/2-steps))*(1/4) of half-step * When playback is slower, allow delta changes: - * (diff in Factor for octave (0.5))/(12 1/2-steps))*(1/4) of half-step + * (diff in Factor for octave (0.5))/(12 1/2-steps))*(1/4) of half-step */ double lastRequestedDopplerRateRatio = -1.0f; double lastActualDopplerRateRatio = -1.0f; @@ -155,13 +155,13 @@ class JSPositionalSample extends JSSample /* * Process request for Filtering fields - */ + */ boolean filterFlag = false; float filterFreq = -1.0f; /* * Construct a new audio device Sample object - */ + */ public JSPositionalSample() { super(); if (debugFlag) @@ -178,7 +178,7 @@ class JSPositionalSample extends JSSample // TODO: get/set reverbChannel to JSStream/Clip/MIDI /* * Process request for Filtering fields - */ + */ boolean getFilterFlag() { return filterFlag; } @@ -186,11 +186,11 @@ class JSPositionalSample extends JSSample return filterFreq; } - + /** - * Clears the fields associated with sample data for this sound, and + * Clears the fields associated with sample data for this sound, and * frees any device specific data associated with this sample. - */ + */ public void clear() { if (debugFlag) debugPrint("JSPositionalSample.clear() enter"); @@ -212,9 +212,9 @@ class JSPositionalSample extends JSSample } /** - * Reset time and count based fields associated with sample data + * Reset time and count based fields associated with sample data * for this sound - */ + */ void reset() { if (debugFlag) debugPrint("JSPositionalSample.reset() enter"); @@ -224,7 +224,7 @@ class JSPositionalSample extends JSSample sourcePositionChange = -1.0; headPositionChange = -1.0; rateRatio = 1.0f; - numDistances = 0; + numDistances = 0; averageDistances = false; if (debugFlag) debugPrint("JSPositionalSample.reset() exit"); @@ -258,7 +258,7 @@ class JSPositionalSample extends JSSample currentIndex %= MAX_DISTANCES; lastIndex %= MAX_DISTANCES; firstIndex %= MAX_DISTANCES; - } + } } // Not only do we transform position but delta time is calculated and @@ -272,7 +272,7 @@ class JSPositionalSample extends JSSample Point3f newPosition = new Point3f(); if (debugFlag) debugPrint("*** setXformedPosition"); - // xform Position + // xform Position if (getVWrldXfrmFlag()) { if (debugFlag) debugPrint(" Transform set so transform pos"); @@ -294,30 +294,30 @@ class JSPositionalSample extends JSSample incrementIndices(); // store new transformed position - times[currentIndex] = System.currentTimeMillis(); + times[currentIndex] = System.currentTimeMillis(); positions[currentIndex].set(newPosition); if (debugFlag) debugPrint(" xform(sound)Position -" + " positions[" + currentIndex + "] = (" + - positions[currentIndex].x + ", " + + positions[currentIndex].x + ", " + positions[currentIndex].y + ", " + positions[currentIndex].z + ")"); - + // since this is a change to the sound position and not the // head save the last head position into the current element if (numDistances > 1) centerEars[currentIndex].set(centerEars[lastIndex]); - } + } /** - * Set Doppler effect Rate + * Set Doppler effect Rate * * Calculate the rate of change in for the head and sound * between the two time stamps (last two times position or * VirtualWorld transform was updated). - * First determine if the head and sound source are moving - * towards each other (distance between them is decreasing), + * First determine if the head and sound source are moving + * towards each other (distance between them is decreasing), * moving away from each other (distance between them is * increasing), or no change (distance is the same, not moving * or moving the same speed/direction). @@ -335,9 +335,9 @@ class JSPositionalSample extends JSSample * | speedOfSound*rollOff + velocityOfHead*velocityScaleFactor | * | ------------------------------------------------------------- | * | speedOfSound*rollOff - velocityOfSource*velocityScaleFactor | - * + * * For head and sound moving away from each other, velocityRatio (< 1.0) is: - * + * * | speedOfSound*rollOff - velocityOfHead*velocityScaleFactor | * | ------------------------------------------------------------- | * | speedOfSound*rollOff + velocityOfSource*velocityScaleFactor | @@ -345,13 +345,13 @@ class JSPositionalSample extends JSSample * where frequencyScaleFactor, rollOff, velocityScaleFactor all come from * the active AuralAttributes parameters. * The following special cases must be test for AuralAttribute parameters: - * rolloff + * rolloff * Value MUST be > zero for any sound to be heard! * If value is zero, all sounds affected by AuralAttribute region are silent. - * velocityScaleFactor + * velocityScaleFactor * Value MUST be > zero for any sound to be heard! * If value is zero, all sounds affected by AuralAttribute region are paused. - * frequencyScaleFactor + * frequencyScaleFactor * Value of zero disables Doppler calculations: * Sfreq' = Sfreq * frequencyScaleFactor * @@ -378,7 +378,7 @@ class JSPositionalSample extends JSSample Point3f xformCenterEar; float averagedSoundDistances = 0.0f; float averagedEarsDistances = 0.0f; - + /* * Average the differences between the last MAX_DISTANCE * sound positions and head positions @@ -428,7 +428,7 @@ class JSPositionalSample extends JSSample // can't calculate change in direction return 0.0f; // sample rate ratio is zero } - + deltaTime = times[currentIndex] - times[firstIndex]; for (int i=0; i<(MAX_DISTANCES-1); i++) { averagedSoundDistances += positions[i+1].distance(positions[i]); @@ -442,12 +442,12 @@ class JSPositionalSample extends JSSample debugPrint(" " + "delta time = " + deltaTime ); debugPrint(" " + - "soundPosition delta = " + + "soundPosition delta = " + xformPosition.distance(lastXformPosition)); debugPrint(" " + "soundVelocity = " + soundVelocity); debugPrint(" " + - "headPosition delta = " + + "headPosition delta = " + xformCenterEar.distance(lastXformCenterEar)); debugPrint(" " + "headVelocity = " + headVelocity); @@ -467,7 +467,7 @@ class JSPositionalSample extends JSSample headVelocity *= velocityScaleFactor; if (dopplerFlag) { debugPrint(" " + - "attrib velocity scale factor = " + + "attrib velocity scale factor = " + velocityScaleFactor ); debugPrint(" " + "new soundVelocity = " + soundVelocity); @@ -485,7 +485,7 @@ class JSPositionalSample extends JSSample numerator = speedOfSound + headVelocity; denominator = speedOfSound - soundVelocity; } - else { + else { // sound and head moving away from each other // note: no change in distance case covered above if (dopplerFlag) @@ -503,7 +503,7 @@ class JSPositionalSample extends JSSample } else if (denominator <= 0.0) { if (dopplerFlag) - debugPrint("JSPositionalSample.calculateDoppler: " + + debugPrint("JSPositionalSample.calculateDoppler: " + "BOOM!! - velocity of sound source negative"); return -1.0f; } @@ -547,7 +547,7 @@ class JSPositionalSample extends JSSample debugPrint(" No change in ear, so don't reset"); return; } - // store xform Ear + // store xform Ear incrementIndices(); times[currentIndex] = System.currentTimeMillis(); centerEars[currentIndex].set(xformCenterEar); @@ -565,14 +565,14 @@ class JSPositionalSample extends JSSample // TODO: check dirty flags coming in // For now, recalculate ear positions by forcing earsXformed false - boolean earsXformed = false; - if (!earsXformed) { + boolean earsXformed = false; + if (!earsXformed) { if (view != null) { PhysicalBody body = view.getPhysicalBody(); if (body != null) { // Get Head Coord. to Virtual World transform - // TODO: re-enable this when userHeadToVworld is + // TODO: re-enable this when userHeadToVworld is // implemented correctly!!! Transform3D headToVwrld = new Transform3D(); view.getUserHeadToVworld(headToVwrld); @@ -608,20 +608,20 @@ class JSPositionalSample extends JSSample // calculate the new (current) mid-point between the ears // find the mid point between left and right ear positions - xformCenterEar.x = xformLeftEar.x + + xformCenterEar.x = xformLeftEar.x + ((xformRightEar.x - xformLeftEar.x)*0.5f); - xformCenterEar.y = xformLeftEar.y + + xformCenterEar.y = xformLeftEar.y + ((xformRightEar.y - xformLeftEar.y)*0.5f); - xformCenterEar.z = xformLeftEar.z + + xformCenterEar.z = xformLeftEar.z + ((xformRightEar.z - xformLeftEar.z)*0.5f); // TODO: when head changes earDirty should be set! // earDirty = false; if (debugFlag) { debugPrint(" earXformed CALCULATED"); - debugPrint(" xformCenterEar = " + + debugPrint(" xformCenterEar = " + xformCenterEar.x + " " + xformCenterEar.y + " " + - xformCenterEar.z ); + xformCenterEar.z ); } earsXformed = true; } // end of body NOT null @@ -635,19 +635,19 @@ class JSPositionalSample extends JSSample // uses the default head position of (0.0, -0.03, 0.095) if (debugFlag) debugPrint(" earXformed NOT calculated"); - } + } return earsXformed; } - /** + /** * Render this sample * * Calculate the audiodevice parameters necessary to spatially play this * sound. - */ + */ public void render(int dirtyFlags, View view, AuralParameters attribs) { if (debugFlag) - debugPrint("JSPositionalSample.render"); + debugPrint("JSPositionalSample.render"); updateEar(dirtyFlags, view); /* @@ -658,7 +658,7 @@ class JSPositionalSample extends JSSample * are silent. * FrequencyScaleFactor value MUST be > zero for any sound to be heard! * since Sfreq' = Sfreq * frequencyScaleFactor. - * If FrequencyScaleFactor is zero, all sounds affected by + * If FrequencyScaleFactor is zero, all sounds affected by * AuralAttribute region are paused. * VelocityScaleFactor value of zero disables Doppler calculations. * @@ -707,7 +707,7 @@ class JSPositionalSample extends JSSample // error returned by calculateDoppler if (debugFlag) { debugPrint("JSPositionalSample: render: " + - "dopplerRatio returned = " + + "dopplerRatio returned = " + dopplerRatio + "< 0"); } // TODO: Make sound silent @@ -732,10 +732,10 @@ class JSPositionalSample extends JSSample } else { // auralAttributes not null but velocityFactor <= 0 // Doppler is disabled - rateRatio = frequencyScaleFactor * getRateScaleFactor(); + rateRatio = frequencyScaleFactor * getRateScaleFactor(); } } - /* + /* * since aural attributes undefined, default values are used, * thus no Doppler calculated */ @@ -746,31 +746,31 @@ class JSPositionalSample extends JSSample } this.panSample(attribs); - } + } /* ***************** - * + * * Calculate Angular Gain - * + * * *****************/ - /* + /* * Calculates the Gain scale factor applied to the overall gain for * a sound based on angle between a sound's projected direction and the * vector between the sounds position and center ear. * * For Point Sounds this value is always 1.0f. - */ + */ float calculateAngularGain() { return(1.0f); } /* ***************** - * + * * Calculate Filter - * + * * *****************/ - /* - * Calculates the low-pass cutoff frequency filter value applied to the + /* + * Calculates the low-pass cutoff frequency filter value applied to the * a sound based on both: * Distance Filter (from Aural Attributes) based on distance * between the sound and the listeners position @@ -779,7 +779,7 @@ class JSPositionalSample extends JSSample * vector between the sounds position and center ear. * The lowest of these two filter is used. * This filter value is stored into the sample's filterFreq field. - */ + */ void calculateFilter(float distance, AuralParameters attribs) { // setting filter cutoff freq to 44.1kHz which, in this // implementation, is the same as not performing filtering @@ -799,7 +799,7 @@ class JSPositionalSample extends JSSample for (int i=0; i= distanceArray[largestIndex]) { if (debugFlag) { - debugPrint(" findFactor: distance > " + + debugPrint(" findFactor: distance > " + distanceArray[largestIndex]); debugPrint(" distanceArray length = "+ arrayLength); } @@ -884,7 +884,7 @@ class JSPositionalSample extends JSSample debugPrint(" findFactor: distance < " + distanceArray[0]); return factorArray[0]; - } + } /* * Distance between points within attenuation array. * Use binary halfing of distance array @@ -896,11 +896,11 @@ class JSPositionalSample extends JSSample debugPrint(" while loop to find index: "); while (lowIndex < (highIndex-1)) { if (debugFlag) { - debugPrint(" lowIndex " + lowIndex + + debugPrint(" lowIndex " + lowIndex + ", highIndex " + highIndex); - debugPrint(" d.A. pair for lowIndex " + + debugPrint(" d.A. pair for lowIndex " + distanceArray[lowIndex] + ", " + factorArray[lowIndex] ); - debugPrint(" d.A. pair for highIndex " + + debugPrint(" d.A. pair for highIndex " + distanceArray[highIndex] + ", " + factorArray[highIndex] ); } /* @@ -917,7 +917,7 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " index == distanceGain " + lowIndex); - debugPrint(" findFactor returns [LOW=" + + debugPrint(" findFactor returns [LOW=" + lowIndex + "] " + factorArray[lowIndex]); } // take value of scale factor directly from factorArray @@ -932,13 +932,13 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " index == distanceGain " + highIndex); - debugPrint(" findFactor returns [HIGH=" + + debugPrint(" findFactor returns [HIGH=" + highIndex + "] " + factorArray[highIndex]); } // take value of scale factor directly from factorArray return factorArray[highIndex]; } - if (distance > distanceArray[lowIndex] && + if (distance > distanceArray[lowIndex] && distance < distanceArray[highIndex] ) { indexMid = lowIndex + ((highIndex - lowIndex) / 2); if (distance <= distanceArray[indexMid]) @@ -950,7 +950,7 @@ class JSPositionalSample extends JSSample } /* of while */ /* - * ratio: distance from listener to sound source + * ratio: distance from listener to sound source * between lowIndex and highIndex times * attenuation value between lowIndex and highIndex * gives linearly interpolationed attenuation value @@ -958,27 +958,27 @@ class JSPositionalSample extends JSSample if (debugFlag) { debugPrint( " ratio calculated using lowIndex " + lowIndex + ", highIndex " + highIndex); - debugPrint( " d.A. pair for lowIndex " + + debugPrint( " d.A. pair for lowIndex " + distanceArray[lowIndex]+", "+factorArray[lowIndex] ); - debugPrint( " d.A. pair for highIndex " + + debugPrint( " d.A. pair for highIndex " + distanceArray[highIndex]+", "+factorArray[highIndex] ); } - float outputFactor = + float outputFactor = ((float)(((distance - distanceArray[lowIndex])/ (distanceArray[highIndex] - distanceArray[lowIndex]) ) ) * (factorArray[highIndex] - factorArray[lowIndex]) ) + - factorArray[lowIndex] ; + factorArray[lowIndex] ; if (debugFlag) debugPrint(" findFactor returns " + outputFactor); return outputFactor; - } + } } /** * CalculateDistanceAttenuation * - * Simply calls generic (for PointSound) 'findFactor()' with + * Simply calls generic (for PointSound) 'findFactor()' with * a single set of attenuation distance and gain scale factor arrays. */ float calculateDistanceAttenuation(float distance) { @@ -992,11 +992,11 @@ class JSPositionalSample extends JSSample } /* ****************** - * + * * Pan Sample - * + * * ******************/ - /* + /* * Sets pan and delay for a single sample associated with this Sound. * Front and Back quadrants are treated the same. */ @@ -1046,7 +1046,7 @@ class JSPositionalSample extends JSSample float distanceGain = 1.0f; float allGains = this.gain; // product of gain scale factors - + Point3f workingPosition = new Point3f(); Point3f workingCenterEar = new Point3f(); @@ -1085,7 +1085,7 @@ class JSPositionalSample extends JSSample sourceToLeftEar.z = xformLeftEar.z - workingPosition.z; /* - * get distances from SoundSource to + * get distances from SoundSource to * (i) head origin * (ii) right ear * (iii) left ear @@ -1118,7 +1118,7 @@ class JSPositionalSample extends JSSample xformHeadZAxis.length()); } - // Dot Product + // Dot Product double dotProduct = (double)( (sourceToCenterEar.dot(xformHeadZAxis))/ (sourceToCenterEar.length() * xformHeadZAxis.length())); @@ -1146,10 +1146,10 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint( " gamma " + gamma ); - rightEarClosest = + rightEarClosest = (distanceSourceToRightEar>distanceSourceToLeftEar) ? false : true ; /* - * Determine the quadrant sound is in + * Determine the quadrant sound is in */ if (rightEarClosest) { if (debugFlag) @@ -1184,14 +1184,14 @@ class JSPositionalSample extends JSSample debugPrint( " partial distance from edge of head to source = " + distanceSourceToCenterEar); if (rightEarClosest) { - distanceSourceToLeftEar = + distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi+alpha-gamma); if (debugFlag) debugPrint(" new distance from left ear to source = " + distanceSourceToLeftEar); - } + } else { - distanceSourceToRightEar = + distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi+alpha-gamma); if (debugFlag) debugPrint(" new distance from right ear to source = " @@ -1207,16 +1207,16 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint(" closest path is also indirect "); // Path of sound to closest ear is indirect - + if (rightEarClosest) { - distanceSourceToRightEar = + distanceSourceToRightEar = DISTANCE + radiusOfHead * (halfPi-alpha-gamma); if (debugFlag) debugPrint(" new distance from right ear to source = " + distanceSourceToRightEar); } else { - distanceSourceToLeftEar = + distanceSourceToLeftEar = DISTANCE + radiusOfHead * (halfPi-alpha-gamma); if (debugFlag) debugPrint(" new distance from left ear to source = " @@ -1240,11 +1240,11 @@ class JSPositionalSample extends JSSample /** * Short-cut taken. Rather than using actual delays from source - * (where the overall distances would be taken into account in + * (where the overall distances would be taken into account in * determining delay) the difference in the left and right delay * are applied. * This approach will be preceptibly wrong for sound sources that - * are very far away from the listener so both ears would have + * are very far away from the listener so both ears would have * large delay. */ sampleRate = channel.rateInHz * (0.001f); // rate in milliseconds @@ -1307,7 +1307,7 @@ class JSPositionalSample extends JSSample if (debugFlag) debugPrint("panSample: quadrant " + quadrant); switch (quadrant) { - case 1: + case 1: // Sound from front, right of center of head case 4: // Sound from back, right of center of head @@ -1329,7 +1329,7 @@ class JSPositionalSample extends JSSample // Combines distance and angular filter to set this sample's current // frequency cutoff value - calculateFilter(distanceSourceToCenterEar, attribs); + calculateFilter(distanceSourceToCenterEar, attribs); } /* panSample() */ diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java index 91e4eb3..750e177 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSSample.java @@ -68,29 +68,29 @@ class JSSample extends com.sun.j3d.audioengines.Sample * with each sound. */ - /** + /** * Sound Data Types - * + * * Samples can be processed as streaming or buffered data. * Fully spatializing sound sources may require data to be buffered. - * + * * Sound data specified as Streaming is not copied by the AudioDevice * driver implementation. It is up the application to ensure that * this data is continuously accessible during sound rendering. * Futhermore, full sound spatialization may not be possible, for * all AudioDevice implementations on unbuffered sound data. - */ + */ static final int STREAMING_AUDIO_DATA = 1; - /** + /** * Sound data specified as Buffered is copied by the AudioDevice * driver implementation. - */ + */ static final int BUFFERED_AUDIO_DATA = 2; - /** - * MIDI data + /** + * MIDI data * TODO: differentiate between STREAMING and BUFFERED MIDI data * right now all MIDI data is buffered - */ + */ static final int STREAMING_MIDI_DATA = 3; static final int BUFFERED_MIDI_DATA = 3; static final int UNSUPPORTED_DATA_TYPE = -1; @@ -99,19 +99,19 @@ class JSSample extends com.sun.j3d.audioengines.Sample /** * sound data types: BUFFERED (cached) or STREAMING (non-cached) - */ + */ int dataType = BUFFERED_AUDIO_DATA; JSChannel channel = null; /** * Offset pointer within currently playing sample data - */ + */ long dataOffset = 0; /* * Maintain continuously playing silent sound sources. - */ + */ long timeDeactivated = 0; long positionDeactivated = 0; @@ -128,7 +128,7 @@ class JSSample extends com.sun.j3d.audioengines.Sample public JSSample() { super(); - if (debugFlag) + if (debugFlag) debugPrintln("JSSample constructor"); } @@ -153,19 +153,19 @@ class JSSample extends com.sun.j3d.audioengines.Sample else rateRatio = currentRateRatio * freqScaleFactor; } - else - rateRatio = currentRateRatio; + else + rateRatio = currentRateRatio; } /** * Clears/re-initialize fields associated with sample data for * this sound, * and frees any device specific data associated with this sample. - */ + */ public void clear() { super.clear(); if (debugFlag) - debugPrintln("JSSample.clear() entered"); + debugPrintln("JSSample.clear() entered"); // TODO: unload sound data at device // null out samples element that points to this? // would this cause samples list size to shrink? @@ -183,7 +183,7 @@ class JSSample extends com.sun.j3d.audioengines.Sample rateRatio = 1.0f; channel = null; if (debugFlag) - debugPrintln("JSSample.clear() exited"); + debugPrintln("JSSample.clear() exited"); } // @return error true if error occurred @@ -203,11 +203,11 @@ class JSSample extends com.sun.j3d.audioengines.Sample // TODO: How do we determine if the file is a MIDI file??? // for now set dataType to BUFFERED_ or STREAMING_AUDIO_DATA // used to test for ais instanceof AudioMidiInputStream || - // ais instanceof AudioRmfInputStream ) + // ais instanceof AudioRmfInputStream ) // then set dataType = JSSample.BUFFERED_MIDI_DATA; // QUESTION: can non-cached MIDI files ever be supported ? /**************** - // TODO: when we have a way to determine data type use code below + // TODO: when we have a way to determine data type use code below if (dataType==UNSUPPORTED_DATA_TYPE OR error_occurred) clearSound(index); if (debugFlag) @@ -222,10 +222,10 @@ class JSSample extends com.sun.j3d.audioengines.Sample dataType = STREAMING_AUDIO_DATA; if ((url == null) && (inputStream == null) && (path == null)) { - if (debugFlag) + if (debugFlag) debugPrint("JavaSoundMixer.loadSound null data - return error"); return true; - } + } // get ais if (path != null) { @@ -244,10 +244,10 @@ class JSSample extends com.sun.j3d.audioengines.Sample // get DataLine channel based on data type if (dataType == BUFFERED_AUDIO_DATA) { - if (debugFlag) + if (debugFlag) debugPrintln("JSSample.load dataType = BUFFERED "); channel = new JSClip(); - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSClip.initAudioInputStream"); if (url != null) ais = channel.initAudioInputStream(url, cacheFlag); @@ -259,15 +259,15 @@ class JSSample extends com.sun.j3d.audioengines.Sample "initAudioInputStream() failed"); return true; } - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSClip.initDataLine"); dataLine = channel.initDataLine(ais); } else if (dataType == STREAMING_AUDIO_DATA) { - if (debugFlag) + if (debugFlag) debugPrintln("JSSample.load dataType = STREAMING "); channel = new JSStream(); - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSStream.initAudioInputStream"); if (url != null) ais = channel.initAudioInputStream(url, cacheFlag); @@ -279,14 +279,14 @@ class JSSample extends com.sun.j3d.audioengines.Sample "initAudioInputStream() failed"); return true; } - if (debugFlag) + if (debugFlag) debugPrintln(" calls JSStream.initDataLine"); dataLine = channel.initDataLine(ais); } else { if (debugFlag) - debugPrintln("JSSample.load doesn't support MIDI yet"); - } + debugPrintln("JSSample.load doesn't support MIDI yet"); + } if (dataLine == null) { if (debugFlag) debugPrint("JSSample.load initDataLine failed "); @@ -315,47 +315,47 @@ class JSSample extends com.sun.j3d.audioengines.Sample rateRatio = 1.0f; } -// TODO: NEED methods for any field accessed by both JSThread and -// JavaSoundMixer so that we can make these MT safe?? +// TODO: NEED methods for any field accessed by both JSThread and +// JavaSoundMixer so that we can make these MT safe?? /* * Process request for Filtering fields - */ - boolean getFilterFlag() { + */ + boolean getFilterFlag() { return false; } - float getFilterFreq() { + float getFilterFreq() { return -1.0f; } - void setCurrentRateRatio(float ratio) { + void setCurrentRateRatio(float ratio) { currentRateRatio = ratio; } - float getCurrentRateRatio() { + float getCurrentRateRatio() { return currentRateRatio; } - void setTargetRateRatio(float ratio) { + void setTargetRateRatio(float ratio) { targetRateRatio = ratio; } - float getTargetRateRatio() { + float getTargetRateRatio() { return targetRateRatio; } - void setRampRateFlag(boolean flag) { + void setRampRateFlag(boolean flag) { rampRateFlag = flag; } - boolean getRampRateFlag() { + boolean getRampRateFlag() { return rampRateFlag; } - void setDataType(int type) { + void setDataType(int type) { dataType = type; } - int getDataType() { + int getDataType() { return dataType; } diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java index 784186e..9bde9fb 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JSThread.java @@ -67,7 +67,7 @@ class JSThread extends com.sun.j3d.audioengines.AudioEngineThread { */ int totalChannels = 0; /** - * flags denoting if dynamic gain or rate interpolation is to be performed + * flags denoting if dynamic gain or rate interpolation is to be performed */ boolean rampGain = false; @@ -104,7 +104,7 @@ class JSThread extends com.sun.j3d.audioengines.AudioEngineThread { /** * This method performs one iteration of pending work to do - * + * * Wildly "garbled" sounds was caused by unequal changes in delta * time verses delta distances (resulting in jumps in rate factors * calculated for Doppler. This work thread is meant to smoothly @@ -127,7 +127,7 @@ can keep my own loop count for streams??? not really // QUESTION: will size ever get smaller after get performed??? int numSamples = audioEngine.getSampleListSize(); JSSample sample = null; - int numRateRamps = 0; + int numRateRamps = 0; for (int index = 0; index < numSamples; index++) { // loop thru samples looking for ones needing rate incremented sample = (JSSample)audioEngine.getSample(index); @@ -166,7 +166,7 @@ runMonitor(RUN, 0, null); /** * Gradually change rate scale factor - * + * * If the rate change is too great suddenly, it sounds like a * jump, so we need to change gradually over time. * Since an octive delta change up is 2.0 but down is 0.5, forced @@ -202,7 +202,7 @@ runMonitor(RUN, 0, null); } endOfRamp = false; // target value not reached } - /* + /* * otherwise delta change is within tolerance * so use requested RateRatio as calculated w/out change */ @@ -328,7 +328,7 @@ leftGain, rightGain ******/ } - void setSampleDelay(JSSample sample, JSAuralParameters attribs) { + void setSampleDelay(JSSample sample, JSAuralParameters attribs) { /****** // take fields as already set in sample and updates delay // called after sample.render performed @@ -408,7 +408,7 @@ leftDelay, rightDelay // take fields as already set in sample and updates rate // called after sample.render performed this.setSampleRate(sample, rateScaleFactor); - // disables rate from being gradually increased or decreased + // disables rate from being gradually increased or decreased // don't set global thread flat rampRate false just because // one sample's rate is set to a specific value. sample.setRampRateFlag(false); @@ -441,7 +441,7 @@ leftDelay, rightDelay com.sun.j3d.audio.J3DHaeClip.setSampleGain(index, gain); } else { - // dataType==JSAuralParameters.STREAMING_MIDI_DATA + // dataType==JSAuralParameters.STREAMING_MIDI_DATA // dataType==JSAuralParameters.BUFFERED_MIDI_DATA com.sun.j3d.audio.J3DHaeMidi.setSampleGain(index, gain); } @@ -490,7 +490,7 @@ leftDelay, rightDelay } ***********/ sample.setCurrentRateRatio(scaleFactor); - } + } boolean startSample(JSSample sample) { /********** @@ -558,7 +558,7 @@ leftDelay, rightDelay int reverbRtrnVal = JSClip.startSample( ((JSPositionalSample)sample).getReverbIndex(), loopCount, reverbGain); - + if (debugFlag) debugPrint("JSThread " + "start stream positionalSound with gain " + leftGain @@ -583,7 +583,7 @@ leftDelay, rightDelay // TODO: positional MIDI sounds not supported. // The above startSamples really just start on sample // Don't bother with reverb channel for now. - + // // start up reverb channel w/out delay even if reverb not on now // float reverbGain = 0.0f; @@ -668,7 +668,7 @@ leftDelay, rightDelay ************/ return true; } - + void pauseSample(JSSample sample) { /********** @@ -740,7 +740,7 @@ leftDelay, rightDelay ((JSPositionalSample)sample).getSecondIndex()); returnValue = JSStream.unpauseSample( ((JSPositionalSample)sample).getReverbIndex()); - } + } else returnValue = JSStream.unpauseSample(sample); } @@ -751,7 +751,7 @@ leftDelay, rightDelay ((JSPositionalSample)sample).getSecondIndex()); returnValue = JSClip.unpauseSample( ((JSPositionalSample)sample).getReverbIndex()); - } + } else returnValue = JSClip.unpauseSample(sample); } @@ -780,14 +780,14 @@ leftDelay, rightDelay if (debugFlag) debugPrint( "JSThread: Internal Error unpauseSample " + "for sample " + sample + " failed"); - + } // QUESTION: return value or not??? return; *************/ } -// TODO: +// TODO: void muteSample(JSSample sample) { // is this already muted? if so don't do anytning @@ -795,7 +795,7 @@ leftDelay, rightDelay // as a stop, advance restart... } -// TODO: +// TODO: void unmuteSample(JSSample sample) { if (debugFlag) debugPrint( "JSThread.unmuteSample not implemented"); @@ -834,7 +834,7 @@ leftDelay, rightDelay /** * Code to close the device * @return flag: true is closed sucessfully, false if error - */ + */ boolean close() { // TODO: for now do nothing return false; diff --git a/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java b/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java index 29cda52..75ce7ae 100755 --- a/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java +++ b/src/classes/share/com/sun/j3d/audioengines/javasound/JavaSoundMixer.java @@ -68,12 +68,12 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // Debug print flags and methods static final boolean debugFlag = false; static final boolean internalErrors = false; - + void debugPrint(String message) { if (debugFlag) System.out.println(message); } - + void debugPrintln(String message) { if (debugFlag) System.out.println(message); @@ -93,7 +93,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /* * new fields in extended class - */ + */ protected float deviceGain = 1.0f; protected static final int NOT_PAUSED = 0; @@ -106,7 +106,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Construct a new JavaSoundMixer with the specified P.E. * @param physicalEnvironment the physical environment object where we * want access to this device. - */ + */ public JavaSoundMixer(PhysicalEnvironment physicalEnvironment ) { super(physicalEnvironment); thread = new JSThread(Thread.currentThread().getThreadGroup(), this); @@ -117,17 +117,17 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * for this audio device. * Overridden method from AudioEngine. * @return number of maximum voices play simultaneously on JavaSound Mixer. - */ + */ public int getTotalChannels() { if (thread != null) return thread.getTotalChannels(); else return 32; } - + /** * Code to initialize the device - * New interface to mixer/engine specific methods + * New interface to mixer/engine specific methods * @return flag: true is initialized sucessfully, false if error */ public boolean initialize() { @@ -144,7 +144,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /** * Code to close the device. - * New interface to mixer/engine specific methods + * New interface to mixer/engine specific methods * @return flag: true is closed sucessfully, false if error */ public boolean close() { @@ -243,7 +243,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { sample.setSoundData(soundData); } } - + if (debugFlag) { debugPrint(" prepareSound type = "+soundType); debugPrintln("JavaSoundMixer.prepareSound returned "+index); @@ -254,7 +254,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /** * Clears the fields associated with sample data for this sound. * Overriden method from AudioEngine3D. - */ + */ public void clearSound(int index) { // TODO: call JSXXXX clear method JSSample sample = null; @@ -329,9 +329,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setDirection(int index, Vector3d direction) { if (debugFlag) debugPrintln("JavaSoundMixer: setDirection for index " + index); @@ -345,28 +345,28 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } return; } - - /* + + /* * Overriden method from AudioEngine3D. - */ + */ public void setReflectionCoefficient(float coefficient) { super.setReflectionCoefficient(coefficient); auralParams.reverbDirty |= JSAuralParameters.REFLECTION_COEFF_CHANGED; return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setReverbDelay(float reverbDelay) { super.setReverbDelay(reverbDelay); auralParams.reverbDirty |= JSAuralParameters.REVERB_DELAY_CHANGED; return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void setReverbOrder(int reverbOrder) { super.setReverbOrder(reverbOrder); auralParams.reverbDirty |= JSAuralParameters.REVERB_ORDER_CHANGED; @@ -379,7 +379,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Point and Cone sounds?? * * For now background sounds are not reverberated - * + * * Overriden method from AudioEngine3D. */ public int startSample(int index) { @@ -390,7 +390,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { JSSample sample = null; if ( ( (sample = (JSSample)getSample(index)) == null) || - thread == null ) + thread == null ) return JSSample.NULL_SAMPLE; int soundType = sample.getSoundType(); @@ -409,7 +409,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (soundType != AudioDevice3D.BACKGROUND_SOUND) setFilter(index, sample.getFilterFlag(), sample.getFilterFreq()); } - + boolean startSuccessful; startSuccessful = thread.startSample(sample); @@ -417,7 +417,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (!startSuccessful) { if (internalErrors) - debugPrintln( + debugPrintln( "JavaSoundMixer: Internal Error startSample for index " + index + " failed"); return JSSample.NULL_SAMPLE; @@ -426,7 +426,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (debugFlag) debugPrintln(" startSample worked, " + "returning " + startSuccessful); - // NOTE: Set AuralParameters AFTER sound started + // NOTE: Set AuralParameters AFTER sound started // Setting AuralParameters before you start sound doesn't work if (!muted) { if (auralParams.reverbDirty > 0) { @@ -448,10 +448,10 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return index; } } - - /* + + /* * Overriden method from AudioEngine3D. - */ + */ public int stopSample(int index) { // TODO: Rewrite this function @@ -485,9 +485,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void pauseSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: PAUSESample for index " + index); @@ -498,9 +498,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { thread.pauseSample(sample); } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void unpauseSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: UNPAUSESample for index " + index); @@ -510,17 +510,17 @@ public class JavaSoundMixer extends AudioEngine3DL2 { thread.unpauseSample(sample); } - /* + /* * Force thread to update sample. * Overriden method from AudioEngine3D. - */ + */ public void updateSample(int index) { if (debugFlag) debugPrintln("JavaSoundMixer: UPDATESample for index " + index); JSSample sample = null; if ( ( (sample = (JSSample)getSample(index)) == null) || - thread == null ) + thread == null ) return; int soundType = sample.getSoundType(); @@ -550,9 +550,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { setReverb(sample); // ensure reverb is current/correct // TODO: For now sum left & rightGains for reverb gain - float reverbGain = 0.0f; - if (!muted && auralParams.reverbFlag) { - reverbGain = sample.getGain() * auralParams.reflectionCoefficient; + float reverbGain = 0.0f; + if (!muted && auralParams.reverbFlag) { + reverbGain = sample.getGain() * auralParams.reflectionCoefficient; } sample.render(sample.getDirtyFlags(), getView(), auralParams); @@ -567,9 +567,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void muteSample(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -582,9 +582,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public void unmuteSample(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -606,9 +606,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public long getSampleDuration(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -624,24 +624,24 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return duration; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public int getNumberOfChannelsUsed(int index) { /* * Calls same method with different signature containing the * sample's mute flag passed as the 2nd parameter. - */ + */ JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) return 0; - else + else return getNumberOfChannelsUsed(index, sample.getMuteFlag()); } /** * Overriden method from AudioEngine3D. - */ + */ public int getNumberOfChannelsUsed(int index, boolean muted) { /* * The JavaSoundMixer implementation uses THREE channels to render @@ -653,7 +653,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * * TODO: When muted is implemented, that flag should be check * so that zero is returned. - */ + */ JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) return 0; @@ -672,9 +672,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { return 3; } - /* + /* * Overriden method from AudioEngine3D. - */ + */ public long getStartTime(int index) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -752,9 +752,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Remember Coeff change is choosen over Order change if BOTH made * otherwise the last one changed take precidence. */ - if (auralParams.reflectionCoefficient == 0.0f || + if (auralParams.reflectionCoefficient == 0.0f || auralParams.reverbCoefficient == 0.0f) - auralParams.reverbFlag = false; + auralParams.reverbFlag = false; else { auralParams.reverbFlag = true; if (order > 0) { @@ -787,7 +787,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } if (debugFlag) - debugPrintln("JavaSoundMixer: setReverb for " + + debugPrintln("JavaSoundMixer: setReverb for " + sample + ", type = " + auralParams.reverbType + ", flag = " + auralParams.reverbFlag); auralParams.reverbDirty = 0; // clear the attribute reverb dirty flags @@ -804,7 +804,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { */ int soundType = sample.getSoundType(); int dataType = sample.getDataType(); - + // QUESTION: Should reverb be applied to background sounds? if ( (soundType == AudioDevice3D.CONE_SOUND) || (soundType == AudioDevice3D.POINT_SOUND) ) { @@ -814,7 +814,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { if (sample == null) return; JSPositionalSample posSample = (JSPositionalSample)sample; - if (posSample.channel == null) + if (posSample.channel == null) return; /********** @@ -831,9 +831,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { } /********** // TODO: - else if (dataType == JSSample.STREAMING_MIDI_DATA || + else if (dataType == JSSample.STREAMING_MIDI_DATA || dataType == JSSample.BUFFERED_MIDI_DATA) { - JSMidi.setSampleReverb(reverbIndex, + JSMidi.setSampleReverb(reverbIndex, auralParams.reverbType, auralParams.reverbFlag); } **********/ @@ -847,11 +847,11 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // TEMPORARY: Override of method due to bug in Java Sound public void setLoop(int index, int count) { - JSSample sample = null; - if ((sample = (JSSample)getSample(index)) == null) + JSSample sample = null; + if ((sample = (JSSample)getSample(index)) == null) return; int dataType = sample.getDataType(); - + // WORKAROUND: // Bug in Java Sound engine hangs when INFINITE_LOOP count // for Audio Wave data. Leave count unchanged for Midi data. @@ -873,9 +873,9 @@ public class JavaSoundMixer extends AudioEngine3DL2 { // TODO: remove assumption from method void setFilter(int index, boolean filterFlag, float filterFreq) { JSPositionalSample posSample = null; - if ((posSample = (JSPositionalSample)getSample(index)) == null) + if ((posSample = (JSPositionalSample)getSample(index)) == null) return; - if (posSample.channel == null) + if (posSample.channel == null) return; int dataType = posSample.getDataType(); @@ -926,7 +926,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { /* * Set sample specific sample rate scale factor gain * @since Java 3D 1.3 - */ + */ public void setRateScaleFactor(int index, float rateScaleFactor) { JSSample sample = null; if ((sample = (JSSample)getSample(index)) == null) @@ -940,7 +940,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * threads. * Causes all cached sounds to be paused and all streaming sounds to be * stopped. - */ + */ public void pause() { pause = PAUSE_PENDING; // TODO: pause all sounds @@ -950,7 +950,7 @@ public class JavaSoundMixer extends AudioEngine3DL2 { * Resumes audio device engine (if previously paused) without reinitializing * the device. * Causes all paused cached sounds to be resumed and all streaming sounds * restarted. - */ + */ public void resume() { pause = RESUME_PENDING; // TODO: unpause all sounds diff --git a/src/classes/share/com/sun/j3d/exp/swing/JCanvas3D.java b/src/classes/share/com/sun/j3d/exp/swing/JCanvas3D.java index ac92281..369944c 100644 --- a/src/classes/share/com/sun/j3d/exp/swing/JCanvas3D.java +++ b/src/classes/share/com/sun/j3d/exp/swing/JCanvas3D.java @@ -126,13 +126,13 @@ public class JCanvas3D extends JPanel implements AncestorListener { /** the template to be used for this canvas */ private GraphicsConfigTemplate3D template; - + /** the graphics configuration used for this canvas */ private GraphicsConfiguration graphicsConfig; /** The canvas that is linked to the component. */ private InternalCanvas3D canvas; - + /** flag indicating that the JCanvas3D has been added to a container */ private boolean hasBeenAdded = false; @@ -372,7 +372,7 @@ public class JCanvas3D extends JPanel implements AncestorListener { /** * Retrieves the resize mode for that component. - * + * * @return the resize mode, which can be one of RESIZE_IMMEDIATELY or * RESIZE_DELAYED */ @@ -563,7 +563,7 @@ public class JCanvas3D extends JPanel implements AncestorListener { * drawbacks will be users will see nothing. Default delay is set to * 100ms, which is low enough for common human not to be able to really * see that the rendered image is scaled. - * + * * @param resizeMode can be one of RESIZE_IMMEDIATELY or RESIZE_DELAYED * @see #RESIZE_IMMEDIATELY * @see #RESIZE_DELAYED @@ -579,7 +579,7 @@ public class JCanvas3D extends JPanel implements AncestorListener { * resized at the lowest level possible, thus in the rendering pipeline. * Note: Changing this field is only useful if resize mode is set to * RESIZE_IMMEDIATELY or RESIZE_DELAYED - * + * * @param resizeValidationDelay the delay before a real resize would occur. * @see #RESIZE_IMMEDIATELY * @see #RESIZE_DELAYED @@ -654,7 +654,7 @@ public class JCanvas3D extends JPanel implements AncestorListener { /** * Creates a new instance of JCanvas3D. Resize mode is set * to RESIZE_IMMEDIATELY and validation delay to 100ms. - * + * * @param graphicsConfiguration The graphics configuration to be used. * @param lwCanvas the lightweight canvas that is linked to that * heavyweight canvas. @@ -814,7 +814,7 @@ public class JCanvas3D extends JPanel implements AncestorListener { } } - + /** * This Runnable is the class used when the canvas has to be * resized. diff --git a/src/classes/share/com/sun/j3d/internal/ByteBufferWrapper.java b/src/classes/share/com/sun/j3d/internal/ByteBufferWrapper.java index fe6ce6f..e673ae7 100755 --- a/src/classes/share/com/sun/j3d/internal/ByteBufferWrapper.java +++ b/src/classes/share/com/sun/j3d/internal/ByteBufferWrapper.java @@ -64,7 +64,7 @@ public class ByteBufferWrapper extends BufferWrapper { private ByteBuffer buffer = null; /** - * Constructor initializes buffer with a + * Constructor initializes buffer with a * java.nio.ByteBuffer object. */ public ByteBufferWrapper(ByteBuffer buffer) { @@ -81,7 +81,7 @@ public class ByteBufferWrapper extends BufferWrapper { /** * Allocate a direct ByteBuffer with the given capacity. - * @return New ByteBufferWrapper containing the + * @return New ByteBufferWrapper containing the * new buffer. */ public static ByteBufferWrapper allocateDirect(int capacity) { @@ -110,7 +110,7 @@ public class ByteBufferWrapper extends BufferWrapper { /** * Reads the byte at this buffer's current position, - * and then increments the position. + * and then increments the position. */ public byte get() { return buffer.get(); @@ -123,7 +123,7 @@ public class ByteBufferWrapper extends BufferWrapper { return buffer.get(index); } - /** + /** * Bulk get method. Transfers dst.length * bytes from * the buffer to the destination array and increments the @@ -133,9 +133,9 @@ public class ByteBufferWrapper extends BufferWrapper { buffer.get(dst); return this; } - + /** - * Bulk get method. Transfers length bytes + * Bulk get method. Transfers length bytes * from the buffer starting at position offset into * the destination array. */ @@ -153,7 +153,7 @@ public class ByteBufferWrapper extends BufferWrapper { } /** - * Modifies this buffer's byte order. + * Modifies this buffer's byte order. */ public ByteBufferWrapper order(ByteOrderWrapper bo) { @@ -162,7 +162,7 @@ public class ByteBufferWrapper extends BufferWrapper { return this; } - /** + /** * Creates a view of this ByteBufferWrapper as a * FloatBufferWrapper. Uses the correct */ @@ -170,7 +170,7 @@ public class ByteBufferWrapper extends BufferWrapper { return new FloatBufferWrapper( buffer.asFloatBuffer() ); } - /** + /** * Creates a view of this ByteBufferWrapper as a * DoubleBufferWrapper. */ diff --git a/src/classes/share/com/sun/j3d/internal/Distance.java b/src/classes/share/com/sun/j3d/internal/Distance.java index 9365147..4f232e3 100644 --- a/src/classes/share/com/sun/j3d/internal/Distance.java +++ b/src/classes/share/com/sun/j3d/internal/Distance.java @@ -86,9 +86,9 @@ public class Distance { * @param segend Segment end point * @return the square of the minimum distance from the ray to the segment */ - static public double rayToSegment (Point3d rayorig, + static public double rayToSegment (Point3d rayorig, Vector3d raydir, - Point3d segstart, + Point3d segstart, Point3d segend) { return rayToSegment (rayorig, raydir, segstart, segend, null, null, null); } @@ -119,9 +119,9 @@ public class Distance { * @return the square of the minimum distance from the ray to the * segment */ - static public double rayToSegment (Point3d rayorig, + static public double rayToSegment (Point3d rayorig, Vector3d raydir, - Point3d segstart, + Point3d segstart, Point3d segend, Point3d rayint, Point3d segint, @@ -165,7 +165,7 @@ public class Distance { return DIST(s*(A*s+B*t+2*D)+t*(B*s+C*t+2*E)+F); } else { // region 1 - + t = 1; if (D >= 0) { s = 0; @@ -347,11 +347,11 @@ public class Distance { * @param ray0dir Direction of ray 0 * @param ray1orig Origin of ray 1 * @param ray1dir Direction of ray 1 - * @return the square of the minimum distance from the ray to the segment + * @return the square of the minimum distance from the ray to the segment */ - static public double rayToRay (Point3d ray0orig, + static public double rayToRay (Point3d ray0orig, Vector3d ray0dir, - Point3d ray1orig, + Point3d ray1orig, Vector3d ray1dir) { return rayToRay (ray0orig, ray0dir, ray1orig, ray1dir, null, null, null); } @@ -381,9 +381,9 @@ public class Distance { * * @return the square of the minimum distance from the ray to the segment */ - static public double rayToRay (Point3d ray0orig, + static public double rayToRay (Point3d ray0orig, Vector3d ray0dir, - Point3d ray1orig, + Point3d ray1orig, Vector3d ray1dir, Point3d ray0int, Point3d ray1int, @@ -538,8 +538,8 @@ public class Distance { * @param raydir Direction of the ray * @return the square of the minimum distance between the point and the ray */ - static public double pointToRay (Point3d pt, - Point3d rayorig, + static public double pointToRay (Point3d pt, + Point3d rayorig, Vector3d raydir) { return pointToRay (pt, rayorig, raydir, null, null); } @@ -563,8 +563,8 @@ public class Distance { * * @return the square of the minimum distance between the point and the ray */ - static public double pointToRay (Point3d pt, - Point3d rayorig, + static public double pointToRay (Point3d pt, + Point3d rayorig, Vector3d raydir, Point3d rayint, double[] param) { @@ -591,8 +591,8 @@ public class Distance { /** * Minimum pt to segment distance. Returns the square of the distance. */ - static public double pointToSegment (Point3d pt, - Point3d segstart, + static public double pointToSegment (Point3d pt, + Point3d segstart, Point3d segend) { return pointToSegment (pt, segstart, segend, null, null); } @@ -600,8 +600,8 @@ public class Distance { /** * Minimum pt to segment distance. Returns the square of the distance. */ - static public double pointToSegment (Point3d pt, - Point3d segstart, + static public double pointToSegment (Point3d pt, + Point3d segstart, Point3d segend, Point3d segint, double[] param) { @@ -617,7 +617,7 @@ public class Distance { t = 0.0f; if (segint != null) segint.set (segstart); if (param != null) { param[0] = t; } - } + } else { double mDotm = segdir.dot (segdir); //Dot(seg.m,seg.m); if (t >= mDotm) { @@ -643,13 +643,13 @@ public class Distance { * @param seg0end the end of segment 0 * @param seg1start the start of segment 1 * @param seg1end the end of segment 1 - * @return the square of the minimum distance from segment to segment + * @return the square of the minimum distance from segment to segment */ static public double segmentToSegment (Point3d seg0start, Point3d seg0end, - Point3d seg1start, + Point3d seg1start, Point3d seg1end) { - return segmentToSegment (seg0start, seg0end, seg1start, seg1end, + return segmentToSegment (seg0start, seg0end, seg1start, seg1end, null, null, null); } @@ -680,7 +680,7 @@ public class Distance { */ static public double segmentToSegment (Point3d seg0start, Point3d seg0end, - Point3d seg1start, + Point3d seg1start, Point3d seg1end, Point3d seg0int, Point3d seg1int, @@ -689,7 +689,7 @@ public class Distance { Vector3d diff = new Vector3d(); diff.sub (seg0start,seg1start); - + Vector3d seg0dir = new Vector3d(); seg0dir.sub (seg0end, seg0start); Vector3d seg1dir = new Vector3d(); @@ -710,7 +710,7 @@ public class Distance { E = -seg1dir.dot (diff); //-Dot(seg1dir,diff); s = B*E-C*D; t = B*D-A*E; - + if (s >= 0) { if (s <= det) { if (t >= 0) { diff --git a/src/classes/share/com/sun/j3d/internal/FloatBufferWrapper.java b/src/classes/share/com/sun/j3d/internal/FloatBufferWrapper.java index fc83313..0947a53 100755 --- a/src/classes/share/com/sun/j3d/internal/FloatBufferWrapper.java +++ b/src/classes/share/com/sun/j3d/internal/FloatBufferWrapper.java @@ -130,7 +130,7 @@ public class FloatBufferWrapper extends BufferWrapper { */ public FloatBufferWrapper get(float[] dst, int offset, int length){ buffer.get(dst, offset, length); - return this; + return this; } /** diff --git a/src/classes/share/com/sun/j3d/loaders/IncorrectFormatException.java b/src/classes/share/com/sun/j3d/loaders/IncorrectFormatException.java index 70c3d57..84e497d 100644 --- a/src/classes/share/com/sun/j3d/loaders/IncorrectFormatException.java +++ b/src/classes/share/com/sun/j3d/loaders/IncorrectFormatException.java @@ -47,7 +47,7 @@ package com.sun.j3d.loaders; /** * Exception used to indicate that a file of the incorrect - * type was passed to a loader. + * type was passed to a loader. */ public class IncorrectFormatException extends RuntimeException { diff --git a/src/classes/share/com/sun/j3d/loaders/Loader.java b/src/classes/share/com/sun/j3d/loaders/Loader.java index 0a30f86..cd719bc 100644 --- a/src/classes/share/com/sun/j3d/loaders/Loader.java +++ b/src/classes/share/com/sun/j3d/loaders/Loader.java @@ -50,7 +50,7 @@ import java.io.FileNotFoundException; /** * The Loader interface is used to specify the location - * and elements of a file format to load. + * and elements of a file format to load. * The interface is used to give loaders of various * file formats a common public interface. Ideally * the Scene interface will be implemented to give @@ -66,7 +66,7 @@ public interface Loader { // values together to construct an aggregate flag integer // (see the setFlags() method). Users wishing to load all // data in a file should use the LOAD_ALL specifier. - + /** This flag enables the loading of light objects into the scene.*/ public static final int LOAD_LIGHT_NODES = 1; @@ -120,7 +120,7 @@ public interface Loader { public Scene load(Reader reader) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException; - + // Variable get/set methods @@ -157,7 +157,7 @@ public interface Loader { * method. */ public String getBasePath(); - + /** * This method sets the load flags for the file. The flags should * equal 0 by default (which tells the loader to only load geometry). diff --git a/src/classes/share/com/sun/j3d/loaders/LoaderBase.java b/src/classes/share/com/sun/j3d/loaders/LoaderBase.java index 98a01e6..cc5a541 100644 --- a/src/classes/share/com/sun/j3d/loaders/LoaderBase.java +++ b/src/classes/share/com/sun/j3d/loaders/LoaderBase.java @@ -71,7 +71,7 @@ public abstract class LoaderBase implements Loader { */ public LoaderBase() { } - + /** * Constructs a Loader with the specified flags word. */ @@ -108,7 +108,7 @@ public abstract class LoaderBase implements Loader { } /** - * Returns the current base URL setting. + * Returns the current base URL setting. */ public URL getBaseUrl() { return baseUrl; @@ -120,7 +120,7 @@ public abstract class LoaderBase implements Loader { public String getBasePath() { return basePath; } - + /** * This method sets the load flags for the file. The flags should * equal 0 by default (which tells the loader to only load geometry). @@ -135,13 +135,13 @@ public abstract class LoaderBase implements Loader { public int getFlags() { return loadFlags; } - + } - - - - - - + + + + + + diff --git a/src/classes/share/com/sun/j3d/loaders/Scene.java b/src/classes/share/com/sun/j3d/loaders/Scene.java index b214eaf..36ee9e4 100644 --- a/src/classes/share/com/sun/j3d/loaders/Scene.java +++ b/src/classes/share/com/sun/j3d/loaders/Scene.java @@ -63,7 +63,7 @@ import javax.media.j3d.Sound; */ public interface Scene { - + /** * This method returns the BranchGroup containing the overall * scene loaded by the loader. All enabled items will be loaded @@ -88,7 +88,7 @@ public interface Scene { /** * This method returns an array of floats with the horizontal field - * of view. The entries in the array will correspond to those in the + * of view. The entries in the array will correspond to those in the * array returned by the method getViewGroups. The entries from these * two arrays together provide all the information needed to recreate * the viewing parameters associated with a scene graph. @@ -123,7 +123,7 @@ public interface Scene { public Fog[] getFogNodes(); /** - * This method returns an array of all the behavior nodes + * This method returns an array of all the behavior nodes * in the scene. If no Behavior nodes are defined, null is returned. */ public Behavior[] getBehaviorNodes(); @@ -143,6 +143,6 @@ public interface Scene { } - - + + diff --git a/src/classes/share/com/sun/j3d/loaders/SceneBase.java b/src/classes/share/com/sun/j3d/loaders/SceneBase.java index 642fa26..a0b82bb 100644 --- a/src/classes/share/com/sun/j3d/loaders/SceneBase.java +++ b/src/classes/share/com/sun/j3d/loaders/SceneBase.java @@ -83,7 +83,7 @@ public class SceneBase implements Scene { Vector fogVector = new Vector(); Vector backgroundVector = new Vector(); Vector soundVector = new Vector(); - + // Add methods /** @@ -108,7 +108,7 @@ public class SceneBase implements Scene { } /** - * Adds the given behavior to a list of behaviors + * Adds the given behavior to a list of behaviors */ public void addBehaviorNode(Behavior b) { behaviorVector.addElement(b); @@ -170,7 +170,7 @@ public class SceneBase implements Scene { } } } - + /** * This method returns the BranchGroup containing the overall * scene loaded by the loader. @@ -198,7 +198,7 @@ public class SceneBase implements Scene { /** * This method returns an array of floats that contains the horizontal * field of view values for each corresponding entry in the array of - * view groups returned by the method getViewGroups. + * view groups returned by the method getViewGroups. */ public float[] getHorizontalFOVs() { if (hfovVector.isEmpty()) @@ -215,20 +215,20 @@ public class SceneBase implements Scene { tmpFovs[i] = null; } return hfovs; - } + } + - /** * This method returns an array of all Lights defined in the file. */ public Light[] getLightNodes() { if (lightVector.isEmpty()) return null; - Light[] lightNodes = new Light[lightVector.size()]; + Light[] lightNodes = new Light[lightVector.size()]; lightVector.copyInto(lightNodes); return lightNodes; } - + /** * This method returns a Hashtable which contains a list of all named @@ -240,7 +240,7 @@ public class SceneBase implements Scene { public Hashtable getNamedObjects() { return namedObjects; } - + /** * This method returns an array of all Background nodes defined in the @@ -253,7 +253,7 @@ public class SceneBase implements Scene { backgroundVector.copyInto(backgroundNodes); return backgroundNodes; } - + /** * This method returns an array of all Fog nodes defined in the @@ -266,7 +266,7 @@ public class SceneBase implements Scene { fogVector.copyInto(fogNodes); return fogNodes; } - + /** * This method returns a group containing all of the Behavior nodes @@ -275,12 +275,12 @@ public class SceneBase implements Scene { public Behavior[] getBehaviorNodes() { if (behaviorVector.isEmpty()) return null; - Behavior[] behaviorNodes = new Behavior[behaviorVector.size()]; + Behavior[] behaviorNodes = new Behavior[behaviorVector.size()]; behaviorVector.copyInto(behaviorNodes); return behaviorNodes; } - + /** * This method returns an array of all of the Sound nodes defined @@ -306,6 +306,6 @@ public class SceneBase implements Scene { } - - + + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/DebugOutput.java b/src/classes/share/com/sun/j3d/loaders/lw3d/DebugOutput.java index 1d90d1a..886c8b5 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/DebugOutput.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/DebugOutput.java @@ -50,7 +50,7 @@ package com.sun.j3d.loaders.lw3d; */ class DebugOutput { - + int validOutput = 0; final static int TRACE = 1, VALUES = 2, MISC = 4, LINE_TRACE = 8; final static int NONE = 0, EXCEPTION = 16, TIME = 32, WARNING = 64; @@ -80,6 +80,6 @@ class DebugOutput { } - + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/EnvelopeHandler.java b/src/classes/share/com/sun/j3d/loaders/lw3d/EnvelopeHandler.java index c2ceaf4..1bf8dc9 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/EnvelopeHandler.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/EnvelopeHandler.java @@ -87,7 +87,7 @@ class EnvelopeHandler extends TextfileParser { * Constructor: This constructor is called with the name of a class * that can handle the encountered envelope. This is done so that this * EnvelopeHandler class can generically call the given class to handle - * the envelope, whether it results in parsing/ignoring the data or + * the envelope, whether it results in parsing/ignoring the data or * in actually using the data */ EnvelopeHandler(StreamTokenizer st, diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/FloatValueInterpolator.java b/src/classes/share/com/sun/j3d/loaders/lw3d/FloatValueInterpolator.java index 3039856..6c23687 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/FloatValueInterpolator.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/FloatValueInterpolator.java @@ -43,7 +43,7 @@ */ package com.sun.j3d.loaders.lw3d; - + import javax.vecmath.*; import java.util.BitSet; import java.util.Enumeration; @@ -56,19 +56,19 @@ import javax.media.j3d.Interpolator; import com.sun.j3d.internal.J3dUtilsI18N; /** - * This class acts as an interpolator between values specified in a - * floating point array, based on knot values (keyframes) specified in a + * This class acts as an interpolator between values specified in a + * floating point array, based on knot values (keyframes) specified in a * knots array. */ abstract class FloatValueInterpolator extends Interpolator { private float knots[]; private int knotsLength; - protected int currentKnotIndex; + protected int currentKnotIndex; protected float currentInterpolationRatio; protected float values[]; protected float currentValue; - + /** * Constructs a new FloatValueInterpolator object. * @param alpha the alpha object for this interpolator @@ -85,9 +85,9 @@ abstract class FloatValueInterpolator extends Interpolator { } // Check that last knot = 1.0f - if ((k[knotsLength-1] - 1.0f) < -0.0001 || + if ((k[knotsLength-1] - 1.0f) < -0.0001 || (k[knotsLength-1] - 1.0f) > 0.0001) { - + throw new IllegalArgumentException(J3dUtilsI18N.getString("FloatValueInterpolator1")); } @@ -114,7 +114,7 @@ abstract class FloatValueInterpolator extends Interpolator { } /** - * This method sets the value at the specified index for + * This method sets the value at the specified index for * this interpolator. * @param index the index to be changed * @param position the new value at index @@ -135,7 +135,7 @@ abstract class FloatValueInterpolator extends Interpolator { /** * This method computes the bounding knot indices and interpolation value * "currentValue" given the current value of alpha, the knots[] array and - * the array of values. + * the array of values. * If the index is 0 and there will be no interpolation, both the * index variable and the interpolation variable are set to 0. * Otherwise, currentKnotIndex is set to the lower index of the @@ -168,4 +168,4 @@ abstract class FloatValueInterpolator extends Interpolator { } } - + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/ImageScaler.java b/src/classes/share/com/sun/j3d/loaders/lw3d/ImageScaler.java index 20009c4..9d8389a 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/ImageScaler.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/ImageScaler.java @@ -59,7 +59,7 @@ class ImageScaler { int origW, origH; Image origImage; - + ImageScaler(Image image, int w, int h) { origImage = image; origW = w; @@ -74,12 +74,12 @@ class ImageScaler { /** * Utility method to return closes poser of 2 to the given integer - */ + */ int getClosestPowerOf2(int value) { if (value < 1) return value; - + int powerValue = 1; for (int i = 1; i < 20; ++i) { powerValue *= 2; @@ -96,11 +96,11 @@ class ImageScaler { // shouldn't reach here... return 1; } - + /** * Returns an Image that has been scaled from the original image to * the closest power of 2 - */ + */ Image getScaledImage() { int newWidth = getClosestPowerOf2(origW); int newHeight = getClosestPowerOf2(origH); @@ -111,7 +111,7 @@ class ImageScaler { return origImage; Image scaledImage = null; - + if (origImage instanceof BufferedImage) { // If BufferedImage, then we have some work to do BufferedImage origImageB = (BufferedImage)origImage; @@ -130,7 +130,7 @@ class ImageScaler { (int)((float)(row)* heightScale + .5f)); int oldColumn = - Math.min(origW-1, + Math.min(origW-1, (int)((float)column*widthScale + .5f)); newPixels[row*newWidth + column] = origPixels[oldRow*origW + oldColumn]; diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/J3dLwoParser.java b/src/classes/share/com/sun/j3d/loaders/lw3d/J3dLwoParser.java index 66eadc0..7764f20 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/J3dLwoParser.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/J3dLwoParser.java @@ -76,23 +76,23 @@ import java.net.*; */ class J3dLwoParser extends LwoParser { - + float normalCoordsArray[]; int normalIndicesArray[]; Shape3D objectShape; Color3f color, diffuseColor, specularColor, emissiveColor; float shininess; Vector objectShapeList = new Vector(); - + /** * Constructor: Calls LwoObject to parse file and create data structures - */ - J3dLwoParser(String fileName, + */ + J3dLwoParser(String fileName, int debugVals) throws FileNotFoundException { super(fileName, debugVals); } - J3dLwoParser(URL url, int debugVals) + J3dLwoParser(URL url, int debugVals) throws FileNotFoundException { super(url, debugVals); } @@ -107,7 +107,7 @@ class J3dLwoParser extends LwoParser { * file) into Java3d objects */ void createJava3dGeometry() throws IncorrectFormatException { - + GeometryArray object; LwoTexture texture; @@ -155,7 +155,7 @@ class J3dLwoParser extends LwoParser { if (shape.facetSizes[0] == 1) { // This case happens if the objects are points // Note that points are colored, not lit - object = new + object = new javax.media.j3d.PointArray(vertexCount, vertexFormat); object.setCoordinates(0, shape.coordsArray); ColoringAttributes colorAtt = @@ -163,7 +163,7 @@ class J3dLwoParser extends LwoParser { ColoringAttributes.FASTEST); PointAttributes pointStyle = new PointAttributes(); pointStyle.setPointSize(1); - + appearance.setColoringAttributes(colorAtt); appearance.setPointAttributes(pointStyle); } @@ -184,13 +184,13 @@ class J3dLwoParser extends LwoParser { debugOutputLn(LINE_TRACE, "Creating IndexedTriFanArray"); // create triFanArray vertexFormat |= javax.media.j3d.GeometryArray.NORMALS; - + debugOutputLn(LINE_TRACE, "about to process vertices/indices, facetIndices = " + shape.facetIndices); if (shape.facetIndices != null) { float[] textureCoords = null; int[] textureIndices = null; - + debugOutputLn(LINE_TRACE, "setting vertexCount, normind = " + shape.normalIndices); // If these are null we're going direct (non-indexed) debugOutputLn(LINE_TRACE, "vtxcount, format, indcount = " + @@ -281,8 +281,8 @@ class J3dLwoParser extends LwoParser { } } debugOutputLn(LINE_TRACE, "done creating object"); - - // This does gc + + // This does gc shape.nullify(); objectShape = new Shape3D(object); @@ -421,7 +421,7 @@ class J3dLwoParser extends LwoParser { textureIndices, verts, indices); else if (mappingType.startsWith("Spherical")) - calculateSphericalTextureCoords(textureAxis, + calculateSphericalTextureCoords(textureAxis, textureCenter, textureCoords, textureIndices, verts, indices); @@ -446,11 +446,11 @@ class J3dLwoParser extends LwoParser { return -Math.atan(x / z); } } - + /** See the comments in calculateTextureCoordinates*/ double xyztop(float x,float y,float z) { double p; - + if (x == 0.0 && z == 0.0) { if (y != 0.0) p = (y < 0.0) ? -Math.PI/2 : Math.PI/2; @@ -467,7 +467,7 @@ class J3dLwoParser extends LwoParser { return p; } - + /** See the comments in calculateTextureCoordinates*/ void calculateSphericalTextureCoords(int textureAxis, Vector3f textureCenter, @@ -476,8 +476,8 @@ class J3dLwoParser extends LwoParser { float verts[], int indices[]) { debugOutputLn(TRACE, "calculateSphericalTextureCoords"); double s, t; - - + + for (int i = 0; i < indices.length; ++i) { float x = verts[3*indices[i]] - textureCenter.x; float y = verts[3*indices[i]+1] - textureCenter.y; @@ -501,7 +501,7 @@ class J3dLwoParser extends LwoParser { textureIndices[i] = indices[i]; } } - + /** See the comments in calculateTextureCoordinates*/ void calculateCylindricalTextureCoords(int textureAxis, Vector3f textureSize, @@ -519,7 +519,7 @@ class J3dLwoParser extends LwoParser { verts + ", " + indices); double s, t; - + debugOutputLn(VALUES, "Cyl Texture Coords:"); for (int i = 0; i < indices.length; ++i) { float x = verts[3*indices[i]] - textureCenter.x; @@ -547,7 +547,7 @@ class J3dLwoParser extends LwoParser { "s, t = " + s + ", " + t); } } - + /** See the comments in calculateTextureCoordinates*/ void calculatePlanarTextureCoords(int textureAxis, Vector3f textureSize, Vector3f textureCenter, @@ -589,7 +589,7 @@ class J3dLwoParser extends LwoParser { } } - + Shape3D getJava3dShape() { return objectShape; } diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LWOBFileReader.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LWOBFileReader.java index 727929c..6c3d4e7 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LWOBFileReader.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LWOBFileReader.java @@ -120,7 +120,7 @@ class LWOBFileReader extends BufferedInputStream { /** - * Read four bytes from the file and return their integer value + * Read four bytes from the file and return their integer value */ public int getInt() throws ParsingErrorException { try { diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LightIntensityPathInterpolator.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LightIntensityPathInterpolator.java index 44bd962..2fda42e 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LightIntensityPathInterpolator.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LightIntensityPathInterpolator.java @@ -68,9 +68,9 @@ class LightIntensityPathInterpolator extends FloatValueInterpolator { /** * This method is invoked by the behavior scheduler every frame. It maps - * the alpha value that corresponds to the current time into the + * the alpha value that corresponds to the current time into the * appropriate light intensity for that time as obtained by interpolating - * between the light intensity values for each knot point that were passed + * between the light intensity values for each knot point that were passed * to this class. * @param criteria enumeration of criteria that have triggered this wakeup */ @@ -80,13 +80,13 @@ class LightIntensityPathInterpolator extends FloatValueInterpolator { if (this.getAlpha() != null) { - // Let FloatValueInterpolator calculate the correct + // Let FloatValueInterpolator calculate the correct // interpolated value computePathInterpolation(); - // Set light intensity to the value calculated by + // Set light intensity to the value calculated by // FloatValueInterpolator - if (theLight != null) + if (theLight != null) theLight.setIntensity(currentValue); if ((this.getAlpha()).finished()) diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/Lw3dLoader.java b/src/classes/share/com/sun/j3d/loaders/lw3d/Lw3dLoader.java index b8e3b88..211544d 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/Lw3dLoader.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/Lw3dLoader.java @@ -89,7 +89,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { static final int FILE_TYPE_FILENAME = 2; static final int FILE_TYPE_READER = 4; int fileType = FILE_TYPE_NONE; - + /** * Default constructor. Sets up default values for some variables. */ @@ -114,7 +114,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { loadBehaviors = (loadFlags & Loader.LOAD_BEHAVIOR_NODES); } - + /** * This method loads the named file and returns the Scene * containing the scene. Any data files referenced by the Reader @@ -122,7 +122,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { * users should specify an alternate base path with the setBaseUrl(URL) * method. */ - public Scene load(URL url) throws FileNotFoundException, + public Scene load(URL url) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException { fileType = FILE_TYPE_URL; @@ -139,7 +139,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { fileType = FILE_TYPE_NONE; return returnScene; } - + /** * This method loads the named file and returns the Scene * containing the scene. Any data files referenced by this @@ -147,7 +147,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { * otherwise users should specify an alternate base path with * the setBasePath(String) method. */ - public Scene load(String fileName) throws FileNotFoundException, + public Scene load(String fileName) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException { fileType = FILE_TYPE_FILENAME; @@ -157,20 +157,20 @@ public class Lw3dLoader extends TextfileParser implements Loader { fileType = FILE_TYPE_NONE; return returnScene; } - + /** * This method loads the Reader and returns the Scene * containing the scene. Any data files referenced by the Reader should * be located in the user's current working directory. */ - public Scene load(Reader reader) throws FileNotFoundException, + public Scene load(Reader reader) throws FileNotFoundException, IncorrectFormatException, ParsingErrorException { if (fileType == FILE_TYPE_NONE) fileType = FILE_TYPE_READER; StreamTokenizer tokenizer = new StreamTokenizer(reader); setupTokenizer(tokenizer); - + getAndCheckString(tokenizer, "LWSC"); getNumber(tokenizer); getAndCheckString(tokenizer, "FirstFrame"); @@ -211,7 +211,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { debugOutputLn(TIME, "loading " + filename + " at " + System.currentTimeMillis()); LwsObject obj = new LwsObject(tokenizer, true, - firstFrame, + firstFrame, finalFrame, totalTime, this, debugPrinter.getValidOutput()); @@ -277,13 +277,13 @@ public class Lw3dLoader extends TextfileParser implements Loader { break; } } - + // Set up scene groups and parent objects appropriately sceneGroupNode = new BranchGroup(); sceneBehaviors = new Vector(); parentObjects(); constructScene(); - + return scene; } @@ -318,18 +318,18 @@ public class Lw3dLoader extends TextfileParser implements Loader { addBehaviors(); scene.setSceneGroup(sceneGroupNode); - + // now add named objects to the scenes name table for (Enumeration e = objectList.elements(); e.hasMoreElements() ;) { - + LwsObject obj = (LwsObject)e.nextElement(); if (obj.fileName != null) scene.addNamedObject(obj.fileName,(Object)obj.getObjectNode()); else if (obj.objName != null) scene.addNamedObject(obj.objName,(Object)obj.getObjectNode()); - + } - } + } /** @@ -396,7 +396,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { int getFileType() { return fileType; } - + /** * This method parents all objects in the scene appropriately. If * the scen file specifies a Parent node for the object, then the @@ -406,7 +406,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { void parentObjects() { debugOutputLn(TRACE, "parentObjects()"); for (Enumeration e = objectList.elements(); e.hasMoreElements(); ) { - + LwsObject obj = (LwsObject)e.nextElement(); if (obj.getParent() != -1) { @@ -416,7 +416,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { debugOutputLn(VALUES, "added child successfully"); } else { - + if (obj.getObjectNode() != null) sceneGroupNode.addChild(obj.getObjectNode()); @@ -435,7 +435,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { } - + /** * This method sets the base URL name for data files * associated with the file passed into the load(URL) method. @@ -450,7 +450,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { /** * This method sets the base path to be used when searching for all - * data files within a Lightwave scene. + * data files within a Lightwave scene. */ public void setBasePath(String pathName) { // This routine standardizes path names so that all pathnames @@ -468,7 +468,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { } /** - * Returns the current base URL setting. + * Returns the current base URL setting. */ public URL getBaseUrl() { return baseUrl; @@ -480,7 +480,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { public String getBasePath() { return basePath; } - + /** * This method sets the load flags for the file. The flags should * equal 0 by default (which tells the loader to only load geometry). @@ -497,7 +497,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { } - + /** * getObject() iterates through the objectList checking the given * name against the fileName and objectName of each object in turn. @@ -590,7 +590,7 @@ public class Lw3dLoader extends TextfileParser implements Loader { // scope ambient light to the lw3d scene aLgt.addScope(sceneGroupNode); scene.addLightNode(aLgt); - } + } /** * Add any defined lights to the java3d scene @@ -598,14 +598,14 @@ public class Lw3dLoader extends TextfileParser implements Loader { void addLights() { // Add lights to the scene for (Enumeration e1 = lightList.elements(); e1.hasMoreElements(); ) { - + debugOutputLn(LINE_TRACE, "adding light to scene group"); LwsLight light = (LwsLight)e1.nextElement(); if (light.getObjectNode() != null) { // scope light to the lw3d scene light.getLight().addScope(sceneGroupNode); - + if (light.getParent() != -1) { LwsObject parent = (LwsObject) objectList.elementAt(light.getParent() - 1); @@ -615,14 +615,14 @@ public class Lw3dLoader extends TextfileParser implements Loader { sceneGroupNode.addChild(light.getObjectNode()); } - - // collect behaviors if LOAD_BEHAVIOR_NODES is set + + // collect behaviors if LOAD_BEHAVIOR_NODES is set if (loadBehaviors != 0) { - if (!(light.getObjectBehaviors()).isEmpty()) + if (!(light.getObjectBehaviors()).isEmpty()) sceneBehaviors.addAll(light.getObjectBehaviors()); } - + scene.addLightNode(light.getLight()); } else @@ -652,9 +652,9 @@ public class Lw3dLoader extends TextfileParser implements Loader { } - // collect behaviors if LOAD_BEHAVIOR_NODES is set + // collect behaviors if LOAD_BEHAVIOR_NODES is set if (loadBehaviors != 0) { - if (!(camera.getObjectBehaviors()).isEmpty()) + if (!(camera.getObjectBehaviors()).isEmpty()) sceneBehaviors.addAll(camera.getObjectBehaviors()); } diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwLightObject.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwLightObject.java index b130d7d..8d503df 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwLightObject.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwLightObject.java @@ -62,7 +62,7 @@ class LwLightObject { float intensity; Color3f color; Light theLight; - + LwLightObject(Light theLight, float intensity, Color3f color) { this.intensity = intensity; this.color = color; @@ -96,5 +96,5 @@ class LwLightObject { theLight.setColor(newLightColor); } } - - + + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoParser.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoParser.java index 9def58f..52f6bfe 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoParser.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoParser.java @@ -69,12 +69,12 @@ import com.sun.j3d.loaders.IncorrectFormatException; * surface references and creates a list of LwoSurface objects to hold * the data for each surface.
* Rather than describe in detail how the file is parsed for each method, - * I advise the user of this code to understand the lw3d file format + * I advise the user of this code to understand the lw3d file format * specs, which are pretty clear. */ class LwoParser extends ParserObject { - + LWOBFileReader theReader; int currLength; float coordsArray[]; @@ -86,7 +86,7 @@ class LwoParser extends ParserObject { float diffuse = 0.0f, specular = 0.0f, transparency = 0.0f, luminosity = 0.0f; int gloss = 128; Vector surfNameList = null; - Vector surfaceList = new Vector(200); + Vector surfaceList = new Vector(200); Vector shapeList = new Vector(200); /** @@ -112,7 +112,7 @@ class LwoParser extends ParserObject { try { long start = System.currentTimeMillis(); theReader = new LWOBFileReader(url); - debugOutputLn(TIME, " file opened in " + + debugOutputLn(TIME, " file opened in " + (System.currentTimeMillis() - start)); } catch (IOException ex) { @@ -120,7 +120,7 @@ class LwoParser extends ParserObject { } parseFile(); } - + /** * Detail polygons are currently not implemented by this loader. Their @@ -132,7 +132,7 @@ class LwoParser extends ParserObject { debugOutputLn(TRACE, "skipDetailPolygons(), numPolys = " + numPolys); int lengthRead = 0; int vert; - + try { for (int polyNum = 0; polyNum < numPolys; ++polyNum) { debugOutputLn(VALUES, "polyNum = " + polyNum); @@ -165,11 +165,11 @@ class LwoParser extends ParserObject { return null; } - + /** - * Parse the file for all the data for a POLS object (polygon + * Parse the file for all the data for a POLS object (polygon * description) - */ + */ void getPols(int length) { debugOutputLn(TRACE, "getPols(len), len = " + length); int vert; @@ -190,7 +190,7 @@ class LwoParser extends ParserObject { //shape.facetIndicesList = facetIndicesList; shape.facetIndicesArray = facetIndicesArray; shapeList.addElement(shape); - + //long startTime = (new Date()).getTime(); boolean firstTime = true; while (lengthRead < length) { @@ -275,7 +275,7 @@ class LwoParser extends ParserObject { surfNameList.addElement(surfName); } } - + /** * Parses file to get all vertices */ @@ -293,7 +293,7 @@ class LwoParser extends ParserObject { */ void getSurf(int length) throws FileNotFoundException { debugOutputLn(TRACE, "getSurf()"); - + // Create LwoSurface object to read and hold each surface, then // store that surface in a vector of all surfaces. @@ -312,11 +312,11 @@ class LwoParser extends ParserObject { int length = 0; int lengthRead = 0; int fileLength = 100000; - + long loopStartTime = System.currentTimeMillis(); // Every parsing unit begins with a four character string String tokenString = theReader.getToken(); - + while (!(tokenString == null) && lengthRead < fileLength) { long startTime = System.currentTimeMillis(); @@ -419,6 +419,6 @@ class LwoParser extends ParserObject { } } - + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoSurface.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoSurface.java index 714c39d..1b858c7 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoSurface.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoSurface.java @@ -67,7 +67,7 @@ import com.sun.j3d.loaders.ParsingErrorException; */ class LwoSurface extends ParserObject { - + LWOBFileReader theReader; int red = 255, green = 255, blue = 255; float diffuse = 0.0f, specular = 0.0f, transparency = 0.0f, luminosity = 0.0f; @@ -94,7 +94,7 @@ class LwoSurface extends ParserObject { getSurf(length); setJ3dColors(); } - + /** * Creates Java3d color objects from the lw3d surface data */ @@ -155,7 +155,7 @@ class LwoSurface extends ParserObject { } } catch (ArrayIndexOutOfBoundsException e) { - debugOutputLn(EXCEPTION, + debugOutputLn(EXCEPTION, "getTexture(), exception returning first element: " + e); return null; } @@ -286,7 +286,7 @@ class LwoSurface extends ParserObject { else if (tokenString.endsWith("TEX")) { // Textures are complex - hand off this bit to the // LwoTexture class - LwoTexture texture = + LwoTexture texture = new LwoTexture(theReader, surfStopMarker - theReader.getMarker(), tokenString, @@ -312,5 +312,5 @@ class LwoSurface extends ParserObject { } - + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoTexture.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoTexture.java index 204611c..d27b3aa 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwoTexture.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwoTexture.java @@ -80,7 +80,7 @@ import com.sun.j3d.loaders.ParsingErrorException; */ class LwoTexture extends ParserObject { - + LWOBFileReader theReader; int red = 255, green = 255, blue = 255; Color3f color, diffuseColor, specularColor, emissiveColor; @@ -96,11 +96,11 @@ class LwoTexture extends ParserObject { static Hashtable imageTable = new Hashtable(); static Hashtable textureTable = new Hashtable(); - /** + /** * Constructor: calls readTexture() to parse the file and retrieve * texture parameters */ - LwoTexture(LWOBFileReader reader, int length, String typename, + LwoTexture(LWOBFileReader reader, int length, String typename, int debugVals) throws FileNotFoundException { super(debugVals); debugOutputLn(TRACE, "Constructor"); @@ -108,7 +108,7 @@ class LwoTexture extends ParserObject { type = typename; readTexture(length); } - + String getNextToken() { return nextToken; } @@ -130,7 +130,7 @@ class LwoTexture extends ParserObject { /** * Return the actual Texture object associated with the current image. - * If we've already created a texture for this image, return that; + * If we've already created a texture for this image, return that; * otherwise create a new Texture */ Texture getTexture() { @@ -152,7 +152,7 @@ class LwoTexture extends ParserObject { String getType() { return type; } - + Color3f getColor() { return color; } @@ -168,7 +168,7 @@ class LwoTexture extends ParserObject { int getTextureAxis() { return textureAxis; } - + Vector3f getTextureCenter() { return textureCenter; } @@ -176,27 +176,27 @@ class LwoTexture extends ParserObject { String getMappingType() { return mappingType; } - + /** * Parse the binary file to retrieve all texture parameters for this * surface. If/when we encounter a TIMG parameter, which contains the - * filename of an image, then create a new TargaReader object to + * filename of an image, then create a new TargaReader object to * read that image file - */ + */ void readTexture(int length) throws FileNotFoundException, ParsingErrorException { debugOutputLn(TRACE, "readTexture()"); - + int surfStopMarker = theReader.getMarker() + length; mappingType = theReader.getString(); debugOutputLn(VALUES, "mappingType = " + mappingType); String tokenString = theReader.getToken(); while (!(tokenString == null) && theReader.getMarker() < surfStopMarker) { - + debugOutputLn(VALUES, " tokenString = " + tokenString); debugOutputLn(VALUES, " marker, stop = " + theReader.getMarker() + ", " + surfStopMarker); - + if (tokenString.endsWith("TEX") || (!tokenString.startsWith("T") || tokenString.equals("TRAN"))) { nextToken = tokenString; diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsBackground.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsBackground.java index 35bdcc4..48e3abb 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsBackground.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsBackground.java @@ -71,7 +71,7 @@ class LwsBackground extends TextfileParser { /** * Constructor: parses stream and retrieves all Background-related data - */ + */ LwsBackground(StreamTokenizer st, int debugVals) throws ParsingErrorException { @@ -82,11 +82,11 @@ class LwsBackground extends TextfileParser { skyColor = new Color3f(0f, 0f, 0f); groundColor = new Color3f(0f, 0f, 0f); nadirColor = new Color3f(0f, 0f, 0f); - + solidBackdrop = (int)getNumber(st); while (!isCurrentToken(st, "FogType")) { debugOutputLn(LINE_TRACE, "currentToken = " + st.sval); - + if (isCurrentToken(st, "BackdropColor")) { color.x = (float)getNumber(st)/255f; color.y = (float)getNumber(st)/255f; @@ -129,8 +129,8 @@ class LwsBackground extends TextfileParser { * geometry rather than a solid background color */ void createJava3dObject() { - // TODO: there are various attributes of - // backdrops that we're not currently handling. In + // TODO: there are various attributes of + // backdrops that we're not currently handling. In // particular, if the file calls for a gradient background // (solidBackdrop == 0), we ignore the request and just // create a solid background from the sky color instead. @@ -159,5 +159,5 @@ class LwsBackground extends TextfileParser { debugOutputLn(VALUES, " BACKGROUND vals: "); } - -} + +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsCamera.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsCamera.java index e428301..8ff8836 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsCamera.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsCamera.java @@ -58,7 +58,7 @@ import com.sun.j3d.loaders.ParsingErrorException; * creates Java3D TransformGroup that holds the data for positioning * and orienting the view according to the camera specifications. */ - + class LwsCamera extends TextfileParser implements LwsPrimitive { // data from the file @@ -83,14 +83,14 @@ class LwsCamera extends TextfileParser implements LwsPrimitive { getAndCheckString(st, "CameraMotion"); motion = new LwsMotion(st, firstFrame, totalFrames, totalTime, debugPrinter.getValidOutput()); - + // TODO: buggy way to stop processing the camera. Should actually // process required/optional fields in order and stop when there's - // no more. - + // no more. + while (!isCurrentToken(st, "DepthOfField")) { debugOutputLn(LINE_TRACE, "currentToken = " + st.sval); - + if (isCurrentToken(st, "ParentObject")) { parent = (int)getNumber(st); } @@ -129,7 +129,7 @@ class LwsCamera extends TextfileParser implements LwsPrimitive { Matrix4d m = new Matrix4d(); double scale = .1; m.setColumn(0, scale, 0, 0, 0); // setScale not yet implemented - m.setColumn(1, 0, scale, 0, 0); + m.setColumn(1, 0, scale, 0, 0); m.setColumn(2, 0, 0, scale, 0); m.setColumn(3, 0, 0, 0, 1); Transform3D scaleTrans = new Transform3D(m); @@ -143,10 +143,10 @@ class LwsCamera extends TextfileParser implements LwsPrimitive { objectBehavior = new Vector();; if (loadBehaviors != 0) { motion.createJava3dBehaviors(objectTransform); - Behavior b = motion.getBehaviors(); + Behavior b = motion.getBehaviors(); if (b != null) objectBehavior.addElement(b); - } + } } /** @@ -175,5 +175,5 @@ class LwsCamera extends TextfileParser implements LwsPrimitive { System.out.println(" objName = " + objName); motion.printVals(); } - -} + +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelope.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelope.java index 180b5c1..22839ce 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelope.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelope.java @@ -72,7 +72,7 @@ class LwsEnvelope extends TextfileParser { /** * Constructor: calls getEnvelope() to parse the stream for the * envelope data - */ + */ LwsEnvelope(StreamTokenizer st, int frames, float time) { numFrames = 0; totalTime = time; @@ -83,7 +83,7 @@ class LwsEnvelope extends TextfileParser { /** * Parses the stream to retrieve all envelope data. Creates - * LwsEnvelopeFrame objects for each keyframe of the envelope + * LwsEnvelopeFrame objects for each keyframe of the envelope * (these frames differ slightly from LwsFrame objects because * envelopes contain slightly different data) */ @@ -136,8 +136,8 @@ class LwsEnvelope extends TextfileParser { Behavior getBehaviors() { return behaviors; } - - + + LwsEnvelopeFrame getFirstFrame() { if (numFrames > 0) return frames[0]; @@ -145,7 +145,7 @@ class LwsEnvelope extends TextfileParser { return null; } - + void printVals() { debugOutputLn(VALUES, " name = " + name); debugOutputLn(VALUES, " numChannels = " + numChannels); @@ -157,4 +157,4 @@ class LwsEnvelope extends TextfileParser { } } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeFrame.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeFrame.java index 37d8f05..cfb21bf 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeFrame.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeFrame.java @@ -67,7 +67,7 @@ class LwsEnvelopeFrame extends TextfileParser { /** * Constructor: parses stream and stores data for one keyframe of * an envelope sequence - */ + */ LwsEnvelopeFrame(StreamTokenizer st) { value = getNumber(st); debugOutputLn(VALUES, "value = " + value); @@ -86,13 +86,13 @@ class LwsEnvelopeFrame extends TextfileParser { double getValue() { return value; } - + double getFrameNum() { return frameNumber; } - + void printVals() { debugOutputLn(VALUES, " value = " + value); debugOutputLn(VALUES, " frameNum = " + frameNumber); @@ -102,4 +102,4 @@ class LwsEnvelopeFrame extends TextfileParser { debugOutputLn(VALUES, " bias = " + bias); } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeLightIntensity.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeLightIntensity.java index e33f024..f26feb6 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeLightIntensity.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsEnvelopeLightIntensity.java @@ -63,14 +63,14 @@ class LwsEnvelopeLightIntensity extends LwsEnvelope { /** * Constructor: Calls superclass, which will parse the stream * and store the envelope data - */ + */ LwsEnvelopeLightIntensity(StreamTokenizer st, int frames, float time) { super(st, frames, time); } /** - * Creates Java3d behaviors given the stored envelope data. The + * Creates Java3d behaviors given the stored envelope data. The * Behavior created is a LightIntensityPathInterpolator */ void createJava3dBehaviors(Object target) { @@ -129,8 +129,8 @@ class LwsEnvelopeLightIntensity extends LwsEnvelope { Behavior getBehaviors() { return behaviors; } - - + + LwsEnvelopeFrame getFirstFrame() { if (numFrames > 0) return frames[0]; @@ -138,7 +138,7 @@ class LwsEnvelopeLightIntensity extends LwsEnvelope { return null; } - + void printVals() { debugOutputLn(VALUES, " name = " + name); debugOutputLn(VALUES, " numChannels = " + numChannels); @@ -150,4 +150,4 @@ class LwsEnvelopeLightIntensity extends LwsEnvelope { } } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFog.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFog.java index 8139972..22b19bd 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFog.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFog.java @@ -68,15 +68,15 @@ class LwsFog extends TextfileParser { /** * Constructor: parses stream and stores fog data - */ + */ LwsFog(StreamTokenizer st, int debugVals) throws ParsingErrorException { debugPrinter.setValidOutput(debugVals); debugOutput(TRACE, "LwsFog()"); color = new Color3f(0f, 0f, 0f); - + while (!isCurrentToken(st, "DitherIntensity")) { debugOutputLn(LINE_TRACE, "currentToken = " + st.sval); - + if (isCurrentToken(st, "FogMinDist")) { minDist = (float)getNumber(st); } @@ -139,5 +139,5 @@ class LwsFog extends TextfileParser { debugOutputLn(VALUES, " FOG vals: "); } - -} + +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFrame.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFrame.java index 6592a66..4e16097 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFrame.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsFrame.java @@ -137,7 +137,7 @@ class LwsFrame extends TextfileParser { } /** - * Using hermite interpolation construct a new frame that's + * Using hermite interpolation construct a new frame that's * in-between two given frames. We also need to be given a * frame before the first frame and a frame after the second * frame. The calling function will make sure that we get the @@ -146,8 +146,8 @@ class LwsFrame extends TextfileParser { * Ratio gives the interpolation value for how far in-between * the new frame should be. (.5 is half-way, etc.) */ - LwsFrame(LwsFrame prevFrame, LwsFrame frame1, - LwsFrame frame2, LwsFrame nextFrame, double u, + LwsFrame(LwsFrame prevFrame, LwsFrame frame1, + LwsFrame frame2, LwsFrame nextFrame, double u, double adj0, double adj1) { double h1, h2, h3, h4; @@ -155,57 +155,57 @@ class LwsFrame extends TextfileParser { // pre-compute spline coefficients double u2, u3, z1; - u2 = u * u; + u2 = u * u; u3 = u2 *u; z1 = 3.0f *u2 - u3 - u3; - h1 = 1.0f - z1; + h1 = 1.0f - z1; h2 = z1; h3 = u3 - u2 - u2 + u; h4 = u3 - u2; - dd0a = (1.0f - frame1.tension) * (1.0f + frame1.continuity) + dd0a = (1.0f - frame1.tension) * (1.0f + frame1.continuity) * (1.0f + frame1.bias); - dd0b = (1.0f - frame1.tension) * (1.0f - frame1.continuity) + dd0b = (1.0f - frame1.tension) * (1.0f - frame1.continuity) * (1.0f - frame1.bias); - ds1a = (1.0f - frame2.tension) * (1.0f - frame2.continuity) + ds1a = (1.0f - frame2.tension) * (1.0f - frame2.continuity) * (1.0f + frame2.bias); - ds1b = (1.0f - frame2.tension) * (1.0f + frame2.continuity) + ds1b = (1.0f - frame2.tension) * (1.0f + frame2.continuity) * (1.0f - frame2.bias); double[] v = new double[4]; // interpolate x, y, z - v[0] = prevFrame.x; v[1] = frame1.x; + v[0] = prevFrame.x; v[1] = frame1.x; v[2] = frame2.x; v[3] = nextFrame.x; - x = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); - v[0] = prevFrame.y; v[1] = frame1.y; + x = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); + v[0] = prevFrame.y; v[1] = frame1.y; v[2] = frame2.y; v[3] = nextFrame.y; - y = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); - v[0] = prevFrame.z; v[1] = frame1.z; + y = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); + v[0] = prevFrame.z; v[1] = frame1.z; v[2] = frame2.z; v[3] = nextFrame.z; - z = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); + z = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); - // interpolate heading pitch and bank - v[0] = prevFrame.heading; v[1] = frame1.heading; + // interpolate heading pitch and bank + v[0] = prevFrame.heading; v[1] = frame1.heading; v[2] = frame2.heading ; v[3] = nextFrame.heading; - heading = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); + heading = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); - v[0] = prevFrame.pitch; v[1] = frame1.pitch; + v[0] = prevFrame.pitch; v[1] = frame1.pitch; v[2] = frame2.pitch; v[3] = nextFrame.pitch; - pitch = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); + pitch = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); - v[0] = prevFrame.bank; v[1] = frame1.bank; + v[0] = prevFrame.bank; v[1] = frame1.bank; v[2] = frame2.bank; v[3] = nextFrame.bank; - bank = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, - adj0, adj1, h1, h2, h3, h4); + bank = computeInterpolation (v, dd0a, dd0b, ds1a, ds1b, + adj0, adj1, h1, h2, h3, h4); // interpolate scale - scale interpolation is assumed to be linear xScale = frame1.xScale + (frame2.xScale - frame1.xScale) * u; @@ -220,33 +220,33 @@ class LwsFrame extends TextfileParser { linearValue = frame2.linearValue; // We need to keep the spline smooth between knot points - tension = 0.0; - continuity = 0.0; - bias = 0.0; + tension = 0.0; + continuity = 0.0; + bias = 0.0; } - - double computeInterpolation(double[] value, double dd0a, - double dd0b, double ds1a, - double ds1b, double adj0, + + double computeInterpolation(double[] value, double dd0a, + double dd0b, double ds1a, + double ds1b, double adj0, double adj1, double h1, double h2, double h3, double h4) { double dd0, ds1; - double delta = value[2] - value[1] ; + double delta = value[2] - value[1] ; double result; // if adj != 0 - if (adj0 < -0.0001 || adj0 > 0.0001) + if (adj0 < -0.0001 || adj0 > 0.0001) dd0 = adj0 * (dd0a * (value[1] - value[0]) + dd0b * delta); - else - dd0 = 0.5f * (dd0a + dd0b) * delta; + else + dd0 = 0.5f * (dd0a + dd0b) * delta; // if adj != 0 - if (adj1 < -0.0001 || adj1 > 0.0001) - ds1 = adj1 * (ds1a * delta + ds1b * (value[3] - value[2])); - else - ds1 = 0.5f * (ds1a + ds1b) * delta; + if (adj1 < -0.0001 || adj1 > 0.0001) + ds1 = adj1 * (ds1a * delta + ds1b * (value[3] - value[2])); + else + ds1 = 0.5f * (ds1a + ds1b) * delta; result = value[1] * h1 + value[2] * h2 + dd0 * h3 + ds1 * h4; @@ -256,11 +256,11 @@ class LwsFrame extends TextfileParser { double getHeading() { return heading; } - + double getPitch() { return pitch; } - + double getBank() { return bank; } @@ -274,7 +274,7 @@ class LwsFrame extends TextfileParser { mat.setTranslation(new Vector3d(x, y, z)); Matrix4d m = new Matrix4d(); m.setColumn(0, xScale, 0, 0, 0); // setScale not yet implemented - m.setColumn(1, 0, yScale, 0, 0); + m.setColumn(1, 0, yScale, 0, 0); m.setColumn(2, 0, 0, zScale, 0); m.setColumn(3, 0, 0, 0, 1); mat.mul(m); @@ -336,6 +336,6 @@ class LwsFrame extends TextfileParser { debugOutputLn(VALUES, " bias = " + bias); } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsLight.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsLight.java index 3542c56..6bf9419 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsLight.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsLight.java @@ -58,7 +58,7 @@ import com.sun.j3d.loaders.ParsingErrorException; * instantiates an LwsMotion object to create any associated * animations. */ - + class LwsLight extends TextfileParser implements LwsPrimitive { // data from the file @@ -72,8 +72,8 @@ class LwsLight extends TextfileParser implements LwsPrimitive { int type; Point3f attenuation = new Point3f(1.0f, 0.0f, 0.0f); float spotConeAngle = (float)(Math.PI); - // Meta object, used for holding light and - LwLightObject lwLight; + // Meta object, used for holding light and + LwLightObject lwLight; // light parameters LwsEnvelopeLightIntensity intensityEnvelope = null; Light light = null; @@ -82,7 +82,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { /** * Constructor: parses stream and creates data structures for all * light parameters currently handled by the loader - */ + */ LwsLight(StreamTokenizer st, int totalFrames, float totalTime, int debugVals) throws ParsingErrorException { @@ -91,7 +91,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { debugOutput(TRACE, "LwsLight()"); color = new Color3f(1f, 1f, 1f); lwLight = new LwLightObject(null, 0.0f, null); - + parent = -1; debugOutputLn(LINE_TRACE, "about to get LightName"); getAndCheckString(st, "LightName"); @@ -104,12 +104,12 @@ class LwsLight extends TextfileParser implements LwsPrimitive { debugOutputLn(LINE_TRACE, "got LightMotion"); motion = new LwsMotion(st, totalFrames, totalTime); debugOutputLn(LINE_TRACE, "got motions"); - + // TODO: buggy way to stop processing the light. Should actually // process required/optional fields in order and stop when there's // no more. However, spec says "ShadowCasing" but the files say // "ShadowType". - + while (!isCurrentToken(st, "ShowCamera") && !isCurrentToken(st, "AddLight")) { // TODO: @@ -120,7 +120,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { // "concentration" value, so it's left out for now. debugOutputLn(LINE_TRACE, "currentToken = " + st.sval); - + if (isCurrentToken(st, "ParentObject")) { parent = (int)getNumber(st); } @@ -139,7 +139,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { packageName = ""; else packageName = className.substring(0, classIndex) + "."; - EnvelopeHandler env = + EnvelopeHandler env = new EnvelopeHandler(st, totalFrames, totalTime, packageName + "LwsEnvelopeLightIntensity"); if (env.hasValue) { @@ -150,7 +150,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { lwLight.setIntensity(intensity); } else { - intensityEnvelope = + intensityEnvelope = (LwsEnvelopeLightIntensity)env.theEnvelope; } } @@ -195,7 +195,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { objectTransform.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); Vector3f defaultDir = new Vector3f(0f, 0f, -1f); Point3f defaultPos = new Point3f(0f, 0f, 0f); - + switch (type) { case DIRECTIONAL: light = new DirectionalLight(color, defaultDir); @@ -216,7 +216,7 @@ class LwsLight extends TextfileParser implements LwsPrimitive { light.setCapability(Light.ALLOW_COLOR_WRITE); if (light != null) { lwLight.setLight(light); - BoundingSphere bounds = + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100000.0); light.setInfluencingBounds(bounds); objectTransform.addChild(light); @@ -227,14 +227,14 @@ class LwsLight extends TextfileParser implements LwsPrimitive { Behavior b; b = null; motion.createJava3dBehaviors(objectTransform); - b = motion.getBehaviors(); + b = motion.getBehaviors(); if (b != null) objectBehavior.addElement(b); if (intensityEnvelope != null) { b = null; intensityEnvelope.createJava3dBehaviors(lwLight); - b = intensityEnvelope.getBehaviors(); + b = intensityEnvelope.getBehaviors(); if (b != null) objectBehavior.addElement(b); } @@ -250,14 +250,14 @@ class LwsLight extends TextfileParser implements LwsPrimitive { Light getLight() { return light; } - + public Vector getObjectBehaviors() { debugOutputLn(TRACE, "getObjectBehaviors()"); return objectBehavior; } - + void printVals() { debugOutputLn(VALUES, " LIGHT vals: "); @@ -265,5 +265,5 @@ class LwsLight extends TextfileParser implements LwsPrimitive { motion.printVals(); } - -} + +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsMotion.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsMotion.java index eb73fff..e152a33 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsMotion.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsMotion.java @@ -160,7 +160,7 @@ class LwsMotion extends TextfileParser { * than PI/2 (one quarter rotation - no reason for this, but let's pick a * small value to give our resulting path interpolations a better chance * of behaving correctly), figure out how many frames we need to create to - * get increments of <= PI/2 between each frame. + * get increments of <= PI/2 between each frame. * - Create these new frames * - Set the odl frames pointer to the new frames structures. */ @@ -185,48 +185,48 @@ class LwsMotion extends TextfileParser { double thisAngle = thisFrame.getHeading(); double lastAngle = lastFrame.getHeading(); double angleDifference = Math.abs(thisAngle - lastAngle); - if (angleDifference > largestAngleDifference) + if (angleDifference > largestAngleDifference) largestAngleDifference = angleDifference; thisAngle = thisFrame.getPitch(); lastAngle = lastFrame.getPitch(); angleDifference = Math.abs(thisAngle - lastAngle); - if (angleDifference > largestAngleDifference) + if (angleDifference > largestAngleDifference) largestAngleDifference = angleDifference; thisAngle = thisFrame.getBank(); lastAngle = lastFrame.getBank(); angleDifference = Math.abs(thisAngle - lastAngle); - if (angleDifference > largestAngleDifference) + if (angleDifference > largestAngleDifference) largestAngleDifference = angleDifference; if (largestAngleDifference > halfPI) { - // Angles too big - create new frames + // Angles too big - create new frames addedFrames = true; int numNewFrames = (int)(largestAngleDifference/halfPI); double increment = 1.0/(double)(numNewFrames+1); double currentRatio = increment; double totalf = frames[numFrames-1].getFrameNum(); - double tlength = (thisFrame.getFrameNum() - + double tlength = (thisFrame.getFrameNum() - lastFrame.getFrameNum())/totalf; - double adj0; - double adj1; + double adj0; + double adj1; - // get the previous and next frames - if ((i-1) < 1) { + // get the previous and next frames + if ((i-1) < 1) { prevFrame = frames[i-1]; adj0 = 0.0; } else { prevFrame = frames[i-2]; - adj0 = tlength/((thisFrame.getFrameNum() - - prevFrame.getFrameNum())/totalf); + adj0 = tlength/((thisFrame.getFrameNum() - + prevFrame.getFrameNum())/totalf); } if ((i+1) < numFrames) { nextFrame = frames[i+1]; - adj1 = tlength/((nextFrame.getFrameNum()- - lastFrame.getFrameNum())/totalf); + adj1 = tlength/((nextFrame.getFrameNum()- + lastFrame.getFrameNum())/totalf); } else { nextFrame = frames[i]; adj1 = 1.0; @@ -238,16 +238,16 @@ class LwsMotion extends TextfileParser { // if linear interpolation if (thisFrame.linearValue == 1) { - newFrame = new LwsFrame(lastFrame, + newFrame = new LwsFrame(lastFrame, thisFrame, currentRatio); - + // if spline interpolation } else { - newFrame = new LwsFrame(prevFrame, lastFrame, - thisFrame, nextFrame, + newFrame = new LwsFrame(prevFrame, lastFrame, + thisFrame, nextFrame, currentRatio, adj0, adj1); } - + currentRatio += increment; newFramesList.add(newFrame); } @@ -304,7 +304,7 @@ class LwsMotion extends TextfileParser { frameNumber = number; } } - + /** * This method was added to account for animations that start after @@ -445,7 +445,7 @@ class LwsMotion extends TextfileParser { playWithFrameTimes(frameHolders); long alphaAtOne = 0; - // determine looping + // determine looping int loopCount; if (loop) loopCount = -1; @@ -479,7 +479,7 @@ class LwsMotion extends TextfileParser { Quat4f[] quats = new Quat4f[numFrames]; Point3f[] scales = new Point3f[numFrames]; Transform3D yAxis = new Transform3D(); - Matrix4d mat = new Matrix4d(); + Matrix4d mat = new Matrix4d(); KBKeyFrame[] keyFrames = new KBKeyFrame[numFrames]; for (int i=0; i < numFrames; ++i) { @@ -489,7 +489,7 @@ class LwsMotion extends TextfileParser { // copy position positions[i] = frame.getPosition(); - + // copy scale // Used to hardcode no-scale: scales[i] = 1.0f, 1.0f, 1.0f; // Note that we can't do non-uniform scaling in the current Path @@ -504,16 +504,16 @@ class LwsMotion extends TextfileParser { quats[i].set(mat); debugOutputLn(VALUES, " and quat = " + quats[i]); - // calculate knot points from frame numbers + // calculate knot points from frame numbers if (i == 0) knots[i] = 0.0f; - else + else knots[i] = (float)(frameHolder.frameNumber)/ (float)(lastFrameHolder.frameNumber); // Create KB key frames - keyFrames[i] = new KBKeyFrame(knots[i], frame.linearValue, - positions[i], + keyFrames[i] = new KBKeyFrame(knots[i], frame.linearValue, + positions[i], (float)frame.heading, (float)frame.pitch, (float)frame.bank, @@ -530,7 +530,7 @@ class LwsMotion extends TextfileParser { KBRotPosScaleSplinePathInterpolator b = new KBRotPosScaleSplinePathInterpolator(theAlpha, target, - yAxis, + yAxis, keyFrames); if (b != null) { behaviors = b; @@ -541,7 +541,7 @@ class LwsMotion extends TextfileParser { target.addChild(behaviors); } } - + /** * Create j3d behaviors for the data stored in this animation. This is * done by creating a RotPosScalePathInterpolator object that contains @@ -578,7 +578,7 @@ class LwsMotion extends TextfileParser { debugOutputLn(VALUES, " lastFrame = " + frames[numFrames-1].getFrameNum()); - if (!loop) + if (!loop) alphaAtOne = (long)(1000.0*totalTime - animTime); Alpha theAlpha = new Alpha(loopCount, Alpha.INCREASING_ENABLE, @@ -591,7 +591,7 @@ class LwsMotion extends TextfileParser { Point3f[] scales = new Point3f[numFrames]; Transform3D yAxis = new Transform3D(); Matrix4d mat = new Matrix4d(); - KBKeyFrame[] keyFrames = new KBKeyFrame[numFrames]; + KBKeyFrame[] keyFrames = new KBKeyFrame[numFrames]; for (int i=0; i < numFrames; ++i) { @@ -611,7 +611,7 @@ class LwsMotion extends TextfileParser { quats[i] = new Quat4f(); quats[i].set(mat); debugOutputLn(VALUES, " and quat = " + quats[i]); - + // calculate knot points from frame numbers if (i == 0) knots[i] = 0.0f; @@ -621,7 +621,7 @@ class LwsMotion extends TextfileParser { // Create KB key frames keyFrames[i] = new KBKeyFrame(knots[i],frames[i].linearValue, - positions[i], + positions[i], (float)frames[i].heading, (float)frames[i].pitch, (float)frames[i].bank, @@ -629,7 +629,7 @@ class LwsMotion extends TextfileParser { (float)frames[i].tension, (float)frames[i].continuity, (float)frames[i].bias); - + debugOutputLn(VALUES, "pos, knots, quat = " + positions[i] + knots[i] + quats[i]); @@ -639,7 +639,7 @@ class LwsMotion extends TextfileParser { KBRotPosScaleSplinePathInterpolator b = new KBRotPosScaleSplinePathInterpolator(theAlpha, target, - yAxis, + yAxis, keyFrames); if (b != null) { behaviors = b; @@ -659,7 +659,7 @@ class LwsMotion extends TextfileParser { Behavior getBehaviors() { return behaviors; } - + /** * Returns the first LwsFrame object (which contains the initial * setup for a given object) @@ -685,4 +685,4 @@ class LwsMotion extends TextfileParser { } } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsObject.java b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsObject.java index fdd7d16..bef1c44 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/LwsObject.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/LwsObject.java @@ -105,7 +105,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { int firstFrame, int totalFrames, float totalTime, Lw3dLoader loader, int debugVals) throws java.io.FileNotFoundException, - ParsingErrorException { + ParsingErrorException { debugPrinter.setValidOutput(debugVals); parent = -1; @@ -203,10 +203,10 @@ class LwsObject extends TextfileParser implements LwsPrimitive { pivotTransGroup = new TransformGroup(pivotTransform); pivotTransGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); } - + else if (isCurrentToken(st, "ObjDissolve")) { // Just handle it for now, don't care about value - EnvelopeHandler env = + EnvelopeHandler env = new EnvelopeHandler(st, totalFrames, totalTime); } st.nextToken(); @@ -237,13 +237,13 @@ class LwsObject extends TextfileParser implements LwsPrimitive { * * If the filename is absolute, it will use the path information from * the filename first, then the path information from the lws file. - * If the file can not be found in these locations, the local directory + * If the file can not be found in these locations, the local directory * will be searched. - * In addition, it will look for filenames converted to lowercase to + * In addition, it will look for filenames converted to lowercase to * make it easier to use between Windows and Unix. */ - String getQualifiedFilename(String pathname, String filename) + String getQualifiedFilename(String pathname, String filename) throws java.io.FileNotFoundException { int index; @@ -261,7 +261,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { return null; // something out of the ordinary happened } } - + // See if we can find the file // --------------------------- @@ -274,39 +274,39 @@ class LwsObject extends TextfileParser implements LwsPrimitive { catch (NullPointerException ex) { ex.printStackTrace(); } - // Try lowercase filename + // Try lowercase filename if (new File(pathname2 + filename.toLowerCase()).exists()) { return (pathname2 + filename.toLowerCase()); } - // Try original pathname + // Try original pathname if (new File(pathname + filename).exists()) { return (pathname + filename); } - // Try lowercase filename + // Try lowercase filename if (new File(pathname + filename.toLowerCase()).exists()) { return (pathname + filename.toLowerCase()); } - // Finally, let's check the local directory + // Finally, let's check the local directory if (new File(filename).exists()) { return (filename); } - // Try lowercase filename + // Try lowercase filename if (new File(filename.toLowerCase()).exists()) { return (filename.toLowerCase()); } - // Conditions that determine when we give up on the recursive search - if ((pathname.equals(File.separator)) || + // Conditions that determine when we give up on the recursive search + if ((pathname.equals(File.separator)) || (pathname == null) || (pathname.equals(""))) { - + throw new java.io.FileNotFoundException(filename); } - // Try to find the file in the upper directories - // Chop off the last directory from pathname and recurse + // Try to find the file in the upper directories + // Chop off the last directory from pathname and recurse StringBuffer newPathName = new StringBuffer(128); StringTokenizer st = new StringTokenizer(pathname, File.separator); int tokenCount = st.countTokens() - 1; @@ -324,7 +324,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { URL getQualifiedURL(String path, String file) throws MalformedURLException { - + URL url = null; // try the path and the file -- this is the lightwave spec @@ -363,7 +363,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { throw new MalformedURLException(path + file); } } - + /** * Returns parent object */ @@ -413,7 +413,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { Matrix4d mat = new Matrix4d(); mat.setIdentity(); // Set the node's transform matrix according to the first frame - // of the object's motion + // of the object's motion LwsFrame firstFrame = motion.getFirstFrame(); firstFrame.setMatrix(mat); Transform3D t1 = new Transform3D(); @@ -439,7 +439,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { // standard than on some proprietary hack of our own. if (fileName != null && fileName.indexOf(seqToken) != -1) { // Tloop - + int index = fileName.indexOf(seqToken); index += seqToken.length(); String seqFilename = fileName.substring(index); @@ -462,7 +462,7 @@ class LwsObject extends TextfileParser implements LwsPrimitive { objectBehavior = sr.getObjectBehaviors(); return; - } + } } // Okay, now that that hack is out of the way, let's get on with @@ -567,4 +567,4 @@ class LwsObject extends TextfileParser implements LwsPrimitive { debugOutputLn(VALUES, " objName = " + objName); motion.printVals(); } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/ParserObject.java b/src/classes/share/com/sun/j3d/loaders/lw3d/ParserObject.java index 4021edd..7205311 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/ParserObject.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/ParserObject.java @@ -50,15 +50,15 @@ package com.sun.j3d.loaders.lw3d; */ class ParserObject { - + final static int TRACE = DebugOutput.TRACE, VALUES = DebugOutput.VALUES; final static int MISC = DebugOutput.MISC, LINE_TRACE = DebugOutput.LINE_TRACE; final static int NONE = DebugOutput.NONE, EXCEPTION = DebugOutput.EXCEPTION; final static int TIME = DebugOutput.TIME, WARNING = DebugOutput.WARNING; - + protected DebugOutput debugPrinter; - + ParserObject() { debugPrinter = new DebugOutput(EXCEPTION); @@ -68,7 +68,7 @@ class ParserObject { this(); debugPrinter.setValidOutput(debugVals); } - + protected void debugOutputLn(int outputType, String theOutput) { if (theOutput.equals("")) @@ -86,6 +86,6 @@ class ParserObject { } - + diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceLine.java b/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceLine.java index 532741c..54d8144 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceLine.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceLine.java @@ -50,10 +50,10 @@ import java.util.Hashtable; import java.util.Vector; import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.io.StreamTokenizer; -import java.io.IOException; -import javax.media.j3d.*; +import java.io.FileReader; +import java.io.StreamTokenizer; +import java.io.IOException; +import javax.media.j3d.*; import javax.vecmath.Point3d; import com.sun.j3d.loaders.IncorrectFormatException; @@ -61,9 +61,9 @@ import com.sun.j3d.loaders.ParsingErrorException; import java.io.FileNotFoundException; /** - * This class was created to handle "sequence files", which allow + * This class was created to handle "sequence files", which allow * holosketch-type Tloop sequences to be loaded through the lw3d loader. - * The class reads a sequence file line by line and uses SequenceLine to + * The class reads a sequence file line by line and uses SequenceLine to * load the file specified in each line.
* Idea behind the Tloop process:
* Artist creates "tloops" (animations with each keyframe's @@ -77,19 +77,19 @@ import java.io.FileNotFoundException; * special name, such as "bucket_sequence_bucketsequence.txt.lwo", which tells * the lw3d loader that it should look for a sequence file by the name of * bucketsequence.txt. What happens to this object is irrelevant (as far as - * the loader is concerned); all animation information is taken from its + * the loader is concerned); all animation information is taken from its * parent instead.
* 2) Artist saves out the geometry of the bucket at whatever frames she wants - * to. If she's saving a tloop (a sequence of frames), she should save them + * to. If she's saving a tloop (a sequence of frames), she should save them * under the names xxx.lwo, where xxx is the 3-digit sequence number * (000, 001, 002, etc.).
* 3) Artist creates the sequence file, which lists all saved geometry files - * (except sequences - these can be referred to simply by the first file - * (...000.lwo)), along with their associated start/end frames. She also lists + * (except sequences - these can be referred to simply by the first file + * (...000.lwo)), along with their associated start/end frames. She also lists * the number of files in the sequence, although this parameter is implied * anyway, through the existence of the sequence files and their naming * convention. Maybe we should trash this guy.
- * 4) In the lw3d loader, when LwsObject encounters an object with the + * 4) In the lw3d loader, when LwsObject encounters an object with the * filename "..._sequence_.lwo", it searches for filename. If * found, it parses the file (using the SequenceReader class) to retrieve * all parameters.
@@ -121,7 +121,7 @@ class SequenceLine { // storedRefList keeps references to already loaded objects static Hashtable storedRefList = new Hashtable(); - + SequenceLine(StreamTokenizer st, float time, int frames) throws ParsingErrorException { try { @@ -157,7 +157,7 @@ class SequenceLine { (float)startFrame/(float)totalFrames; Alpha theAlpha = new Alpha(-1, (long)startTime, 0, (long)animTime, 0, 0); - + SwitchValueInterpolator b=new SwitchValueInterpolator(theAlpha,target); behaviors = b; BoundingSphere bounds = @@ -165,9 +165,9 @@ class SequenceLine { b.setSchedulingBounds(bounds); target.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); target.addChild(behaviors); - + } - + /** * Create Java3d objects from the data in the sequence line. This * means that for a tloop file (ends in "000"), we're going to create @@ -190,7 +190,7 @@ class SequenceLine { if (storedRefList.get(tempFileName) != null) { // System.out.println("retrieve stored version of " + // tempFileName); - SharedGroup storedGroup = + SharedGroup storedGroup = (SharedGroup)storedRefList.get(tempFileName); Link newLink = new Link(storedGroup); s.addChild(newLink); @@ -232,7 +232,7 @@ class SequenceLine { geometryGroup = new Group(); if (storedRefList.get(fileName) != null) { // System.out.println("getting old ref to " + fileName); - SharedGroup storedGroup = + SharedGroup storedGroup = (SharedGroup)storedRefList.get(fileName); Link newLink = new Link(storedGroup); geometryGroup.addChild(newLink); @@ -265,5 +265,5 @@ class SequenceLine { Behavior getBehavior() { return behaviors; } - + } diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceReader.java b/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceReader.java index 8890a30..b2b545e 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceReader.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/SequenceReader.java @@ -50,10 +50,10 @@ import java.util.Hashtable; import java.util.Vector; import java.io.BufferedReader; import java.io.File; -import java.io.FileReader; -import java.io.StreamTokenizer; -import java.io.IOException; -import javax.media.j3d.*; +import java.io.FileReader; +import java.io.StreamTokenizer; +import java.io.IOException; +import javax.media.j3d.*; import javax.vecmath.Point3d; import com.sun.j3d.loaders.IncorrectFormatException; @@ -74,7 +74,7 @@ class SequenceReader { Vector sequenceLines; float totalTime; int totalFrames; - + TransformGroup objectTransform; Vector behaviorVector; @@ -108,7 +108,7 @@ class SequenceReader { /** * Creates Java3D objects from the data defined in the sequence - * file. Calls each sequenceLine object to create its own + * file. Calls each sequenceLine object to create its own * j3d objects, then puts all of those objects in a single Switch * node. Finally, it creates a SwitchPathInterpolator object which * handles switching between each object/s defined by each line @@ -142,7 +142,7 @@ class SequenceReader { Alpha theAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, (long)(1000f * totalTime), 0, 0, 0, 0, 0); - + SwitchPathInterpolator switchPath = new SwitchPathInterpolator(theAlpha, knots, @@ -161,7 +161,7 @@ class SequenceReader { Vector getObjectBehaviors() { return behaviorVector; } - + void printLines() { Enumeration e = sequenceLines.elements(); while (e.hasMoreElements()) { diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/ShapeHolder.java b/src/classes/share/com/sun/j3d/loaders/lw3d/ShapeHolder.java index 146ce73..5a7cf57 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/ShapeHolder.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/ShapeHolder.java @@ -56,7 +56,7 @@ import javax.vecmath.Vector3f; class ShapeHolder extends ParserObject { - + Vector facetSizesList; Vector facetIndicesList; int facetIndicesArray[]; @@ -68,7 +68,7 @@ class ShapeHolder extends ParserObject { int normalIndices[]; float normalCoords[]; float coordsArray[]; - + ShapeHolder() { } @@ -78,7 +78,7 @@ class ShapeHolder extends ParserObject { /** - * Print out (to stdout) the geometry data (coords, indices, + * Print out (to stdout) the geometry data (coords, indices, * and facet sizes). This is a debugging utility. */ void printGeometryData(LwoSurface surface) { @@ -92,7 +92,7 @@ class ShapeHolder extends ParserObject { System.out.println("Facet of size " + polySize); for (j = 0; j < polySize; ++j) { int coordIndex = 3 * facetIndices[indicesIndex++]; - System.out.println("x, y, z = " + + System.out.println("x, y, z = " + coordsArray[coordIndex] + ", " + coordsArray[coordIndex+1] + ", " + coordsArray[coordIndex+2]); @@ -102,17 +102,17 @@ class ShapeHolder extends ParserObject { /** * Constructs geometry arrays given a winding rule (it turns out that - * lw3d winding is opposite of j3d winding, so this is always set to + * lw3d winding is opposite of j3d winding, so this is always set to * true in J3dLwoParser) */ void createArrays(boolean reverseWinding) { debugOutputLn(TRACE, "createArrays()"); - // debugOutputLn(VALUES, "facetIndices, faceSizesList = " + + // debugOutputLn(VALUES, "facetIndices, faceSizesList = " + // facetIndicesList + facetSizesList); //debugOutputLn(VALUES, "ind and sizes size " + - // facetIndicesList.size() + ", " + + // facetIndicesList.size() + ", " + // facetSizesList.size()); - //facetIndices = + //facetIndices = // new int[facetIndicesList.size()]; facetIndices = new int[currentNumIndices]; if (reverseWinding) { @@ -164,13 +164,13 @@ class ShapeHolder extends ParserObject { facetIndices = null; } - facetSizes = + facetSizes = new int[facetSizesList.size()]; for (int i = 0; i < facetSizes.length; ++i) { - facetSizes[i] = + facetSizes[i] = ((Integer)facetSizesList.elementAt(i)).intValue(); } - + facetSizesList = null; // Force garbage collection on Vectors facetIndicesList = null; facetIndicesArray = null; @@ -193,10 +193,10 @@ class ShapeHolder extends ParserObject { * This method calculates facet normals for the geometry. It is no * longer used, as we're now using the GeometryInfo utility to calculate * smooth normals - */ + */ void calcNormals() { debugOutputLn(TRACE, "calcNormals()"); - debugOutputLn(LINE_TRACE, "coordsLength, facetsizes.len = " + + debugOutputLn(LINE_TRACE, "coordsLength, facetsizes.len = " + coordsArray.length + ", " + facetSizes.length); if (facetSizes[0] > 2) { // points and lines don't need normals, polys do @@ -208,7 +208,7 @@ class ShapeHolder extends ParserObject { normalCoords = new float[coordsArray.length]; } debugOutputLn(LINE_TRACE, "normalCoords, incides len = " + - normalCoords.length + ", " + + normalCoords.length + ", " + ((facetIndices == null) ? 0 : normalIndices.length)); int facetIndex = 0; int tempIndex = -1; @@ -236,11 +236,11 @@ class ShapeHolder extends ParserObject { index2 = facetIndex+1; index3 = facetIndex+2; } - v1 = new + v1 = new Vector3f(coordsArray[index2*3] - coordsArray[index1*3], coordsArray[index2*3+1] - coordsArray[index1*3+1], coordsArray[index2*3+2] - coordsArray[index1*3+2]); - v2 = new + v2 = new Vector3f(coordsArray[index3*3] - coordsArray[index1*3], coordsArray[index3*3+1] - coordsArray[index1*3+1], coordsArray[index3*3+2] - coordsArray[index1*3+2]); @@ -249,7 +249,7 @@ class ShapeHolder extends ParserObject { norm.cross(v1, v2); norm.normalize(norm); } - + for (int j = 0; j < currFacetSize; ++j) { int normIndex = facetIndex + j; normalCoords[normIndex*3] = norm.x; diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/SwitchPathInterpolator.java b/src/classes/share/com/sun/j3d/loaders/lw3d/SwitchPathInterpolator.java index 8d6006a..3c2ff73 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/SwitchPathInterpolator.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/SwitchPathInterpolator.java @@ -44,7 +44,7 @@ package com.sun.j3d.loaders.lw3d; - + import javax.vecmath.*; import java.util.BitSet; import java.util.Enumeration; @@ -59,7 +59,7 @@ import com.sun.j3d.internal.J3dUtilsI18N; /** * This class was used in conjunction with SequenceReader to create * Tloop functionality inside of Lightwave files. This behavior handles - * the switching between objects defined in separate lines of a + * the switching between objects defined in separate lines of a * sequence file. That is, each line in a sequence file has the name * of an object (or an object sequence, if the name ends in "000") * and details the start and end frames that that object should be active. @@ -74,7 +74,7 @@ class SwitchPathInterpolator extends FloatValueInterpolator { int lastSwitchIndex; int currentChild; int childCount; - + /** * Constructs a new SwitchPathInterpolator object. * @param alpha the alpha object for this interpolator @@ -95,7 +95,7 @@ class SwitchPathInterpolator extends FloatValueInterpolator { /** * This method sets the correct child for the Switch node according - * to alpha + * to alpha * @param criteria enumeration of criteria that have triggered this wakeup */ @@ -103,18 +103,18 @@ class SwitchPathInterpolator extends FloatValueInterpolator { int child; - // Handle stimulus + // Handle stimulus if (this.getAlpha() != null) { // Let PathInterpolator calculate the correct - // interpolated knot point + // interpolated knot point computePathInterpolation(); if (currentKnotIndex > 0) child = currentKnotIndex - 1; else child = 0; - + if (target.getWhichChild() != child) { target.setWhichChild(child); } diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/TargaReader.java b/src/classes/share/com/sun/j3d/loaders/lw3d/TargaReader.java index bc922e7..66daab2 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/TargaReader.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/TargaReader.java @@ -142,7 +142,7 @@ class TargaReader extends ParserObject { boolean bottomToTop = ((flags & 0x20) == 0); boolean leftToRight = ((flags & 0x10) == 0); bufferedReader.skip(idLength); - + // Check on the file parameters to see whether we should punt if ((colormapPresent == 1) || imageType != 2 || diff --git a/src/classes/share/com/sun/j3d/loaders/lw3d/TextfileParser.java b/src/classes/share/com/sun/j3d/loaders/lw3d/TextfileParser.java index 12f7b5e..5d4167d 100644 --- a/src/classes/share/com/sun/j3d/loaders/lw3d/TextfileParser.java +++ b/src/classes/share/com/sun/j3d/loaders/lw3d/TextfileParser.java @@ -55,7 +55,7 @@ import com.sun.j3d.loaders.ParsingErrorException; class TextfileParser { - // class variables + // class variables static int WORD = StreamTokenizer.TT_WORD; static int NUMBER = StreamTokenizer.TT_NUMBER; int currentLevel = 3; @@ -73,7 +73,7 @@ class TextfileParser { debugOutputLn(VALUES, "lineSeparatorChar = " + (int)lineSeparatorChar); } - + protected void debugOutputLn(int outputType, String theOutput) { if (theOutput.equals("")) debugPrinter.println(outputType, theOutput); @@ -89,7 +89,7 @@ class TextfileParser { /** * Utility method to advance the tokenizer until we see the given - * string. This is used to skip by various parameters that we + * string. This is used to skip by various parameters that we * currently ignore in the loader. */ void skipUntilString(StreamTokenizer st, String theString) @@ -112,7 +112,7 @@ class TextfileParser { /** * Returns number from the tokenizer. Note that we don't recognize * numbers in the tokenizer automatically because numbers might be in - * scientific notation, which isn't processed correctly by + * scientific notation, which isn't processed correctly by * StreamTokenizer */ double getNumber(StreamTokenizer st) @@ -143,11 +143,11 @@ class TextfileParser { /** * Returns a "name" from the stream. This is different from simply a - * String because the name could contain whitespace characters + * String because the name could contain whitespace characters * (such as "object 1" or "objectname (sequence)") that would confuse * the string parser. So we just grab all characters until EOL and * concatenate them together to form the name - */ + */ String getName(StreamTokenizer st) throws ParsingErrorException { String theName = ""; st.ordinaryChar(lineSeparatorChar); @@ -175,7 +175,7 @@ class TextfileParser { } /** - * Gets the next token and ensures that it is the string we were + * Gets the next token and ensures that it is the string we were * expecting to see */ void getAndCheckString(StreamTokenizer st, String expectedValue) @@ -216,7 +216,7 @@ class TextfileParser { /** * Utility routine - gets next token, checks it against our expectation, - * then skips a given number of tokens. This can be used to parse + * then skips a given number of tokens. This can be used to parse * through (and ignore) certain parameter/value sets in the files */ void skip(StreamTokenizer st, String tokenString, int skipVals) @@ -232,7 +232,7 @@ class TextfileParser { throw new ParsingErrorException(e.getMessage()); } } - + /** * Utility method- used to check whether the current token is equal * to the given string @@ -242,4 +242,4 @@ class TextfileParser { return (st.sval.equals(tokenString)); return false; } -} +} diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/DefaultMaterials.java b/src/classes/share/com/sun/j3d/loaders/objectfile/DefaultMaterials.java index 7005ed7..d93e795 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/DefaultMaterials.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/DefaultMaterials.java @@ -51,7 +51,7 @@ class DefaultMaterials { /** * String that describes the default materials. */ - static final String materials = + static final String materials = "newmtl amber\n" + "Ka 0.0531 0.0531 0.0531\n" + "Kd 0.5755 0.2678 0.0000\n" + diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java index 7d116f9..bcf4303 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFile.java @@ -82,9 +82,9 @@ import java.net.MalformedURLException; * Wavefront's Advanced Visualizer (tm) and available for purchase from * Viewpoint DataLabs, as well as other 3D model companies. Object Files * are text based - * files supporting both polygonal and free-form geometry (curves + * files supporting both polygonal and free-form geometry (curves * and surfaces). The Java 3D .obj file loader supports a subset of the - * file format, but it is enough to load almost all commonly available + * file format, but it is enough to load almost all commonly available * Object Files. Free-form geometry is not supported.

* * The Object File tokens currently supported by this loader are:

@@ -93,7 +93,7 @@ import java.net.MalformedURLException; * listed in the file has index 1, * and subsequent vertices are numbered sequentially.

* vn float float float

- *
A normal. The first normal in the file is index 1, and + *
A normal. The first normal in the file is index 1, and * subsequent normals are numbered sequentially.

* vt float float

*
A texture coordinate. The first texture coordinate in the file is @@ -120,7 +120,7 @@ import java.net.MalformedURLException; * These geometry groups are returned as separated Shape3D objects * attached to the parent SceneGroup. Each named Shape3D will also * be in the Hashtable returned by Scene.getNamedObjects(). It is - * legal to add faces to a group, switch to another group, and then + * legal to add faces to a group, switch to another group, and then * add more faces to the original group by reissuing the same name * with the g token. If faces are added to the model before the g * token is seen, the faces are put into the default group called @@ -135,9 +135,9 @@ import java.net.MalformedURLException; * is used to group faces geometrically. Faces in the same smoothing * group will have their normals calculated as if they are part of * the same smooth surface. To do this, we use the Java 3D NormalGenerator - * utility with the creaseAngle parameter set to PI (180 degrees - - * smooth shading, no creases) or to whatever the user has set the - * creaseAngle. Faces in group 0 or 'off' use a + * utility with the creaseAngle parameter set to PI (180 degrees - + * smooth shading, no creases) or to whatever the user has set the + * creaseAngle. Faces in group 0 or 'off' use a * creaseAngle of zero, meaning there is no smoothing (the normal * of the face is used at all vertices giving the surface a faceted * look; there will be a @@ -196,7 +196,7 @@ import java.net.MalformedURLException; *
Load material properties from the named file. Materials * with the same name as the predefined materials above will override * the default value. Any directory path information in (filename) - * is ignored. The .mtl files are assumed to be in the same directory + * is ignored. The .mtl files are assumed to be in the same directory * as the .obj file. If they are in a different directory, use * Loader.setBasePath() (or Loader.setBaseUrl() ). The format of the * material properties files @@ -553,7 +553,7 @@ public class ObjectFile implements Loader { */ void readFile(ObjectFileParser st) throws ParsingErrorException { int t; - + st.getToken(); while (st.ttype != ObjectFileParser.TT_EOF) { @@ -663,7 +663,7 @@ public class ObjectFile implements Loader { * the filename. * To attach the model to your scene, call getSceneGroup() on * the Scene object passed back, and attach the returned - * BranchGroup to your scene graph. For an example, see + * BranchGroup to your scene graph. For an example, see * j3d-examples/ObjLoad/ObjLoad.java. */ public Scene load(String filename) throws FileNotFoundException, @@ -698,7 +698,7 @@ public class ObjectFile implements Loader { * The object file is loaded off of the web. * To attach the model to your scene, call getSceneGroup() on * the Scene object passed back, and attach the returned - * BranchGroup to your scene graph. For an example, see + * BranchGroup to your scene graph. For an example, see * j3d-examples/ObjLoad/ObjLoad.java. */ public Scene load(URL url) throws FileNotFoundException, @@ -933,7 +933,7 @@ public class ObjectFile implements Loader { * groups, which are also being converted to a new triangle based format. * * We need to convert to triangles before normals are generated - * because of smoothing groups. The faces in a smoothing group + * because of smoothing groups. The faces in a smoothing group * are copied into a GeometryInfo to have their normals calculated, * and then the normals are copied out of the GeometryInfo using * GeometryInfo.getNormalIndices. As part of Normal generation, @@ -941,7 +941,7 @@ public class ObjectFile implements Loader { * to triangles *before* Normal generation so that the normals we * read out of the GeometryInfo match up with the vertex data * that we sent in. If we sent in TRIANGLE_FAN data, the normal - * generator would convert it to triangles and we'd read out + * generator would convert it to triangles and we'd read out * normals formatted for Triangle data. This would not match up * with our original Fan data, so we couldn't tell which normals * go with which vertices. @@ -1016,7 +1016,7 @@ public class ObjectFile implements Loader { if (normals) newNormIdxList = new ArrayList(); } - // Repeat for each face in the model - add the triangles from each + // Repeat for each face in the model - add the triangles from each // face to the Geometry and Smoothing Groups int baseVertex = 0; for (int f = 0 ; f < numFaces ; f++) { @@ -1216,7 +1216,7 @@ public class ObjectFile implements Loader { * The Object File is loaded from the already opened file. * To attach the model to your scene, call getSceneGroup() on * the Scene object passed back, and attach the returned - * BranchGroup to your scene graph. For an example, see + * BranchGroup to your scene graph. For an example, see * j3d-examples/ObjLoad/ObjLoad.java. */ public Scene load(Reader reader) throws FileNotFoundException, diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java index 43b39e0..663294d 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileMaterials.java @@ -99,7 +99,7 @@ class ObjectFileMaterials implements ImageObserver { public Texture2D t; public boolean transparent; public float transparencyLevel; - + } @@ -107,7 +107,7 @@ class ObjectFileMaterials implements ImageObserver { ObjectFileMaterial p = null; if ((DEBUG & 1) != 0) System.out.println("Color " + matName); - + Material m = new Material(); p = (ObjectFileMaterial)materials.get(matName); Appearance a = new Appearance(); @@ -136,7 +136,7 @@ class ObjectFileMaterials implements ImageObserver { } } - if (p.transparent) + if (p.transparent) a.setTransparencyAttributes( new TransparencyAttributes(TransparencyAttributes.NICEST, p.transparencyLevel)); diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileParser.java b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileParser.java index 4209ff1..f856104 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileParser.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/ObjectFileParser.java @@ -152,7 +152,7 @@ class ObjectFileParser extends StreamTokenizer { * * Gets a number from the stream. Note that we don't recognize * numbers in the tokenizer automatically because numbers might be in - * scientific notation, which isn't processed correctly by + * scientific notation, which isn't processed correctly by * StreamTokenizer. The number is returned in nval. */ void getNumber() throws ParsingErrorException { diff --git a/src/classes/share/com/sun/j3d/loaders/objectfile/RgbFile.java b/src/classes/share/com/sun/j3d/loaders/objectfile/RgbFile.java index 304ffa5..c47892a 100644 --- a/src/classes/share/com/sun/j3d/loaders/objectfile/RgbFile.java +++ b/src/classes/share/com/sun/j3d/loaders/objectfile/RgbFile.java @@ -106,7 +106,7 @@ class RgbFile extends BufferedInputStream { if (storage != 0) throw new IOException("RLE Compressed files not supported"); - + byte bpc = getByte(); dimension = getShort(); xSize = getShort(); @@ -141,7 +141,7 @@ class RgbFile extends BufferedInputStream { int[] nBits = {8}; cm = new ComponentColorModel(cs, nBits, false, false, - Transparency.OPAQUE, + Transparency.OPAQUE, DataBuffer.TYPE_BYTE); } else if (zSize == 2) { diff --git a/src/classes/share/com/sun/j3d/utils/applet/JMainFrame.java b/src/classes/share/com/sun/j3d/utils/applet/JMainFrame.java index b3064e6..63741dc 100644 --- a/src/classes/share/com/sun/j3d/utils/applet/JMainFrame.java +++ b/src/classes/share/com/sun/j3d/utils/applet/JMainFrame.java @@ -171,14 +171,14 @@ public class JMainFrame extends JFrame { public void windowClosing(WindowEvent winEvent) { - if (JMainFrame.this.applet != null) { + if (JMainFrame.this.applet != null) { JMainFrame.this.applet.destroy(); } hide(); try { dispose(); } catch (IllegalStateException e) {} - + if (_doExit) { System.exit(0); } diff --git a/src/classes/share/com/sun/j3d/utils/applet/MainFrame.java b/src/classes/share/com/sun/j3d/utils/applet/MainFrame.java index 156d1e4..e8e8461 100644 --- a/src/classes/share/com/sun/j3d/utils/applet/MainFrame.java +++ b/src/classes/share/com/sun/j3d/utils/applet/MainFrame.java @@ -117,7 +117,7 @@ import java.util.*; // Fetch the software.
// Fetch the entire Acme package. -public class MainFrame extends Frame implements +public class MainFrame extends Frame implements Runnable, AppletStub, AppletContext { @@ -132,7 +132,7 @@ public class MainFrame extends Frame implements private static final String PARAM_PROP_PREFIX = "parameter."; /// Constructor with everything specified. - public MainFrame(Applet applet, String[] args, + public MainFrame(Applet applet, String[] args, int width, int height) { build(applet, args, width, height); } @@ -148,7 +148,7 @@ public class MainFrame extends Frame implements } // Internal constructor routine. - private void build( Applet applet, String[] args, + private void build( Applet applet, String[] args, int width, int height) { ++instances; this.applet = applet; @@ -241,7 +241,7 @@ public class MainFrame extends Frame implements // methods, in case they take a long time. (new Thread( this )).start(); } - + // Turn command-line arguments into Applet parameters, by way of the // properties list. private static void parseArgs( String[] args, Properties props) { @@ -277,7 +277,7 @@ public class MainFrame extends Frame implements public boolean isActive() { return true; } - + public URL getDocumentBase() { // Returns the current directory. String dir = System.getProperty( "user.dir" ); @@ -288,7 +288,7 @@ public class MainFrame extends Frame implements return null; } } - + public URL getCodeBase() { // Hack: loop through each item in CLASSPATH, checking if // the appropriately named .class file exists there. But @@ -310,12 +310,12 @@ public class MainFrame extends Frame implements } return null; } - + public String getParameter(String name) { // Return a parameter via the munged names in the properties list. return System.getProperty( PARAM_PROP_PREFIX + name.toLowerCase() ); } - + public void appletResize(int width, int height) { // Change the frame's size by the same amount that the applet's // size is changing. @@ -329,7 +329,7 @@ public class MainFrame extends Frame implements public AppletContext getAppletContext() { return this; } - + // Methods from AppletContext. public AudioClip getAudioClip( URL url ) { @@ -350,7 +350,7 @@ public class MainFrame extends Frame implements return null; } } - + public Applet getApplet(String name) { // Returns this Applet or nothing. if (name.equals( this.name )) { @@ -358,22 +358,22 @@ public class MainFrame extends Frame implements } return null; } - + public Enumeration getApplets() { // Just yields this applet. Vector v = new Vector(); v.addElement( applet ); return v.elements(); } - + public void showDocument( URL url ) { // Ignore. } - + public void showDocument( URL url, String target ) { // Ignore. } - + public void showStatus( String status ) { if (label != null) { label.setText(status); diff --git a/src/classes/share/com/sun/j3d/utils/audio/DistanceAttenuation.java b/src/classes/share/com/sun/j3d/utils/audio/DistanceAttenuation.java index 6d36a79..41c381f 100644 --- a/src/classes/share/com/sun/j3d/utils/audio/DistanceAttenuation.java +++ b/src/classes/share/com/sun/j3d/utils/audio/DistanceAttenuation.java @@ -53,7 +53,7 @@ package com.sun.j3d.utils.audio; import java.io.* ; import javax.vecmath.* ; -import java.lang.String; +import java.lang.String; import javax.media.j3d.*; import com.sun.j3d.internal.J3dUtilsI18N; @@ -74,7 +74,7 @@ public class DistanceAttenuation * recommend that the distance attenuation Point2f array is defined to * be allocated to be 10 for DOUBLE_DISTANCE_HALF_GAIN - since 1/(2^10) * exceeds 1/1000 scale that is agreed to be affective zero gain - * + * * First method assumes that: * type is half gain for every double of distance * inner radius is 0.0 but region between 0th and 1st elements is constant @@ -98,7 +98,7 @@ public class DistanceAttenuation distanceAttenuation[i].y = nextGain; nextDistance *= 2.0f; nextGain *= 0.5f; - } + } } public void fillDistanceAttenuation( @@ -121,7 +121,7 @@ public class DistanceAttenuation distanceAttenuation[i].y = nextGain; nextDistance *= 2.0f; nextGain *= 0.5f; - } + } } public void fillDistanceAttenuation( diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineCurve.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineCurve.java index 373b476..e69a2ff 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineCurve.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineCurve.java @@ -50,21 +50,21 @@ import javax.vecmath.*; import com.sun.j3d.internal.J3dUtilsI18N; /** - * CubicSplineCurve is a container class that holds a number of - * cubicSplineSegments - * + * CubicSplineCurve is a container class that holds a number of + * cubicSplineSegments + * * @since Java3D 1.1 */ public class CubicSplineCurve { - - private float totalCurveLength; + + private float totalCurveLength; private CubicSplineSegment[] cubicSplineSegment; public int numSegments; - + /** - * Default constructor + * Default constructor */ CubicSplineCurve () { numSegments = 0; @@ -75,20 +75,20 @@ public class CubicSplineCurve { * This method takes a list of key frames and creates spline segments * from it. It requires at least four key frames to be passed to it. * Given n key frames, it creates n-3 CubicSplineSegments. - * @param keys the list of key frames that specify the motion path + * @param keys the list of key frames that specify the motion path */ CubicSplineCurve (TCBKeyFrame keys[]) { int keyLength = keys.length; - // Require at least 4 key frames for cubic spline curve + // Require at least 4 key frames for cubic spline curve if (keyLength < 4) throw new IllegalArgumentException(J3dUtilsI18N.getString("CubicSplineCurve0")); - + numSegments = keyLength - 3; this.cubicSplineSegment = new CubicSplineSegment[numSegments]; - // intialize and calculate coefficients for each segment + // intialize and calculate coefficients for each segment int k0 = 0; int k1 = 1; int k2 = 2; int k3 = 3; for (; k0 < numSegments; k0++, k1++, k2++, k3++) { this.cubicSplineSegment[k0] = new CubicSplineSegment @@ -100,8 +100,8 @@ public class CubicSplineCurve { } /** - * This method takes a list of spline segments creates the - * CubicSplineCurve. + * This method takes a list of spline segments creates the + * CubicSplineCurve. * @param the list of segments that comprise the complete motion path */ @@ -118,9 +118,9 @@ public class CubicSplineCurve { } /** - * This method takes a list of spline segments to replace the existing + * This method takes a list of spline segments to replace the existing * set of CubicSplineSegments that comprise the current CubicSplineCurve - * motion path. + * motion path. * @param s the list of segments that comprise the complete motion path */ @@ -137,32 +137,32 @@ public class CubicSplineCurve { } /** - * This method returns the CubicSplineSegments pointed to by index - * @param index the index of the CubicSplineSegment required + * This method returns the CubicSplineSegments pointed to by index + * @param index the index of the CubicSplineSegment required * @return index the CubicSplineSegment pointed to by index */ public CubicSplineSegment getSegment (int index) { return this.cubicSplineSegment[index]; - } - + } + - // computes the total length of the curve + // computes the total length of the curve private void computeTotalCurveLength () { totalCurveLength = 0f; for (int i = 0; i < numSegments; i++) { totalCurveLength += cubicSplineSegment[i].length; - } + } } /** - * This method returns the total length of the entire CubicSplineCurve + * This method returns the total length of the entire CubicSplineCurve * motion path. * - * @return the length of the CubicSplineCurve motion path + * @return the length of the CubicSplineCurve motion path */ public float getTotalCurveLength () { @@ -170,6 +170,6 @@ public class CubicSplineCurve { return this.totalCurveLength; } - + } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineSegment.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineSegment.java index f83b685..582226f 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineSegment.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/CubicSplineSegment.java @@ -50,19 +50,19 @@ import javax.vecmath.*; /** - * The CubicSplineSegment class creates the representation of a - * TCB (Kochanek-Bartels Spline). This class takes 4 key frames as + * The CubicSplineSegment class creates the representation of a + * TCB (Kochanek-Bartels Spline). This class takes 4 key frames as * its input (using TCBKeyFrame). If interpolating between the ith - * and (i+1)th key frame then the four key frames that need to - * be specified are the (i-1)th, ith, (i+1)th + * and (i+1)th key frame then the four key frames that need to + * be specified are the (i-1)th, ith, (i+1)th * and (i+2)th keyframes in order. The CubicSegmentClass - * then pre-computes the hermite interpolation basis coefficients if the - * (i+1)th frame has the linear flag set to zero. These are used to - * calculate the interpolated position, scale and quaternions when they - * requested by the user using the getInterpolated* methods. If the the - * (i+1)th frame's linear flag is set to 1 then the class uses - * linear interpolation to calculate the interpolated position, sccale and - * quaternions it returns through the getInterpolated* methods. + * then pre-computes the hermite interpolation basis coefficients if the + * (i+1)th frame has the linear flag set to zero. These are used to + * calculate the interpolated position, scale and quaternions when they + * requested by the user using the getInterpolated* methods. If the the + * (i+1)th frame's linear flag is set to 1 then the class uses + * linear interpolation to calculate the interpolated position, sccale and + * quaternions it returns through the getInterpolated* methods. * * @since Java3D 1.1 */ @@ -94,13 +94,13 @@ public class CubicSplineSegment { // Key Frames TCBKeyFrame[] keyFrame = new TCBKeyFrame[4]; - - // H.C + + // H.C Point3f c0, c1, c2, c3; // coefficients for position - Point3f e0, e1, e2, e3; // coefficients for scale + Point3f e0, e1, e2, e3; // coefficients for scale // variables for destination derivative - float one_minus_t_in; + float one_minus_t_in; float one_minus_c_in; float one_minus_b_in; float one_plus_c_in; @@ -112,7 +112,7 @@ public class CubicSplineSegment { float one_minus_t_out; float one_minus_c_out; float one_minus_b_out; - float one_plus_c_out; + float one_plus_c_out; float one_plus_b_out; float dsb; float dsa; @@ -122,9 +122,9 @@ public class CubicSplineSegment { // interpolation type int linear; - + /** - * Default constructor + * Default constructor */ CubicSplineSegment () { @@ -133,26 +133,26 @@ public class CubicSplineSegment { } /** - * Creates a cubic spline segment between two key frames using the - * key frames provided. If creating a spline between the ith frame and - * the (i+1)th frame then send down the (i - 1)th, - * ith , (i+1)th and the (i+2)th key - * frames. - * + * Creates a cubic spline segment between two key frames using the + * key frames provided. If creating a spline between the ith frame and + * the (i+1)th frame then send down the (i - 1)th, + * ith , (i+1)th and the (i+2)th key + * frames. + * * @param kf0 (i - 1)th Key Frame - * @param kf1 ith Key Frame + * @param kf1 ith Key Frame * @param kf2 (i + 1)th Key Frame - * @param kf3 (i + 2)th Key Frame + * @param kf3 (i + 2)th Key Frame */ CubicSplineSegment (TCBKeyFrame kf0, TCBKeyFrame kf1, TCBKeyFrame kf2, TCBKeyFrame kf3) { // Copy KeyFrame information - keyFrame[0] = new TCBKeyFrame(kf0); - keyFrame[1] = new TCBKeyFrame(kf1); - keyFrame[2] = new TCBKeyFrame(kf2); - keyFrame[3] = new TCBKeyFrame(kf3); + keyFrame[0] = new TCBKeyFrame(kf0); + keyFrame[1] = new TCBKeyFrame(kf1); + keyFrame[2] = new TCBKeyFrame(kf2); + keyFrame[3] = new TCBKeyFrame(kf3); // if linear interpolation is requested then just set linear flag // if spline interpolation is needed then compute spline coefficients @@ -170,32 +170,32 @@ public class CubicSplineSegment { } // compute the common coefficients - private void computeCommonCoefficients (TCBKeyFrame kf0, + private void computeCommonCoefficients (TCBKeyFrame kf0, TCBKeyFrame kf1, - TCBKeyFrame kf2, + TCBKeyFrame kf2, TCBKeyFrame kf3) { // variables for destination derivative float one_minus_t_in = 1.0f - kf1.tension; - float one_minus_c_in = 1.0f - kf1.continuity; + float one_minus_c_in = 1.0f - kf1.continuity; float one_minus_b_in = 1.0f - kf1.bias; float one_plus_c_in = 1.0f + kf1.continuity; float one_plus_b_in = 1.0f + kf1.bias; // coefficients for the incoming Tangent - ddb = one_minus_t_in * one_minus_c_in * one_minus_b_in; - dda = one_minus_t_in * one_plus_c_in * one_plus_b_in; + ddb = one_minus_t_in * one_minus_c_in * one_minus_b_in; + dda = one_minus_t_in * one_plus_c_in * one_plus_b_in; // variables for source derivative - float one_minus_t_out = 1.0f - kf2.tension; - float one_minus_c_out = 1.0f - kf2.continuity; + float one_minus_t_out = 1.0f - kf2.tension; + float one_minus_c_out = 1.0f - kf2.continuity; float one_minus_b_out = 1.0f - kf2.bias; float one_plus_c_out = 1.0f + kf2.continuity; float one_plus_b_out = 1.0f + kf2.bias; - + // coefficients for the outgoing Tangent - dsb = one_minus_t_in * one_plus_c_in * one_minus_b_in; - dsa = one_minus_t_in * one_minus_c_in * one_plus_b_in; + dsb = one_minus_t_in * one_plus_c_in * one_minus_b_in; + dsa = one_minus_t_in * one_minus_c_in * one_plus_b_in; } @@ -209,7 +209,7 @@ public class CubicSplineSegment { Point3f deltaP = new Point3f(); Point3f deltaS = new Point3f(); - // Find the difference in position and scale + // Find the difference in position and scale deltaP.x = kf2.position.x - kf1.position.x; deltaP.y = kf2.position.y - kf1.position.y; deltaP.z = kf2.position.z - kf1.position.z; @@ -217,12 +217,12 @@ public class CubicSplineSegment { deltaS.x = kf2.scale.x - kf1.scale.x; deltaS.y = kf2.scale.y - kf1.scale.y; deltaS.z = kf2.scale.z - kf1.scale.z; - + // Incoming Tangent Point3f dd_pos = new Point3f(); Point3f dd_scale = new Point3f(); - // If this is the first keyframe of the animation + // If this is the first keyframe of the animation if (kf0.knot == kf1.knot) { float ddab = 0.5f * (dda + ddb); @@ -232,7 +232,7 @@ public class CubicSplineSegment { dd_pos.y = ddab * deltaP.y; dd_pos.z = ddab * deltaP.z; - // Scale + // Scale dd_scale.x = ddab * deltaS.x; dd_scale.y = ddab * deltaS.y; dd_scale.z = ddab * deltaS.z; @@ -242,27 +242,27 @@ public class CubicSplineSegment { float adj0 = (kf1.knot - kf0.knot)/(kf2.knot - kf0.knot); // Position - dd_pos.x = adj0 * + dd_pos.x = adj0 * ((ddb * deltaP.x) + (dda * (kf1.position.x - kf0.position.x))); dd_pos.y = adj0 * ((ddb * deltaP.y) + (dda * (kf1.position.y - kf0.position.y))); - dd_pos.z = adj0 * + dd_pos.z = adj0 * ((ddb * deltaP.z) + (dda * (kf1.position.z - kf0.position.z))); - // Scale - dd_scale.x = adj0 * + // Scale + dd_scale.x = adj0 * ((ddb * deltaS.x) + (dda * (kf1.scale.x - kf0.scale.x))); - dd_scale.y = adj0 * + dd_scale.y = adj0 * ((ddb * deltaS.y) + (dda * (kf1.scale.y - kf0.scale.y))); - dd_scale.z = adj0 * + dd_scale.z = adj0 * ((ddb * deltaS.z) + (dda * (kf1.scale.z - kf0.scale.z))); } - + // Outgoing Tangent Point3f ds_pos = new Point3f(); Point3f ds_scale = new Point3f(); - // If this is the last keyframe of the animation + // If this is the last keyframe of the animation if (kf2.knot == kf3.knot) { float dsab = 0.5f * (dsa + dsb); @@ -271,7 +271,7 @@ public class CubicSplineSegment { ds_pos.x = dsab * deltaP.x; ds_pos.y = dsab * deltaP.y; ds_pos.z = dsab * deltaP.z; - + // Scale ds_scale.x = dsab * deltaS.x; ds_scale.y = dsab * deltaS.y; @@ -282,19 +282,19 @@ public class CubicSplineSegment { float adj1 = (kf2.knot - kf1.knot)/(kf3.knot - kf1.knot); // Position - ds_pos.x = adj1 * + ds_pos.x = adj1 * ((dsb * (kf3.position.x - kf2.position.x)) + (dsa * deltaP.x)); - ds_pos.y = adj1 * + ds_pos.y = adj1 * ((dsb * (kf3.position.y - kf2.position.y)) + (dsa * deltaP.y)); - ds_pos.z = adj1 * + ds_pos.z = adj1 * ((dsb * (kf3.position.z - kf2.position.z)) + (dsa * deltaP.z)); // Scale - ds_scale.x = adj1 * + ds_scale.x = adj1 * ((dsb * (kf3.scale.x - kf2.scale.x)) + (dsa * deltaS.x)); - ds_scale.y = adj1 * + ds_scale.y = adj1 * ((dsb * (kf3.scale.y - kf2.scale.y)) + (dsa * deltaS.y)); - ds_scale.z = adj1 * + ds_scale.z = adj1 * ((dsb * (kf3.scale.z - kf2.scale.z)) + (dsa * deltaS.z)); } @@ -319,7 +319,7 @@ public class CubicSplineSegment { c3.y = -2*deltaP.y + dd_pos.y + ds_pos.y; c3.z = -2*deltaP.z + dd_pos.z + ds_pos.z; - // Calculate the coefficients of the polynomial for scale + // Calculate the coefficients of the polynomial for scale e0 = new Point3f(); e0.x = kf1.scale.x; e0.y = kf1.scale.y; @@ -345,7 +345,7 @@ public class CubicSplineSegment { /** * Computes the length of the curve at a given point between * key frames. - * @param u specifies the point between keyframes where 0 <= u <= 1. + * @param u specifies the point between keyframes where 0 <= u <= 1. */ public float computeLength (float u) { @@ -375,18 +375,18 @@ public class CubicSplineSegment { v.y = c1.y + u * (2 * c2.y + 3 * u * c3.y); v.z = c1.z + u * (2 * c2.z + 3 * u * c3.z); - return (float)(Math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)); + return (float)(Math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)); } /** - * Computes the interpolated quaternion along the curve at + * Computes the interpolated quaternion along the curve at * a given point between key frames. This routine uses linear - * interpolation if the (i+1)th key frame's linear - * value is equal to 1. - * - * @param u specifies the point between keyframes where 0 <= u <= 1. - * @param newQuat returns the value of the interpolated quaternion + * interpolation if the (i+1)th key frame's linear + * value is equal to 1. + * + * @param u specifies the point between keyframes where 0 <= u <= 1. + * @param newQuat returns the value of the interpolated quaternion */ public void getInterpolatedQuaternion (float u, Quat4f newQuat) { @@ -395,30 +395,30 @@ public class CubicSplineSegment { if (this.linear == 1) { double quatDot; - quatDot = keyFrame[1].quat.x * keyFrame[2].quat.x + + quatDot = keyFrame[1].quat.x * keyFrame[2].quat.x + keyFrame[1].quat.y * keyFrame[2].quat.y + - keyFrame[1].quat.z * keyFrame[2].quat.z + + keyFrame[1].quat.z * keyFrame[2].quat.z + keyFrame[1].quat.w * keyFrame[2].quat.w; if (quatDot < 0) { - newQuat.x = keyFrame[1].quat.x + + newQuat.x = keyFrame[1].quat.x + (-keyFrame[2].quat.x - keyFrame[1].quat.x) * u; - newQuat.y = keyFrame[1].quat.y + + newQuat.y = keyFrame[1].quat.y + (-keyFrame[2].quat.y - keyFrame[1].quat.y) * u; - newQuat.z = keyFrame[1].quat.z + + newQuat.z = keyFrame[1].quat.z + (-keyFrame[2].quat.z - keyFrame[1].quat.z) * u; - newQuat.w = keyFrame[1].quat.w + + newQuat.w = keyFrame[1].quat.w + (-keyFrame[2].quat.w - keyFrame[1].quat.w) * u; } else { - newQuat.x = keyFrame[1].quat.x + + newQuat.x = keyFrame[1].quat.x + (keyFrame[2].quat.x - keyFrame[1].quat.x) * u; - newQuat.y = keyFrame[1].quat.y + + newQuat.y = keyFrame[1].quat.y + (keyFrame[2].quat.y - keyFrame[1].quat.y) * u; - newQuat.z = keyFrame[1].quat.z + + newQuat.z = keyFrame[1].quat.z + (keyFrame[2].quat.z - keyFrame[1].quat.z) * u; - newQuat.w = keyFrame[1].quat.w + + newQuat.w = keyFrame[1].quat.w + (keyFrame[2].quat.w - keyFrame[1].quat.w) * u; - } + } } else { @@ -428,32 +428,32 @@ public class CubicSplineSegment { // we might want to do cubic interpolation of quaternions newQuat.interpolate (keyFrame[1].quat, keyFrame[2].quat, u); } - + } /** * Computes the interpolated scale along the curve at a given point - * between key frames and returns a Point3f with the interpolated + * between key frames and returns a Point3f with the interpolated * x, y, and z scale components. This routine uses linear - * interpolation if the (i+1)th key frame's linear - * value is equal to 1. - * - * @param u specifies the point between keyframes where 0 <= u <= 1. + * interpolation if the (i+1)th key frame's linear + * value is equal to 1. + * + * @param u specifies the point between keyframes where 0 <= u <= 1. * @param newScale returns the interpolated x,y,z scale value in a Point3f */ public void getInterpolatedScale (float u, Point3f newScale) { - + // if linear interpolation if (this.linear == 1) { - newScale.x = keyFrame[1].scale.x + + newScale.x = keyFrame[1].scale.x + ((keyFrame[2].scale.x - keyFrame[1].scale.x) * u); - newScale.y = keyFrame[1].scale.y + + newScale.y = keyFrame[1].scale.y + ((keyFrame[2].scale.y - keyFrame[1].scale.y) * u); - newScale.z = keyFrame[1].scale.z + + newScale.z = keyFrame[1].scale.z + ((keyFrame[2].scale.z - keyFrame[1].scale.z) * u); } else { @@ -468,7 +468,7 @@ public class CubicSplineSegment { /** * Computes the interpolated position along the curve at a given point - * between key frames and returns a Point3f with the interpolated + * between key frames and returns a Point3f with the interpolated * x, y, and z scale components. This routine uses linear * interpolation if the (i+1)th key frame's linear * value is equal to 1. @@ -478,14 +478,14 @@ public class CubicSplineSegment { */ public void getInterpolatedPosition (float u, Point3f newPos) { - + // if linear interpolation if (this.linear == 1) { - newPos.x = keyFrame[1].position.x + + newPos.x = keyFrame[1].position.x + ((keyFrame[2].position.x - keyFrame[1].position.x) * u); - newPos.y = keyFrame[1].position.y + + newPos.y = keyFrame[1].position.y + ((keyFrame[2].position.y - keyFrame[1].position.y) * u); - newPos.z = keyFrame[1].position.z + + newPos.z = keyFrame[1].position.z + ((keyFrame[2].position.z - keyFrame[1].position.z) * u); } else { @@ -499,23 +499,23 @@ public class CubicSplineSegment { /** * Computes the interpolated position along the curve at a given point - * between key frames and returns a Vector3f with the interpolated + * between key frames and returns a Vector3f with the interpolated * x, y, and z scale components. This routine uses linear * interpolation if the (i+1)th key frame's linear * value is equal to 1. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @param newPos returns the interpolated x,y,z position in a Vector3f. + * @param newPos returns the interpolated x,y,z position in a Vector3f. */ public void getInterpolatedPositionVector (float u, Vector3f newPos) { // if linear interpolation if (this.linear == 1) { - newPos.x = keyFrame[1].position.x + + newPos.x = keyFrame[1].position.x + ((keyFrame[2].position.x - keyFrame[1].position.x) * u); - newPos.y = keyFrame[1].position.y + + newPos.y = keyFrame[1].position.y + ((keyFrame[2].position.y - keyFrame[1].position.y) * u); - newPos.z = keyFrame[1].position.z + + newPos.z = keyFrame[1].position.z + ((keyFrame[2].position.z - keyFrame[1].position.z) * u); } else { @@ -531,10 +531,10 @@ public class CubicSplineSegment { * key frame to the position specified by u to the length of the entire * spline segment from the ith key frame to the (i+1) * th key frame. When the (i+1)th key frame's linear - * value is equal to 1, this is meaninful otherwise it should return u. + * value is equal to 1, this is meaninful otherwise it should return u. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @return the interpolated ratio + * @return the interpolated ratio */ public float getInterpolatedValue (float u) { diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineCurve.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineCurve.java index c9a4d76..dfc10dc 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineCurve.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineCurve.java @@ -50,20 +50,20 @@ import javax.vecmath.*; import com.sun.j3d.internal.J3dUtilsI18N; /** - * KBCubicSplineCurve is a container class that holds a number of - * KBCubicSplineSegments - * + * KBCubicSplineCurve is a container class that holds a number of + * KBCubicSplineSegments + * * @since Java3D 1.2 */ public class KBCubicSplineCurve { - - private float totalCurveLength; + + private float totalCurveLength; private KBCubicSplineSegment[] cubicSplineSegment; public int numSegments; - - // default constructor + + // default constructor KBCubicSplineCurve () { numSegments = 0; totalCurveLength = 0f; @@ -73,21 +73,21 @@ public class KBCubicSplineCurve { * This method takes a list of key frames and creates spline segments * from it. It requires at least four key frames to be passed to it. * Given n key frames, it creates n-3 KBCubicSplineSegments. - * @param the list of key frames that specify the motion path + * @param the list of key frames that specify the motion path */ KBCubicSplineCurve (KBKeyFrame keys[]) { int keyLength = keys.length; - // Require at least 4 key frames for cubic spline curve + // Require at least 4 key frames for cubic spline curve if (keyLength < 4) - throw new + throw new IllegalArgumentException(J3dUtilsI18N.getString("KBCubicSplineCurve0")); - + numSegments = keyLength - 3; this.cubicSplineSegment = new KBCubicSplineSegment[numSegments]; - // intialize and calculate coefficients for each segment + // intialize and calculate coefficients for each segment int k0 = 0; int k1 = 1; int k2 = 2; int k3 = 3; for (; k0 < numSegments; k0++, k1++, k2++, k3++) { this.cubicSplineSegment[k0] = new KBCubicSplineSegment @@ -99,8 +99,8 @@ public class KBCubicSplineCurve { } /** - * This method takes a list of spline segments creates the - * KBCubicSplineCurve. + * This method takes a list of spline segments creates the + * KBCubicSplineCurve. * @param the list of segments that comprise the complete motion path */ @@ -117,9 +117,9 @@ public class KBCubicSplineCurve { } /** - * This method takes a list of spline segments to replace the existing - * set of KBCubicSplineSegments that comprise the current - * KBCubicSplineCurve motion path. + * This method takes a list of spline segments to replace the existing + * set of KBCubicSplineSegments that comprise the current + * KBCubicSplineCurve motion path. * @param s the list of segments that comprise the complete motion path */ @@ -136,32 +136,32 @@ public class KBCubicSplineCurve { } /** - * This method returns the KBCubicSplineSegments pointed to by index - * @param index the index of the KBCubicSplineSegment required + * This method returns the KBCubicSplineSegments pointed to by index + * @param index the index of the KBCubicSplineSegment required * @return the KBCubicSplineSegment pointed to by index */ public KBCubicSplineSegment getSegment (int index) { return this.cubicSplineSegment[index]; - } - + } + - // computes the total length of the curve + // computes the total length of the curve private void computeTotalCurveLength () { totalCurveLength = 0f; for (int i = 0; i < numSegments; i++) { totalCurveLength += cubicSplineSegment[i].length; - } + } } /** - * This method returns the total length of the entire KBCubicSplineCurve + * This method returns the total length of the entire KBCubicSplineCurve * motion path. * - * @return the length of the KBCubicSplineCurve motion path + * @return the length of the KBCubicSplineCurve motion path */ public float getTotalCurveLength () { @@ -169,6 +169,6 @@ public class KBCubicSplineCurve { return this.totalCurveLength; } - + } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineSegment.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineSegment.java index d1b4f63..20ea2a2 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineSegment.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBCubicSplineSegment.java @@ -50,20 +50,20 @@ import javax.vecmath.*; /** - * The KBCubicSplineSegment class creates the representation of a + * The KBCubicSplineSegment class creates the representation of a * Kochanek-Bartel's (also known as the TCB or Tension-Continuity-Bias - * Spline. This class takes 4 key frames as its input (using KBKeyFrame). - * If interpolating between the ith and (i+1)th key - * frame then the four key frames that need to be specified are the - * (i-1)th, ith, (i+1)th + * Spline. This class takes 4 key frames as its input (using KBKeyFrame). + * If interpolating between the ith and (i+1)th key + * frame then the four key frames that need to be specified are the + * (i-1)th, ith, (i+1)th * and (i+2)th keyframes in order. The KBCubicSegmentClass - * then pre-computes the hermite interpolation basis coefficients if the - * (i+1)th frame has the linear flag set to zero. These are used to - * calculate the interpolated position, scale and quaternions when they - * requested by the user using the getInterpolated* methods. If the the - * (i+1)th frame's linear flag is set to 1 then the class uses - * linear interpolation to calculate the interpolated position, scale, heading - * pitch and bank it returns through the getInterpolated* methods. + * then pre-computes the hermite interpolation basis coefficients if the + * (i+1)th frame has the linear flag set to zero. These are used to + * calculate the interpolated position, scale and quaternions when they + * requested by the user using the getInterpolated* methods. If the the + * (i+1)th frame's linear flag is set to 1 then the class uses + * linear interpolation to calculate the interpolated position, scale, heading + * pitch and bank it returns through the getInterpolated* methods. * * @since Java3D 1.2 */ @@ -94,16 +94,16 @@ public class KBCubicSplineSegment { // Key Frames KBKeyFrame[] keyFrame = new KBKeyFrame[4]; - - // H.C + + // H.C Point3f c0, c1, c2, c3; // coefficients for position - Point3f e0, e1, e2, e3; // coefficients for scale - float h0, h1, h2, h3; // coefficients for heading - float p0, p1, p2, p3; // coefficients for pitch - float b0, b1, b2, b3; // coefficients for bank + Point3f e0, e1, e2, e3; // coefficients for scale + float h0, h1, h2, h3; // coefficients for heading + float p0, p1, p2, p3; // coefficients for pitch + float b0, b1, b2, b3; // coefficients for bank // variables for destination derivative - float one_minus_t_in; + float one_minus_t_in; float one_minus_c_in; float one_minus_b_in; float one_plus_c_in; @@ -115,7 +115,7 @@ public class KBCubicSplineSegment { float one_minus_t_out; float one_minus_c_out; float one_minus_b_out; - float one_plus_c_out; + float one_plus_c_out; float one_plus_b_out; float dsb; float dsa; @@ -125,8 +125,8 @@ public class KBCubicSplineSegment { // interpolation type int linear; - - // Default constructor + + // Default constructor KBCubicSplineSegment () { length = 0; @@ -134,26 +134,26 @@ public class KBCubicSplineSegment { } /** - * Creates a cubic spline segment between two key frames using the - * key frames provided. If creating a spline between the ith frame and - * the (i+1)th frame then send down the (i - 1)th, - * ith , (i+1)th and the (i+2)th key - * frames. - * + * Creates a cubic spline segment between two key frames using the + * key frames provided. If creating a spline between the ith frame and + * the (i+1)th frame then send down the (i - 1)th, + * ith , (i+1)th and the (i+2)th key + * frames. + * * @param kf0 (i - 1)th Key Frame - * @param kf1 ith Key Frame + * @param kf1 ith Key Frame * @param kf2 (i + 1)th Key Frame - * @param kf3 (i + 2)th Key Frame + * @param kf3 (i + 2)th Key Frame */ KBCubicSplineSegment (KBKeyFrame kf0, KBKeyFrame kf1, KBKeyFrame kf2, KBKeyFrame kf3) { // Copy KeyFrame information - keyFrame[0] = new KBKeyFrame(kf0); - keyFrame[1] = new KBKeyFrame(kf1); - keyFrame[2] = new KBKeyFrame(kf2); - keyFrame[3] = new KBKeyFrame(kf3); + keyFrame[0] = new KBKeyFrame(kf0); + keyFrame[1] = new KBKeyFrame(kf1); + keyFrame[2] = new KBKeyFrame(kf2); + keyFrame[3] = new KBKeyFrame(kf3); // if linear interpolation is requested then just set linear flag // if spline interpolation is needed then compute spline coefficients @@ -171,32 +171,32 @@ public class KBCubicSplineSegment { } // compute the common coefficients - private void computeCommonCoefficients (KBKeyFrame kf0, + private void computeCommonCoefficients (KBKeyFrame kf0, KBKeyFrame kf1, - KBKeyFrame kf2, + KBKeyFrame kf2, KBKeyFrame kf3) { // variables for destination derivative float one_minus_t_in = 1.0f - kf1.tension; - float one_minus_c_in = 1.0f - kf1.continuity; + float one_minus_c_in = 1.0f - kf1.continuity; float one_minus_b_in = 1.0f - kf1.bias; float one_plus_c_in = 1.0f + kf1.continuity; float one_plus_b_in = 1.0f + kf1.bias; // coefficients for the incoming Tangent - ddb = one_minus_t_in * one_minus_c_in * one_minus_b_in; - dda = one_minus_t_in * one_plus_c_in * one_plus_b_in; + ddb = one_minus_t_in * one_minus_c_in * one_minus_b_in; + dda = one_minus_t_in * one_plus_c_in * one_plus_b_in; // variables for source derivative - float one_minus_t_out = 1.0f - kf2.tension; - float one_minus_c_out = 1.0f - kf2.continuity; + float one_minus_t_out = 1.0f - kf2.tension; + float one_minus_c_out = 1.0f - kf2.continuity; float one_minus_b_out = 1.0f - kf2.bias; float one_plus_c_out = 1.0f + kf2.continuity; float one_plus_b_out = 1.0f + kf2.bias; - + // coefficients for the outgoing Tangent - dsb = one_minus_t_in * one_plus_c_in * one_minus_b_in; - dsa = one_minus_t_in * one_minus_c_in * one_plus_b_in; + dsb = one_minus_t_in * one_plus_c_in * one_minus_b_in; + dsa = one_minus_t_in * one_minus_c_in * one_plus_b_in; } @@ -213,7 +213,7 @@ public class KBCubicSplineSegment { float deltaT; float deltaB; - // Find the difference in position and scale + // Find the difference in position and scale deltaP.x = kf2.position.x - kf1.position.x; deltaP.y = kf2.position.y - kf1.position.y; deltaP.z = kf2.position.z - kf1.position.z; @@ -226,13 +226,13 @@ public class KBCubicSplineSegment { deltaH = kf2.heading - kf1.heading; deltaT = kf2.pitch - kf1.pitch; deltaB = kf2.bank - kf1.bank; - + // Incoming Tangent Point3f dd_pos = new Point3f(); Point3f dd_scale = new Point3f(); float dd_heading, dd_pitch, dd_bank; - // If this is the first keyframe of the animation + // If this is the first keyframe of the animation if (kf0.knot == kf1.knot) { float ddab = 0.5f * (dda + ddb); @@ -242,7 +242,7 @@ public class KBCubicSplineSegment { dd_pos.y = ddab * deltaP.y; dd_pos.z = ddab * deltaP.z; - // Scale + // Scale dd_scale.x = ddab * deltaS.x; dd_scale.y = ddab * deltaS.y; dd_scale.z = ddab * deltaS.z; @@ -257,36 +257,36 @@ public class KBCubicSplineSegment { float adj0 = (kf1.knot - kf0.knot)/(kf2.knot - kf0.knot); // Position - dd_pos.x = adj0 * + dd_pos.x = adj0 * ((ddb * deltaP.x) + (dda * (kf1.position.x - kf0.position.x))); dd_pos.y = adj0 * ((ddb * deltaP.y) + (dda * (kf1.position.y - kf0.position.y))); - dd_pos.z = adj0 * + dd_pos.z = adj0 * ((ddb * deltaP.z) + (dda * (kf1.position.z - kf0.position.z))); - // Scale - dd_scale.x = adj0 * + // Scale + dd_scale.x = adj0 * ((ddb * deltaS.x) + (dda * (kf1.scale.x - kf0.scale.x))); - dd_scale.y = adj0 * + dd_scale.y = adj0 * ((ddb * deltaS.y) + (dda * (kf1.scale.y - kf0.scale.y))); - dd_scale.z = adj0 * + dd_scale.z = adj0 * ((ddb * deltaS.z) + (dda * (kf1.scale.z - kf0.scale.z))); // Heading, Pitch and Bank - dd_heading = adj0 * + dd_heading = adj0 * ((ddb * deltaH) + (dda * (kf1.heading - kf0.heading))); - dd_pitch = adj0 * + dd_pitch = adj0 * ((ddb * deltaT) + (dda * (kf1.pitch - kf0.pitch))); - dd_bank = adj0 * + dd_bank = adj0 * ((ddb * deltaB) + (dda * (kf1.bank - kf0.bank))); } - + // Outgoing Tangent Point3f ds_pos = new Point3f(); Point3f ds_scale = new Point3f(); float ds_heading, ds_pitch, ds_bank; - // If this is the last keyframe of the animation + // If this is the last keyframe of the animation if (kf2.knot == kf3.knot) { float dsab = 0.5f * (dsa + dsb); @@ -295,7 +295,7 @@ public class KBCubicSplineSegment { ds_pos.x = dsab * deltaP.x; ds_pos.y = dsab * deltaP.y; ds_pos.z = dsab * deltaP.z; - + // Scale ds_scale.x = dsab * deltaS.x; ds_scale.y = dsab * deltaS.y; @@ -311,27 +311,27 @@ public class KBCubicSplineSegment { float adj1 = (kf2.knot - kf1.knot)/(kf3.knot - kf1.knot); // Position - ds_pos.x = adj1 * + ds_pos.x = adj1 * ((dsb * (kf3.position.x - kf2.position.x)) + (dsa * deltaP.x)); - ds_pos.y = adj1 * + ds_pos.y = adj1 * ((dsb * (kf3.position.y - kf2.position.y)) + (dsa * deltaP.y)); - ds_pos.z = adj1 * + ds_pos.z = adj1 * ((dsb * (kf3.position.z - kf2.position.z)) + (dsa * deltaP.z)); // Scale - ds_scale.x = adj1 * + ds_scale.x = adj1 * ((dsb * (kf3.scale.x - kf2.scale.x)) + (dsa * deltaS.x)); - ds_scale.y = adj1 * + ds_scale.y = adj1 * ((dsb * (kf3.scale.y - kf2.scale.y)) + (dsa * deltaS.y)); - ds_scale.z = adj1 * + ds_scale.z = adj1 * ((dsb * (kf3.scale.z - kf2.scale.z)) + (dsa * deltaS.z)); - // Heading, Pitch and Bank - ds_heading = adj1 * + // Heading, Pitch and Bank + ds_heading = adj1 * ((dsb * (kf3.heading - kf2.heading)) + (dsa * deltaH)); - ds_pitch = adj1 * + ds_pitch = adj1 * ((dsb * (kf3.pitch - kf2.pitch)) + (dsa * deltaT)); - ds_bank = adj1 * + ds_bank = adj1 * ((dsb * (kf3.bank - kf2.bank)) + (dsa * deltaB)); } @@ -356,7 +356,7 @@ public class KBCubicSplineSegment { c3.y = -2*deltaP.y + dd_pos.y + ds_pos.y; c3.z = -2*deltaP.z + dd_pos.z + ds_pos.z; - // Calculate the coefficients of the polynomial for scale + // Calculate the coefficients of the polynomial for scale e0 = new Point3f(); e0.x = kf1.scale.x; e0.y = kf1.scale.y; @@ -377,7 +377,7 @@ public class KBCubicSplineSegment { e3.y = -2*deltaS.y + dd_scale.y + ds_scale.y; e3.z = -2*deltaS.z + dd_scale.z + ds_scale.z; - // Calculate the coefficients of the polynomial for heading, pitch + // Calculate the coefficients of the polynomial for heading, pitch // and bank h0 = kf1.heading; p0 = kf1.pitch; @@ -400,7 +400,7 @@ public class KBCubicSplineSegment { /** * Computes the length of the curve at a given point between * key frames. - * @param u specifies the point between keyframes where 0 <= u <= 1. + * @param u specifies the point between keyframes where 0 <= u <= 1. */ public float computeLength (float u) { @@ -430,31 +430,31 @@ public class KBCubicSplineSegment { v.y = c1.y + u * (2 * c2.y + 3 * u * c3.y); v.z = c1.z + u * (2 * c2.z + 3 * u * c3.z); - return (float)(Math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)); + return (float)(Math.sqrt(v.x*v.x + v.y*v.y + v.z*v.z)); } /** * Computes the interpolated scale along the curve at a given point - * between key frames and returns a Point3f with the interpolated + * between key frames and returns a Point3f with the interpolated * x, y, and z scale components. This routine uses linear - * interpolation if the (i+1)th key frame's linear - * value is equal to 1. - * - * @param u specifies the point between keyframes where 0 <= u <= 1. + * interpolation if the (i+1)th key frame's linear + * value is equal to 1. + * + * @param u specifies the point between keyframes where 0 <= u <= 1. * @param newScale returns the interpolated x,y,z scale value in a Point3f */ public void getInterpolatedScale (float u, Point3f newScale) { - + // if linear interpolation if (this.linear == 1) { - newScale.x = keyFrame[1].scale.x + + newScale.x = keyFrame[1].scale.x + ((keyFrame[2].scale.x - keyFrame[1].scale.x) * u); - newScale.y = keyFrame[1].scale.y + + newScale.y = keyFrame[1].scale.y + ((keyFrame[2].scale.y - keyFrame[1].scale.y) * u); - newScale.z = keyFrame[1].scale.z + + newScale.z = keyFrame[1].scale.z + ((keyFrame[2].scale.z - keyFrame[1].scale.z) * u); } else { @@ -469,7 +469,7 @@ public class KBCubicSplineSegment { /** * Computes the interpolated position along the curve at a given point - * between key frames and returns a Point3f with the interpolated + * between key frames and returns a Point3f with the interpolated * x, y, and z scale components. This routine uses linear * interpolation if the (i+1)th key frame's linear * value is equal to 1. @@ -479,14 +479,14 @@ public class KBCubicSplineSegment { */ public void getInterpolatedPosition (float u, Point3f newPos) { - + // if linear interpolation if (this.linear == 1) { - newPos.x = keyFrame[1].position.x + + newPos.x = keyFrame[1].position.x + ((keyFrame[2].position.x - keyFrame[1].position.x) * u); - newPos.y = keyFrame[1].position.y + + newPos.y = keyFrame[1].position.y + ((keyFrame[2].position.y - keyFrame[1].position.y) * u); - newPos.z = keyFrame[1].position.z + + newPos.z = keyFrame[1].position.z + ((keyFrame[2].position.z - keyFrame[1].position.z) * u); } else { @@ -500,23 +500,23 @@ public class KBCubicSplineSegment { /** * Computes the interpolated position along the curve at a given point - * between key frames and returns a Vector3f with the interpolated + * between key frames and returns a Vector3f with the interpolated * x, y, and z scale components. This routine uses linear * interpolation if the (i+1)th key frame's linear * value is equal to 1. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @param newPos returns the interpolated x,y,z position in a Vector3f. + * @param newPos returns the interpolated x,y,z position in a Vector3f. */ public void getInterpolatedPositionVector (float u, Vector3f newPos) { // if linear interpolation if (this.linear == 1) { - newPos.x = keyFrame[1].position.x + + newPos.x = keyFrame[1].position.x + ((keyFrame[2].position.x - keyFrame[1].position.x) * u); - newPos.y = keyFrame[1].position.y + + newPos.y = keyFrame[1].position.y + ((keyFrame[2].position.y - keyFrame[1].position.y) * u); - newPos.z = keyFrame[1].position.z + + newPos.z = keyFrame[1].position.z + ((keyFrame[2].position.z - keyFrame[1].position.z) * u); } else { @@ -529,22 +529,22 @@ public class KBCubicSplineSegment { /** * Computes the interpolated heading along the curve at a given point - * between key frames and returns the interpolated value as a float - * This routine uses linear interpolation if the (i+1)th + * between key frames and returns the interpolated value as a float + * This routine uses linear interpolation if the (i+1)th * key frame's linear value is equal to 1. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @return returns the interpolated heading value + * @return returns the interpolated heading value */ public float getInterpolatedHeading (float u) { float newHeading; - + // if linear interpolation if (this.linear == 1) { - newHeading = keyFrame[1].heading + + newHeading = keyFrame[1].heading + ((keyFrame[2].heading - keyFrame[1].heading) * u); } else { @@ -558,22 +558,22 @@ public class KBCubicSplineSegment { /** * Computes the interpolated pitch along the curve at a given point - * between key frames and returns the interpolated value as a float - * This routine uses linear interpolation if the (i+1)th + * between key frames and returns the interpolated value as a float + * This routine uses linear interpolation if the (i+1)th * key frame's linear value is equal to 1. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @return returns the interpolated pitch value + * @return returns the interpolated pitch value */ public float getInterpolatedPitch (float u) { float newPitch; - + // if linear interpolation if (this.linear == 1) { - newPitch = keyFrame[1].pitch + + newPitch = keyFrame[1].pitch + ((keyFrame[2].pitch - keyFrame[1].pitch) * u); } else { @@ -586,22 +586,22 @@ public class KBCubicSplineSegment { /** * Computes the interpolated bank along the curve at a given point - * between key frames and returns the interpolated value as a float - * This routine uses linear interpolation if the (i+1)th + * between key frames and returns the interpolated value as a float + * This routine uses linear interpolation if the (i+1)th * key frame's linear value is equal to 1. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @return returns the interpolated bank value + * @return returns the interpolated bank value */ public float getInterpolatedBank (float u) { float newBank; - + // if linear interpolation if (this.linear == 1) { - newBank = keyFrame[1].bank + + newBank = keyFrame[1].bank + ((keyFrame[2].bank - keyFrame[1].bank) * u); } else { @@ -618,10 +618,10 @@ public class KBCubicSplineSegment { * key frame to the position specified by u to the length of the entire * spline segment from the ith key frame to the (i+1) * th key frame. When the (i+1)th key frame's linear - * value is equal to 1, this is meaninful otherwise it should return u. + * value is equal to 1, this is meaninful otherwise it should return u. * * @param u specifies the point between keyframes where 0 <= u <= 1. - * @return the interpolated ratio + * @return the interpolated ratio */ public float getInterpolatedValue (float u) { diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBKeyFrame.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBKeyFrame.java index 18519d5..4a8bad8 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBKeyFrame.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBKeyFrame.java @@ -56,41 +56,41 @@ import com.sun.j3d.internal.J3dUtilsI18N; * @since Java3D 1.2 */ public class KBKeyFrame { - + // Position, Rotation and Scale - public Point3f position; + public Point3f position; public float heading; public float pitch; public float bank; - public Point3f scale; + public Point3f scale; // Tension, Continuity & Bias public float tension; public float continuity; public float bias; - // Sample Time + // Sample Time public float knot; // Interpolation type (linear = 0 -> spline interpolation) - public int linear; + public int linear; - // default constructor + // default constructor KBKeyFrame () { tension = continuity = bias = 0.0f; } public KBKeyFrame (KBKeyFrame kf) { - this(kf.knot, kf.linear, kf.position, kf.heading, kf.pitch, kf.bank, + this(kf.knot, kf.linear, kf.position, kf.heading, kf.pitch, kf.bank, kf.scale, kf.tension, kf.continuity, kf.bias); - + } /** - * Creates a key frame using the given inputs. + * Creates a key frame using the given inputs. * - * @param k knot value for this key frame + * @param k knot value for this key frame * @param l the linear flag (0 - Spline Interp, 1, Linear Interp * @param pos the position at the key frame * @param hd the heading value at the key frame @@ -101,10 +101,10 @@ public class KBKeyFrame { * @param c continuity (-1.0 < c < 1.0) * @param b bias (-1.0 < b < 1.0) */ - public KBKeyFrame (float k, int l, Point3f pos, float hd, float pi, + public KBKeyFrame (float k, int l, Point3f pos, float hd, float pi, float bk, Point3f s, float t, float c, float b) { - knot = k; + knot = k; linear = l; position = new Point3f(pos); heading = hd; @@ -132,19 +132,19 @@ public class KBKeyFrame { } /** - * Prints information comtained in this key frame + * Prints information comtained in this key frame * @param tag string tag for identifying debug message */ public void debugPrint (String tag) { - System.out.println ("\n" + tag); - System.out.println (" knot = " + knot); - System.out.println (" linear = " + linear); - System.out.println (" position(x,y,z) = " + position.x + " " + System.out.println ("\n" + tag); + System.out.println (" knot = " + knot); + System.out.println (" linear = " + linear); + System.out.println (" position(x,y,z) = " + position.x + " " + position.y + " " + position.z); - - System.out.println (" tension = " + tension); - System.out.println (" continuity = " + continuity); - System.out.println (" bias = " + bias); + + System.out.println (" tension = " + tension); + System.out.println (" continuity = " + continuity); + System.out.println (" bias = " + bias); } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBRotPosScaleSplinePathInterpolator.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBRotPosScaleSplinePathInterpolator.java index 815446e..1b7d032 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBRotPosScaleSplinePathInterpolator.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBRotPosScaleSplinePathInterpolator.java @@ -50,7 +50,7 @@ import javax.vecmath.*; /** - * KBRotPosScaleSplinePathInterpolator; A rotation and position path + * KBRotPosScaleSplinePathInterpolator; A rotation and position path * interpolation behavior node using Kochanek-Bartels cubic splines * (also known as TCB or Tension-Continuity-Bias Splines). * @@ -58,16 +58,16 @@ import javax.vecmath.*; */ /** - * KBRotPosScaleSplinePathInterpolator behavior. This class defines a - * behavior that varies the rotational, translational, and scale components - * of its target TransformGroup by using the Kochanek-Bartels cubic spline + * KBRotPosScaleSplinePathInterpolator behavior. This class defines a + * behavior that varies the rotational, translational, and scale components + * of its target TransformGroup by using the Kochanek-Bartels cubic spline * interpolation to interpolate among a series of key frames * (using the value generated by the specified Alpha object). The * interpolated position, orientation, and scale are used to generate - * a transform in the local coordinate system of this interpolator. + * a transform in the local coordinate system of this interpolator. */ -public class KBRotPosScaleSplinePathInterpolator +public class KBRotPosScaleSplinePathInterpolator extends KBSplinePathInterpolator { private Transform3D rotation = new Transform3D(); @@ -77,13 +77,13 @@ public class KBRotPosScaleSplinePathInterpolator private Matrix4d tMat = new Matrix4d(); // transformation matrix private Matrix4d sMat = new Matrix4d(); // scale matrix //Quat4f iQuat = new Quat4f(); // interpolated quaternion - private Vector3f iPos = new Vector3f(); // interpolated position - private Point3f iScale = new Point3f(); // interpolated scale + private Vector3f iPos = new Vector3f(); // interpolated position + private Point3f iScale = new Point3f(); // interpolated scale float iHeading, iPitch, iBank; // interpolated heading, // pitch and bank KBCubicSplineCurve cubicSplineCurve = new KBCubicSplineCurve(); - KBCubicSplineSegment cubicSplineSegments[]; + KBCubicSplineSegment cubicSplineSegments[]; int numSegments; int currentSegmentIndex; KBCubicSplineSegment currentSegment; @@ -93,9 +93,9 @@ public class KBRotPosScaleSplinePathInterpolator } /** - * Constructs a new KBRotPosScaleSplinePathInterpolator object that - * varies the rotation, translation, and scale of the target - * TransformGroup's transform. At least 2 key frames are required for + * Constructs a new KBRotPosScaleSplinePathInterpolator object that + * varies the rotation, translation, and scale of the target + * TransformGroup's transform. At least 2 key frames are required for * this interpolator. The first key * frame's knot must have a value of 0.0 and the last knot must have a * value of 1.0. An intermediate key frame with index k must have a @@ -105,16 +105,16 @@ public class KBRotPosScaleSplinePathInterpolator * @param target the TransformGroup node affected by this interpolator * @param axisOfTransform the transform that specifies the local * coordinate system in which this interpolator operates. - * @param keys an array of key frames that defien the motion path + * @param keys an array of key frames that defien the motion path */ public KBRotPosScaleSplinePathInterpolator(Alpha alpha, TransformGroup target, Transform3D axisOfTransform, KBKeyFrame keys[]) { super(alpha,target, axisOfTransform, keys); - + // Create a spline curve using the derived key frames - cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); + cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); numSegments = cubicSplineCurve.numSegments; } @@ -126,7 +126,7 @@ public class KBRotPosScaleSplinePathInterpolator public void setAxisOfRotPosScale(Transform3D axisOfRotPosScale) { setTransformAxis(axisOfRotPosScale); } - + /** * @deprecated As of Java 3D version 1.3, replaced by * TransformInterpolator.getTransformAxis() @@ -145,7 +145,7 @@ public class KBRotPosScaleSplinePathInterpolator // TODO Optimize this // Create a spline curve using the derived key frames - cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); + cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); numSegments = cubicSplineCurve.numSegments; } @@ -157,7 +157,7 @@ public class KBRotPosScaleSplinePathInterpolator super.setKeyFrames( keyFrame ); // Create a spline curve using the derived key frames - cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); + cubicSplineCurve = new KBCubicSplineCurve(this.keyFrames); numSegments = cubicSplineCurve.numSegments; } @@ -172,14 +172,14 @@ public class KBRotPosScaleSplinePathInterpolator * @since Java 3D 1.3 */ public void computeTransform(float alphaValue, Transform3D transform) { - // compute the current value of u from alpha and the + // compute the current value of u from alpha and the // determine lower and upper knot points computePathInterpolation( alphaValue ); // Determine the segment within which we will be interpolating currentSegmentIndex = this.lowerKnot - 1; - - // if we are at the start of the curve + + // if we are at the start of the curve if (currentSegmentIndex == 0 && currentU == 0f) { iHeading = keyFrames[1].heading; @@ -188,8 +188,8 @@ public class KBRotPosScaleSplinePathInterpolator iPos.set(keyFrames[1].position); iScale.set(keyFrames[1].scale); - // if we are at the end of the curve - } else if (currentSegmentIndex == (numSegments-1) && + // if we are at the end of the curve + } else if (currentSegmentIndex == (numSegments-1) && currentU == 1.0) { iHeading = keyFrames[upperKnot].heading; @@ -202,24 +202,24 @@ public class KBRotPosScaleSplinePathInterpolator } else { // Get a reference to the current spline segment i.e. the - // one bounded by lowerKnot and upperKnot - currentSegment + // one bounded by lowerKnot and upperKnot + currentSegment = cubicSplineCurve.getSegment(currentSegmentIndex); - // interpolate quaternions + // interpolate quaternions iHeading = currentSegment.getInterpolatedHeading (currentU); iPitch = currentSegment.getInterpolatedPitch (currentU); iBank = currentSegment.getInterpolatedBank (currentU); // interpolate position - currentSegment.getInterpolatedPositionVector(currentU,iPos); + currentSegment.getInterpolatedPositionVector(currentU,iPos); // interpolate position currentSegment.getInterpolatedScale(currentU,iScale); } - // Generate a transformation matrix in tMat using interpolated + // Generate a transformation matrix in tMat using interpolated // heading, pitch and bank pitchMat.setIdentity(); pitchMat.rotX(-iPitch); @@ -231,7 +231,7 @@ public class KBRotPosScaleSplinePathInterpolator tMat.mul(bankMat); // TODO: Handle Non-Uniform scale - // Currently this interpolator does not handle non uniform scale + // Currently this interpolator does not handle non uniform scale // We cheat by just taking the x scale component // Scale the transformation matrix @@ -243,18 +243,18 @@ public class KBRotPosScaleSplinePathInterpolator tMat.m13 = iPos.y; tMat.m23 = iPos.z; rotation.set(tMat); - - // construct a Transform3D from: axis * rotation * axisInverse + + // construct a Transform3D from: axis * rotation * axisInverse transform.mul(axis, rotation); transform.mul(transform, axisInverse); } - + /** * Copies KBRotPosScaleSplinePathInterpolator information from * originalNode into * the current node. This method is called from the * cloneNode method which is, in turn, called by the - * cloneTree method.

+ * cloneTree method.

* * @param forceDuplicate when set to true, causes the * duplicateOnCloneTree flag to be ignored. When @@ -268,7 +268,7 @@ public class KBRotPosScaleSplinePathInterpolator * @see Node#duplicateNode * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree - */ + */ public Node cloneNode(boolean forceDuplicate) { KBRotPosScaleSplinePathInterpolator spline = new KBRotPosScaleSplinePathInterpolator(); @@ -282,7 +282,7 @@ public class KBRotPosScaleSplinePathInterpolator * originalNode into * the current node. This method is called from the * cloneNode method which is, in turn, called by the - * cloneTree method.

+ * cloneTree method.

* * @param originalNode the original node to duplicate. * @param forceDuplicate when set to true, causes the @@ -297,15 +297,15 @@ public class KBRotPosScaleSplinePathInterpolator * @see Node#duplicateNode * @see Node#cloneTree * @see NodeComponent#setDuplicateOnCloneTree - */ + */ public void duplicateNode(Node originalNode, boolean forceDuplicate) { super.duplicateNode(originalNode, forceDuplicate); - + KBRotPosScaleSplinePathInterpolator interpolator = (KBRotPosScaleSplinePathInterpolator)originalNode; setAxisOfRotPosScale(interpolator.axis); target = interpolator.target; - cubicSplineCurve = new KBCubicSplineCurve(interpolator.keyFrames); + cubicSplineCurve = new KBCubicSplineCurve(interpolator.keyFrames); numSegments = cubicSplineCurve.numSegments; } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBSplinePathInterpolator.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBSplinePathInterpolator.java index 9a1c5ec..bf6695e 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBSplinePathInterpolator.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/KBSplinePathInterpolator.java @@ -51,14 +51,14 @@ import com.sun.j3d.internal.J3dUtilsI18N; /** * KBSplinePathInterpolator behavior. This class defines the base class for - * all Kochanek-Bartels (also known as TCB or Tension-Continuity-Bias) - * Spline Path Interpolators. + * all Kochanek-Bartels (also known as TCB or Tension-Continuity-Bias) + * Spline Path Interpolators. * * @since Java3D 1.2 */ public abstract class KBSplinePathInterpolator extends TransformInterpolator { - + private int keysLength; /** * An array of KBKeyFrame for interpolator @@ -66,7 +66,7 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { protected KBKeyFrame[] keyFrames; /** - * This value is the distance between knots + * This value is the distance between knots * value which can be used in further calculations by the subclass. */ protected float currentU; @@ -88,7 +88,7 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { */ KBSplinePathInterpolator() { } - + /** * @deprecated As of Java 3D version 1.3, replaced by @@ -102,14 +102,14 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { * Constructs a new KBSplinePathInterpolator object that interpolates * between keyframes with specified alpha, target and an default * axisOfTranform set to identity. - * It takes at least two key frames. The first key + * It takes at least two key frames. The first key * frame's knot must have a value of 0.0 and the last knot must have a - * value of 1.0. An intermediate key frame with index k must have a - * knot value strictly greater than the knot value of a key frame with + * value of 1.0. An intermediate key frame with index k must have a + * knot value strictly greater than the knot value of a key frame with * index less than k. Once this constructor has all the valid key frames * it creates its own list of key fames that duplicates the first key frame * at the beginning of the list and the last key frame at the end of the - * list. + * list. * @param alpha the alpha object for this interpolator * @param target the TransformGroup node affected by this interpolator * @param keys an array of KBKeyFrame. Requires at least two key frames. @@ -120,18 +120,18 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { super(alpha, target); processKeyFrames( keys ); } - + /** * Constructs a new KBSplinePathInterpolator object that interpolates * between keyframes with specified alpha, target and axisOfTransform. - * It takes at least two key frames. The first key + * It takes at least two key frames. The first key * frame's knot must have a value of 0.0 and the last knot must have a - * value of 1.0. An intermediate key frame with index k must have a - * knot value strictly greater than the knot value of a key frame with + * value of 1.0. An intermediate key frame with index k must have a + * knot value strictly greater than the knot value of a key frame with * index less than k. Once this constructor has all the valid key frames * it creates its own list of key fames that duplicates the first key frame * at the beginning of the list and the last key frame at the end of the - * list. + * list. * @param alpha the alpha object for this interpolator * @param target the TransformGroup node affected by this interpolator * @param axisOfTransform the transform that defines the local coordinate @@ -159,46 +159,46 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { } - // Make sure that the first key frame's knot is equal to 0.0 + // Make sure that the first key frame's knot is equal to 0.0 if (keys[0].knot < -0.0001 || keys[0].knot > 0.0001) { throw new IllegalArgumentException(J3dUtilsI18N.getString("KBSplinePathInterpolator1")); } - - // Make sure that the last key frames knot is equal to 1.0 + + // Make sure that the last key frames knot is equal to 1.0 if (keys[keysLength-1].knot -1.0 < -0.0001 || keys[keysLength-1].knot -1.0 > 0.0001) { throw new IllegalArgumentException(J3dUtilsI18N.getString("KBSplinePathInterpolator2")); } - // Make sure that all the knots are in sequence + // Make sure that all the knots are in sequence for (int i = 0; i < keysLength; i++) { if (i>0 && keys[i].knot < keys[i-1].knot) { throw new IllegalArgumentException(J3dUtilsI18N.getString("KBSplinePathInterpolator3")); } } - // Make space for a leading and trailing key frame in addition to + // Make space for a leading and trailing key frame in addition to // the keys passed in keyFrames = new KBKeyFrame[keysLength+2]; keyFrames[0] = new KBKeyFrame(); keyFrames[0] = keys[0]; for (int i = 1; i < keysLength+1; i++) { - keyFrames[i] = keys[i-1]; + keyFrames[i] = keys[i-1]; } keyFrames[keysLength+1] = new KBKeyFrame(); - keyFrames[keysLength+1] = keys[keysLength-1]; + keyFrames[keysLength+1] = keys[keysLength-1]; // Make key frame length reflect the 2 added key frames keysLength += 2; } - + /** * This method retrieves the length of the key frame array. - * @return the number of key frames + * @return the number of key frames */ public int getArrayLength(){ return keysLength-2; } - + /** * This method retrieves the key frame at the specified index. * @param index the index of the key frame requested @@ -239,21 +239,21 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { /** * This method computes the bounding knot indices and interpolation value - * "CurrentU" given the current value of the knots[] array and the + * "CurrentU" given the current value of the knots[] array and the * specified alpha value * @param alphaValue alpha value between 0.0 and 1.0 - * + * * @since Java 3D 1.3 */ protected void computePathInterpolation( float alphaValue ) { - // skip knots till we find the two we fall between + // skip knots till we find the two we fall between int i = 1; int len = keysLength - 2; while ((alphaValue > keyFrames[i].knot) && (i < len)) { i++; } - + if (i == 1) { currentU = 0f; lowerKnot = 1; @@ -271,7 +271,7 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { * originalNode into * the current node. This method is called from the * cloneNode method which is, in turn, called by the - * cloneTree method.

+ * cloneTree method.

* * @param originalNode the original node to duplicate. * @param forceDuplicate when set to true, causes the @@ -289,7 +289,7 @@ public abstract class KBSplinePathInterpolator extends TransformInterpolator { */ public void duplicateNode(Node originalNode, boolean forceDuplicate) { super.duplicateNode(originalNode, forceDuplicate); - KBSplinePathInterpolator originalSpline = + KBSplinePathInterpolator originalSpline = (KBSplinePathInterpolator) originalNode; setAlpha(originalSpline.getAlpha()); keysLength = originalSpline.keysLength; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/RotPosScaleTCBSplinePathInterpolator.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/RotPosScaleTCBSplinePathInterpolator.java index 0043b1e..3caeebe 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/RotPosScaleTCBSplinePathInterpolator.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/RotPosScaleTCBSplinePathInterpolator.java @@ -50,29 +50,29 @@ import javax.vecmath.*; /** - * RotPosScaleTCBSplinePathInterpolator behavior. This class defines a - * behavior that varies the rotational, translational, and scale components - * of its target TransformGroup by using the Kochanek-Bartels cubic spline + * RotPosScaleTCBSplinePathInterpolator behavior. This class defines a + * behavior that varies the rotational, translational, and scale components + * of its target TransformGroup by using the Kochanek-Bartels cubic spline * interpolation to interpolate among a series of key frames * (using the value generated by the specified Alpha object). The * interpolated position, orientation, and scale are used to generate - * a transform in the local coordinate system of this interpolator. + * a transform in the local coordinate system of this interpolator. * * @since Java3D 1.1 */ -public class RotPosScaleTCBSplinePathInterpolator +public class RotPosScaleTCBSplinePathInterpolator extends TCBSplinePathInterpolator { private Transform3D rotation = new Transform3D(); private Matrix4d tMat = new Matrix4d(); private Matrix4d sMat = new Matrix4d(); private Quat4f iQuat = new Quat4f(); // interpolated quaternion - private Vector3f iPos = new Vector3f(); // interpolated position - private Point3f iScale = new Point3f(); // interpolated scale + private Vector3f iPos = new Vector3f(); // interpolated position + private Point3f iScale = new Point3f(); // interpolated scale CubicSplineCurve cubicSplineCurve = new CubicSplineCurve(); - CubicSplineSegment cubicSplineSegments[]; + CubicSplineSegment cubicSplineSegments[]; int numSegments; int currentSegmentIndex; CubicSplineSegment currentSegment; @@ -82,9 +82,9 @@ extends TCBSplinePathInterpolator { } /** - * Constructs a new RotPosScaleTCBSplinePathInterpolator object that - * varies the rotation, translation, and scale of the target - * TransformGroup's transform. At least 2 key frames are required for + * Constructs a new RotPosScaleTCBSplinePathInterpolator object that + * varies the rotation, translation, and scale of the target + * TransformGroup's transform. At least 2 key frames are required for * this interpolator. The first key * frame's knot must have a value of 0.0 and the last knot must have a * value of 1.0. An intermediate key frame with index k must have a @@ -94,7 +94,7 @@ extends TCBSplinePathInterpolator { * @param target the TransformGroup node affected by this interpolator * @param axisOfTransform the transform that specifies the local * coordinate system in which this interpolator operates. - * @param keys an array of key frames that defien the motion path + * @param keys an array of key frames that defien the motion path */ public RotPosScaleTCBSplinePathInterpolator(Alpha alpha, TransformGroup target, @@ -102,7 +102,7 @@ extends TCBSplinePathInterpolator { TCBKeyFrame keys[]) { super(alpha, target, axisOfTransform, keys); // Create a spline curve using the derived key frames - cubicSplineCurve = new CubicSplineCurve(this.keyFrames); + cubicSplineCurve = new CubicSplineCurve(this.keyFrames); numSegments = cubicSplineCurve.numSegments; } @@ -115,15 +115,15 @@ extends TCBSplinePathInterpolator { public void setAxisOfRotPosScale(Transform3D axisOfRotPosScale) { setTransformAxis(axisOfRotPosScale); } - + /** * @deprecated As of Java 3D version 1.3, replaced by * TransformInterpolator.getTransformAxis() - */ + */ public Transform3D getAxisOfRotPosScale() { return getTransformAxis(); } - + /** * Computes the new transform for this interpolator for a given * alpha value. @@ -136,22 +136,22 @@ extends TCBSplinePathInterpolator { */ public void computeTransform(float alphaValue, Transform3D transform) { - // compute the current value of u from alpha and the + // compute the current value of u from alpha and the // determine lower and upper knot points computePathInterpolation(alphaValue); // Determine the segment within which we will be interpolating currentSegmentIndex = this.lowerKnot - 1; - - // if we are at the start of the curve + + // if we are at the start of the curve if (currentSegmentIndex == 0 && currentU == 0f) { iQuat.set(keyFrames[1].quat); iPos.set(keyFrames[1].position); iScale.set(keyFrames[1].scale); - // if we are at the end of the curve - } else if (currentSegmentIndex == (numSegments-1) && + // if we are at the end of the curve + } else if (currentSegmentIndex == (numSegments-1) && currentU == 1.0) { iQuat.set(keyFrames[upperKnot].quat); @@ -162,15 +162,15 @@ extends TCBSplinePathInterpolator { } else { // Get a reference to the current spline segment i.e. the - // one bounded by lowerKnot and upperKnot - currentSegment + // one bounded by lowerKnot and upperKnot + currentSegment = cubicSplineCurve.getSegment(currentSegmentIndex); - // interpolate quaternions + // interpolate quaternions currentSegment.getInterpolatedQuaternion(currentU,iQuat); // interpolate position - currentSegment.getInterpolatedPositionVector(currentU,iPos); + currentSegment.getInterpolatedPositionVector(currentU,iPos); // interpolate position currentSegment.getInterpolatedScale(currentU,iScale); @@ -178,7 +178,7 @@ extends TCBSplinePathInterpolator { } // Alway normalize the quaternion - iQuat.normalize(); + iQuat.normalize(); tMat.set(iQuat); // Set the translation components. @@ -186,12 +186,12 @@ extends TCBSplinePathInterpolator { tMat.m13 = iPos.y; tMat.m23 = iPos.z; rotation.set(tMat); - - // construct a Transform3D from: axis * rotation * axisInverse + + // construct a Transform3D from: axis * rotation * axisInverse transform.mul(axis, rotation); - transform.setScale(new Vector3d(iScale)); + transform.setScale(new Vector3d(iScale)); transform.mul(transform, axisInverse); - + } /** @@ -214,13 +214,13 @@ extends TCBSplinePathInterpolator { spline.duplicateNode(this, forceDuplicate); return spline; } - + /** * Copies RotPosScaleTCBSplinePathInterpolator information from * originalNode into * the current node. This method is called from the * cloneNode method which is, in turn, called by the - * cloneTree method.

+ * cloneTree method.

* * @param originalNode the original node to duplicate. * @param forceDuplicate when set to true, causes the @@ -238,9 +238,9 @@ extends TCBSplinePathInterpolator { */ public void duplicateNode(Node originalNode, boolean forceDuplicate) { super.duplicateNode(originalNode, forceDuplicate); - RotPosScaleTCBSplinePathInterpolator interpolator = + RotPosScaleTCBSplinePathInterpolator interpolator = (RotPosScaleTCBSplinePathInterpolator)originalNode; - + cubicSplineCurve = new CubicSplineCurve(interpolator.keyFrames); numSegments = cubicSplineCurve.numSegments; } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBKeyFrame.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBKeyFrame.java index fca38c7..270329b 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBKeyFrame.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBKeyFrame.java @@ -57,24 +57,24 @@ import com.sun.j3d.internal.J3dUtilsI18N; */ public class TCBKeyFrame { - + // Position, Rotation and Scale - public Point3f position; + public Point3f position; public Quat4f quat; - public Point3f scale; + public Point3f scale; // Tension, Continuity & Bias public float tension; public float continuity; public float bias; - // Sample Time + // Sample Time public float knot; // Interpolation type (linear = 0 -> spline interpolation) - public int linear; + public int linear; - // default constructor + // default constructor TCBKeyFrame () { tension = continuity = bias = 0.0f; } @@ -82,13 +82,13 @@ public class TCBKeyFrame { public TCBKeyFrame (TCBKeyFrame kf) { this(kf.knot, kf.linear, kf.position, kf.quat, kf.scale, kf.tension, kf.continuity, kf.bias); - + } /** - * Creates a key frame using the given inputs. + * Creates a key frame using the given inputs. * - * @param k knot value for this key frame + * @param k knot value for this key frame * @param l the linear flag (0 - Spline Interp, 1, Linear Interp * @param pos the position at the key frame * @param q the rotations at the key frame @@ -97,10 +97,10 @@ public class TCBKeyFrame { * @param c continuity (-1.0 < c < 1.0) * @param b bias (-1.0 < b < 1.0) */ - public TCBKeyFrame (float k, int l, Point3f pos, Quat4f q, Point3f s, + public TCBKeyFrame (float k, int l, Point3f pos, Quat4f q, Point3f s, float t, float c, float b) { - knot = k; + knot = k; linear = l; position = new Point3f(pos); quat = new Quat4f(q); @@ -126,19 +126,19 @@ public class TCBKeyFrame { } /** - * Prints information comtained in this key frame + * Prints information comtained in this key frame * @param tag string tag for identifying debug message */ public void debugPrint (String tag) { - System.out.println ("\n" + tag); - System.out.println (" knot = " + knot); - System.out.println (" linear = " + linear); - System.out.println (" position(x,y,z) = " + position.x + " " + System.out.println ("\n" + tag); + System.out.println (" knot = " + knot); + System.out.println (" linear = " + linear); + System.out.println (" position(x,y,z) = " + position.x + " " + position.y + " " + position.z); - - System.out.println (" tension = " + tension); - System.out.println (" continuity = " + continuity); - System.out.println (" bias = " + bias); + + System.out.println (" tension = " + tension); + System.out.println (" continuity = " + continuity); + System.out.println (" bias = " + bias); } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBSplinePathInterpolator.java b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBSplinePathInterpolator.java index 9f43278..9f6c3ca 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBSplinePathInterpolator.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/interpolators/TCBSplinePathInterpolator.java @@ -51,22 +51,22 @@ import com.sun.j3d.internal.J3dUtilsI18N; /** * TCBSplinePathInterpolator behavior. This class defines the base class for - * all TCB (Kochanek-Bartels) Spline Path Interpolators. + * all TCB (Kochanek-Bartels) Spline Path Interpolators. * * @since Java3D 1.1 */ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { - + private int keysLength; - + /** * An array of KBKeyFrame for interpolator */ protected TCBKeyFrame[] keyFrames; /** - * This value is the distance between knots + * This value is the distance between knots * value which can be used in further calculations by the subclass. */ protected float currentU; @@ -90,26 +90,26 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { TCBSplinePathInterpolator() { } - + /** - * @deprecated As of Java 3D version 1.3, replaced by + * @deprecated As of Java 3D version 1.3, replaced by * TCBSplinePathInterpolator(Alpha, TransformGroup, TCBKeyFrame[]) */ public TCBSplinePathInterpolator(Alpha alpha, TCBKeyFrame keys[]) { - this(alpha, null, keys); + this(alpha, null, keys); } /** * Constructs a new TCBSplinePathInterpolator object that interpolates * between keyframes with specified alpha, target and default axisOfTransform - * set to identity. It takes at least two key frames. The first key + * set to identity. It takes at least two key frames. The first key * frame's knot must have a value of 0.0 and the last knot must have a - * value of 1.0. An intermediate key frame with index k must have a - * knot value strictly greater than the knot value of a key frame with + * value of 1.0. An intermediate key frame with index k must have a + * knot value strictly greater than the knot value of a key frame with * index less than k. Once this constructor has all the valid key frames * it creates its own list of key fames that duplicates the first key frame * at the beginning of the list and the last key frame at the end of the - * list. + * list. * @param alpha the alpha object for this interpolator * @param target the TransformGroup node effected by this TCBSplinePathInterpolator * @param keys an array of TCBKeyFrame. Requires at least two key frames. @@ -120,18 +120,18 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { super(alpha, target); processKeyFrames(keys); } - + /** * Constructs a new TCBSplinePathInterpolator object that interpolates * between keyframes with specified alpha, target and axisOfTransform. - * It takes at least two key frames. The first key + * It takes at least two key frames. The first key * frame's knot must have a value of 0.0 and the last knot must have a - * value of 1.0. An intermediate key frame with index k must have a - * knot value strictly greater than the knot value of a key frame with + * value of 1.0. An intermediate key frame with index k must have a + * knot value strictly greater than the knot value of a key frame with * index less than k. Once this constructor has all the valid key frames * it creates its own list of key fames that duplicates the first key frame * at the beginning of the list and the last key frame at the end of the - * list. + * list. * @param alpha the alpha object for this interpolator * @param target the TransformGroup node effected by this TCBSplinePathInterpolator * @param axisOfTransform the transform that defines the local coordinate @@ -144,12 +144,12 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { super(alpha, target, axisOfTransform); processKeyFrames(keys); } - + /** * Process the new array of key frames */ private void processKeyFrames( TCBKeyFrame keys[] ){ - + // Make sure that we have at least two key frames keysLength = keys.length; if (keysLength < 2) { @@ -157,46 +157,46 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { } - // Make sure that the first key frame's knot is equal to 0.0 + // Make sure that the first key frame's knot is equal to 0.0 if (keys[0].knot < -0.0001 || keys[0].knot > 0.0001) { throw new IllegalArgumentException(J3dUtilsI18N.getString("TCBSplinePathInterpolator1")); } - - // Make sure that the last key frames knot is equal to 1.0 + + // Make sure that the last key frames knot is equal to 1.0 if (keys[keysLength-1].knot -1.0 < -0.0001 || keys[keysLength-1].knot -1.0 > 0.0001) { - throw new IllegalArgumentException(J3dUtilsI18N.getString("TCBSplinePathInterpolator2")); + throw new IllegalArgumentException(J3dUtilsI18N.getString("TCBSplinePathInterpolator2")); } - // Make sure that all the knots are in sequence + // Make sure that all the knots are in sequence for (int i = 0; i < keysLength; i++) { if (i>0 && keys[i].knot < keys[i-1].knot) { throw new IllegalArgumentException(J3dUtilsI18N.getString("TCBSplinePathInterpolator3")); } } - // Make space for a leading and trailing key frame in addition to + // Make space for a leading and trailing key frame in addition to // the keys passed in keyFrames = new TCBKeyFrame[keysLength+2]; keyFrames[0] = new TCBKeyFrame(); keyFrames[0] = keys[0]; for (int i = 1; i < keysLength+1; i++) { - keyFrames[i] = keys[i-1]; + keyFrames[i] = keys[i-1]; } keyFrames[keysLength+1] = new TCBKeyFrame(); - keyFrames[keysLength+1] = keys[keysLength-1]; + keyFrames[keysLength+1] = keys[keysLength-1]; // Make key frame length reflect the 2 added key frames keysLength += 2; } - + /** * This method retrieves the length of the key frame array. - * @return the number of key frames + * @return the number of key frames */ public int getArrayLength(){ return keysLength-2; } - + /** * This method retrieves the key frame at the specified index. * @param index the index of the key frame requested @@ -217,13 +217,13 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { */ protected void computePathInterpolation(float alphaValue) { - // skip knots till we find the two we fall between + // skip knots till we find the two we fall between int i = 1; int len = keysLength - 2; while ((alphaValue > keyFrames[i].knot) && (i < len)) { i++; } - + if (i == 1) { currentU = 0f; lowerKnot = 1; @@ -244,13 +244,13 @@ public abstract class TCBSplinePathInterpolator extends TransformInterpolator { float value = (this.getAlpha()).value(); computePathInterpolation(value); } - + /** * Copies all TCBSplinePathInterpolator information from * originalNode into * the current node. This method is called from the * cloneNode method which is, in turn, called by the - * cloneTree method.

+ * cloneTree method.

* * @param originalNode the original node to duplicate. * @param forceDuplicate when set to true, causes the diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigator.java b/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigator.java index 48a279a..72d5116 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigator.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigator.java @@ -281,7 +281,7 @@ public class KeyNavigator { if (((modifier_key_state & ALT) != 0) && (key_state & PAGE_UP) == 0 && (key_state & PAGE_DOWN) != 0) accKeyAdd(a, downAcc, downDrag, scaleVel); - + /* * Drag due to new or existing motion @@ -483,7 +483,7 @@ public class KeyNavigator { modifier_key_state |= META; else modifier_key_state &= ~META; - + if (keyEvent.isAltDown()) modifier_key_state |= ALT; else diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigatorBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigatorBehavior.java index b6f975c..f2783f7 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigatorBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/keyboard/KeyNavigatorBehavior.java @@ -94,7 +94,7 @@ public class KeyNavigatorBehavior extends Behavior implements KeyListener { WakeupCriterion genericEvt; AWTEvent[] events; boolean sawFrame = false; - + while (criteria.hasMoreElements()) { genericEvt = (WakeupCriterion) criteria.nextElement(); if (genericEvt instanceof WakeupOnAWTEvent) { @@ -184,7 +184,7 @@ public class KeyNavigatorBehavior extends Behavior implements KeyListener { if (c != null) { c.addKeyListener(this); } - listener = true; + listener = true; } public void keyPressed(KeyEvent evt) { diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseBehavior.java index 9d98f22..b323eee 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseBehavior.java @@ -55,14 +55,14 @@ import com.sun.j3d.internal.J3dUtilsI18N; /** * Base class for all mouse manipulators (see MouseRotate, MouseZoom * and MouseTranslate for - * examples of how to extend this base class). + * examples of how to extend this base class). */ public abstract class MouseBehavior extends Behavior implements MouseListener, MouseMotionListener, MouseWheelListener { private boolean listener = false; - + protected WakeupCriterion[] mouseEvents; protected WakeupOr mouseCriterion; protected int x, y; @@ -88,9 +88,9 @@ public abstract class MouseBehavior extends Behavior */ public static final int MANUAL_WAKEUP = 0x1; - /** + /** * Set this flag if you want to invert the inputs. This is useful when - * the transform for the view platform is being changed instead of the + * the transform for the view platform is being changed instead of the * transform for the object. */ public static final int INVERT_INPUT = 0x2; @@ -101,7 +101,7 @@ public abstract class MouseBehavior extends Behavior */ public MouseBehavior(TransformGroup transformGroup) { super(); - // need to remove old behavior from group + // need to remove old behavior from group this.transformGroup = transformGroup; currXform = new Transform3D(); transformX = new Transform3D(); @@ -167,15 +167,15 @@ public abstract class MouseBehavior extends Behavior } listener = true; } - - /** - * Swap a new transformGroup replacing the old one. This allows + + /** + * Swap a new transformGroup replacing the old one. This allows * manipulators to operate on different nodes. - * + * * @param transformGroup The *new* transform group to be manipulated. */ public void setTransformGroup(TransformGroup transformGroup){ - // need to remove old behavior from group + // need to remove old behavior from group this.transformGroup = transformGroup; currXform = new Transform3D(); transformX = new Transform3D(); @@ -220,9 +220,9 @@ public abstract class MouseBehavior extends Behavior x_last = 0; y_last = 0; } - - /** - * Manually wake up the behavior. If MANUAL_WAKEUP flag was set upon + + /** + * Manually wake up the behavior. If MANUAL_WAKEUP flag was set upon * creation, you must wake up this behavior each time it is handled. */ @@ -242,8 +242,8 @@ public abstract class MouseBehavior extends Behavior else if (evt.getID()==MouseEvent.MOUSE_RELEASED){ buttonPress = false; wakeUp = false; - } - /* + } + /* else if (evt.getID() == MouseEvent.MOUSE_MOVED) { // Process mouse move event } @@ -252,7 +252,7 @@ public abstract class MouseBehavior extends Behavior } */ } - + /** * All mouse manipulators must implement this. */ @@ -291,7 +291,7 @@ public abstract class MouseBehavior extends Behavior synchronized (mouseq) { mouseq.add(e); // only need to post if this is the only event in the queue - if (mouseq.size() == 1) + if (mouseq.size() == 1) postId(MouseEvent.MOUSE_PRESSED); } } @@ -321,7 +321,7 @@ public abstract class MouseBehavior extends Behavior synchronized (mouseq) { mouseq.add(e); // only need to post if this is the only event in the queue - if (mouseq.size() == 1) + if (mouseq.size() == 1) postId(MouseEvent.MOUSE_DRAGGED); } } @@ -339,14 +339,14 @@ public abstract class MouseBehavior extends Behavior public void mouseWheelMoved(MouseWheelEvent e){ System.out.println("MouseBehavior : mouseWheel enable = " + enable ); - + // add new event to the to the queue // must be MT safe. if (enable) { synchronized (mouseq) { mouseq.add(e); // only need to post if this is the only event in the queue - if (mouseq.size() == 1) + if (mouseq.size() == 1) postId(MouseEvent.MOUSE_WHEEL); } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseRotate.java b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseRotate.java index 85a6bef..baa2c22 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseRotate.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseRotate.java @@ -51,13 +51,13 @@ import javax.media.j3d.*; import javax.vecmath.*; /** - * MouseRotate is a Java3D behavior object that lets users control the + * MouseRotate is a Java3D behavior object that lets users control the * rotation of an object via a mouse. *

- * To use this utility, first create a transform group that this + * To use this utility, first create a transform group that this * rotate behavior will operate on. Then, *

- * 
+ *
  *   MouseRotate behavior = new MouseRotate();
  *   behavior.setTransformGroup(objTrans);
  *   objTrans.addChild(behavior);
@@ -146,7 +146,7 @@ public class MouseRotate extends MouseBehavior {
     public MouseRotate(Component c, int flags) {
 	super(c, flags);
     }
-    
+
     public void initialize() {
 	super.initialize();
 	x_angle = 0;
@@ -157,21 +157,21 @@ public class MouseRotate extends MouseBehavior {
 	    y_factor *= -1;
 	}
     }
-    
+
     /**
      * Return the x-axis movement multipler.
      **/
     public double getXFactor() {
 	return x_factor;
     }
-  
+
     /**
      * Return the y-axis movement multipler.
      **/
     public double getYFactor() {
 	return y_factor;
     }
-  
+
 
     /**
      * Set the x-axis amd y-axis movement multipler with factor.
@@ -186,7 +186,7 @@ public class MouseRotate extends MouseBehavior {
      **/
     public void setFactor( double xFactor, double yFactor) {
 	x_factor = xFactor;
-	y_factor = yFactor;    
+	y_factor = yFactor;
     }
 
     public void processStimulus (Enumeration criteria) {
@@ -195,7 +195,7 @@ public class MouseRotate extends MouseBehavior {
  	MouseEvent evt;
 // 	int id;
 // 	int dx, dy;
-	
+
 	while (criteria.hasMoreElements()) {
 	    wakeup = (WakeupCriterion) criteria.nextElement();
 	    if (wakeup instanceof WakeupOnAWTEvent) {
@@ -236,27 +236,27 @@ public class MouseRotate extends MouseBehavior {
 	if (((buttonPress)&&((flags & MANUAL_WAKEUP) == 0)) ||
 	    ((wakeUp)&&((flags & MANUAL_WAKEUP) != 0))) {
 	    id = evt.getID();
-	    if ((id == MouseEvent.MOUSE_DRAGGED) && 
+	    if ((id == MouseEvent.MOUSE_DRAGGED) &&
 		!evt.isMetaDown() && ! evt.isAltDown()){
 		x = evt.getX();
 		y = evt.getY();
-		
+
 		dx = x - x_last;
 		dy = y - y_last;
-		
-		if (!reset){	    
+
+		if (!reset){
 		    x_angle = dy * y_factor;
 		    y_angle = dx * x_factor;
-		    
+
 		    transformX.rotX(x_angle);
 		    transformY.rotY(y_angle);
-		    
+
 		    transformGroup.getTransform(currXform);
-		    
+
 		    Matrix4d mat = new Matrix4d();
 		    // Remember old matrix
 		    currXform.get(mat);
-		    
+
 		    // Translate to origin
 		    currXform.setTranslation(new Vector3d(0.0,0.0,0.0));
 		    if (invert) {
@@ -266,17 +266,17 @@ public class MouseRotate extends MouseBehavior {
 			currXform.mul(transformX, currXform);
 			currXform.mul(transformY, currXform);
 		    }
-		    
+
 		    // Set old translation back
-		    Vector3d translation = new 
+		    Vector3d translation = new
 			Vector3d(mat.m03, mat.m13, mat.m23);
 		    currXform.setTranslation(translation);
-		    
+
 		    // Update xform
 		    transformGroup.setTransform(currXform);
-		    
+
 		    transformChanged( currXform );
-		    
+
 		    if (callback!=null)
 			callback.transformChanged( MouseBehaviorCallback.ROTATE,
 						   currXform );
@@ -284,7 +284,7 @@ public class MouseRotate extends MouseBehavior {
 		else {
 		    reset = false;
 		}
-		
+
 		x_last = x;
 		y_last = y;
 	    }
@@ -294,7 +294,7 @@ public class MouseRotate extends MouseBehavior {
 	    }
 	}
     }
-    
+
     /**
      * Users can overload this method  which is called every time
      * the Behavior updates the transform
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseTranslate.java b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseTranslate.java
index 27f88ba..7b79ea3 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseTranslate.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseTranslate.java
@@ -51,11 +51,11 @@ import javax.media.j3d.*;
 import javax.vecmath.*;
 
 /**
- * MouseTranslate is a Java3D behavior object that lets users control the 
+ * MouseTranslate is a Java3D behavior object that lets users control the
  * translation (X, Y) of an object via a mouse drag motion with the third
  * mouse button (alt-click on PC). See MouseRotate for similar usage info.
  */
- 
+
 public class MouseTranslate extends MouseBehavior {
 
     double x_factor = .02;
@@ -71,7 +71,7 @@ public class MouseTranslate extends MouseBehavior {
     public MouseTranslate(TransformGroup transformGroup) {
 	super(transformGroup);
     }
-   
+
     /**
      * Creates a default translate behavior.
      */
@@ -102,7 +102,7 @@ public class MouseTranslate extends MouseBehavior {
      */
     public MouseTranslate(Component c) {
 	super(c, 0);
-    } 
+    }
 
     /**
      * Creates a translate behavior that uses AWT listeners and behavior
@@ -144,35 +144,35 @@ public class MouseTranslate extends MouseBehavior {
 	    y_factor *= -1;
 	}
     }
-    
+
     /**
      * Return the x-axis movement multipler.
      **/
     public double getXFactor() {
 	return x_factor;
     }
-  
+
     /**
      * Return the y-axis movement multipler.
      **/
     public double getYFactor() {
 	return y_factor;
     }
-  
+
     /**
      * Set the x-axis amd y-axis movement multipler with factor.
      **/
     public void setFactor( double factor) {
 	x_factor = y_factor = factor;
     }
-  
+
     /**
      * Set the x-axis amd y-axis movement multipler with xFactor and yFactor
      * respectively.
      **/
     public void setFactor( double xFactor, double yFactor) {
 	x_factor = xFactor;
-	y_factor = yFactor;    
+	y_factor = yFactor;
     }
 
     public void processStimulus (Enumeration criteria) {
@@ -181,10 +181,10 @@ public class MouseTranslate extends MouseBehavior {
  	MouseEvent evt;
 // 	int id;
 // 	int dx, dy;
-    
+
 	while (criteria.hasMoreElements()) {
 	    wakeup = (WakeupCriterion) criteria.nextElement();
-      
+
 	    if (wakeup instanceof WakeupOnAWTEvent) {
 		events = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
 		if (events.length > 0) {
@@ -220,42 +220,42 @@ public class MouseTranslate extends MouseBehavior {
 	int dx, dy;
 
 	processMouseEvent(evt);
-	
+
 	if (((buttonPress)&&((flags & MANUAL_WAKEUP) == 0)) ||
 	    ((wakeUp)&&((flags & MANUAL_WAKEUP) != 0))){
 	    id = evt.getID();
 	    if ((id == MouseEvent.MOUSE_DRAGGED) &&
 		!evt.isAltDown() && evt.isMetaDown()) {
-		
+
 		x = evt.getX();
 		y = evt.getY();
-		
+
 		dx = x - x_last;
 		dy = y - y_last;
-		
+
 		if ((!reset) && ((Math.abs(dy) < 50) && (Math.abs(dx) < 50))) {
 		    //System.out.println("dx " + dx + " dy " + dy);
 		    transformGroup.getTransform(currXform);
-		    
-		    translation.x = dx*x_factor; 
+
+		    translation.x = dx*x_factor;
 		    translation.y = -dy*y_factor;
-		    
+
 		    transformX.set(translation);
-		    
+
 		    if (invert) {
 			currXform.mul(currXform, transformX);
 		    } else {
 			currXform.mul(transformX, currXform);
 		    }
-		    
+
 		    transformGroup.setTransform(currXform);
-		    
+
 		    transformChanged( currXform );
-		    
+
 		    if (callback!=null)
 			callback.transformChanged( MouseBehaviorCallback.TRANSLATE,
 						   currXform );
-		    
+
 		}
 		else {
 		    reset = false;
@@ -269,7 +269,7 @@ public class MouseTranslate extends MouseBehavior {
 	    }
 	}
     }
-    
+
     /**
      * Users can overload this method  which is called every time
      * the Behavior updates the transform
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseWheelZoom.java b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseWheelZoom.java
index 01a1830..0c071fc 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseWheelZoom.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseWheelZoom.java
@@ -58,12 +58,12 @@ import javax.vecmath.*;
  */
 
 public class MouseWheelZoom extends MouseBehavior {
-	
+
 	double z_factor = .1;
 	Vector3d translation = new Vector3d();
-	
+
 	private MouseBehaviorCallback callback = null;
-	
+
 	/**
 	 * Creates a zoom behavior given the transform group.
 	 * @param transformGroup The transformGroup to operate on.
@@ -71,14 +71,14 @@ public class MouseWheelZoom extends MouseBehavior {
 	public MouseWheelZoom(TransformGroup transformGroup) {
 		super(transformGroup);
 	}
-	
+
 	/**
 	 * Creates a default mouse zoom behavior.
 	 **/
 	public MouseWheelZoom() {
 		super(0);
 	}
-	
+
 	/**
 	 * Creates a zoom behavior.
 	 * Note that this behavior still needs a transform
@@ -89,7 +89,7 @@ public class MouseWheelZoom extends MouseBehavior {
 	public MouseWheelZoom(int flags) {
 		super(flags);
 	}
-	
+
 	/**
 	 * Creates a zoom behavior that uses AWT listeners and behavior
 	 * posts rather than WakeupOnAWTEvent.  The behavior is added to the
@@ -103,7 +103,7 @@ public class MouseWheelZoom extends MouseBehavior {
 	public MouseWheelZoom(Component c) {
 		super(c, 0);
 	}
-	
+
 	/**
 	 * Creates a zoom behavior that uses AWT listeners and behavior
 	 * posts rather than WakeupOnAWTEvent.  The behaviors is added to
@@ -118,7 +118,7 @@ public class MouseWheelZoom extends MouseBehavior {
 	public MouseWheelZoom(Component c, TransformGroup transformGroup) {
 		super(c, transformGroup);
 	}
-	
+
 	/**
 	 * Creates a zoom behavior that uses AWT listeners and behavior
 	 * posts rather than WakeupOnAWTEvent.  The behavior is added to the
@@ -134,7 +134,7 @@ public class MouseWheelZoom extends MouseBehavior {
 	public MouseWheelZoom(Component c, int flags) {
 		super(c, flags);
 	}
-	
+
 	public void initialize() {
 	    super.initialize();
 	    if ((flags & INVERT_INPUT) == INVERT_INPUT) {
@@ -142,22 +142,22 @@ public class MouseWheelZoom extends MouseBehavior {
 		invert = true;
 	    }
 	}
-	
+
     /**
      * Return the y-axis movement multipler.
      **/
     public double getFactor() {
 	return z_factor;
     }
-	
+
     /**
      * Set the wheel units movement multipler with factor.
      **/
     public void setFactor( double factor) {
 	z_factor = factor;
     }
-	
-	
+
+
     public void processStimulus(Enumeration criteria) {
 	WakeupCriterion wakeup;
 	AWTEvent[] events;
@@ -172,7 +172,7 @@ public class MouseWheelZoom extends MouseBehavior {
 		    doProcess(evt);
 		}
 	    }
-	    
+
 	    else if (wakeup instanceof WakeupOnBehaviorPost) {
 		while (true) {
 		    synchronized (mouseq) {
@@ -189,51 +189,51 @@ public class MouseWheelZoom extends MouseBehavior {
 		    doProcess(evt);
 		}
 	    }
-	    
+
 	}
 	wakeupOn(mouseCriterion);
     }
-	
+
     void doProcess(MouseEvent evt) {
 	int units = 0;
-		
+
 	processMouseEvent(evt);
-		
+
 	if ((evt.getID() == MouseEvent.MOUSE_WHEEL)) {
 	    MouseWheelEvent wheelEvent = (MouseWheelEvent)evt;
 	    if (wheelEvent.getScrollType() == wheelEvent.WHEEL_UNIT_SCROLL ) {
 		units = wheelEvent.getUnitsToScroll();
 	    }
-			
+
 	    if (!reset) {
 		transformGroup.getTransform(currXform);
-		
+
 		translation.z  = units*z_factor;
-		
+
 		transformX.set(translation);
-				
+
 		if (invert) {
 		    currXform.mul(currXform, transformX);
 		} else {
 		    currXform.mul(transformX, currXform);
 		}
-				
+
 		transformGroup.setTransform(currXform);
-		
+
 		transformChanged( currXform );
-		
+
 		if (callback!=null)
 		    callback.transformChanged( MouseBehaviorCallback.ZOOM,
 					       currXform );
-				
+
 	    }
 	    else {
 		reset = false;
-	    }		
+	    }
 	}
     }
-	
-	
+
+
     /**
      * Users can overload this method  which is called every time
      * the Behavior updates the transform
@@ -242,7 +242,7 @@ public class MouseWheelZoom extends MouseBehavior {
      */
     public void transformChanged( Transform3D transform ) {
     }
-	
+
     /**
      * The transformChanged method in the callback class will
      * be called every time the transform is updated
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseZoom.java b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseZoom.java
index 436bfec..a5f86c9 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseZoom.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/mouse/MouseZoom.java
@@ -52,16 +52,16 @@ import javax.vecmath.*;
 
 
 /**
- * MouseZoom is a Java3D behavior object that lets users control the 
+ * MouseZoom is a Java3D behavior object that lets users control the
  * Z axis translation of an object via a mouse drag motion with the second
  * mouse button. See MouseRotate for similar usage info.
  */
- 
+
 public class MouseZoom extends MouseBehavior {
 
     double z_factor = .04;
     Vector3d translation = new Vector3d();
-  
+
     private MouseBehaviorCallback callback = null;
 
     /**
@@ -142,21 +142,21 @@ public class MouseZoom extends MouseBehavior {
 	    invert = true;
 	}
     }
-    
+
     /**
      * Return the y-axis movement multipler.
      **/
     public double getFactor() {
 	return z_factor;
     }
-  
+
     /**
      * Set the y-axis movement multipler with factor.
      **/
     public void setFactor( double factor) {
 	z_factor = factor;
     }
-  
+
 
     public void processStimulus (Enumeration criteria) {
 	WakeupCriterion wakeup;
@@ -164,7 +164,7 @@ public class MouseZoom extends MouseBehavior {
  	MouseEvent evt;
 // 	int id;
 // 	int dx, dy;
-    
+
 	while (criteria.hasMoreElements()) {
 	    wakeup = (WakeupCriterion) criteria.nextElement();
 	    if (wakeup instanceof WakeupOnAWTEvent) {
@@ -191,7 +191,7 @@ public class MouseZoom extends MouseBehavior {
 		    doProcess(evt);
 		}
 	    }
-	    
+
 	}
 	wakeupOn (mouseCriterion);
     }
@@ -201,45 +201,45 @@ public class MouseZoom extends MouseBehavior {
 	int dx, dy;
 
 	processMouseEvent(evt);
-	
+
 	if (((buttonPress)&&((flags & MANUAL_WAKEUP) == 0)) ||
 	    ((wakeUp)&&((flags & MANUAL_WAKEUP) != 0))){
 	    id = evt.getID();
 	    if ((id == MouseEvent.MOUSE_DRAGGED) &&
 		evt.isAltDown() && !evt.isMetaDown()){
-		
+
 		x = evt.getX();
 		y = evt.getY();
-		
+
 		dx = x - x_last;
 		dy = y - y_last;
-		
+
 		if (!reset){
 		    transformGroup.getTransform(currXform);
-		    
+
 		    translation.z  = dy*z_factor;
-		    
+
 		    transformX.set(translation);
-		    
+
 		    if (invert) {
 			currXform.mul(currXform, transformX);
 		    } else {
 			currXform.mul(transformX, currXform);
 		    }
-		    
+
 		    transformGroup.setTransform(currXform);
-		    
+
 		    transformChanged( currXform );
-		    
+
 		    if (callback!=null)
 			callback.transformChanged( MouseBehaviorCallback.ZOOM,
 						   currXform );
-		    
+
 		}
 		else {
 		    reset = false;
 		}
-		
+
 		x_last = x;
 		y_last = y;
 	    }
@@ -250,7 +250,7 @@ public class MouseZoom extends MouseBehavior {
 	}
     }
 
-    
+
   /**
     * Users can overload this method  which is called every time
     * the Behavior updates the transform
@@ -259,7 +259,7 @@ public class MouseZoom extends MouseBehavior {
     */
   public void transformChanged( Transform3D transform ) {
   }
- 
+
   /**
     * The transformChanged method in the callback class will
     * be called every time the transform is updated
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/picking/Intersect.java b/src/classes/share/com/sun/j3d/utils/behaviors/picking/Intersect.java
index 2fde464..684f97b 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/picking/Intersect.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/picking/Intersect.java
@@ -52,7 +52,7 @@ import com.sun.j3d.internal.J3dUtilsI18N;
 /*
  * Contains static methods to aid in the intersection test between
  * various PickShape classes and geometry primitives (such as quad,
- * triangle, line and point). 
+ * triangle, line and point).
  */
 
 
@@ -63,7 +63,7 @@ import com.sun.j3d.internal.J3dUtilsI18N;
 
 public class Intersect
 {
-  
+
   /**
    * Determines if the PickRay and quadrilateral
    * objects intersect.
@@ -74,25 +74,25 @@ public class Intersect
    * @param coordinates An array holding the quadrilateral data.
    * @param index An array index that designates the starting position
    *  in the array of the quadrilateral to test.
-   * @param dist On return dist[0] will be set to the distance between ray's 
-   * origin and the point of intersection, if it exists.  
+   * @param dist On return dist[0] will be set to the distance between ray's
+   * origin and the point of intersection, if it exists.
    * The dist array should be allocated by the user.
    * @return true if the ray intersects the quad,
    *  false if the ray does not intersect the object.
-   */ 
-  public static boolean rayAndQuad( PickRay ray, Point3d coordinates[], 
+   */
+  public static boolean rayAndQuad( PickRay ray, Point3d coordinates[],
 				    int index, double dist[] ) {
-    
-    if((coordinates.length - index) < 4) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect0"));   
+
+    if((coordinates.length - index) < 4)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect0"));
 
     Point3d pnts[] = new Point3d[4];
-    
+
     for(int i=0; i<4; i++)
       pnts[i] = coordinates[index+i];
-   
+
     return rayAndPoly(pnts, ray, dist);
-    
+
   }
 
   /**
@@ -113,17 +113,17 @@ public class Intersect
    */
   public static boolean rayAndTriangle( PickRay ray, Point3d coordinates[],
 					int index, double dist[] ) {
-    
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect1"));   
+
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect1"));
 
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = coordinates[index+i];
-    
+
     return rayAndPoly(pnts, ray, dist);
-    
+
   }
 
   /**
@@ -137,24 +137,24 @@ public class Intersect
    * @param dist On return dist[0] will be set to the distance between ray's origin and the point intersection, if
    * exist.
    * @return true if ray intersects triangle, else return false.
-   */ 
-  
+   */
+
   public static boolean rayAndTriangle( PickRay ray, Point3f coordinates[],
 					int index, double dist[] ) {
-    
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect1"));   
+
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect1"));
 
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = new Point3d(coordinates[index+i]);
-    
+
     return rayAndPoly(pnts, ray, dist);
-    
+
   }
-  
-  
+
+
   /**
    * Caluates the intersection between a PickSegment
    * object and a quadrilateral.
@@ -173,16 +173,16 @@ public class Intersect
   public static boolean segmentAndQuad( PickSegment segment,
                                         Point3d coordinates[],
 					int index, double dist[] ) {
-    if((coordinates.length - index) < 4) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect3"));   
+    if((coordinates.length - index) < 4)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect3"));
 
     Point3d pnts[] = new Point3d[4];
 
     for(int i=0; i<4; i++)
       pnts[i] = coordinates[index+i];
-    
+
     return segmentAndPoly(pnts, segment, dist);
-    
+
   }
 
   /**
@@ -193,25 +193,25 @@ public class Intersect
    * @param segment The segment that is used in intersection test.
    * @param coordinates an array of vertices.
    * @param index the vertex index
-   * @param dist On return dist[0] will be set to the distance between segment's start and the point 
+   * @param dist On return dist[0] will be set to the distance between segment's start and the point
    * intersection, if exist.
    * @return true if segment intersects quad, else return false.
-   */ 
-  
+   */
+
   public static boolean segmentAndQuad( PickSegment segment, Point3f coordinates[],
 					int index, double dist[] ) {
-    if((coordinates.length - index) < 4) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect3"));   
+    if((coordinates.length - index) < 4)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect3"));
 
     Point3d pnts[] = new Point3d[4];
-    
+
     for(int i=0; i<4; i++)
       pnts[i] = new Point3d(coordinates[index+i]);
-    
+
     return segmentAndPoly(pnts, segment, dist);
-    
+
   }
-  
+
   /**
    * Caluates the intersection between a PickSegment
    * object and a triangle.
@@ -227,20 +227,20 @@ public class Intersect
    * @return true if the segment intersects the triangle,
    *  false if the segment does not intersect the object.
    */
-  public static boolean segmentAndTriangle( PickSegment segment, 
+  public static boolean segmentAndTriangle( PickSegment segment,
                                             Point3d coordinates[],
-                                            int index,  
+                                            int index,
 					    double dist[] ) {
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect5"));   
- 
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect5"));
+
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = coordinates[index+i];
-    
+
     return segmentAndPoly(pnts, segment, dist);
-    
+
   }
 
   /**
@@ -251,26 +251,26 @@ public class Intersect
    * @param segment The segment that is used in intersection test.
    * @param coordinates an array of vertices.
    * @param index the vertex index
-   * @param dist On return dist[0] will be set to the distance between segment's start and the point 
+   * @param dist On return dist[0] will be set to the distance between segment's start and the point
    * intersection, if exist.
    * @return true if segment intersects triangle, else return false.
-   */ 
-  
-  public static boolean segmentAndTriangle( PickSegment segment, 
-					    Point3f coordinates[], int index,  
+   */
+
+  public static boolean segmentAndTriangle( PickSegment segment,
+					    Point3f coordinates[], int index,
 					    double dist[] ) {
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect6"));   
- 
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect6"));
+
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = new Point3d(coordinates[index+i]);
-    
+
     return segmentAndPoly(pnts, segment, dist);
-    
+
   }
- 
+
   /**
    * Caluates the intersection between a PickPoint
    * object and a quadrilateral.
@@ -288,14 +288,14 @@ public class Intersect
                                        Point3d coordinates[],
 				       int index) {
 
-    if((coordinates.length - index) < 4) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect7"));   
-    
+    if((coordinates.length - index) < 4)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect7"));
+
     Point3d pnts[] = new Point3d[4];
-    
+
     for(int i=0; i<4; i++)
       pnts[i] = coordinates[index+i];
-    
+
     return pointAndPoly( pnts, point);
 
   }
@@ -308,21 +308,21 @@ public class Intersect
    * @param coordinates an array of vertices.
    * @param index the vertex index
    * @return true if point intersects quad, else return false.
-   */ 
+   */
 
   private static boolean pointAndQuad( PickPoint point, Point3f coordinates[],
 				       int index) {
 
-    if((coordinates.length - index) < 4) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect7"));   
-    
+    if((coordinates.length - index) < 4)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect7"));
+
     Point3d pnts[] = new Point3d[4];
-    
+
     for(int i=0; i<4; i++)
       pnts[i] = new Point3d(coordinates[index+i]);
-    
+
     return pointAndPoly( pnts, point);
-    
+
   }
 
   /**
@@ -342,16 +342,16 @@ public class Intersect
                                            Point3d coordinates[],
 					   int index) {
 
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect9"));   
-    
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect9"));
+
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = coordinates[index+i];
-    
+
     return pointAndPoly( pnts, point);
-    
+
   }
 
   /**
@@ -362,21 +362,21 @@ public class Intersect
    * @param coordinates an array of vertices.
    * @param index the vertex index
    * @return true if point intersects triangle, else return false.
-   */ 
+   */
 
   private static boolean pointAndTriangle( PickPoint point, Point3f coordinates[],
 					   int index) {
 
-    if((coordinates.length - index) < 3) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect10"));   
-    
+    if((coordinates.length - index) < 3)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect10"));
+
     Point3d pnts[] = new Point3d[3];
-    
+
     for(int i=0; i<3; i++)
       pnts[i] = new Point3d(coordinates[index+i]);
-    
+
     return pointAndPoly( pnts, point);
-    
+
   }
 
   /**
@@ -385,20 +385,20 @@ public class Intersect
    *
    * @param ray The ray that is used in the intersection test.
    * @param pnt The point that is used in intersection test.
-   * @param dist On return dist[0] will be set to the distance between ray's origin and the point 
+   * @param dist On return dist[0] will be set to the distance between ray's origin and the point
    * of intersection, if it exists. The dist array
    * should be allocated by the user.
    * @return true if the ray intersects the point,
    *  false if the ray does not intersect the object.
-   */ 
+   */
   public static boolean rayAndPoint( PickRay ray, Point3d pnt,
                                                   double dist[] ) {
-    
+
     Point3d origin = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     ray.get(origin, direction);
-    
+
     return rayAndPoint(pnt, origin, direction, dist);
   }
 
@@ -408,24 +408,24 @@ public class Intersect
    *
    * @param ray The ray that is used in intersection test.
    * @param pnt The point that is used in intersection test.
-   * @param dist On return dist[0] contains the distance between ray's origin and the point 
+   * @param dist On return dist[0] contains the distance between ray's origin and the point
    * intersection, if exist.
    * @return true if ray intersects point, else return false.
-   */ 
-  
+   */
+
   public static boolean rayAndPoint( PickRay ray, Point3f pnt, double dist[] ) {
-    
+
     Point3d origin = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     ray.get(origin, direction);
-  
+
     return rayAndPoint(new Point3d(pnt), origin, direction, dist);
   }
-  
+
   /**
    * Determines if the PickSegment and Point3d
-   * objects intersect.  
+   * objects intersect.
    *
    * @param segment The segment that is used in the intersection test.
    * @param pnt The point that is used in intersection test.
@@ -434,14 +434,14 @@ public class Intersect
    * should be allocated by the user.
    * @return true if the segment intersects the point,
    *  false if the segment does not intersect the object.
-   */ 
-  public static boolean segmentAndPoint( PickSegment segment, Point3d pnt, 
+   */
+  public static boolean segmentAndPoint( PickSegment segment, Point3d pnt,
 					 double dist[] ) {
-    
+
     Point3d start = new Point3d();
     Point3d end = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     segment.get(start, end);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
@@ -449,7 +449,7 @@ public class Intersect
 
     if((rayAndPoint(pnt, start, direction, dist)==true) && (dist[0] <= 1.0))
       return true;
-    
+
     return false;
   }
 
@@ -459,49 +459,49 @@ public class Intersect
    *
    * @param segment The segment that is used in intersection test.
    * @param pnt The point that is used in intersection test.
-   * @param dist On return dist[0] contains the distance between segment's start and the point 
+   * @param dist On return dist[0] contains the distance between segment's start and the point
    * intersection, if exist.
    * @return true if segment intersects point, else return false.
-   */ 
+   */
 
-  public static boolean segmentAndPoint( PickSegment segment, Point3f pnt, 
+  public static boolean segmentAndPoint( PickSegment segment, Point3f pnt,
 					 double dist[] ) {
-    
+
     Point3d start = new Point3d();
     Point3d end = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     segment.get(start, end);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
     direction.z = end.z - start.z;
 
-    if((rayAndPoint(new Point3d(pnt), start, direction, dist)==true) 
+    if((rayAndPoint(new Point3d(pnt), start, direction, dist)==true)
        && (dist[0] <= 1.0))
       return true;
-    
+
     return false;
   }
 
   /**
    * Determines if the PickPoint and Point3d
-   * objects intersect.  
+   * objects intersect.
    *
    * @param point The PickPoint that is used in the intersection test.
    * @param pnt The Point3d that is used in intersection test.
    * @return true if the PickPoint and Point3d objects
    *  intersect, false if the do not intersect.
-   */ 
+   */
   public static boolean pointAndPoint( PickPoint point, Point3d pnt) {
-    
+
     Point3d location = new Point3d();
-    
+
     point.get(location);
 
     if ((location.x == pnt.x) && (location.y == pnt.y) &&
        (location.z == pnt.z))
       return true;
-     
+
     return false;
   }
 
@@ -511,24 +511,24 @@ public class Intersect
    * @param point The point that is used in intersection test.
    * @param pnt The point that is used in intersection test.
    * @return true if point intersects pnt, else return false.
-   */ 
-  
+   */
+
   public static boolean pointAndPoint( PickPoint point, Point3f pnt) {
-    
+
     Point3d location = new Point3d();
-    
+
     point.get(location);
-    
-    if(((float) location.x == pnt.x) && ((float) location.y == pnt.y) 
+
+    if(((float) location.x == pnt.x) && ((float) location.y == pnt.y)
        && ((float) location.z == pnt.z))
       return true;
-    
+
     return false;
   }
-  
+
   /**
    * Determines if the PickRay and Line
-   * objects intersect.  
+   * objects intersect.
    * The line is defined as coordinates[index] to
    * coordinates[index+1].
    *
@@ -539,22 +539,22 @@ public class Intersect
    * should be allocated by the user.
    * @return true if the ray intersects the line,
    *  false if the ray does not intersect the object.
-   */ 
+   */
   public static boolean rayAndLine(PickRay ray, Point3d coordinates[],
-                                   int index,  
+                                   int index,
 				   double dist[] ) {
     Point3d origin = new Point3d();
     Vector3d direction = new Vector3d();
 
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect11"));   
-    
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect11"));
+
     ray.get(origin, direction);
     Point3d start = coordinates[index++];
     Point3d end = coordinates[index];
-    
+
     return lineAndRay( start, end, origin, direction, dist );
-    
+
   }
 
   /**
@@ -568,24 +568,24 @@ public class Intersect
    * @param dist On return dist[0] contains the distance between ray's origin and the point intersection, if
    * exist.
    * @return true if ray intersects line, else return false.
-   */ 
+   */
 
-  public static boolean rayAndLine(PickRay ray, Point3f coordinates[], int index,  
+  public static boolean rayAndLine(PickRay ray, Point3f coordinates[], int index,
 				   double dist[] ) {
     Point3d origin = new Point3d();
     Vector3d direction = new Vector3d();
 
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect11"));   
-    
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect11"));
+
     ray.get(origin, direction);
     Point3d start = new Point3d(coordinates[index++]);
     Point3d end = new Point3d(coordinates[index]);
-    
+
     return lineAndRay( start, end, origin, direction, dist );
-    
+
   }
-  
+
   /**
    * Determines if the PickSegment and Line
    * objects intersect.
@@ -599,7 +599,7 @@ public class Intersect
    * should be allocated by the user.
    * @return true if the segment intersects the line,
    *  false if the segment does not intersect the object.
-   */ 
+   */
   public static boolean segmentAndLine(PickSegment segment,
                                        Point3d coordinates[],
 				       int index, double dist[] ) {
@@ -607,22 +607,22 @@ public class Intersect
     Point3d start = new Point3d();
     Point3d end = new Point3d();
     Vector3d direction = new Vector3d();
-        
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));   
-    
+
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));
+
     segment.get(start, end);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
     direction.z = end.z - start.z;
-    
+
     Point3d startpnt = coordinates[index++];
     Point3d endpnt = coordinates[index];
-    
+
     if(lineAndRay(startpnt, endpnt, start, direction, dist)==true)
       if(dist[0] <= 1.0)
 	return true;
-    
+
     return false;
   }
 
@@ -634,10 +634,10 @@ public class Intersect
    * @param segment The segment that is used in intersection test.
    * @param coordinates an array of vertices.
    * @param index the vertex index
-   * @param dist On return dist[0] contains the distance between segment's start and the point 
+   * @param dist On return dist[0] contains the distance between segment's start and the point
    * intersection, if exist.
    * @return true if segment intersects line, else return false.
-   */ 
+   */
 
   public static boolean segmentAndLine(PickSegment segment, Point3f coordinates[],
 				       int index, double dist[] ) {
@@ -645,25 +645,25 @@ public class Intersect
     Point3d start = new Point3d();
     Point3d end = new Point3d();
     Vector3d direction = new Vector3d();
-        
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));   
-    
+
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));
+
     segment.get(start, end);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
     direction.z = end.z - start.z;
-    
+
     Point3d startpnt = new Point3d(coordinates[index++]);
     Point3d endpnt = new Point3d(coordinates[index]);
-    
+
     if(lineAndRay(startpnt, endpnt, start, direction, dist)==true)
       if(dist[0] <= 1.0)
 	return true;
-    
+
     return false;
   }
-  
+
   /**
    * Determines if the PickPoint and Line
    * objects intersect.
@@ -674,19 +674,19 @@ public class Intersect
    * @param coordinates An array holding the line data.
    * @return true if the the point intersects the line,
    *  false if the the point does not intersect the object.
-   */ 
+   */
   public static boolean pointAndLine(PickPoint point, Point3d coordinates[],
 				     int index ) {
 
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));   
-    
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));
+
     double dist[] = new double[1];
     Point3d start = coordinates[index++];
     Point3d end = coordinates[index];
     Point3d location = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     point.get(location);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
@@ -695,9 +695,9 @@ public class Intersect
     if ((rayAndPoint(location, start, direction, dist)==true) &&
         (dist[0] <= 1.0))
       return true;
-    
+
     return false;
-    
+
   }
 
   /**
@@ -708,47 +708,47 @@ public class Intersect
    * @param coordinates an array of vertices.
    * @param index the vertex index
    * @return true if point intersects line, else return false.
-   */ 
-  
+   */
+
   public static boolean pointAndLine(PickPoint point, Point3f coordinates[],
 				     int index ) {
 
-    if((coordinates.length - index) < 2) 
-      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));   
-    
+    if((coordinates.length - index) < 2)
+      throw new RuntimeException(J3dUtilsI18N.getString("Intersect13"));
+
     double dist[] = new double[1];
     Point3d start = new Point3d(coordinates[index++]);
     Point3d end = new Point3d(coordinates[index]);
     Point3d location = new Point3d();
     Vector3d direction = new Vector3d();
-    
+
     point.get(location);
     direction.x = end.x - start.x;
     direction.y = end.y - start.y;
     direction.z = end.z - start.z;
-    
+
     if((rayAndPoint(location, start, direction, dist)==true) && (dist[0] <= 1.0))
       return true;
-    
+
     return false;
-    
+
   }
 
   /**
    *  Return true if point is on the inside of halfspace test. The
-   *  halfspace is 
+   *  halfspace is
    * partition by the plane of triangle or quad.
    * */
-     
+
   private static boolean pointAndPoly( Point3d coordinates[], PickPoint point) {
-    
+
     Vector3d vec0 = new Vector3d(); // Edge vector from point 0 to point 1;
     Vector3d vec1 = new Vector3d(); // Edge vector from point 0 to point 2 or 3;
     Vector3d pNrm = new Vector3d();
     double  absNrmX, absNrmY, absNrmZ, pD = 0.0;
     Vector3d tempV3d = new Vector3d();
-    double pNrmDotrDir = 0.0; 
-    
+    double pNrmDotrDir = 0.0;
+
     double tempD;
 
     int i, j;
@@ -761,7 +761,7 @@ public class Intersect
       if(vec0.length() > 0.0)
 	break;
     }
-        
+
     for(j=i; j 0.0)
 	break;
     }
-    
+
     if(j == (coordinates.length-1)) {
       // System.out.println("(1) Degenerated polygon.");
       return false;  // Degenerated polygon.
     }
 
-    /* 
+    /*
        System.out.println("Ray orgin : " + ray.origin + " dir " + ray.direction);
        System.out.println("Triangle/Quad :");
-       for(i=0; i1.0)) // Before or after the end points of line.
@@ -847,7 +847,7 @@ public class Intersect
 
     tmp1 = ori.z + s * dir.z;
     tmp2 = start.z + t * lDir.z;
-  
+
     if((tmp1 < (tmp2 - Double.MIN_VALUE)) || (tmp1 > (tmp2 + Double.MIN_VALUE)))
       return false;
 
@@ -859,7 +859,7 @@ public class Intersect
 				     Vector3d dir, double dist[] ) {
     int flag = 0;
     double temp;
-    
+
     if(dir.x != 0.0) {
       flag = 0;
       dist[0] = (pnt.x - ori.x)/dir.x;
@@ -875,7 +875,7 @@ public class Intersect
 	return false;
       flag = 2;
       dist[0] = (pnt.z - ori.z)/dir.z;
-           
+
     }
     else
       return false;
@@ -886,9 +886,9 @@ public class Intersect
     if(flag == 0) {
       temp = ori.y + dist[0] * dir.y;
       if((pnt.y < (temp - Double.MIN_VALUE)) || (pnt.y > (temp + Double.MIN_VALUE)))
-	return false;    
+	return false;
     }
-    
+
     if(flag < 2) {
       temp = ori.z + dist[0] * dir.z;
       if((pnt.z < (temp - Double.MIN_VALUE)) || (pnt.z > (temp + Double.MIN_VALUE)))
@@ -896,24 +896,24 @@ public class Intersect
     }
 
     return true;
-    
+
   }
 
-  private static boolean rayAndPoly( Point3d coordinates[], 
+  private static boolean rayAndPoly( Point3d coordinates[],
 				     PickRay ray, double dist[] ) {
-    
+
     Vector3d vec0 = new Vector3d(); // Edge vector from point 0 to point 1;
     Vector3d vec1 = new Vector3d(); // Edge vector from point 0 to point 2 or 3;
     Vector3d pNrm = new Vector3d();
     double  absNrmX, absNrmY, absNrmZ, pD = 0.0;
     Vector3d tempV3d = new Vector3d();
-    double pNrmDotrDir = 0.0; 
+    double pNrmDotrDir = 0.0;
     int axis, nc, sh, nsh;
     Point3d origin = new Point3d();
     Vector3d direction = new Vector3d();
 
     Point3d iPnt = new Point3d(); // Point of intersection.
-    
+
     double uCoor[] = new double[4]; // Only need to support up to quad.
     double vCoor[] = new double[4];
     double tempD;
@@ -928,7 +928,7 @@ public class Intersect
       if(vec0.length() > 0.0)
 	break;
     }
-        
+
     for(j=i; j 0.0)
 	break;
     }
-    
+
     if(j == (coordinates.length-1)) {
       // System.out.println("(1) Degenerated polygon.");
       return false;  // Degenerated polygon.
     }
 
-    /* 
+    /*
        System.out.println("Triangle/Quad :");
-       for(i=0; i absNrmY)
       axis = 0;
-    else 
+    else
       axis = 1;
 
     if(axis == 0) {
       if(absNrmX < absNrmZ)
 	axis = 2;
-    }    
+    }
     else if(axis == 1) {
       if(absNrmY < absNrmZ)
 	axis = 2;
-    }    
-    
+    }
+
     // System.out.println("Normal " + pNrm + " axis " + axis );
-    
+
     for(i=0; i 0)
 	    // This line cross U+.
-	    nc++;	  
-	}	
+	    nc++;
+	}
 	sh = nsh;
       } // sh != nsh
     }
 
     // System.out.println("nc " + nc);
-   
+
     if((nc%2) == 1) {
-      
+
 	// calculate the distance
 	dist[0] *= direction.length();
 
-	// System.out.println("Ray Intersected!");	
-	/* 
+	// System.out.println("Ray Intersected!");
+	/*
 	   System.out.println("Ray orgin : " + origin + " dir " + direction);
 	   System.out.println("Triangle/Quad :");
-	   for(i=0; i 0.0)
 	break;
     }
-        
+
     for(j=i; j 0.0)
 	break;
     }
-    
+
     if(j == (coordinates.length-1)) {
       // System.out.println("(1) Degenerated polygon.");
       return false;  // Degenerated polygon.
     }
-    
-    /* 
+
+    /*
        System.out.println("Triangle/Quad :");
-       for(i=0; i absNrmY)
       axis = 0;
-    else 
+    else
       axis = 1;
 
     if(axis == 0) {
       if(absNrmX < absNrmZ)
 	axis = 2;
-    }    
+    }
     else if(axis == 1) {
       if(absNrmY < absNrmZ)
 	axis = 2;
-    }    
-    
+    }
+
     // System.out.println("Normal " + pNrm + " axis " + axis );
-    
+
     for(i=0; i 0)
 	    // This line cross U+.
-	    nc++;	  
-	}	
+	    nc++;
+	}
 	sh = nsh;
       } // sh != nsh
     }
 
     // System.out.println("nc " + nc);
-   
+
     if((nc%2) == 1) {
-      
+
 	// calculate the distance
 	dist[0] *= direction.length();
-	
-	// System.out.println("Segment Intersected!");	
-	/* 
+
+	// System.out.println("Segment Intersected!");
+	/*
 	   System.out.println("Segment orgin : " + start + " dir " + direction);
 	   System.out.println("Triangle/Quad :");
-	   for(i=0; iShape3D node from 
-   * a given SceneGraphPath. 
+   * Shape3D node from
+   * a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int SHAPE3D = 0x1;
 
   /**
    * A flag to indicate to the pickNode method to return a
-   * Morph node from 
-   * a given SceneGraphPath. 
+   * Morph node from
+   * a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int MORPH = 0x2;
 
   /**
    * A flag to indicate to the pickNode method to return a
-   * Primitive node 
-   * from a given SceneGraphPath. 
+   * Primitive node
+   * from a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int PRIMITIVE = 0x4;
 
   /**
    * A flag to indicate to the pickNode method to return a
-   * Link node from 
-   * a given SceneGraphPath. 
+   * Link node from
+   * a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int LINK = 0x8;
 
   /**
    * A flag to indicate to the pickNode method to return a
-   * Group node from 
-   * a given SceneGraphPath. 
+   * Group node from
+   * a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int GROUP = 0x10;
-  
+
   /**
    * A flag to indicate to the pickNode method to return a
-   * TransformGroup 
-   * node from a given SceneGraphPath. 
+   * TransformGroup
+   * node from a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int TRANSFORM_GROUP = 0x20;
- 
+
   /**
    * A flag to indicate to the pickNode method to return a
-   * BranchGroup 
-   * node from a given SceneGraphPath. 
+   * BranchGroup
+   * node from a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int BRANCH_GROUP = 0x40;
 
   /**
    * A flag to indicate to the pickNode method to return a
-   * Switch node from 
-   * a given SceneGraphPath. 
+   * Switch node from
+   * a given SceneGraphPath.
    *
-   * @see PickObject#pickNode 
+   * @see PickObject#pickNode
    */
   public static final int SWITCH = 0x80;
 
@@ -191,14 +191,14 @@ public class PickObject extends Object {
    * Set this flag if you want to pick by bounds.
    */
   public static final int USE_BOUNDS = 0x200;
-  
+
   BranchGroup pickRoot;
   Canvas3D canvas;
   Point3d origin = new Point3d();
   Vector3d direction = new Vector3d();
   PickRay pickRay = new PickRay();
-  SceneGraphPath sceneGraphPath = null;  
-  SceneGraphPath sceneGraphPathArr[] = null;  
+  SceneGraphPath sceneGraphPath = null;
+  SceneGraphPath sceneGraphPathArr[] = null;
   int pickBy;    // To pick by Bounds or Geometry.
 
   static final boolean debug = false;
@@ -211,11 +211,11 @@ public class PickObject extends Object {
    *
    * @see BranchGroup
    * @see Canvas3D
-   */ 
+   */
   public PickObject(Canvas3D c, BranchGroup root)
     {
       pickRoot = root;
-      canvas = c;      
+      canvas = c;
     }
 
   /**
@@ -225,15 +225,15 @@ public class PickObject extends Object {
    * @param xpos The value along the x-axis.
    * @param ypos The value along the y-axis.
    * @return A PickShape object that is the constructed PickRay.
-   */ 
+   */
   public PickShape generatePickRay(int xpos, int ypos)
     {
-            
+
       Transform3D motion=new Transform3D();
       Point3d eyePosn = new Point3d();
       Point3d mousePosn = new Point3d();
       Vector3d mouseVec=new Vector3d();
-      
+
       canvas.getCenterEyeInImagePlate(eyePosn);
       canvas.getPixelLocationInImagePlate(xpos,ypos,mousePosn);
       if (canvas.getView().getProjectionPolicy() ==
@@ -251,28 +251,28 @@ public class PickObject extends Object {
 	System.out.println("mouse position " + xpos + " " + ypos);
 	System.out.println("before, mouse " + mousePosn + " eye " + eyePosn);
       }
-      
+
       motion.transform(eyePosn);
       motion.transform(mousePosn);
       mouseVec.sub(mousePosn, eyePosn);
       mouseVec.normalize();
-      
+
       if (debug) {
 	System.out.println(motion + "\n");
-	System.out.println("after, mouse " + mousePosn + " eye " + eyePosn + 
+	System.out.println("after, mouse " + mousePosn + " eye " + eyePosn +
 			   " mouseVec " + mouseVec);
       }
 
       pickRay.set(eyePosn, mouseVec);
-            
-      return (PickShape) pickRay;      
-      
+
+      return (PickShape) pickRay;
+
     }
-  
+
   /**
    * Returns an array referencing all the items that are pickable below the
    * BranchGroup (specified in the PickObject constructor) that
-   * intersect with a ray that starts at the 
+   * intersect with a ray that starts at the
    * viewer position and points into the scene in the direction of (xpos, ypos)
    * specified in window space. The resultant array is unordered.
    *
@@ -283,20 +283,20 @@ public class PickObject extends Object {
    * If no pickable object is found null is returned..
    *
    * @see SceneGraphPath
-   */  
+   */
   public SceneGraphPath[] pickAll(int xpos, int ypos)
     {
       pickRay = (PickRay) generatePickRay(xpos, ypos);
       sceneGraphPathArr = pickRoot.pickAll(pickRay);
       return sceneGraphPathArr;
     }
-  
+
   /**
    * Returns a sorted array of references to all the Pickable items below the
    * BranchGroup (specified in the PickObject constructor) that
-   * intersect with the ray that starts at the viewer 
-   * position and points into the scene in the direction of (xpos, ypos) 
-   * in the window space. 
+   * intersect with the ray that starts at the viewer
+   * position and points into the scene in the direction of (xpos, ypos)
+   * in the window space.
    * Element [0] references the item closest to viewer.
    *
    * @param xpos The value along the x-axis.
@@ -318,8 +318,8 @@ public class PickObject extends Object {
   /**
    * Returns a reference to any item that is Pickable below the specified
    * BranchGroup (specified in the PickObject constructor) which
-   *  intersects with the ray that starts at the viewer 
-   * position and points into the scene in the direction of (xpos, ypos) in 
+   *  intersects with the ray that starts at the viewer
+   * position and points into the scene in the direction of (xpos, ypos) in
    * window space.
    *
    * @param xpos The value along the x-axis.
@@ -340,7 +340,7 @@ public class PickObject extends Object {
   /**
    * Returns a reference to the item that is closest to the viewer and is
    * Pickable below the BranchGroup (specified in the PickObject
-   * constructor) which intersects with the ray that starts at 
+   * constructor) which intersects with the ray that starts at
    * the viewer position and points into the scene in the direction of
    * (xpos, ypos) in the window space.
    *
@@ -362,7 +362,7 @@ public class PickObject extends Object {
   /**
    * Returns an array referencing all the items that are pickable below the
    * BranchGroup (specified in the PickObject constructor) that
-   * intersect with a ray that starts at the 
+   * intersect with a ray that starts at the
    * viewer position and points into the scene in the direction of (xpos, ypos)
    * specified in window space. The resultant array is unordered.
    *
@@ -374,26 +374,26 @@ public class PickObject extends Object {
    * If no pickable object is found null is returned..
    *
    * @see SceneGraphPath
-   */  
+   */
   public SceneGraphPath[] pickAll(int xpos, int ypos, int flag)
     {
 
       if(flag == USE_BOUNDS) {
 	return pickAll(xpos, ypos);
       }
-      else if(flag == USE_GEOMETRY) {   
+      else if(flag == USE_GEOMETRY) {
 	return pickGeomAll(xpos, ypos);
       }
-      else 
+      else
 	return null;
     }
-  
+
   /**
    * Returns a sorted array of references to all the Pickable items below the
    * BranchGroup (specified in the PickObject constructor) that
-   * intersect with the ray that starts at the viewer 
-   * position and points into the scene in the direction of (xpos, ypos) 
-   * in the window space. 
+   * intersect with the ray that starts at the viewer
+   * position and points into the scene in the direction of (xpos, ypos)
+   * in the window space.
    * Element [0] references the item closest to viewer.
    *
    * @param xpos The value along the x-axis.
@@ -412,10 +412,10 @@ public class PickObject extends Object {
       if(flag == USE_BOUNDS) {
 	return pickAllSorted(xpos, ypos);
       }
-      else if(flag == USE_GEOMETRY) {   
+      else if(flag == USE_GEOMETRY) {
 	return pickGeomAllSorted(xpos, ypos);
       }
-      else 
+      else
 	return null;
 
     }
@@ -423,8 +423,8 @@ public class PickObject extends Object {
   /**
    * Returns a reference to any item that is Pickable below the specified
    * BranchGroup (specified in the PickObject constructor) which
-   *  intersects with the ray that starts at the viewer 
-   * position and points into the scene in the direction of (xpos, ypos) in 
+   *  intersects with the ray that starts at the viewer
+   * position and points into the scene in the direction of (xpos, ypos) in
    * window space.
    *
    * @param xpos The value along the x-axis.
@@ -442,17 +442,17 @@ public class PickObject extends Object {
       if(flag == USE_BOUNDS) {
 	return pickAny(xpos, ypos);
       }
-      else if(flag == USE_GEOMETRY) {   
+      else if(flag == USE_GEOMETRY) {
 	return pickGeomAny(xpos, ypos);
       }
-      else 
+      else
 	return null;
     }
 
   /**
    * Returns a reference to the item that is closest to the viewer and is
    * Pickable below the BranchGroup (specified in the PickObject
-   * constructor) which intersects with the ray that starts at 
+   * constructor) which intersects with the ray that starts at
    * the viewer position and points into the scene in the direction of
    * (xpos, ypos) in the window space.
    *
@@ -470,10 +470,10 @@ public class PickObject extends Object {
       if(flag == USE_BOUNDS) {
 	return pickClosest(xpos, ypos);
       }
-      else if(flag == USE_GEOMETRY) {   
+      else if(flag == USE_GEOMETRY) {
 	return pickGeomClosest(xpos, ypos);
       }
-      else 
+      else
 	return null;
     }
 
@@ -484,25 +484,25 @@ public class PickObject extends Object {
 
       pickRay = (PickRay) generatePickRay(xpos, ypos);
       sceneGraphPathArr = pickRoot.pickAll(pickRay);
-      
+
       if(sceneGraphPathArr == null)
 	return null;
-      
+
       boolean found[] = new boolean[sceneGraphPathArr.length];
 
       for(i=0; inull is returned.
    */
   public Node pickNode(SceneGraphPath sgPath, int flags)
     {
-      
-      if (sgPath != null) {	
+
+      if (sgPath != null) {
 	Node pickedNode = sgPath.getObject();
-	
+
 	if ((pickedNode instanceof Shape3D) && ((flags & SHAPE3D) != 0)){
 	  if (debug) System.out.println("Shape3D found");
 	  return pickedNode;
-	} 
+	}
 	else if ((pickedNode instanceof Morph) && ((flags & MORPH) != 0)){
-	  if (debug) System.out.println("Morph found"); 
+	  if (debug) System.out.println("Morph found");
 	  return pickedNode;
 	}
-	else {	  
+	else {
 	  for (int j=sgPath.nodeCount()-1; j>=0; j--){
-	    pickedNode = sgPath.getNode(j); 
+	    pickedNode = sgPath.getNode(j);
 	    if (debug) System.out.println("looking at node " + pickedNode);
-	    
+
 	    if ((pickedNode instanceof Primitive) &&
 		((flags & PRIMITIVE) != 0)){
 	      if (debug) System.out.println("Primitive found");
@@ -740,17 +740,17 @@ public class PickObject extends Object {
 	    else if ((pickedNode instanceof Group) && ((flags & GROUP) != 0)){
 	      if (debug) System.out.println("Group found");
 	      return pickedNode;
-	    }	     
+	    }
 	  }
-	  
+
 	  if (pickedNode == null)
 	    if (debug) System.out.println("ERROR: null SceneGraphPath");
 	}
 
       }
-      
+
       return null;
-      
+
     }
 
 
@@ -768,32 +768,32 @@ public class PickObject extends Object {
    * 1 means to return the first occurrence of that object type (the object
    * closest to the Locale).
    * @return the nth occurrence of a Node
-   * of type flags, starting from the Locale. If no pickable object is 
+   * of type flags, starting from the Locale. If no pickable object is
    * found, null is returned.
-   */  
+   */
   public Node pickNode(SceneGraphPath sgPath, int flags, int occurrence)
     {
       int curCnt=0;
-      
-      if (sgPath != null) {	
+
+      if (sgPath != null) {
 	Node pickedNode = sgPath.getObject();
-	
+
 	// Shape3D and Morph are leaf nodes and have no children. It doesn't
         // make sense to do occurrence check here. We'll just return it for now.
 	if ((pickedNode instanceof Shape3D) && ((flags & SHAPE3D) != 0)){
 	  if (debug) System.out.println("Shape3D found");
 	  return pickedNode;
 	} else if ((pickedNode instanceof Morph) && ((flags & MORPH) != 0)){
-	  if (debug) System.out.println("Morph found"); 
+	  if (debug) System.out.println("Morph found");
 	  return pickedNode;
 	}
-	else {	  
+	else {
 	  for (int j = 0; j < sgPath.nodeCount(); j++){
 	    pickedNode = sgPath.getNode(j);
 	    if (debug) System.out.println("looking at node " + pickedNode);
-	    
+
 	    if ((pickedNode instanceof Group) && ((flags & GROUP) != 0)){
-	      if (debug) System.out.println("Group found"); 
+	      if (debug) System.out.println("Group found");
 	      curCnt++;
 	      if(curCnt == occurrence)
 		return pickedNode;
@@ -803,7 +803,7 @@ public class PickObject extends Object {
 	      if (debug) System.out.println("Branch group found");
 	      curCnt++;
 	      if(curCnt == occurrence)
-		return pickedNode;	      
+		return pickedNode;
 	    }
 	    else if ((pickedNode instanceof TransformGroup) &&
                     ((flags & TRANSFORM_GROUP) != 0)){
@@ -821,20 +821,20 @@ public class PickObject extends Object {
 	    }
 	    else if ((pickedNode instanceof Link) && ((flags & LINK) != 0)){
 	      if (debug) System.out.println("Link found");
-	      curCnt++;	
+	      curCnt++;
 	      if(curCnt == occurrence)
 		return pickedNode;
 	    }
 	  }
-	  
+
 	  if (pickedNode == null)
 	    if (debug) System.out.println("ERROR: null SceneGraphPath");
 	}
 
       }
-      
+
       return null;
-      
+
     }
 
 }
diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickRotateBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickRotateBehavior.java
index cad7eb2..b615d4a 100644
--- a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickRotateBehavior.java
+++ b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickRotateBehavior.java
@@ -53,7 +53,7 @@ import javax.vecmath.*;
 
 /*
  * A mouse behavior that allows user to pick and drag scene graph objects.
- * Common usage: 
+ * Common usage:
  * 

* 1. Create your scene graph. *

@@ -85,7 +85,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** * Creates a pick/rotate behavior that waits for user mouse events for - * the scene graph. This method has its pickMode set to BOUNDS picking. + * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -107,11 +107,11 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickObject.USE_BOUNDS or PickObject.USE_GEOMETRY. - * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in - * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. + * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in + * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. **/ - public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, + public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode){ super(canvas, root, bounds); drag = new MouseRotate(MouseRotate.MANUAL_WAKEUP); @@ -126,7 +126,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi * Sets the pickMode component of this PickRotateBehavior to the value of * the passed pickMode. * @param pickMode the pickMode to be copied. - **/ + **/ public void setPickMode(int pickMode) { @@ -135,33 +135,33 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** * Return the pickMode component of this PickRotateBehavior. - **/ + **/ public int getPickMode() { return pickMode; } /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (!mevent.isMetaDown() && !mevent.isAltDown()){ - + // tg = (TransformGroup) pickScene.pickNode(pickScene.pickClosest(xpos, ypos), // PickObject.TRANSFORM_GROUP); tg =(TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos, ypos,pickMode), PickObject.TRANSFORM_GROUP); - // Make sure the selection exists and is movable. - if ((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + // Make sure the selection exists and is movable. + if ((tg != null) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ drag.setTransformGroup(tg); drag.wakeup(); @@ -178,7 +178,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ROTATE, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickTranslateBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickTranslateBehavior.java index 6ccf6d3..9771d6a 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickTranslateBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickTranslateBehavior.java @@ -53,7 +53,7 @@ import javax.vecmath.*; // A mouse behavior that allows user to pick and translate scene graph objects. // Common usage: 1. Create your scene graph. 2. Create this behavior with -// the root and canvas. See PickRotateBehavior for more details. +// the root and canvas. See PickRotateBehavior for more details. /** * @deprecated As of Java 3D version 1.2, replaced by @@ -70,7 +70,7 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Creates a pick/translate behavior that waits for user mouse events for - * the scene graph. This method has its pickMode set to BOUNDS picking. + * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -92,8 +92,8 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickObject.USE_BOUNDS or PickObject.USE_GEOMETRY. - * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in - * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. + * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in + * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, @@ -111,7 +111,7 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh * Sets the pickMode component of this PickTranslateBehavior to the value of * the passed pickMode. * @param pickMode the pickMode to be copied. - **/ + **/ public void setPickMode(int pickMode) { this.pickMode = pickMode; @@ -119,39 +119,39 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Return the pickMode component of this PickTranslaeBehavior. - **/ + **/ public int getPickMode() { return pickMode; } /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (!mevent.isAltDown() && mevent.isMetaDown()){ - + tg =(TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos, ypos, pickMode), PickObject.TRANSFORM_GROUP); - //Check for valid selection. - if ((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + //Check for valid selection. + if ((tg != null) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ - + translate.setTransformGroup(tg); translate.wakeup(); currentTG = tg; } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); } - + } /** diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickZoomBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickZoomBehavior.java index 2220227..ca6e86d 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickZoomBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/picking/PickZoomBehavior.java @@ -54,7 +54,7 @@ import javax.vecmath.*; // A mouse behavior that allows user to pick and zoom scene graph objects. // Common usage: 1. Create your scene graph. 2. Create this behavior with -// the root and canvas. See PickRotateBehavior for more details. +// the root and canvas. See PickRotateBehavior for more details. /** * @deprecated As of Java 3D version 1.2, replaced by @@ -71,7 +71,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior /** * Creates a pick/zoom behavior that waits for user mouse events for - * the scene graph. This method has its pickMode set to BOUNDS picking. + * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -93,8 +93,8 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickObject.USE_BOUNDS or PickObject.USE_GEOMETRY. - * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in - * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. + * Note: If pickMode is set to PickObject.USE_GEOMETRY, all geometry object in + * the scene graph that allows pickable must have its ALLOW_INTERSECT bit set. **/ public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, @@ -105,49 +105,49 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior currGrp.addChild(zoom); zoom.setSchedulingBounds(bounds); this.setSchedulingBounds(bounds); - this.pickMode = pickMode; + this.pickMode = pickMode; } - + /** * Sets the pickMode component of this PickZoomBehavior to the value of * the passed pickMode. * @param pickMode the pickMode to be copied. - **/ + **/ public void setPickMode(int pickMode) { this.pickMode = pickMode; } - - + + /** * Return the pickMode component of this PickZoomBehavior. - **/ + **/ public int getPickMode() { return pickMode; } - + /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (mevent.isAltDown() && !mevent.isMetaDown()){ - + tg =(TransformGroup)pickScene.pickNode(pickScene.pickClosest(xpos, ypos, pickMode), PickObject.TRANSFORM_GROUP); - + // Check for valid selection - if ((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + if ((tg != null) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ zoom.setTransformGroup(tg); zoom.wakeup(); @@ -164,7 +164,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ZOOM, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/Mouse6DPointerBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/Mouse6DPointerBehavior.java index f783fa4..3e01bb6 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/Mouse6DPointerBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/Mouse6DPointerBehavior.java @@ -52,10 +52,10 @@ import javax.vecmath.Vector3f ; /** * This class provides basic behavior for a 6DOF mouse sensor. It * generates a visible 3D cursor echo in the virtual world which tracks the - * position and orientation of the 6DOF mouse in the physical world. It + * position and orientation of the 6DOF mouse in the physical world. It * can be extended to provide other functions by accessing its - * SensorEventAgent. - * + * SensorEventAgent. + * * @see SensorEventAgent * @since Java 3D 1.3 */ @@ -73,7 +73,7 @@ public class Mouse6DPointerBehavior extends Behavior { * The default echo is a solid 6-pointed star where each point is aligned * with the axes of the local coordinate system of the sensor, and with * the center of the star at the location of the sensor hotspot. - * + * * @param sensor a 6 degree of freedom Sensor which generates position * and orientation relative to the tracker base. * @param size the physical width of the echo in centimeters. @@ -134,7 +134,7 @@ public class Mouse6DPointerBehavior extends Behavior { /** * Gets the echo used by this behavior. * - * @return the TransformGroup parenting this behavior's echo geometry + * @return the TransformGroup parenting this behavior's echo geometry */ public TransformGroup getEcho() { return echoTransformGroup ; @@ -160,7 +160,7 @@ public class Mouse6DPointerBehavior extends Behavior { } /** - * Processes a stimulus meant for this behavior. + * Processes a stimulus meant for this behavior. * NOTE: Applications should not call this method. It is called by the * Java 3D behavior scheduler. */ diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorBeamEcho.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorBeamEcho.java index 533afb2..fa95846 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorBeamEcho.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorBeamEcho.java @@ -59,15 +59,15 @@ import javax.vecmath.Vector3f ; /** * A Shape3D representing a beam pointing from the origin of a * sensor's local coordinate system to its hotspot. - * + * * @since Java 3D 1.3 */ public class SensorBeamEcho extends Shape3D { /** * Creates a SensorBeamEcho. Read and write capabilities are granted - * for the Appearance, Material, TransparencyAttributes, and + * for the Appearance, Material, TransparencyAttributes, and * TransparencyAttributes mode and value. - * + * * @param hotspot location of the sensor's hotspot in the sensor's * local coordinate system; this must not be (0, 0, 0) * @param baseWidth width of the beam in meters @@ -75,7 +75,7 @@ public class SensorBeamEcho extends Shape3D { * generated and lighting enabled * @exception IllegalArgumentException if hotspot is (0, 0, 0) */ - public SensorBeamEcho(Point3d hotspot, double baseWidth, + public SensorBeamEcho(Point3d hotspot, double baseWidth, boolean enableLighting) { super() ; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.java index ea77aab..c16aa99 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorButtonListener.java @@ -46,13 +46,13 @@ package com.sun.j3d.utils.behaviors.sensor ; /** * This defines the interface for handling a sensor's button events in - * conjunction with a SensorEventAgent instance. + * conjunction with a SensorEventAgent instance. *

* The events passed to this listener's methods are ephemeral; they * are only valid until the listener has returned. If a listener needs to * retain the event it must be copied using the * SensorEvent(SensorEvent) constructor. - * + * * @see SensorEvent * @see SensorEventAgent * @see SensorReadListener @@ -61,14 +61,14 @@ package com.sun.j3d.utils.behaviors.sensor ; public interface SensorButtonListener { /** * This method is called when a sensor's button is pressed. - * + * * @param e the sensor event */ public void pressed(SensorEvent e) ; /** * This method is called when a sensor's button is released. - * + * * @param e the sensor event */ public void released(SensorEvent e) ; @@ -79,7 +79,7 @@ public interface SensorButtonListener { * if any button bound to the listener is down and has not changed * state since the last invocation. The sensor value has not * necessarily changed from the last drag event. - * + * * @param e the sensor event */ public void dragged(SensorEvent e) ; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEvent.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEvent.java index 4deba71..76d5c44 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEvent.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEvent.java @@ -59,7 +59,7 @@ import javax.media.j3d.Transform3D ; * behaviors that wake up every frame. If a listener needs to retain the * event it must be copied using the SensorEvent(SensorEvent) * constructor. - * + * * @see SensorEventAgent * @see SensorButtonListener * @see SensorReadListener @@ -104,7 +104,7 @@ public class SensorEvent { /** * Creates a new SensorEvent. - * + * * @param source a reference to the originating object which * instantiated the SensorEventAgent, usually a * Behavior; may be null @@ -192,7 +192,7 @@ public class SensorEvent { * Sets the fields of an ephemeral event. No objects are copied. An * IllegalStateException will be thrown if this event * is not ephemeral. - * + * * @param source a reference to the originating object which * instantiated the SensorEventAgent, usually a * Behavior; may be null @@ -252,7 +252,7 @@ public class SensorEvent { public int getID() { return id ; } - + /** * Gets a reference to the provoking sensor. @@ -289,7 +289,7 @@ public class SensorEvent { /** * Copies the sensor's read value at the time of the event into the * given Transform3D. - * + * * @param t the transform to receive the sensor read */ public void getSensorRead(Transform3D t) { @@ -311,7 +311,7 @@ public class SensorEvent { /** * Copies the state of the sensor's buttons at the time of the event * into the given array. A 1 in the array indicates that the button - * at that index is down, while a 0 indicates that button is up. + * at that index is down, while a 0 indicates that button is up. * @param buttonState the state of the sensor buttons */ public void getButtonState(int[] buttonState) { diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.java index a13168c..285a222 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorEventAgent.java @@ -111,7 +111,7 @@ import com.sun.j3d.utils.timer.J3DTimer ; * constructor. *

* It is safe to add and remove listeners in response to a callback. - * + * * @see SensorEvent * @see SensorButtonListener * @see SensorReadListener @@ -134,7 +134,7 @@ public class SensorEventAgent { /** * Create a SensorEventAgent to generate and dispatch * sensor events to registered listeners. - * + * * @param source reference to the originating object for inclusion in * generated SensorEvents; intended to refer to the * instantiating Behavior but may be any reference, or null @@ -186,7 +186,7 @@ public class SensorEventAgent { ((SensorReadListener)readBindingsList.get(i)) + "\n" ; return s ; } - } + } /** * This class contains an array of SensorButtonListener @@ -241,7 +241,7 @@ public class SensorEventAgent { /** * Creates a binding of the specified sensor button to the given * SensorButtonListener implementation. - * + * * @param sensor the sensor with the button to be bound * @param button the index of the button to be bound on the specified * sensor; may range from 0 to @@ -286,7 +286,7 @@ public class SensorEventAgent { * they occur. This allows actions to be bound to combinations of * button presses, but is also convenient for listeners that don't * care which button was pressed. - * + * * @param sensor the sensor to be bound * @param buttonListener the SensorButtonListener * implementation that will be called for all button events @@ -327,7 +327,7 @@ public class SensorEventAgent { * among the listeners specified in the array. If multiple sensor * buttons are held down at the same time, callbacks are invoked only * for the button that was depressed first. - * + * * @param sensor the sensor to be bound * @param buttonListeners array of implementations of * SensorButtonListener; array entries may be null or @@ -361,7 +361,7 @@ public class SensorEventAgent { /** * Gets the SensorButtonListener implementations bound to * the given sensor and button. - * + * * @param sensor the sensor of interest * @param button the button of interest * @return array of SensorButtonListener implementations @@ -424,13 +424,13 @@ public class SensorEventAgent { /** * Remove the given SensorButtonListener binding from the * specified sensor. - * + * * @param sensor the sensor from which to remove the listener * @param listener the listener to be removed */ public synchronized void removeSensorButtonListener (Sensor sensor, SensorButtonListener listener) { - + if (sensor == null) throw new NullPointerException("\nsensor is null") ; @@ -448,7 +448,7 @@ public class SensorEventAgent { /** * Remove the given SensorButtonListener from all sensors. - * + * * @param listener the listener to remove */ public synchronized void removeSensorButtonListener @@ -472,7 +472,7 @@ public class SensorEventAgent { * SensorReadListener. The read listener is invoked * every time dispatchEvents is called and a button * listener is not invoked. - * + * * @param sensor the sensor to be bound * @param readListener the SensorReadListener * implementation @@ -495,7 +495,7 @@ public class SensorEventAgent { /** * Gets the SensorReadListeners bound to the specified * sensor. - * + * * @param sensor the sensor of interest * @return array of SensorReadListeners bound to the * given sensor, or null @@ -531,13 +531,13 @@ public class SensorEventAgent { /** * Remove the given SensorReadListener binding from the * specified sensor. - * + * * @param sensor the sensor from which to remove the listener * @param listener the listener to be removed */ public synchronized void removeSensorReadListener (Sensor sensor, SensorReadListener listener) { - + if (sensor == null) throw new NullPointerException("\nsensor is null") ; @@ -555,7 +555,7 @@ public class SensorEventAgent { /** * Remove the given SensorReadListener from all sensors. - * + * * @param listener the listener to remove */ public synchronized void removeSensorReadListener @@ -608,7 +608,7 @@ public class SensorEventAgent { /** * Copies binding lists to arrays for event dispatch. This allows * listeners to add or remove themselves or other listeners safely. - */ + */ private synchronized void updateArrays() { bindings = (SensorBinding[])bindingsList.toArray (new SensorBinding[bindingsList.size()]) ; @@ -628,7 +628,7 @@ public class SensorEventAgent { public void dispatchEvents() { long t1 = t0 ; t0 = J3DTimer.getValue() ; - + if (listsDirty) { updateArrays() ; listsDirty = false ; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorGnomonEcho.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorGnomonEcho.java index 3fbe45c..eac90cb 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorGnomonEcho.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorGnomonEcho.java @@ -58,7 +58,7 @@ import javax.vecmath.Vector3f ; * A Shape3D representing a gnomon pointing along each coordinate * axis. The base of the gnomon is a cube, and the coordinate axes are * represented by pyramids attached to each face of the cube. - * + * * @since Java 3D 1.3 */ public class SensorGnomonEcho extends Shape3D { @@ -66,7 +66,7 @@ public class SensorGnomonEcho extends Shape3D { * Constructs a SensorGnomonEcho. Read and write capabilities are * granted for the Appearance, Material, TransparencyAttributes, * and TransparencyAttributes mode and value. - * + * * @param transform translation and/or rotation to apply to the gnomon * geometry; this should be the position and orientation of the sensor * hotspot in the sensor's local coordinate system @@ -91,7 +91,7 @@ public class SensorGnomonEcho extends Shape3D { Point3f[] axes = new Point3f[6] ; float length = (float)axisLength ; - axes[FRONT] = new Point3f(0f, 0f, length) ; + axes[FRONT] = new Point3f(0f, 0f, length) ; axes[BACK] = new Point3f(0f, 0f, -length) ; axes[LEFT] = new Point3f(-length, 0f, 0f) ; axes[RIGHT] = new Point3f( length, 0f, 0f) ; @@ -157,7 +157,7 @@ public class SensorGnomonEcho extends Shape3D { vertices[v++] = cube[i][0] ; vertices[v++] = axes[i] ; } - + int vertexFormat ; Material m = new Material() ; m.setCapability(Material.ALLOW_COMPONENT_READ) ; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorInputAdaptor.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorInputAdaptor.java index 98de3b6..52f816c 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorInputAdaptor.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorInputAdaptor.java @@ -48,7 +48,7 @@ package com.sun.j3d.utils.behaviors.sensor ; * The adaptor which receives sensor button and read events. The methods * in this class are empty; the ones of interest should be overridden by * classes extending this adaptor. - * + * * @since Java 3D 1.3 */ public class SensorInputAdaptor diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorReadListener.java b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorReadListener.java index 0daa1fc..4cecf7f 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorReadListener.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/sensor/SensorReadListener.java @@ -52,7 +52,7 @@ package com.sun.j3d.utils.behaviors.sensor ; * are only valid until the listener has returned. If a listener needs to * retain the event it must be copied using the * SensorEvent(SensorEvent) constructor. - * + * * @see SensorEvent * @see SensorEventAgent * @see SensorButtonListener @@ -65,7 +65,7 @@ public interface SensorReadListener { * sensor's buttons have been handled by a button listener. The * sensor read value has not necessarily changed since the last read * event. - * + * * @param e the sensor event */ public void read(SensorEvent e) ; diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java index 57168bf..00d68f4 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/vp/OrbitBehavior.java @@ -138,7 +138,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { private Point3d rotationCenter = new Point3d(); private Matrix3d rotMatrix = new Matrix3d(); private Transform3D currentXfm = new Transform3D(); - + private int mouseX = 0; private int mouseY = 0; @@ -165,11 +165,11 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { private int rightButton = TRANSLATE; private int middleButton = ZOOM; - // the factor to be applied to wheel zooming so that it does not - // look much different with mouse movement zooming. + // the factor to be applied to wheel zooming so that it does not + // look much different with mouse movement zooming. // This is a totally subjective factor. private float wheelZoomFactor = 50.0f; - + /** * Constructor flag to reverse the rotate behavior */ @@ -197,7 +197,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { * radius default is 0.0. */ public static final int STOP_ZOOM = 0x100; - + /** * Constructor flag to disable rotate */ @@ -220,9 +220,9 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { * is determined by the zoom factor. */ public static final int PROPORTIONAL_ZOOM = 0x1000; - + /** - * Used to set the fuction for a mouse button to Rotate + * Used to set the fuction for a mouse button to Rotate */ private static final int ROTATE = 0; @@ -264,7 +264,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { * * @param c The Canvas3D to add the behavior to */ - public OrbitBehavior(Canvas3D c) { + public OrbitBehavior(Canvas3D c) { this(c, 0 ); } @@ -276,11 +276,11 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { */ public OrbitBehavior(Canvas3D c, int flags) { super(c, MOUSE_LISTENER | MOUSE_MOTION_LISTENER | MOUSE_WHEEL_LISTENER | flags ); - + if ((flags & DISABLE_ROTATE) != 0) rotateEnabled = false; if ((flags & DISABLE_ZOOM) != 0) zoomEnabled = false; if ((flags & DISABLE_TRANSLATE) != 0) translateEnabled = false; - if ((flags & REVERSE_TRANSLATE) != 0) reverseTrans = true; + if ((flags & REVERSE_TRANSLATE) != 0) reverseTrans = true; if ((flags & REVERSE_ROTATE) != 0) reverseRotate = true; if ((flags & REVERSE_ZOOM) != 0) reverseZoom = true; if ((flags & STOP_ZOOM) != 0) stopZoom = true; @@ -293,17 +293,17 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { protected synchronized void processAWTEvents( final AWTEvent[] events ) { motion = false; for(int i=0; inot call this method. + * NOTE: Applications should not call this method. */ @Override public void setViewingPlatform(ViewingPlatform vp) { @@ -434,9 +434,9 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { if (vp!=null) { resetView(); integrateTransforms(); - } + } } - + /** * Reset the orientation and distance of this behavior to the current * values in the ViewPlatform Transform Group @@ -453,7 +453,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { targetTransform.get( rotMatrix ); rotateTransform.set( rotMatrix ); - + // compute the initial x/y/z offset temp1.set(centerToView); rotateTransform.invert(); @@ -466,15 +466,15 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { // reset rotMatrix rotateTransform.set( rotMatrix ); } - + protected synchronized void integrateTransforms() { // Check if the transform has been changed by another // behavior targetTG.getTransform(currentXfm) ; if (! targetTransform.equals(currentXfm)) resetView() ; - - longditudeTransform.rotY( longditude ); + + longditudeTransform.rotY( longditude ); latitudeTransform.rotX( latitude ); rotateTransform.mul(rotateTransform, latitudeTransform); rotateTransform.mul(rotateTransform, longditudeTransform); @@ -495,11 +495,11 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { // handle rotationCenter temp1.set(centerVector); temp1.mul(targetTransform); - + invertCenterVector.x = -centerVector.x; invertCenterVector.y = -centerVector.y; invertCenterVector.z = -centerVector.z; - + temp2.set(invertCenterVector); targetTransform.mul(temp1, temp2); @@ -507,7 +507,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { // reset yaw and pitch angles longditude = 0.0; - latitude = 0.0; + latitude = 0.0; } /** @@ -540,10 +540,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { if (! (center.length == 1 && center[0] instanceof Point3d)) throw new IllegalArgumentException ("RotationCenter must be a single Point3d"); - + setRotationCenter((Point3d)center[0]); } - + /** * Places the value of the center around which the View rotates * into the Point3d. @@ -562,7 +562,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { // // Methods also need to correctly set sign of variables depending on // the Reverse settings. - + /** * Sets the rotation x and y factors. The factors are used to determine * how many radians to rotate the view for each pixel of mouse movement. @@ -570,7 +570,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { * movement. The default factor is 1.0. * @param xfactor The x movement multiplier * @param yfactor The y movement multiplier - **/ + **/ public synchronized void setRotFactors(double xfactor, double yfactor) { rotXFactor = xfactor; rotYFactor = yfactor; @@ -589,18 +589,18 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { factors[0] instanceof Double && factors[1] instanceof Double)) throw new IllegalArgumentException ("RotFactors must be two Doubles"); - + setRotFactors(((Double)factors[0]).doubleValue(), ((Double)factors[1]).doubleValue()); } - + /** * Sets the rotation x factor. The factors are used to determine * how many radians to rotate the view for each pixel of mouse movement. * The view is rotated factor * 0.01 radians for each pixel of mouse * movement. The default factor is 1.0. * @param xfactor The x movement multiplier - **/ + **/ public synchronized void setRotXFactor(double xfactor) { rotXFactor = xfactor; rotXMul = NOMINAL_ROT_FACTOR * xfactor; @@ -615,17 +615,17 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void RotXFactor(Object[] xFactor) { if (! (xFactor.length == 1 && xFactor[0] instanceof Double)) throw new IllegalArgumentException("RotXFactor must be a Double"); - + setRotXFactor(((Double)xFactor[0]).doubleValue()); } - + /** * Sets the rotation y factor. The factors are used to determine * how many radians to rotate the view for each pixel of mouse movement. * The view is rotated factor * 0.01 radians for each pixel of mouse * movement. The default factor is 1.0. * @param yfactor The y movement multiplier - **/ + **/ public synchronized void setRotYFactor(double yfactor) { rotYFactor = yfactor; rotYMul = NOMINAL_ROT_FACTOR * yfactor; @@ -640,10 +640,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void RotYFactor(Object[] yFactor) { if (! (yFactor.length == 1 && yFactor[0] instanceof Double)) throw new IllegalArgumentException("RotYFactor must be a Double"); - + setRotYFactor(((Double)yFactor[0]).doubleValue()); } - + /** * Sets the translation x and y factors. The factors are used to determine * how many units to translate the view for each pixel of mouse movement. @@ -651,7 +651,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { * movement. The default factor is 1.0. * @param xfactor The x movement multiplier * @param yfactor The y movement multiplier - **/ + **/ public synchronized void setTransFactors(double xfactor, double yfactor) { transXFactor = xfactor; @@ -671,18 +671,18 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { factors[0] instanceof Double && factors[1] instanceof Double)) throw new IllegalArgumentException ("TransFactors must be two Doubles"); - + setTransFactors(((Double)factors[0]).doubleValue(), ((Double)factors[1]).doubleValue()); } - + /** * Sets the translation x factor. The factors are used to determine * how many units to translate the view for each pixel of mouse movement. * The view is translated factor * 0.01 units for each pixel of mouse * movement. The default factor is 1.0. * @param xfactor The x movement multiplier - **/ + **/ public synchronized void setTransXFactor(double xfactor) { transXFactor = xfactor; transXMul = NOMINAL_TRANS_FACTOR * xfactor; @@ -697,17 +697,17 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void TransXFactor(Object[] xFactor) { if (! (xFactor.length == 1 && xFactor[0] instanceof Double)) throw new IllegalArgumentException("TransXFactor must be a Double"); - + setTransXFactor(((Double)xFactor[0]).doubleValue()); } - + /** * Sets the translation y factor. The factors are used to determine * how many units to translate the view for each pixel of mouse movement. * The view is translated factor * 0.01 units for each pixel of mouse * movement. The default factor is 1.0. * @param yfactor The y movement multiplier - **/ + **/ public synchronized void setTransYFactor(double yfactor) { transYFactor = yfactor; transYMul = NOMINAL_TRANS_FACTOR * yfactor; @@ -722,10 +722,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void TransYFactor(Object[] yFactor) { if (! (yFactor.length == 1 && yFactor[0] instanceof Double)) throw new IllegalArgumentException("TransYFactor must be a Double"); - + setTransYFactor(((Double)yFactor[0]).doubleValue()); } - + /** * Sets the zoom factor. The factor is used to determine how many * units to zoom the view for each pixel of mouse movement. @@ -754,10 +754,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void ZoomFactor(Object[] zFactor) { if (! (zFactor.length == 1 && zFactor[0] instanceof Double)) throw new IllegalArgumentException("ZoomFactor must be a Double"); - + setZoomFactor(((Double)zFactor[0]).doubleValue()); } - + /** * Returns the x rotation movement multiplier * @return The movement multiplier for x rotation @@ -815,10 +815,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void RotateEnable(Object[] enabled) { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException("RotateEnable must be Boolean"); - + setRotateEnable(((Boolean)enabled[0]).booleanValue()); } - + /** * Enables or disables zoom. The default is true. * @param enabled true or false to enable or disable zoom @@ -836,10 +836,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void ZoomEnable(Object[] enabled) { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException("ZoomEnable must be Boolean"); - + setZoomEnable(((Boolean)enabled[0]).booleanValue()); } - + /** * Enables or disables translate. The default is true. * @param enabled true or false to enable or disable translate @@ -858,10 +858,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { if (! (enabled.length == 1 && enabled[0] instanceof Boolean)) throw new IllegalArgumentException ("TranslateEnable must be Boolean"); - + setTranslateEnable(((Boolean)enabled[0]).booleanValue()); } - + /** * Retrieves the state of rotate enabled * @return the rotate enable state @@ -967,10 +967,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void MinRadius(Object[] r) { if (! (r.length == 1 && r[0] instanceof Double)) throw new IllegalArgumentException("MinRadius must be a Double"); - + setMinRadius(((Double)r[0]).doubleValue()); } - + /** * Returns the minimum orbit radius. The zoom will stop at this distance * from the center of rotation if the STOP_ZOOM constructor flag is set. @@ -999,10 +999,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException ("ReverseTranslate must be Boolean"); - + setReverseTranslate(((Boolean)state[0]).booleanValue()); } - + /** * Set reverse rotate behavior. The default is false. * @param state if true, reverse rotate behavior @@ -1021,10 +1021,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void ReverseRotate(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException("ReverseRotate must be Boolean"); - + setReverseRotate(((Boolean)state[0]).booleanValue()); } - + /** * Set reverse zoom behavior. The default is false. * @param state if true, reverse zoom behavior @@ -1043,10 +1043,10 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { public void ReverseZoom(Object[] state) { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException("ReverseZoom must be Boolean"); - + setReverseZoom(((Boolean)state[0]).booleanValue()); } - + /** * Set proportional zoom behavior. The default is false. * @param state if true, use proportional zoom behavior @@ -1073,7 +1073,7 @@ public class OrbitBehavior extends ViewPlatformAWTBehavior { if (! (state.length == 1 && state[0] instanceof Boolean)) throw new IllegalArgumentException ("ProportionalZoom must be Boolean"); - + setProportionalZoom(((Boolean)state[0]).booleanValue()); } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformAWTBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformAWTBehavior.java index af2449c..00b3afd 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformAWTBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformAWTBehavior.java @@ -78,7 +78,7 @@ import com.sun.j3d.utils.universe.*; * AWT Events are captured and placed in a queue. * * While there are pending events or motion the behavior will wake - * up every frame, call processAWTEvents and integrateTransforms. + * up every frame, call processAWTEvents and integrateTransforms. * * @since Java 3D 1.2.1 */ @@ -86,7 +86,7 @@ public abstract class ViewPlatformAWTBehavior extends ViewPlatformBehavior implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { private final static boolean DEBUG = false; - + /** * Behavior PostId used in this behavior */ @@ -96,7 +96,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { * The different criterion for the behavior to wakeup */ protected WakeupOnElapsedFrames frameWakeup; - + /** * The Or of the different criterion for the behavior to wakeup */ @@ -106,12 +106,12 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { * The target Transform3D for this behavior */ protected Transform3D targetTransform = new Transform3D(); - + /** * Boolean for whether the mouse is in motion */ protected boolean motion = false; - + /** * Flag indicating Behavior should listen for Mouse Events */ @@ -144,7 +144,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { /** * Parameterless constructor for this behavior, intended for use by * subclasses instantiated through ConfiguredUniverse. Such a constructor - * is required for configurable behaviors. + * is required for configurable behaviors. * @since Java 3D 1.3 */ protected ViewPlatformAWTBehavior() { @@ -154,8 +154,8 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { /** * Construct a behavior which listens for events specified by the given * flags, intended for use by subclasses instantiated through - * ConfiguredUniverse. - * + * ConfiguredUniverse. + * * @param listenerFlags Indicates which listener should be registered, * one or more of MOUSE_LISTENER, MOUSE_MOTION_LISTENER, KEY_LISTENER, MOUSE_WHEEL_LISTENER * @since Java 3D 1.3 @@ -167,7 +167,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { /** * Constructs a new ViewPlatformAWTBehavior. - * + * * @param c The Canvas3D on which to listen for events. If this is null a * NullPointerException will be thrown. * @param listenerFlags Indicates which listener should be registered, @@ -175,14 +175,14 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { */ public ViewPlatformAWTBehavior(Canvas3D c, int listenerFlags ) { super(); - + if (c == null) throw new NullPointerException(); - canvases = new Canvas3D[] { c }; + canvases = new Canvas3D[] { c }; setListenerFlags(listenerFlags); - } - + } + /** * Sets listener flags for this behavior. * @@ -193,7 +193,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { protected void setListenerFlags(int listenerFlags) { this.listenerFlags = listenerFlags; } - + /** * Initializes the behavior. * NOTE: Applications should not call this method. It is called by the @@ -202,12 +202,12 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { public void initialize() { frameWakeup = new WakeupOnElapsedFrames( 0 ); postWakeup = new WakeupOnBehaviorPost( this, POST_ID ); - + wakeupOn(postWakeup); } /** - * Process a stimulus meant for this behavior. + * Process a stimulus meant for this behavior. * NOTE: Applications should not call this method. It is called by the * Java 3D behavior scheduler. */ @@ -226,12 +226,12 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { eventQueue.clear(); } processAWTEvents(events); - + if (motion) integrateTransforms(); } } - + if (motion || hadPost) { // wake up on behavior posts and elapsed frames if in motion wakeupOn( frameWakeup ); @@ -240,7 +240,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { wakeupOn( postWakeup ); } } - + /** * Overload setEnable from Behavior. * @@ -250,14 +250,14 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { public void setEnable( boolean state ) { if (state==getEnable()) return; - + super.setEnable(state); if (canvases != null) { enableListeners(state); } } - + private void enableListeners( boolean enable ) { if (enable) { firstEvent = true ; @@ -300,7 +300,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { * called by the ViewingPlatform. * If a sub-calls overrides this method, it must call * super.setViewingPlatform(vp). - * NOTE: Applications should not call this method. + * NOTE: Applications should not call this method. */ public void setViewingPlatform(ViewingPlatform vp) { super.setViewingPlatform( vp ); @@ -328,7 +328,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { } } } - + /** * This is called once per frame if there are any AWT events to * process. @@ -341,7 +341,7 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { * arrived from AWT. */ protected abstract void processAWTEvents( final java.awt.AWTEvent[] events ); - + /** * Called once per frame (if the view is moving) to calculate the new * view platform transform @@ -369,15 +369,15 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { } } } - + public void mouseClicked(final MouseEvent e) { queueAWTEvent( e ); } - + public void mouseEntered(final MouseEvent e) { queueAWTEvent( e ); } - + public void mouseExited(final MouseEvent e) { queueAWTEvent( e ); } @@ -401,17 +401,17 @@ implements MouseListener, MouseMotionListener, KeyListener, MouseWheelListener { public void keyReleased(final java.awt.event.KeyEvent e) { queueAWTEvent( e ); } - + public void keyPressed(final java.awt.event.KeyEvent e) { queueAWTEvent( e ); } - + public void keyTyped(final java.awt.event.KeyEvent e) { queueAWTEvent( e ); } public void mouseWheelMoved( final java.awt.event.MouseWheelEvent e) { queueAWTEvent( e ); - } + } } diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformBehavior.java index 0198fa5..5cc2f83 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/vp/ViewPlatformBehavior.java @@ -80,14 +80,14 @@ abstract public class ViewPlatformBehavior extends Behavior { * Sets the ViewingPlatform for this behavior. This method is called by * the ViewingPlatform. If a sub-calls overrides this method, it must * call super.setViewingPlatform(vp).

- * - * NOTE: Applications should not call this method. + * + * NOTE: Applications should not call this method. * * @param vp the target ViewingPlatform for this behavior */ public void setViewingPlatform(ViewingPlatform vp) { this.vp = vp; - + if (vp!=null) targetTG = vp.getViewPlatformTransform(); else @@ -105,7 +105,7 @@ abstract public class ViewPlatformBehavior extends Behavior { /** * Copies the given Transform3D into the "home" transform, used to * position and reorient the ViewingPlatform to a known point of interest. - * + * * @param home source transform to be copied * @since Java 3D 1.3 */ @@ -118,7 +118,7 @@ abstract public class ViewPlatformBehavior extends Behavior { /** * Returns the behaviors "home" transform. - * + * * @param home transform to be returned * @since Java 3D 1.3 */ diff --git a/src/classes/share/com/sun/j3d/utils/behaviors/vp/WandViewBehavior.java b/src/classes/share/com/sun/j3d/utils/behaviors/vp/WandViewBehavior.java index 42882d0..1d4d4ed 100644 --- a/src/classes/share/com/sun/j3d/utils/behaviors/vp/WandViewBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/behaviors/vp/WandViewBehavior.java @@ -113,7 +113,7 @@ import com.sun.j3d.utils.behaviors.sensor.* ; * TranslateBackward - Translates the view platform backwards * along the direction the sensor is pointing; the virtual world appears to * move away from the sensor. The default is button 2 if three buttons are - * available. + * available. * *

  • * RotateCCW - Rotates the view platform counter-clockwise about @@ -245,13 +245,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Indicates that a 2D sensor button or read action should be bound - * to translation. + * to translation. */ public static final int TRANSLATION = 8 ; /** * Indicates that a 2D sensor button or read action should be bound - * to scaling. + * to scaling. */ public static final int SCALE = 9 ; @@ -288,13 +288,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Indicates that rotation speed should be in radians. */ public static final int RADIANS = 15 ; - + /** * Indicates that rotation speed should be in degrees. This is the * default. */ public static final int DEGREES = 16 ; - + /** * Indicates that rotation should occur in view platform * coordinates. @@ -330,7 +330,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * default. */ public static final int ECHO = 22 ; - + /** * Indicates that the echo type is a gnomon displaying the * directions of the sensor's local coordinate system axes at the location @@ -364,7 +364,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { private boolean configured = false ; // The rest of these private fields are all configurable through - // ConfiguredUniverse. + // ConfiguredUniverse. private Sensor sensor6D = null ; private Sensor sensor2D = null ; private int x2D = 3 ; @@ -431,7 +431,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * instantiated from a configuration file then it must then be explicitly * attached to a ViewingPlatform instance with the * ViewingPlatform.setViewPlatformBehavior method. - * + * * @param sensor6D a six degree of freedom sensor which generates reads * relative to the tracker base in physical units; may be * null @@ -471,7 +471,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * transform and to read, write, and extend its children will be set. The * echo geometry is assumed to incorporate the position and orientation of * the 6DOF sensor hotspot. - * + * * @param sensor6D a six degree of freedom sensor which generates reads * relative to the tracker base in physical units; may be * null @@ -515,13 +515,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { * responsible for adding the echo to the virtual universe. The echo * geometry is assumed to incorporate the position and orientation of the * 6DOF sensor hotspot. - * + * * @param sensor6D a six degree of freedom sensor which generates reads * relative to the tracker base in physical units; may be * null * @param sensor2D 2D valuator which generates X and Y reads ranging from * [-1.0 .. +1.0]; may be null - * @param view a reference to the View attached to the + * @param view a reference to the View attached to the * ViewPlatform to be manipulated by this behavior * @param viewTransform a TransformGroup containing the view * platform transform; appropriate capabilities to update the transform @@ -586,7 +586,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { } /** - * Processes a stimulus meant for this behavior. + * Processes a stimulus meant for this behavior. * NOTE: Applications should not call this method. It is called by * the Java 3D behavior scheduler. */ @@ -614,7 +614,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { } super.setEnable(enable) ; } - + /** * Sets the ViewingPlatform for this behavior. If a subclass * overrides this method, it must call @@ -659,7 +659,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { attachEcho() ; } - + /** * Attaches the echo BranchGroup to the ViewingPlatform if appropriate. */ @@ -699,14 +699,14 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (universe != null && universe instanceof ConfiguredUniverse) { // Check if sensors were instantiated from a config file. Map sensorMap = ((ConfiguredUniverse)universe).getNamedSensors() ; - + if (sensor2D == null && sensor2DName != null) { sensor2D = (Sensor)sensorMap.get(sensor2DName) ; if (sensor2D == null) throw new IllegalArgumentException ("\nsensor " + sensor2DName + " not found") ; } - + if (sensor6D == null && sensor6DName != null) { sensor6D = (Sensor)sensorMap.get(sensor6DName) ; if (sensor6D == null) @@ -734,7 +734,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { throw new IllegalArgumentException ("\nbutton index " + (buttonActionCount-1) + " >= number of buttons (" + buttonCount +")") ; - + // Assign default button actions. if (buttonCount > 2 && (buttonActionCount < 3 || buttonActions6D.get(2) == null)) @@ -760,7 +760,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { sbls[i] = new GrabViewListener6D() ; else if (action == TRANSLATE_FORWARD) sbls[i] = new TranslationListener6D(false) ; - else if (action == TRANSLATE_BACKWARD) + else if (action == TRANSLATE_BACKWARD) sbls[i] = new TranslationListener6D(true) ; else if (action == ROTATE_CCW) sbls[i] = new RotationListener6D(false) ; @@ -944,7 +944,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Initializes the listener action. Subclasses must call this before * starting the action, either from pressed or when a 2D * valuator exits the deadzone threshold. - * + * * @param s reference to a 6DOF sensor if used by the listener; may * be null */ @@ -969,7 +969,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Ends the action. Subclasses must be call this from * released or when a 2D valuator enters the deadzone * threshold. - * + * * @param s reference to a 6DOF sensor if used by the listener; may * be null */ @@ -1092,7 +1092,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { closestToOne = 1 ; if (Math.abs(s3Tmp[2] - 1.0) < Math.abs(s3Tmp[closestToOne] - 1.0)) closestToOne = 2 ; - + double scale ; for (int i = 0 ; i < 3 ; i++) { if (i == closestToOne) continue ; @@ -1101,13 +1101,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { m16Tmp[i+4] *= scale ; m16Tmp[i+8] *= scale ; } - + // Set the view transform and bail out if unsuccessful. viewPlatformToVworld.set(m16Tmp) ; if ((viewPlatformToVworld.getType() & Transform3D.CONGRUENT) == 0) goHome() ; else - targetTG.setTransform(viewPlatformToVworld) ; + targetTG.setTransform(viewPlatformToVworld) ; } } @@ -1135,7 +1135,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { Sensor s = e.getSensor() ; s.getRead(sensorToTracker) ; sensorToVworld.mul(trackerToVworld, sensorToTracker) ; - + // Solve for T, where T x initialSensorToVworld = sensorToVworld t3d.mul(sensorToVworld, initialVworldToSensor) ; @@ -1251,7 +1251,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * about a Y axis. This axis can be relative to the sensor, user head, or * view platform. The rotation center can be the sensor hotspot or a * fixed point in virtual world coordinates. - * + * * @see #setButtonAction6D * @see #setRotationCoords * @see #setTransformCenterSource @@ -1382,7 +1382,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Implements a 6DOF sensor button listener that scales the view platform. * The center of scaling can be the sensor hotspot or a fixed location in * virtual world coordinates. - * + * * @see #setButtonAction6D * @see #setTransformCenterSource * @see #setTransformCenter @@ -1483,7 +1483,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Implements a 6DOF sensor read listener that updates the orientation and * position of the sensor's echo in the virtual world. - * + * * @see #setEchoType * @see #setEchoSize * @see #setReadAction6D @@ -1568,9 +1568,9 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Construct an instance of this class with the specified sensors. - * + * * @param sensor2D the 2D valuator whose X and Y values drive the - * rotation + * rotation * @param sensor6D the 6DOF sensor to use if the rotation coordinate * system is set to SENSOR or the rotation center source * is HOTSPOT; may be null @@ -1593,7 +1593,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { m[y2D] > threshold2D || m[y2D] < -threshold2D) { // Initialize action on threshold crossing. if (!isActive()) initAction(sensor6D) ; - + // m[x2D] is the X valuator value and m[y2D] is the Y valuator // value. Use these to construct the rotation axis. double length = Math.sqrt(m[x2D]*m[x2D] + m[y2D]*m[y2D]) ; @@ -1692,7 +1692,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * occurs along the basis vectors of the 6DOF sensor's coordinate system; * otherwise, the translation occurs along the view platform's basis * vectors. - * + * * @see #setReadAction2D * @see #setButtonAction2D * @see #setTranslationSpeed @@ -1725,7 +1725,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Construct an instance of this class using the specified sensors. - * + * * @param sensor2D 2D valuator sensor for translation * @param sensor6D 6DOF sensor for translation direction; may be * null @@ -1831,7 +1831,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * called with the value HOTSPOT, then scaling is about the * 6DOF sensor's hotspot; otherwise, the scaling center is the value set * by setTransformCenter. - * + * * @see #setReadAction2D * @see #setButtonAction2D * @see #setScaleSpeed @@ -1865,7 +1865,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Construct an instance of this class with the specified sensors. - * + * * @param sensor2D the 2D valuator whose Y value drive the scaling * @param sensor6D the 6DOF sensor to use if the rotation/scale center * source is HOTSPOT; may be null @@ -1960,7 +1960,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Resets the view back to the home transform when a specified number of * buttons are down simultaneously. - * + * * @see #setResetViewButtonCount6D * @see ViewPlatformBehavior#setHomeTransform * ViewPlatformBehavior.setHomeTransform @@ -2007,7 +2007,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * sensor hotspot position if applicable. This implementation assumes the * hotspot position and orientation have been incorporated into the echo * geometry. - * + * * @param sensor the sensor to be echoed * @param sensorToVworld transform from sensor coordinates to virtual * world coordinates @@ -2037,7 +2037,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Alternative Syntax:
    (ViewPlatformBehaviorProperty * <name> Sensor6D (Sensor <sensorName>)) - * + * * @param sensor array of length 1 containing a String or * a Sensor */ @@ -2054,11 +2054,11 @@ public class WandViewBehavior extends ViewPlatformBehavior { throw new IllegalArgumentException ("Sensor6D must be a name or a Sensor instance") ; } - + /** * Returns a reference to the 6DOF sensor used for manipulating the view * platform. - * + * * @return the 6DOF sensor */ public Sensor getSensor6D() { @@ -2087,7 +2087,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Alternative Syntax:
    (ViewPlatformBehaviorProperty * <name> Sensor2D (Sensor <sensorName>)) - * + * * @param sensor array of length 1 containing a String or * a Sensor */ @@ -2108,7 +2108,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Returns a reference to the 2D valuator used for manipulating the view * platform. - * + * * @return the 2D valuator */ public Sensor getSensor2D() { @@ -2144,10 +2144,10 @@ public class WandViewBehavior extends ViewPlatformBehavior { * ConfiguredUniverse. *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> - * ButtonAction6D <button index> + * ButtonAction6D <button index> * [GrabView | TranslateForward | TranslateBackward | RotateCCW | * RotateCW | ScaleUp | ScaleDown | None]) - * + * * @param action array of length 2 containing a Double and a * String. * @see #setButtonAction6D @@ -2155,7 +2155,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * @see #TranslationSpeed TranslationSpeed * @see #AccelerationTime AccelerationTime * @see #ConstantSpeedTime ConstantSpeedTime - * @see #FastSpeedFactor FastSpeedFactor + * @see #FastSpeedFactor FastSpeedFactor * @see #RotationSpeed RotationSpeed * @see #RotationCoords RotationCoords * @see #ScaleSpeed ScaleSpeed @@ -2171,7 +2171,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { action[0] instanceof Double && action[1] instanceof String)) throw new IllegalArgumentException ("\nButtonAction6D must be a number and a string") ; - + int button = ((Double)action[0]).intValue() ; String actionString = (String)action[1] ; @@ -2197,7 +2197,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { "TranslateBackward, RotateCCW, RotateCW, ScaleUp, " + "ScaleDown, or None") ; } - + /** * Sets a button action for the 6DOF sensor. The choices are * TRANSLATE_FORWARD, TRANSLATE_BACKWARD, @@ -2227,8 +2227,8 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * This method only configures the button listeners pre-defined by * this behavior. For complete control over the button actions, access - * the SensorEventAgent used by this behavior directly. - * + * the SensorEventAgent used by this behavior directly. + * * @param button index of the button to bind * @param action either TRANSLATE_FORWARD, * TRANSLATE_BACKWARD, GRAB_VIEW, @@ -2268,7 +2268,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the action associated with the specified button on the 6DOF sensor. - * + * * @return the action associated with the button */ public int getButtonAction6D(int button) { @@ -2331,7 +2331,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ReadAction2D [Rotation | Translation | Scale | None]) - * + * * @param action array of length 1 containing a String * @see #setReadAction2D * @see #RotationCoords RotationCoords @@ -2350,7 +2350,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (action.length == 1 && action[0] instanceof String)) throw new IllegalArgumentException ("\nReadAction2D must be a String") ; - + String actionString = (String)action[0] ; if (actionString.equals("Rotation")) @@ -2412,8 +2412,8 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * This method only configures the read listeners pre-defined by * this behavior. For complete control over the read actions, access - * the SensorEventAgent used by this behavior directly. - * + * the SensorEventAgent used by this behavior directly. + * * @param action either ROTATION, TRANSLATION, * SCALE, or NONE * @see #setRotationCoords @@ -2441,7 +2441,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the configured 2D valuator read action. - * + * * @return the action associated with the sensor read */ public int getReadAction2D() { @@ -2467,9 +2467,9 @@ public class WandViewBehavior extends ViewPlatformBehavior { * ConfiguredUniverse. *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> - * ButtonAction2D <button index> + * ButtonAction2D <button index> * [Rotation | Translation | Scale | None]) - * + * * @param action array of length 2 containing a Double and a * String. * @see #setButtonAction2D @@ -2491,7 +2491,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { action[0] instanceof Double && action[1] instanceof String)) throw new IllegalArgumentException ("\nButtonAction2D must be a number and a string") ; - + int button = ((Double)action[0]).intValue() ; String actionString = (String)action[1] ; @@ -2508,7 +2508,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { ("\nButtonAction2D must be Rotation, Translation, Scale " + "or None") ; } - + /** * Sets a button action for the 2D valuator. The possible values are * ROTATION, TRANSLATION, SCALE, or @@ -2522,8 +2522,8 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * This method only configures the button listeners pre-defined by * this behavior. For complete control over the button actions, access - * the SensorEventAgent used by this behavior directly. - * + * the SensorEventAgent used by this behavior directly. + * * @param button index of the button to bind * @param action either ROTATION, TRANSLATION, * SCALE, or NONE @@ -2556,7 +2556,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the action associated with the specified button on the 2D valuator. - * + * * @return the action associated with the button */ public int getButtonAction2D(int button) { @@ -2585,7 +2585,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ReadAction6D [Echo | None]) - * + * * @param action array of length 1 containing a String * @see #setReadAction6D * @see EchoReadListener6D @@ -2594,7 +2594,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (action.length == 1 && action[0] instanceof String)) throw new IllegalArgumentException ("\nReadAction6D must be a String") ; - + String actionString = (String)action[0] ; if (actionString.equals("Echo")) @@ -2617,8 +2617,8 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * This method only configures the read listeners pre-defined by * this behavior. For complete control over the read actions, access - * the SensorEventAgent used by this behavior directly. - * + * the SensorEventAgent used by this behavior directly. + * * @param action either ECHO or NONE * @see EchoReadListener6D * @see #getSensorEventAgent @@ -2633,7 +2633,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the configured 6DOF sensor read action. - * + * * @return the configured 6DOF sensor read action */ public int getReadAction6D() { @@ -2651,7 +2651,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Syntax:
    (ViewPlatformBehaviorProperty <name> * TranslationSpeed <speed> [PhysicalMeters | VirtualUnits] * [PerFrame | PerSecond]) - * + * * @param speed array of length 3; first element is a Double * for the speed, the second is a String for the units, and * the third is a String for the time base @@ -2662,7 +2662,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { speed[1] instanceof String && speed[2] instanceof String)) throw new IllegalArgumentException ("\nTranslationSpeed must be number, units, and time base") ; - + double v = ((Double)speed[0]).doubleValue() ; String unitsString = (String)speed[1] ; String timeBaseString = (String)speed[2] ; @@ -2691,7 +2691,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Sets the normal translation speed. The default is 0.1 physical * meters/second. - * + * * @param speed how fast to translate * @param units either PHYSICAL_METERS or * VIRTUAL_UNITS @@ -2717,7 +2717,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the normal speed at which to translate the view platform. - * + * * @return the normal translation speed */ public double getTranslationSpeed() { @@ -2726,7 +2726,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the translation speed units. - * + * * @return the translation units */ public int getTranslationUnits() { @@ -2735,7 +2735,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the time base for translation speed. - * + * * @return the translation time base */ public int getTranslationTimeBase() { @@ -2748,10 +2748,10 @@ public class WandViewBehavior extends ViewPlatformBehavior { * the normal and fast translation speeds. The default is 1 second. This * property is set in the configuration file read by * ConfiguredUniverse.

    - * + * * Syntax:
    (ViewPlatformBehaviorProperty <name> * AccelerationTime <seconds>) - * + * * @param time array of length 1 containing a Double * @see #setAccelerationTime */ @@ -2759,7 +2759,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (time.length == 1 && time[0] instanceof Double)) throw new IllegalArgumentException ("\nAccelerationTime must be a number") ; - + setAccelerationTime(((Double)time[0]).doubleValue()) ; } @@ -2767,7 +2767,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Sets the time interval for accelerating to the translation, rotation, * or scale speeds and for transitioning between the normal and fast * translation speeds. The default is 1 second. - * + * * @param time number of seconds to accelerate to normal or fast speed */ public void setAccelerationTime(double time) { @@ -2777,7 +2777,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the time interval for accelerating to normal speed and for * transitioning between the normal and fast translation speeds. - * + * * @return the acceleration time */ public double getAccelerationTime() { @@ -2791,7 +2791,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ConstantSpeedTime <seconds>) - * + * * @param time array of length 1 containing a Double * @see #setConstantSpeedTime */ @@ -2799,14 +2799,14 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (time.length == 1 && time[0] instanceof Double)) throw new IllegalArgumentException ("\nConstantSpeedTime must be a number") ; - + setConstantSpeedTime(((Double)time[0]).doubleValue()) ; } /** * Sets the time interval for which the translation occurs at the normal * speed. The default is 8 seconds. - * + * * @param time number of seconds to translate at a constant speed */ public void setConstantSpeedTime(double time) { @@ -2816,7 +2816,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the time interval for which the translation occurs at the * normal speed. - * + * * @return the constant speed time */ public double getConstantSpeedTime() { @@ -2830,7 +2830,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * FastSpeedFactor <factor>) - * + * * @param factor array of length 1 containing a Double * @see #setFastSpeedFactor */ @@ -2838,14 +2838,14 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (factor.length == 1 && factor[0] instanceof Double)) throw new IllegalArgumentException ("\nFastSpeedFactor must be a number") ; - + setFastSpeedFactor(((Double)factor[0]).doubleValue()) ; } /** * Sets the fast translation speed factor. The default is 10 times the * normal speed. - * + * * @param factor scale by which the normal translation speed is multiplied */ public void setFastSpeedFactor(double factor) { @@ -2855,7 +2855,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the factor by which the normal translation speed is multiplied * after the constant speed time interval. - * + * * @return the fast speed factor */ public double getFastSpeedFactor() { @@ -2870,7 +2870,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * Threshold2D <threshold>) - * + * * @param threshold array of length 1 containing a Double * @see #setThreshold2D */ @@ -2885,7 +2885,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Sets the threshold for 2D valuator reads. The default is 0.0. It can * be set higher to handle noisy valuators. - * + * * @param threshold if the absolute values of both the X and Y valuator * reads are less than this value then the values are ignored */ @@ -2895,7 +2895,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the 2D valuator threshold. - * + * * @return the threshold value */ public double getThreshold2D() { @@ -2911,7 +2911,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * MatrixIndices2D <X index> <Y index>) - * + * * @param indices array of length 2 containing Doubles * @see #setMatrixIndices2D */ @@ -2920,16 +2920,16 @@ public class WandViewBehavior extends ViewPlatformBehavior { indices[0] instanceof Double && indices[1] instanceof Double)) throw new IllegalArgumentException ("\nMatrixIndices2D must be a numbers") ; - + setMatrixIndices2D(((Double)indices[0]).intValue(), ((Double)indices[1]).intValue()) ; } - + /** * Specifies where to find the X and Y values in the matrix read generated * by a 2D valuator. The defaults are along the translation components of * the matrix, at indices 3 and 7. - * + * * @param xIndex index of the X valuator value * @param yIndex index of the Y valuator value */ @@ -2941,7 +2941,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the index where the X value of a 2D valuator read matrix can be * found. - * + * * @return the X index in the read matrix */ public int getMatrixXIndex2D() { @@ -2951,7 +2951,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the index where the Y value of a 2D valuator read matrix can be * found. - * + * * @return the Y index in the read matrix */ public int getMatrixYIndex2D() { @@ -2966,7 +2966,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Syntax:
    (ViewPlatformBehaviorProperty <name> * RotationSpeed <speed> [Degrees | Radians] * [PerFrame | PerSecond]) - * + * * @param speed array of length 3; first element is a Double * for the speed, the second is a String for the units, and * the third is a String for the time base @@ -2977,7 +2977,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { speed[1] instanceof String && speed[2] instanceof String)) throw new IllegalArgumentException ("\nRotationSpeed must be number, units, and time base") ; - + double v = ((Double)speed[0]).doubleValue() ; String unitsString = (String)speed[1] ; String timeBaseString = (String)speed[2] ; @@ -3004,7 +3004,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Sets the rotation speed. The default is 180 degrees/second. - * + * * @param speed how fast to rotate * @param units either DEGREES or RADIANS * @param timeBase either PER_SECOND or PER_FRAME @@ -3036,7 +3036,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the rotation speed units - * + * * @return the rotation units */ public int getRotationUnits() { @@ -3045,7 +3045,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the time base for rotation speed. - * + * * @return the rotation time base */ public int getRotationTimeBase() { @@ -3066,7 +3066,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * RotationCoords [Sensor | ViewPlatform | Head]) - * + * * @param coords array of length 1 containing a String * @see #setRotationCoords */ @@ -3074,7 +3074,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (coords.length == 1 && coords[0] instanceof String)) throw new IllegalArgumentException ("\nRotationCoords must be a String") ; - + String coordsString = (String)coords[0] ; if (coordsString.equals("Sensor")) @@ -3096,7 +3096,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * to the XY plane of the view platform. The latter is also the fallback * if a 6DOF sensor is not specified. If the value is HEAD, * then rotation occurs in head coordinates. - * + * * @param coords either SENSOR, VIEW_PLATFORM, or * HEAD */ @@ -3110,7 +3110,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the rotation coordinate system. - * + * * @return the rotation coordinate system */ public int getRotationCoords() { @@ -3121,7 +3121,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Property which sets the scaling speed. The default is 2.0 per second, * which means magnification doubles the apparent size of the virtual * world every second, and minification halves the apparent size of the - * virtual world every second. + * virtual world every second. *

    * The scaling applied with each frame is Math.pow(scaleSpeed, * frameTime), where frameTime is the time in seconds @@ -3139,7 +3139,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ScaleSpeed <speed> [PerFrame | PerSecond]) - * + * * @param speed array of length 2; first element is a Double * for the speed, and the second is a String for the time * base @@ -3150,7 +3150,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { speed[0] instanceof Double && speed[1] instanceof String)) throw new IllegalArgumentException ("\nScalingSpeed must be a number and a string") ; - + double v = ((Double)speed[0]).doubleValue() ; String timeBaseString = (String)speed[2] ; int timeBase ; @@ -3182,7 +3182,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * exponent. If scaling is performed by the 6DOF sensor, then the scale * speed can be inverted with a negative exponent by using the appropriate * listener constructor flag. - * + * * @param speed specifies the scale speed * @param timeBase either PER_SECOND or PER_FRAME */ @@ -3198,7 +3198,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the scaling speed. - * + * * @return the scaling speed */ public double getScaleSpeed() { @@ -3207,7 +3207,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the time base for scaling speed. - * + * * @return the scaling time base */ public int getScaleTimeBase() { @@ -3226,7 +3226,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * TransformCenterSource [Hotspot | VworldFixed]) - * + * * @param source array of length 1 containing a String * @see #setTransformCenterSource */ @@ -3234,7 +3234,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (source.length == 1 && source[0] instanceof String)) throw new IllegalArgumentException ("\nTransformCenterSource must be a String") ; - + String sourceString = (String)source[0] ; if (sourceString.equals("Hotspot")) @@ -3257,7 +3257,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * The transform center source can be dynamically updated while the * behavior is running. - * + * * @param source either HOTSPOT or VWORLD_FIXED */ public void setTransformCenterSource(int source) { @@ -3271,7 +3271,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the rotation/scale center source. - * + * * @return the rotation/scale center source */ public int getTransformCenterSource() { @@ -3287,7 +3287,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * TransformCenter <Point3d>) - * + * * @param center array of length 1 containing a Point3d * @see #setTransformCenter */ @@ -3295,7 +3295,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (center.length == 1 && center[0] instanceof Point3d)) throw new IllegalArgumentException ("\nTransformCenter must be a Point3d") ; - + setTransformCenter((Point3d)center[0]) ; } @@ -3306,7 +3306,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * default is (0.0, 0.0, 0.0) in virtual world coordinates. *

    * The transform center can be dynamically updated while the behavior is - * running. + * running. * * @param center point in virtual world coordinates about which to rotate * and scale @@ -3359,7 +3359,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Syntax:
    (ViewPlatformBehaviorProperty <name> * NominalSensorRotation [<Matrix4d> | * <Matrix3d>]) - * + * * @param matrix array of length 1 containing a Matrix4d or * Matrix3d * @see #setNominalSensorRotation @@ -3369,14 +3369,14 @@ public class WandViewBehavior extends ViewPlatformBehavior { matrix[0] instanceof Matrix4d))) throw new IllegalArgumentException ("\nNominalSensorRotation must be a Matrix3d or Matrix4d") ; - + Transform3D t3d = new Transform3D() ; if (matrix[0] instanceof Matrix3d) t3d.set((Matrix3d)matrix[0]) ; else t3d.set((Matrix4d)matrix[0]) ; - + setNominalSensorRotation(t3d) ; } @@ -3408,7 +3408,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * defined in this behavior; for compatibility with the core Java 3D API, * sensor reads and the sensor hotspot location are still expressed in the * sensor's local coordinate system. - * + * * @param transform Rotates vectors from the nominal sensor coordinate * system system to the sensor's local coordinate system; only the * rotational components are used. May be set null for @@ -3419,7 +3419,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { nominalSensorRotation = null ; return ; } - + if (nominalSensorRotation == null) nominalSensorRotation = new Transform3D() ; @@ -3430,7 +3430,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the nominal sensor transform. - * + * * @param t3d Transform3D to receive a copy of the * nominal sensor transform */ @@ -3451,7 +3451,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ResetViewButtonCount6D [<count> | None]) - * + * * @param count array of length 1 containing a Double or * String * @see #setResetViewButtonCount6D @@ -3482,10 +3482,10 @@ public class WandViewBehavior extends ViewPlatformBehavior { * on the 6DOF sensor in order to reset the view back to the home * transform. The value must be greater than 1; the default is 3. A * value of NONE disables this action. - * + * * @param count either NONE or button count > 1 * @see ViewPlatformBehavior#setHomeTransform - * ViewPlatformBehavior.setHomeTransform + * ViewPlatformBehavior.setHomeTransform */ public void setResetViewButtonCount6D(int count) { if (count == NONE || count > 1) { @@ -3501,13 +3501,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Gets the number of buttons to be pressed simultaneously on the 6DOF * sensor in order to reset the view back to the home transform. A value * of NONE indicates this action is disabled. - * + * * @return the number of buttons to press simultaneously for a view reset */ public int getResetViewButtonCount6D() { return resetViewButtonCount6D ; } - + /** * Property which sets the number of buttons to be pressed simultaneously * on the 2D valuator in order to reset the view back to the home @@ -3518,7 +3518,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * ResetViewButtonCount2D [<count> | None]) - * + * * @param count array of length 1 containing a Double or * String * @see #setResetViewButtonCount2D @@ -3549,7 +3549,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * valuator in order to reset the view back to the home transform. The * value must be greater than 1; the default is NONE. A * value of NONE disables this action. - * + * * @param count either NONE or button count > 1 * @see ViewPlatformBehavior#setHomeTransform * ViewPlatformBehavior.setHomeTransform @@ -3568,13 +3568,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Gets the number of buttons to be pressed simultaneously on the 2D * valuator in order to reset the view back to the home transform. A value * of NONE indicates this action is disabled. - * + * * @return the number of buttons to press simultaneously for a view reset */ public int getResetViewButtonCount2D() { return resetViewButtonCount2D ; } - + /** * Property which sets the 6DOF sensor echo type. The default is * Gnomon, which displays an object with points indicating @@ -3589,7 +3589,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * EchoType [Gnomon | Beam | None]) - * + * * @param type array of length 1 containing a String * @see #setEchoType */ @@ -3597,7 +3597,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (type.length == 1 && type[0] instanceof String)) throw new IllegalArgumentException ("\nEchoType must be a String") ; - + String typeString = (String)type[0] ; if (typeString.equals("Gnomon")) @@ -3620,7 +3620,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * hotspot must not be (0, 0, 0) or an * IllegalArgumentException will result. The width of each * of these echo types is specified by setEchoSize. - * + * * @param type GNOMON, BEAM, or * NONE are recognized */ @@ -3630,7 +3630,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the echo type. - * + * * @return the echo type */ public int getEchoType() { @@ -3645,7 +3645,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * EchoSize <size>) - * + * * @param echoSize array of length 1 containing a Double * @see #setEchoSize */ @@ -3653,15 +3653,15 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (echoSize.length == 1 && echoSize[0] instanceof Double)) throw new IllegalArgumentException ("\nEchoSize must be a Double") ; - + setEchoSize(((Double)echoSize[0]).doubleValue()) ; } - + /** * Sets the size of the 6DOF sensor echo in physical meters. This is used * for the width of the gnomon and beam echoes. The default is 1 * centimeter. - * + * * @param echoSize the size in meters */ public void setEchoSize(double echoSize) { @@ -3670,13 +3670,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the size of the 6DOF sensor echo in meters. - * + * * @return the echo size */ public double getEchoSize() { return echoSize ; } - + /** * Property which sets the color of the 6DOF sensor echo. The default is * white. This property is set in the configuration file read by @@ -3684,7 +3684,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * EchoColor <red> <green> <blue>) - * + * * @param color array of length 3 containing Doubles * @see #setEchoColor */ @@ -3693,17 +3693,17 @@ public class WandViewBehavior extends ViewPlatformBehavior { color[1] instanceof Double && color[2] instanceof Double)) throw new IllegalArgumentException ("\nEchoColor must be 3 numbers for red, green, and blue") ; - + setEchoColor(new Color3f(((Double)color[0]).floatValue(), ((Double)color[1]).floatValue(), ((Double)color[2]).floatValue())) ; } - + /** * Sets the color of the 6DOF sensor echo. The default is white. This * can be called to set the color before or after the echo geometry is * created. - * + * * @param color the echo color */ public void setEchoColor(Color3f color) { @@ -3721,7 +3721,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the 6DOF sensor echo color. - * + * * @param color the Color3f into which to copy the echo color */ public void getEchoColor(Color3f color) { @@ -3730,7 +3730,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { else color.set(echoColor) ; } - + /** * Property which sets the 6DOF sensor echo transparency. The default is * opaque. A value of 0.0 is fully opaque and 1.0 is fully transparent. @@ -3739,7 +3739,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * Syntax:
    (ViewPlatformBehaviorProperty <name> * EchoTransparency <transparency>) - * + * * @param transparency array of length 1 containing a Double * @see #setEchoTransparency */ @@ -3747,16 +3747,16 @@ public class WandViewBehavior extends ViewPlatformBehavior { if (! (transparency.length == 1 && transparency[0] instanceof Double)) throw new IllegalArgumentException ("\nEchoTransparency must be a number") ; - + setEchoTransparency(((Double)transparency[0]).floatValue()) ; } - + /** * Sets the 6DOF sensor echo transparency. The default is opaque. A * value of 0.0 is fully opaque and 1.0 is fully transparent. This can be * called to set the transparency before or after the echo geometry is * created. - * + * * @param transparency the transparency value */ public void setEchoTransparency(float transparency) { @@ -3781,13 +3781,13 @@ public class WandViewBehavior extends ViewPlatformBehavior { /** * Gets the 6DOF sensor echo transparency value. - * + * * @return the transparency value */ public float getEchoTransparency() { return echoTransparency ; } - + /** * Sets the transform group containing a 6DOF sensor's echo geometry. * This is used to specify a custom echo. Its transform will be @@ -3797,7 +3797,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { *

    * This method must be called before the behavior is made live in order to * have an effect. - * + * * @param echo the TransformGroup containing the * echo geometry */ @@ -3813,7 +3813,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Gets the transform group containing a 6DOF sensor's echo geometry. * Capabilities to write its transform and read, write, and extend its * children are granted. - * + * * @return the echo's transform group */ public TransformGroup getEchoTransformGroup() { @@ -3826,7 +3826,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * read and write. If a custom echo was supplied by providing the echo * transform group directly then the return value will be * null. - * + * * @return the echo geometry, or null if a custom echo was * supplied */ @@ -3838,7 +3838,7 @@ public class WandViewBehavior extends ViewPlatformBehavior { * Gets the SensorEventAgent used by this behavior. Sensor * event generation is delegated to this agent. This can be accessed to * manipulate the sensor button and read action bindings directly. - * + * * @return the sensor event agent */ public SensorEventAgent getSensorEventAgent() { diff --git a/src/classes/share/com/sun/j3d/utils/compression/CommandStream.java b/src/classes/share/com/sun/j3d/utils/compression/CommandStream.java index d7a7220..2b16dbf 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CommandStream.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CommandStream.java @@ -115,17 +115,17 @@ class CommandStream { /** * Add a compression command to this instance.

    - * + * * A compression command includes an 8-bit header and can range up to 72 * bits in length. The command with the maximum length is a 2-bit color * command with a 6-bit tag in the header, followed by four 16-bit color * components of data.

    - * + * * A subcommand is either a position, normal, or color, though in practice * a position subcommand can only be part of a vertex command. Normal and * color subcommands can be parts of separate global normal and color * commands as well as parts of a vertex command.

    - * + * * A subcommand includes a 6-bit header. Its length is 2 bits less than * the length of the corresponding command. * @@ -147,7 +147,7 @@ class CommandStream { // // Add the rightmost bitCount bits of b to the end of the command stream. - // + // private void addByte(int b, int bitCount) { int bitsEmpty = 8 - bitOffset ; b &= (int)CompressionStreamElement.lengthMask[bitCount] ; @@ -173,14 +173,14 @@ class CommandStream { // // Add the rightmost bitCount bits of l to the end of the command stream. - // + // private void addLong(long l, int bitCount) { int byteCount = bitCount / 8 ; int excessBits = bitCount - byteCount * 8 ; if (excessBits > 0) addByte((int)(l >>> (byteCount * 8)), excessBits) ; - + while (byteCount > 0) { addByte((int)((l >>> ((byteCount - 1) * 8)) & 0xff), 8) ; byteCount-- ; @@ -214,7 +214,7 @@ class CommandStream { int fillBytes = 8 - excessBytes ; padBits = (8 * fillBytes) + (8 - bitOffset) ; } - + // The minimum length for a no-op command body is 5 bits. if (padBits < 5) // Have to cross the next 64-bit boundary. @@ -227,7 +227,7 @@ class CommandStream { addLong((padBits - 5) << (padBits - 5), padBits) ; return ; } - + // The number of bits to pad at this point is [37..68]. Knock off 24 // bits with the body of the 1st no-op to reduce the number of pad // bits to [13..44], which can be filled with 1 more no-op. diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressedGeometryFile.java b/src/classes/share/com/sun/j3d/utils/compression/CompressedGeometryFile.java index 253c87f..8019053 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressedGeometryFile.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressedGeometryFile.java @@ -269,7 +269,7 @@ public class CompressedGeometryFile { public CompressedGeometryFile(RandomAccessFile file) throws IOException { // Copy the file reference. cgFile = file ; - + // Set up the file fields. initialize() ; } @@ -281,7 +281,7 @@ public class CompressedGeometryFile { * must be removed manually before it can be rewritten. The close() * method must be called sometime after invoking clear() in order to write * out the new directory structure. - * + * * @exception IOException if clear fails */ public void clear() throws IOException { @@ -364,7 +364,7 @@ public class CompressedGeometryFile { * index is incremented by 1 after the read. When the last object is read * the index becomes invalid and an immediately subsequent call to * readNext() returns null. - * + * * @return a CompressedGeometry node component, or null if the last object * has been read * @exception IOException if read fails @@ -384,7 +384,7 @@ public class CompressedGeometryFile { public CompressedGeometry[] read() throws IOException { long startTime = 0 ; CompressedGeometry cg[] = new CompressedGeometry[objectCount] ; - + if (benchmark) startTime = System.currentTimeMillis() ; @@ -477,7 +477,7 @@ public class CompressedGeometryFile { (cgh.size+BLOCK_HEADER_SIZE) + " bytes") ; } - + cg.getCompressedGeometry(cgBuffer) ; write(cgh, cgBuffer) ; } @@ -505,7 +505,7 @@ public class CompressedGeometryFile { (cgh.size+BLOCK_HEADER_SIZE) + " bytes") ; } - + // Assuming backward compatibility, the version number of the file // should be the maximum of all individual compressed object versions. if ((cgh.majorVersionNumber > majorVersionNumber) @@ -557,12 +557,12 @@ public class CompressedGeometryFile { if (objectCount == directory.length) { long newDirectory[] = new long[2*objectCount] ; int newObjectSizes[] = new int[2*objectCount] ; - + System.arraycopy(directory, 0, newDirectory, 0, objectCount) ; System.arraycopy(objectSizes, 0, newObjectSizes, 0, objectCount) ; - + directory = newDirectory ; objectSizes = newObjectSizes ; @@ -660,7 +660,7 @@ public class CompressedGeometryFile { // Reset number of objects that can be read sequentially from cache. bufferNextObjectCount = 0 ; } - + // // Initialize directory, object size array, read/write buffer, and the // shared compressed geometry header. @@ -740,7 +740,7 @@ public class CompressedGeometryFile { // // Read the file header. - // + // void readFileHeader() throws IOException { byte header[] = new byte[HEADER_SIZE] ; @@ -817,7 +817,7 @@ public class CompressedGeometryFile { } catch (IOException e) { throw new IOException - (e.getMessage() + + (e.getMessage() + "\ncould not write file header for " + fileName) ; } } @@ -844,7 +844,7 @@ public class CompressedGeometryFile { } for (int i = 0 ; i < directory.length ; i++) { - directory[i] = + directory[i] = ((long)(buff[i*8+0] & 0xff) << 56) | ((long)(buff[i*8+1] & 0xff) << 48) | ((long)(buff[i*8+2] & 0xff) << 40) | @@ -881,7 +881,7 @@ public class CompressedGeometryFile { } directoryOffset += 8-directoryAlign ; } - + try { for (int i = 0 ; i < objectCount ; i++) cgFile.writeLong(directory[i]) ; @@ -899,7 +899,7 @@ public class CompressedGeometryFile { // // Get the next compressed object in the file, either from the read-ahead // cache or from the file itself. - // + // CompressedGeometry readNext(int bufferReadLimit) throws IOException { if (objectIndex == objectCount) @@ -926,7 +926,7 @@ public class CompressedGeometryFile { } catch (IOException e) { throw new IOException - (e.getMessage() + + (e.getMessage() + "\nfailed to read " + curSize + " bytes, object " + objectIndex + " in file " + fileName) ; } @@ -970,7 +970,7 @@ public class CompressedGeometryFile { return newCG(geomSize, geomStart, geomDataType) ; } - + // // Construct and return a compressed geometry node. // @@ -986,17 +986,17 @@ public class CompressedGeometryFile { cgh.bufferType = CompressedGeometryHeader.LINE_BUFFER ; else if ((geomDataType & TYPE_MASK) == TYPE_TRIANGLE) cgh.bufferType = CompressedGeometryHeader.TRIANGLE_BUFFER ; - + cgh.bufferDataPresent = 0 ; if ((geomDataType & NORMAL_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryHeader.NORMAL_IN_BUFFER ; - + if ((geomDataType & COLOR_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryHeader.COLOR_IN_BUFFER ; - + if ((geomDataType & ALPHA_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryHeader.ALPHA_IN_BUFFER ; diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressionStream.java b/src/classes/share/com/sun/j3d/utils/compression/CompressionStream.java index c1dfaba..d1619b7 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressionStream.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressionStream.java @@ -282,7 +282,7 @@ public class CompressionStream { * At 0 bits of quantization normals are represented only as 6 bit * sextant/octant pairs and 14 specially encoded normals (the 6 axis * normals and the 8 octant midpoint normals); since U and V can only be 0 - * at the minimum quantization, the totally number of unique normals is + * at the minimum quantization, the totally number of unique normals is * 12 + 14 = 26. */ int normalQuant ; @@ -532,7 +532,7 @@ public class CompressionStream { * whenever possible. Each geometric element is mapped to a HuffmanNode * object containing its resulting bit length, right shift (trailing 0 * count), and absolute or relative status.

    - * + * * Positions are normalized to span a unit cube via an offset and a * uniform scale factor that maps the midpoint of the object extents along * each dimension to the origin, and the longest dimension of the object to @@ -541,7 +541,7 @@ public class CompressionStream { * position quantization of 6 bits, an object would be normalized so that * its most negative dimension is at (-1 + 1/64) and the most positive is * at (1 - 1/64).

    - * + * * Normals are assumed to be of unit length. Color components are clamped * to the [0..1) range, where the right endpoint is one quantum less * than 1.0.

    @@ -702,7 +702,7 @@ public class CompressionStream { } /** - * Retrieve the number of mesh buffer references created for this stream. + * Retrieve the number of mesh buffer references created for this stream. * @return mesh buffer reference count */ int getMeshReferenceCount() { @@ -1004,7 +1004,7 @@ public class CompressionStream { void addVertex(Point3f pos, Vector3f norm, Object color, int stripFlag, int meshFlag) { - if (vertexColor3) + if (vertexColor3) stream.add(new CompressionStreamVertex (this, pos, norm, (Color3f)color, stripFlag, meshFlag)) ; else @@ -1083,16 +1083,16 @@ public class CompressionStream { /** * Interface to access GeometryArray vertex components and add them to the * compression stream. - * + * * A processVertex() implementation retrieves vertex components using the * appropriate access semantics of a particular GeometryArray, and adds * them to the compression stream. - * + * * The implementation always pushes vertices into the mesh buffer unless * they match ones already there; if they do, it generates mesh buffer * references instead. This reduces the number of vertices when * non-stripped abutting facets are added to the stream. - * + * * Note: Level II geometry compression semantics allow the mesh buffer * normals to be substituted with the value of an immediately * preceding SetNormal command, but this is unavailable in Level I. @@ -1235,7 +1235,7 @@ public class CompressionStream { /** * Class which holds indices for a specific vertex of an - * IndexedGeometryArray. + * IndexedGeometryArray. */ private static class VertexIndices { int pi, ni, ci ; @@ -1289,7 +1289,7 @@ public class CompressionStream { if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r)) addColor(colors3[vi.ci]) ; - + else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r)) addColor(colors4[vi.ci]) ; @@ -1300,7 +1300,7 @@ public class CompressionStream { // // NOTE: For now, copies are made of all GeometryArray vertex components - // even when by-reference access is available. + // even when by-reference access is available. // private static class VertexCopy { Object c = null ; @@ -1324,7 +1324,7 @@ public class CompressionStream { if (vertexNormals && !noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r)))) addNormal(vc.n) ; - + if (vertexColor3 && (! vc.c3.equals(meshBuffer.getColor3(r)))) addColor(vc.c3) ; @@ -1355,7 +1355,7 @@ public class CompressionStream { if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r)) addColor(vc.c3) ; - + else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r)) addColor(vc.c4) ; @@ -1417,7 +1417,7 @@ public class CompressionStream { */ private class InterleavedGeometryFloat extends InterleavedGeometry { float[] vdata = null ; - + InterleavedGeometryFloat(GeometryArray ga) { super(ga) ; vdata = ga.getInterleavedVertices() ; @@ -1477,7 +1477,7 @@ public class CompressionStream { } /** - * This class implements the GeometryAccessor interface for + * This class implements the GeometryAccessor interface for * interleaved NIO geometry arrays. */ private class InterleavedGeometryNIO extends InterleavedGeometry { @@ -1603,7 +1603,7 @@ public class CompressionStream { if (normals == null) throw new UnsupportedOperationException ("\nby-reference access to Normal3f array") ; - + initialNormalIndex = ga.getInitialNormalIndex() ; } } @@ -1730,7 +1730,7 @@ public class CompressionStream { if (vertexColors) { buffer = ga.getColorRefBuffer() ; initialColorIndex = ga.getInitialColorIndex() ; - + switch (BufferWrapper.getBufferType(buffer)) { case BufferWrapper.TYPE_BYTE: colorsB = new ByteBufferWrapper(buffer) ; @@ -1956,7 +1956,7 @@ public class CompressionStream { } else if (ga instanceof TriangleFanArray || ga instanceof IndexedTriangleFanArray) { - + strips = true ; replaceCode = REPLACE_MIDDLE ; if (debug) System.out.println("fans") ; @@ -2295,8 +2295,8 @@ public class CompressionStream { /** * Get the original bounds of the coordinate data, in modeling coordinates. * Coordinate data is positioned and scaled to a normalized cube after - * compression. - * + * compression. + * * @return Point3d array of length 2, where the 1st Point3d is the lower * bounds and the 2nd Point3d is the upper bounds. * @since Java 3D 1.3 @@ -2311,7 +2311,7 @@ public class CompressionStream { /** * Get the bounds of the compressed object in normalized coordinates. * These have an maximum bounds by [-1.0 .. +1.0] across each axis. - * + * * @return Point3d array of length 2, where the 1st Point3d is the lower * bounds and the 2nd Point3d is the upper bounds. * @since Java 3D 1.3 diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamColor.java b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamColor.java index f6af3a5..ff2b728 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamColor.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamColor.java @@ -57,7 +57,7 @@ class CompressionStreamColor extends CompressionStreamElement { private boolean color3 ; private boolean color4 ; private float colorR, colorG, colorB, colorA ; - + int rAbsolute, gAbsolute, bAbsolute, aAbsolute ; /** @@ -96,7 +96,7 @@ class CompressionStreamColor extends CompressionStreamElement { * Quantize a floating point color to fixed point integer components of * the specified number of bits. The bit length can range from a maximum * of 16 to a minimum of 2 bits since negative colors are not defined.

    - * + * * The bit length is the total number of bits in the signed version of the * fixed point representation of the input color, which is assumed to * be normalized into the [0..1) range. With the maximum bit length of @@ -109,7 +109,7 @@ class CompressionStreamColor extends CompressionStreamElement { */ void quantize(CompressionStream stream, HuffmanTable huffmanTable) { // Clamp quantization. - int quant = + int quant = (stream.colorQuant < 2? 2 : (stream.colorQuant > 16? 16 : stream.colorQuant)) ; @@ -142,7 +142,7 @@ class CompressionStreamColor extends CompressionStreamElement { G = (G > 32767? 32767: (G < 0? 0: G)) ; B = (B > 32767? 32767: (B < 0? 0: B)) ; A = (A > 32767? 32767: (A < 0? 0: A)) ; - + // Compute quantized values. R &= quantizationMask[quant] ; G &= quantizationMask[quant] ; @@ -173,11 +173,11 @@ class CompressionStreamColor extends CompressionStreamElement { else if (color4) computeLengthShift(R, G, B, A) ; - + // 0-length components are allowed only for normals. if (length == 0) length = 1 ; - + // Add this element to the Huffman table associated with this stream. huffmanTable.addColorEntry(length, shift, absolute) ; } @@ -206,7 +206,7 @@ class CompressionStreamColor extends CompressionStreamElement { } // - // Output the final compressed bits to the output command stream. + // Output the final compressed bits to the output command stream. // private void outputColor(HuffmanTable table, CommandStream output, int header, int headerLength) { @@ -228,7 +228,7 @@ class CompressionStreamColor extends CompressionStreamElement { G = (G >> t.shift) & (int)lengthMask[componentLength] ; B = (B >> t.shift) & (int)lengthMask[componentLength] ; - long colorSubcommand = + long colorSubcommand = (((long)t.tag) << (3 * componentLength)) | (((long)R) << (2 * componentLength)) | (((long)G) << (1 * componentLength)) | diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamElement.java b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamElement.java index 10440a6..512d309 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamElement.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamElement.java @@ -76,7 +76,7 @@ abstract class CompressionStreamElement { 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF } ; - + /** * Array with elements that can be used as masks to retain the number of * trailing bits of data indicated by the referencing index [0..64]. Used @@ -148,7 +148,7 @@ abstract class CompressionStreamElement { * this includes the first 0 starting from the left, plus a 1 sign bit. * 0 is a special case returning 0; however, 0-length components are valid * ONLY for normals. - * + * * The decompressor uses the data length to determine how many bits of * sign extension to add to the data coming in from the compressed stream * in order to create a 16-bit signed 2's complement integer. E.g., a data @@ -243,7 +243,7 @@ abstract class CompressionStreamElement { int s1 = n1 & 0x8000 ; // equal sign optimization - if (s0 == s1) + if (s0 == s1) if (s0 == 0) this.length = getLength(n0 | n1) ; else @@ -253,7 +253,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1) ; } - + /** * Computes common length and shift of 3 numbers. @@ -295,7 +295,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1 | n2) ; } - + /** * Computes common length and shift of 4 numbers. @@ -306,7 +306,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1 | n2 | n3) ; } - + /** * Finds the maximum of two integers. diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamNormal.java b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamNormal.java index ee25f61..a6c5ddb 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamNormal.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamNormal.java @@ -59,7 +59,7 @@ class CompressionStreamNormal extends CompressionStreamElement { int octant, sextant ; boolean specialNormal ; int uAbsolute, vAbsolute ; - + /** * Create a CompressionStreamNormal. * @@ -75,7 +75,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // // Normal Encoding Parameterization - // + // // A floating point normal is quantized to a desired number of bits by // comparing it to candidate entries in a table of every possible normal // at that quantization and finding the closest match. This table of @@ -85,52 +85,52 @@ class CompressionStreamNormal extends CompressionStreamElement { // th and psi, using usual spherical coordinates. th is the angle about // the y axis, psi is the inclination to the plane containing the point. // The mapping between rectangular and spherical coordinates is: - // + // // x = cos(th)*cos(psi) // y = sin(psi) // z = sin(th)*cos(psi) - // + // // Points on sphere are folded first by octant, and then by sort order // of xyz into one of six sextants. All the table encoding takes place in // the positive octant, in the region bounded by the half spaces: - // + // // x >= z // z >= y // y >= 0 - // + // // This triangular shaped patch runs from 0 to 45 degrees in th, and // from 0 to as much as 0.615479709 (MAX_Y_ANG) in psi. The xyz bounds // of the patch is: - // + // // (1, 0, 0) (1/sqrt(2), 0, 1/sqrt(2)) (1/sqrt(3), 1/sqrt(3), 1/sqrt(3)) - // + // // When dicing this space up into discrete points, the choice for y is // linear quantization in psi. This means that if the y range is to be // divided up into n segments, the angle of segment j is: - // + // // psi(j) = MAX_Y_ANG*(j/n) - // + // // The y height of the patch (in arc length) is *not* the same as the xz // dimension. However, the subdivision quantization needs to treat xz and // y equally. To achieve this, the th angles are re-parameterized as // reflected psi angles. That is, the i-th point's th is: - // + // // th(i) = asin(tan(psi(i))) = asin(tan(MAX_Y_ANG*(i/n))) - // + // // To go the other direction, the angle th corresponds to the real index r // (in the same 0-n range as i): - // + // // r(th) = n*atan(sin(th))/MAX_Y_ANG - // + // // Rounded to the nearest integer, this gives the closest integer index i // to the xz angle th. Because the triangle has a straight edge on the // line x=z, it is more intuitive to index the xz angles in reverse // order. Thus the two equations above are replaced by: - // + // // th(i) = asin(tan(psi(i))) = asin(tan(MAX_Y_ANG*((n-i)/n))) - // + // // r(th) = n*(1 - atan(sin(th))/MAX_Y_ANG) - // + // // Each level of quantization subdivides the triangular patch twice as // densely. The case in which only the three vertices of the triangle are // present is the first logical stage of representation, but because of @@ -191,7 +191,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // An inverse sine table is used for each quantization level to take the Y // component of a normal (which is the sine of the inclination angle) and // obtain the closest quantized Y angle. - // + // // At any level of compression, there are a fixed number of different Y // angles (between 0 and MAX_Y_ANG). The inverse table is built to have // slightly more than twice as many entries as y angles at any particular @@ -199,19 +199,19 @@ class CompressionStreamNormal extends CompressionStreamElement { // of the right one. The size of the table should be as small as // possible, but with its delta sine still smaller than the delta sine // between the last two angles to be encoded. - // + // // Example: the inverse sine table has a maximum angle of 0.615479709. At // the maximum resolution of 6 bits there are 65 discrete angles used, // but twice as many are needed for thresholding between angles, so the // delta angle is 0.615479709/128. The difference then between the last // two angles to be encoded is: // sin(0.615479709*128.0/128.0) - sin(0.615479709*127.0/128.0) = 0.003932730 - // + // // Using 8 significent bits below the binary point, fixed point can // represent sines in increments of 0.003906250, just slightly smaller. // However, because the maximum Y angle sine is 0.577350269, only 148 // instead of 256 table entries are needed. - // + // private static final short inverseSine[][] = new short[MAX_UV_BITS+1][] ; // UNITY_14 * sin(MAX_Y_ANGLE) @@ -236,54 +236,54 @@ class CompressionStreamNormal extends CompressionStreamElement { // Bits below binary point for fixed point delta sine: 8 // Integer delta sine: 64 // Inverse sine table size: 148 entries - deltaSin = 1 << (14 - 8) ; + deltaSin = 1 << (14 - 8) ; break ; case 5: // Delta angle: MAX_Y_ANGLE/64.0 // Bits below binary point for fixed point delta sine: 7 // Integer delta sine: 128 // Inverse sine table size: 74 entries - deltaSin = 1 << (14 - 7) ; + deltaSin = 1 << (14 - 7) ; break ; case 4: // Delta angle: MAX_Y_ANGLE/32.0 // Bits below binary point for fixed point delta sine: 6 // Integer delta sine: 256 // Inverse sine table size: 37 entries - deltaSin = 1 << (14 - 6) ; + deltaSin = 1 << (14 - 6) ; break ; case 3: // Delta angle: MAX_Y_ANGLE/16.0 // Bits below binary point for fixed point delta sine: 5 // Integer delta sine: 512 // Inverse sine table size: 19 entries - deltaSin = 1 << (14 - 5) ; + deltaSin = 1 << (14 - 5) ; break ; case 2: // Delta angle: MAX_Y_ANGLE/8.0 // Bits below binary point for fixed point delta sine: 4 // Integer delta sine: 1024 // Inverse sine table size: 10 entries - deltaSin = 1 << (14 - 4) ; + deltaSin = 1 << (14 - 4) ; break ; case 1: // Delta angle: MAX_Y_ANGLE/4.0 // Bits below binary point for fixed point delta sine: 3 // Integer delta sine: 2048 // Inverse sine table size: 5 entries - deltaSin = 1 << (14 - 3) ; + deltaSin = 1 << (14 - 3) ; break ; case 0: // Delta angle: MAX_Y_ANGLE/2.0 // Bits below binary point for fixed point delta sine: 2 // Integer delta sine: 4096 // Inverse sine table size: 3 entries - deltaSin = 1 << (14 - 2) ; + deltaSin = 1 << (14 - 2) ; break ; } inverseSine[quant] = new short[(MAX_SIN_14BIT/deltaSin) + 1] ; - + intSin = 0 ; for (int i = 0 ; i < inverseSine[quant].length ; i++) { // Compute float representation of integer sine with desired @@ -335,7 +335,7 @@ class CompressionStreamNormal extends CompressionStreamElement { double nx, ny, nz, t ; // Clamp UV quantization. - int quant = + int quant = (stream.normalQuant < 0? 0 : (stream.normalQuant > 6? 6 : stream.normalQuant)) ; @@ -452,7 +452,7 @@ class CompressionStreamNormal extends CompressionStreamElement { specialNormal = true ; u = v = 0 ; } - + // Compute deltas if possible. // Use the non-normalized ii and jj indices. int du = 0 ; @@ -460,7 +460,7 @@ class CompressionStreamNormal extends CompressionStreamElement { int uv64 = 64 >> (6 - quant) ; absolute = false ; - if (stream.firstNormal || stream.normalQuantChanged || + if (stream.firstNormal || stream.normalQuantChanged || stream.lastSpecialNormal || specialNormal) { // The first normal by definition is absolute, and normals cannot // be represented as deltas to or from special normals, nor from @@ -488,7 +488,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // sextant has. du = ii - stream.lastU ; dv = -jj - stream.lastV ; - + // Can't delta by less than -64. if (dv < -uv64) absolute = true ; @@ -553,7 +553,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // truncate the 0 sign bit for values > 0x001f. length = 6 ; } - + // Add this element to the Huffman table associated with this stream. huffmanTable.addNormalEntry(length, shift, absolute) ; @@ -647,7 +647,7 @@ class CompressionStreamNormal extends CompressionStreamElement { header |= (int)(normalSubcommand >>> (subcommandLength - 6)) ; subcommandLength -= 6 ; } - + // Add the header and body to the output buffer. output.addCommand(header, headerLength, normalSubcommand, subcommandLength) ; diff --git a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamVertex.java b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamVertex.java index fdd3b2a..d237ae7 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamVertex.java +++ b/src/classes/share/com/sun/j3d/utils/compression/CompressionStreamVertex.java @@ -66,7 +66,7 @@ class CompressionStreamVertex extends CompressionStreamElement { int xAbsolute, yAbsolute, zAbsolute ; CompressionStreamColor color = null ; CompressionStreamNormal normal = null ; - + /** * Create a CompressionStreamVertex with the given parameters. * @@ -133,7 +133,7 @@ class CompressionStreamVertex extends CompressionStreamElement { stream.byteCount += 12 ; stream.vertexCount++ ; - + if (p.x < stream.mcBounds[0].x) stream.mcBounds[0].x = p.x ; if (p.y < stream.mcBounds[0].y) stream.mcBounds[0].y = p.y ; if (p.z < stream.mcBounds[0].z) stream.mcBounds[0].z = p.z ; @@ -158,7 +158,7 @@ class CompressionStreamVertex extends CompressionStreamElement { double px, py, pz ; // Clamp quantization. - int quant = + int quant = (stream.positionQuant < 1? 1 : (stream.positionQuant > 16? 16 : stream.positionQuant)) ; @@ -227,7 +227,7 @@ class CompressionStreamVertex extends CompressionStreamElement { // 0-length components are allowed only for normals. if (length == 0) length = 1 ; - + // Add this element to the Huffman table associated with this stream. huffmanTable.addPositionEntry(length, shift, absolute) ; @@ -271,12 +271,12 @@ class CompressionStreamVertex extends CompressionStreamElement { Y = (Y >> t.shift) & (int)lengthMask[componentLength] ; Z = (Z >> t.shift) & (int)lengthMask[componentLength] ; - long positionSubcommand = + long positionSubcommand = (((long)t.tag) << (3 * componentLength)) | (((long)X) << (2 * componentLength)) | (((long)Y) << (1 * componentLength)) | (((long)Z) << (0 * componentLength)) ; - + if (subcommandLength < 6) { // The header will have some empty bits. The Huffman tag // computation will prevent this if necessary. @@ -316,7 +316,7 @@ class CompressionStreamVertex extends CompressionStreamElement { "fixed point " + d + + X + " " + Y + " " + Z + "\n" + "length " + length + " shift " + shift + (absolute? " absolute" : " relative") + "\n" + - "strip flag " + stripFlag + " mesh flag " + meshFlag + + "strip flag " + stripFlag + " mesh flag " + meshFlag + c + n ; } } diff --git a/src/classes/share/com/sun/j3d/utils/compression/GeometryCompressor.java b/src/classes/share/com/sun/j3d/utils/compression/GeometryCompressor.java index 2a59b0d..58ed898 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/GeometryCompressor.java +++ b/src/classes/share/com/sun/j3d/utils/compression/GeometryCompressor.java @@ -56,7 +56,7 @@ import javax.vecmath.Point3d; * of the Java 3D specification. The resulting data may be output * in the form of a CompressedGeometry node component or appended * to a CompressedGeometryFile. - * + * * @see CompressionStream * @see CompressedGeometry * @see CompressedGeometryFile @@ -75,7 +75,7 @@ public class GeometryCompressor { private long startTime ; public GeometryCompressor() { - // Create a compressed geometry header. + // Create a compressed geometry header. cgHeader = new CompressedGeometryHeader() ; // v1.0.0 - pre-FCS @@ -88,7 +88,7 @@ public class GeometryCompressor { /** * Compress a stream into a CompressedGeometry node component. - * + * * @param stream CompressionStream containing the geometry to be compressed * @return a CompressedGeometry node component */ @@ -155,11 +155,11 @@ public class GeometryCompressor { if (stream.vertexNormals) cgHeader.bufferDataPresent |= CompressedGeometryHeader.NORMAL_IN_BUFFER ; - + if (stream.vertexColor3 || stream.vertexColor4) cgHeader.bufferDataPresent |= CompressedGeometryHeader.COLOR_IN_BUFFER ; - + if (stream.vertexColor4) cgHeader.bufferDataPresent |= CompressedGeometryHeader.ALPHA_IN_BUFFER ; @@ -178,20 +178,20 @@ public class GeometryCompressor { int totalVertices = meshReferenceCount + vertexCount ; float meshPercent = 100f * meshReferenceCount/(float)totalVertices ; - float compressionRatio = + float compressionRatio = stream.getByteCount() / ((float)outputBuffer.getByteCount()) ; - int vertexBytes = + int vertexBytes = 12 + (stream.vertexColor3 ? 12 : 0) + (stream.vertexColor4 ? 16 : 0) + (stream.vertexNormals ? 12 : 0) ; float compressedVertexBytes = outputBuffer.getByteCount() / (float)totalVertices ; - + System.out.println ("\nGeometryCompressor:\n" + totalVertices + " total vertices\n" + vertexCount + " streamed vertices\n" + meshReferenceCount + - " mesh buffer references (" + meshPercent + "%)\n" + + " mesh buffer references (" + meshPercent + "%)\n" + stream.getByteCount() + " bytes streamed geometry compressed to " + outputBuffer.getByteCount() + " in " + (t/1000f) + " sec\n" + (stream.getByteCount()/(float)t) + " kbytes/sec, " + diff --git a/src/classes/share/com/sun/j3d/utils/compression/HuffmanNode.java b/src/classes/share/com/sun/j3d/utils/compression/HuffmanNode.java index 96efac3..0d33b6a 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/HuffmanNode.java +++ b/src/classes/share/com/sun/j3d/utils/compression/HuffmanNode.java @@ -168,7 +168,7 @@ class HuffmanNode { } else return false ; } - + int incrementLength() { if (shift > 0) shift-- ; diff --git a/src/classes/share/com/sun/j3d/utils/compression/HuffmanTable.java b/src/classes/share/com/sun/j3d/utils/compression/HuffmanTable.java index a610afb..d521809 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/HuffmanTable.java +++ b/src/classes/share/com/sun/j3d/utils/compression/HuffmanTable.java @@ -56,7 +56,7 @@ import java.util.ListIterator; * HuffmanNode objects. A HuffmanNode contains a tag describing the * associated token's data length, right shift value, and absolute/relative * status.

    - * + * * The tags are computed using Huffman's algorithm to build a binary tree with * a minimal total weighted path length. The frequency of each token is * used as its node's weight when building the tree. The path length from the @@ -82,7 +82,7 @@ class HuffmanTable { // lookup tables are therefore 2*17*16=544 entries in length to // account for all possible combinations of data lengths, shifts, // and relative or absolute status. - // + // colors = new HuffmanNode[544] ; positions = new HuffmanNode[544] ; @@ -264,7 +264,7 @@ class HuffmanTable { getEntries(normals, nodeList) ; computeTags(nodeList, 2) ; } - + // // Compute tags for a list of Huffman tokens. // @@ -305,7 +305,7 @@ class HuffmanTable { // Tokens need to be merged and the tree rebuilt with the new // combined frequencies. merge(nodes) ; - + } else { // Increase tag length + data length if they're too small. expand(nodes, minComponentCount) ; @@ -390,7 +390,7 @@ class HuffmanTable { // private void addNodeInOrder(LinkedList l, HuffmanNode node, Comparator c) { ListIterator i = l.listIterator(0) ; - + while (i.hasNext()) { HuffmanNode n = (HuffmanNode)i.next() ; if (c.compare(n, node) > 0) { @@ -423,7 +423,7 @@ class HuffmanTable { // // Output a setTable command for each unique token. - // + // private void outputCommands(Collection nodes, CommandStream output, int tableId) { diff --git a/src/classes/share/com/sun/j3d/utils/compression/MeshBuffer.java b/src/classes/share/com/sun/j3d/utils/compression/MeshBuffer.java index 39d77d4..0342a0b 100644 --- a/src/classes/share/com/sun/j3d/utils/compression/MeshBuffer.java +++ b/src/classes/share/com/sun/j3d/utils/compression/MeshBuffer.java @@ -54,11 +54,11 @@ import javax.vecmath.Vector3f; * compression semantics. */ class MeshBuffer { - // + // // The fixed-length mesh buffer stack is represented by circular buffers. // Three stack representations are provided: vertices, positions, and // indices. - // + // // The vertex representation stores references to CompressionStreamVertex // objects. The position representation stores references to Point3f, // Vector3f, Color3f, and Color4f objects, while the index representation diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Box.java b/src/classes/share/com/sun/j3d/utils/geometry/Box.java index 58ab0ca..2403111 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Box.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Box.java @@ -50,7 +50,7 @@ import javax.vecmath.*; /** * Box is a geometry primitive created with a given length, width, and height. - * It is centered at the origin. By default, it lies within the bounding + * It is centered at the origin. By default, it lies within the bounding * box, [-1,-1,-1] and [1,1,1]. * * When a texture is applied to a box, it is map CCW like on a Cylinder. @@ -119,11 +119,11 @@ public class Box extends Primitive { public static final int BOTTOM = 5; float xDim, yDim, zDim; - + int numTexUnit = 1; /** - * Constructs a default box of 1.0 in all dimensions. + * Constructs a default box of 1.0 in all dimensions. * Normals are generated by default, texture coordinates are not. */ @@ -132,7 +132,7 @@ public class Box extends Primitive { this(1.0f, 1.0f, 1.0f, GENERATE_NORMALS, null); } - /** + /** * Constructs a box of a given dimension and appearance. * Normals are generated by default, texture coordinates are not. * @@ -147,7 +147,7 @@ public class Box extends Primitive { this(xdim, ydim, zdim, GENERATE_NORMALS, ap); } - /** + /** * Constructs a box of a given dimension, flags, and appearance. * * @param xdim X-dimension size. @@ -156,7 +156,7 @@ public class Box extends Primitive { * @param primflags primitive flags. * @param ap Appearance */ - + public Box(float xdim, float ydim, float zdim, int primflags, Appearance ap, int numTexUnit) { int i; @@ -168,13 +168,13 @@ public class Box extends Primitive { flags = primflags; this.numTexUnit = numTexUnit; boolean texCoordYUp = (flags & GENERATE_TEXTURE_COORDS_Y_UP) != 0; - + //Depending on whether normal inward bit is set. if ((flags & GENERATE_NORMALS_INWARD) != 0) sign = -1.0; else sign = 1.0; - - + + // TransformGroup objTrans = new TransformGroup(); // objTrans.setCapability(ALLOW_CHILDREN_READ); // this.addChild(objTrans); @@ -182,7 +182,7 @@ public class Box extends Primitive { Shape3D shape[] = new Shape3D[6]; GeomBuffer cache = null; - + for (i = FRONT; i <= BOTTOM; i++){ cache = getCachedGeometry(Primitive.BOX, xdim, ydim, zdim, i, i, @@ -196,34 +196,34 @@ public class Box extends Primitive { else { GeomBuffer gbuf = new GeomBuffer(4, numTexUnit); - + gbuf.begin(GeomBuffer.QUAD_STRIP); for (int j = 0; j < 2; j++){ - gbuf.normal3d( (double) normals[i].x*sign, - (double) normals[i].y*sign, + gbuf.normal3d( (double) normals[i].x*sign, + (double) normals[i].y*sign, (double) normals[i].z*sign); if (texCoordYUp) { - gbuf.texCoord2d(tcoords[i*8 + j*2], 1.0 - tcoords[i*8 + j*2 + 1]); + gbuf.texCoord2d(tcoords[i*8 + j*2], 1.0 - tcoords[i*8 + j*2 + 1]); } else { gbuf.texCoord2d(tcoords[i*8 + j*2], tcoords[i*8 + j*2 + 1]); } - - gbuf.vertex3d( (double) verts[i*12 + j*3]*xdim, + + gbuf.vertex3d( (double) verts[i*12 + j*3]*xdim, (double) verts[i*12+ j*3 + 1]*ydim, (double) verts[i*12+ j*3 + 2]*zdim ); } for (int j = 3; j > 1; j--){ - gbuf.normal3d( (double) normals[i].x*sign, - (double) normals[i].y*sign, + gbuf.normal3d( (double) normals[i].x*sign, + (double) normals[i].y*sign, (double) normals[i].z*sign); if (texCoordYUp) { - gbuf.texCoord2d(tcoords[i*8 + j*2], 1.0 - tcoords[i*8 + j*2 + 1]); + gbuf.texCoord2d(tcoords[i*8 + j*2], 1.0 - tcoords[i*8 + j*2 + 1]); } else { gbuf.texCoord2d(tcoords[i*8 + j*2], tcoords[i*8 + j*2 + 1]); } - gbuf.vertex3d( (double) verts[i*12 + j*3]*xdim, + gbuf.vertex3d( (double) verts[i*12 + j*3]*xdim, (double) verts[i*12+ j*3 + 1]*ydim, (double) verts[i*12+ j*3 + 2]*zdim ); } @@ -250,13 +250,13 @@ public class Box extends Primitive { // objTrans.addChild(shape[i]); this.addChild(shape[i]); } - + if (ap == null){ setAppearance(); } else setAppearance(ap); } - + public Box(float xdim, float ydim, float zdim, int primflags, Appearance ap) { this(xdim, ydim, zdim, primflags, ap, 1); @@ -264,8 +264,8 @@ public class Box extends Primitive { /** * Gets one of the faces (Shape3D) from the box that contains the - * geometry and appearance. This allows users to modify the - * appearance or geometry of individual parts. + * geometry and appearance. This allows users to modify the + * appearance or geometry of individual parts. * @param partId The part to return. * @return The Shape3D object associated with the partID. If an * invalid partId is passed in, null is returned. @@ -277,14 +277,14 @@ public class Box extends Primitive { return (Shape3D)getChild(partId); return null; } - + /** * Sets appearance of the box. This will set each face of the - * box to the same appearance. To set each face's appearance + * box to the same appearance. To set each face's appearance * separately, use getShape(partId) to get the - * individual shape and call shape.setAppearance(ap). + * individual shape and call shape.setAppearance(ap). */ - + public void setAppearance(Appearance ap){ // ((Shape3D)((Group)getChild(0)).getChild(TOP)).setAppearance(ap); // ((Shape3D)((Group)getChild(0)).getChild(LEFT)).setAppearance(ap); @@ -348,7 +348,7 @@ public class Box extends Primitive { 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, }; - + private static final double[] tcoords = { // front 1.0, 0.0, @@ -381,8 +381,8 @@ public class Box extends Primitive { 1.0, 0.0, 1.0, 1.0 }; - - + + private static final Vector3f[] normals = { new Vector3f( 0.0f, 0.0f, 1.0f), // front face new Vector3f( 0.0f, 0.0f, -1.0f), // back face @@ -391,7 +391,7 @@ public class Box extends Primitive { new Vector3f( 0.0f, 1.0f, 0.0f), // top face new Vector3f( 0.0f, -1.0f, 0.0f), // bottom face }; - + /** * Used to create a new instance of the node. This routine is called diff --git a/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java b/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java index ef87122..4014607 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/ColorCube.java @@ -123,7 +123,7 @@ public class ColorCube extends Shape3D { * color cube are [-1,-1,-1] and [1,1,1]. */ public ColorCube() { - QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | + QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | QuadArray.COLOR_3); cube.setCoordinates(0, verts); @@ -141,7 +141,7 @@ public class ColorCube extends Shape3D { * @param scale the scale of the cube */ public ColorCube(double scale) { - QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | + QuadArray cube = new QuadArray(24, QuadArray.COORDINATES | QuadArray.COLOR_3); float scaledVerts[] = new float[verts.length]; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Cone.java b/src/classes/share/com/sun/j3d/utils/geometry/Cone.java index c438a80..d10355a 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Cone.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Cone.java @@ -90,10 +90,10 @@ public class Cone extends Primitive { */ public static final int CAP = 1; - /** + /** * Constructs a default Cone of radius of 1.0 and height * of 2.0. Resolution defaults to 15 divisions along X and axis - * and 1 along the Y axis. Normals are generated, texture + * and 1 along the Y axis. Normals are generated, texture * coordinates are not. */ public Cone(){ @@ -144,7 +144,7 @@ public class Cone extends Primitive { /** * Obtains the Shape3D node associated with one of the parts of the * cone (the body or the cap). This allows users to modify the appearance - * or geometry of individual parts. + * or geometry of individual parts. * @param partId The part to return (BODY or CAP). * @return The Shape3D object associated with the partId. If an * invalid partId is passed in, null is returned. @@ -182,9 +182,9 @@ public class Cone extends Primitive { } - /** + /** * Constructs a customized Cone of a given radius, height, flags, - * resolution (X and Y dimensions), and appearance. The + * resolution (X and Y dimensions), and appearance. The * resolution is defined in terms of number of subdivisions * along the object's X axis (width) and Y axis (height). More divisions * lead to finer tesselated objects. @@ -225,7 +225,7 @@ public class Cone extends Primitive { numTris += cache.getNumTris(); } else { - // the body of the cone consists of the top of the cone and if + // the body of the cone consists of the top of the cone and if // ydivisions is greater than 1, the body of the cone. gbuf = q.coneTop((double)(height/2.0 - height/ydivisions), (double)(radius/ydivisions), height/ydivisions, @@ -240,7 +240,7 @@ public class Cone extends Primitive { xdivision, ydivision, primflags, gbuf); } } - + // only need to add a body if the ydivisions is greater than 1 if (ydivisions > 1) { cache = getCachedGeometry(Primitive.CONE_DIVISIONS, radius, 0.0f, @@ -266,7 +266,7 @@ public class Cone extends Primitive { } } } - + if ((flags & ENABLE_APPEARANCE_MODIFY) != 0) { (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_READ); (shape[BODY]).setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); @@ -275,7 +275,7 @@ public class Cone extends Primitive { if ((flags & ENABLE_GEOMETRY_PICKING) != 0) { (shape[BODY]).setCapability(Shape3D.ALLOW_GEOMETRY_READ); } - + this.addChild(shape[BODY]); // Create bottom cap. @@ -321,9 +321,9 @@ public class Cone extends Primitive { objectMat.mul(objectMat, rotMat); t2.set(objectMat); */ - + this.addChild(shape[CAP]); - + if (ap == null){ setAppearance(); } diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Cylinder.java b/src/classes/share/com/sun/j3d/utils/geometry/Cylinder.java index 76f6cf9..92071b7 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Cylinder.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Cylinder.java @@ -53,7 +53,7 @@ import javax.vecmath.*; /** * Cylinder is a geometry primitive defined with a radius and a height. * It is a capped cylinder centered at the origin with its central axis - * aligned along the Y-axis. + * aligned along the Y-axis. *

    * When a texture is applied to a cylinder, the texture is applied to the * caps and the body different. A texture is mapped CCW from the back of the @@ -100,10 +100,10 @@ public class Cylinder extends Primitive{ */ public static final int BOTTOM = 2; - /** + /** * Constructs a default cylinder of radius of 1.0 and height - * of 2.0. Normals are generated by default, texture - * coordinates are not. Resolution defaults to 15 divisions + * of 2.0. Normals are generated by default, texture + * coordinates are not. Resolution defaults to 15 divisions * along X axis and 1 along the Y axis. */ public Cylinder() { @@ -123,7 +123,7 @@ public class Cylinder extends Primitive{ /** * Constructs a default cylinder of a given radius, height, and - * appearance. Normals are generated by default, texture + * appearance. Normals are generated by default, texture * coordinates are not. * @param radius Radius * @param height Height @@ -137,7 +137,7 @@ public class Cylinder extends Primitive{ /** * - * Constructs a default cylinder of a given radius, height, + * Constructs a default cylinder of a given radius, height, * primitive flags and appearance. * @param radius Radius * @param height Height @@ -152,7 +152,7 @@ public class Cylinder extends Primitive{ /** * Obtains the Shape3D node associated with a given part of the cylinder. * This allows users to modify the appearance or geometry - * of individual parts. + * of individual parts. * @param partId The part to return (BODY, TOP, or BOTTOM). * @return The Shape3D object associated with the partID. If an * invalid partId is passed in, null is returned. @@ -163,9 +163,9 @@ public class Cylinder extends Primitive{ } /** Sets appearance of the cylinder. This will set each part of the - * cylinder (TOP,BOTTOM,BODY) to the same appearance. To set each + * cylinder (TOP,BOTTOM,BODY) to the same appearance. To set each * part's appearance separately, use getShape(partId) to get the - * individual shape and call shape.setAppearance(ap). + * individual shape and call shape.setAppearance(ap). */ public void setAppearance(Appearance ap) { ((Shape3D)getChild(BODY)).setAppearance(ap); @@ -188,13 +188,13 @@ public class Cylinder extends Primitive{ return getShape(partId).getAppearance(); } - - /** + + /** * Constructs a customized cylinder of a given radius, height, - * resolution (X and Y dimensions), and appearance. The + * resolution (X and Y dimensions), and appearance. The * resolution is defined in terms of number of subdivisions * along the object's X axis (width) and Y axis (height). More divisions - * lead to more finely tesselated objects. + * lead to more finely tesselated objects. * @param radius Radius * @param height Height * @param xdivision Number of divisions along X direction. @@ -202,7 +202,7 @@ public class Cylinder extends Primitive{ * @param primflags Primitive flags. * @param ap Appearance */ - public Cylinder(float radius, float height, int primflags, + public Cylinder(float radius, float height, int primflags, int xdivision, int ydivision, Appearance ap) { super(); @@ -280,7 +280,7 @@ public class Cylinder extends Primitive{ if ((flags & ENABLE_GEOMETRY_PICKING) != 0) { (shape[TOP]).setCapability(Shape3D.ALLOW_GEOMETRY_READ); } - + this.addChild(shape[TOP]); // Create bottom diff --git a/src/classes/share/com/sun/j3d/utils/geometry/EarClip.java b/src/classes/share/com/sun/j3d/utils/geometry/EarClip.java index 21da0ec..67794a6 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/EarClip.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/EarClip.java @@ -130,7 +130,7 @@ class EarClip { } - /** + /** * This function checks whether a diagonal is valid, that is, whether it is * locally within the polygon, and whether it does not intersect any other * segment of the polygon. also, some degenerate cases get a special diff --git a/src/classes/share/com/sun/j3d/utils/geometry/EdgeTable.java b/src/classes/share/com/sun/j3d/utils/geometry/EdgeTable.java index 7d2fc20..625283a 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/EdgeTable.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/EdgeTable.java @@ -105,7 +105,7 @@ class EdgeTable { Iterator list = edgeTable.keySet().iterator(); while (list.hasNext()) { Edge edge = (Edge)list.next(); - System.out.println(" (" + edge.v1 + ", " + edge.v2 + ") = " + + System.out.println(" (" + edge.v1 + ", " + edge.v2 + ") = " + get(edge.v1, edge.v2)); } } diff --git a/src/classes/share/com/sun/j3d/utils/geometry/GeomBuffer.java b/src/classes/share/com/sun/j3d/utils/geometry/GeomBuffer.java index a68b8b8..b5eba47 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/GeomBuffer.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/GeomBuffer.java @@ -51,35 +51,35 @@ import javax.media.j3d.*; import javax.vecmath.*; import java.math.*; -/** - * GeomBuffer allows OpenGL-like input of geometry data. It outputs +/** + * GeomBuffer allows OpenGL-like input of geometry data. It outputs * Java 3D geometry array objects. This utility is to simplify porting - * of OpenGL programs to Java 3D. + * of OpenGL programs to Java 3D. *

    * Here is a sample code that use this utility to create some quads. *

    - * 
    + *
      *     GeomBuffer gbuf = new GeomBuffer(100);
      *     gbuf.begin(GeomBuffer.QUADS);
      *
      *     for (int i = 0; i < 5; i++){
      *       gbuf.normal3d(0.0, 1.0, 0.0);
      *       gbuf.vertex3d(1.0, 1.0, 0.0);
    - * 
    + *
      *       gbuf.normal3d(0.0, 1.0, 0.0);
      *       gbuf.vertex3d(0.0, 1.0, 0.0);
    - * 
    + *
      *       gbuf.normal3d(0.0, 1.0, 0.0);
      *       gbuf.vertex3d(0.0, 0.0, 0.0);
    - * 
    + *
      *       gbuf.normal3d(0.0, 1.0, 0.0);
      *       gbuf.vertex3d(1.0, 0.0, 0.0);
      *     }
      *     gbuf.end();
      *     Shape3D shape = new Shape3D(gbuf.getGeom(GeomBuffer.GENERATE_NORMALS));
      * 
    - * Notice, that you only need to specify some upperbound on the number of - * points you'll use at the beginning (100 in this case). + * Notice, that you only need to specify some upperbound on the number of + * points you'll use at the beginning (100 in this case). *

    * Currently, you are limited to one primitive type per geom buffer. Future * versions will add support for mixed primitive types. @@ -93,7 +93,7 @@ class GeomBuffer extends Object{ static final int TRIANGLES = 0x02; static final int QUADS = 0x04; static final int TRIANGLE_FAN = 0x10; - static final int TRIANGLE_STRIP = 0x20; + static final int TRIANGLE_STRIP = 0x20; private int flags; @@ -114,8 +114,8 @@ class GeomBuffer extends Object{ static final int debug = 0; - /** Creates a geometry buffer of given number of vertices - * @param numVerts total number of vertices to allocate by this buffer. + /** Creates a geometry buffer of given number of vertices + * @param numVerts total number of vertices to allocate by this buffer. * This is an upper bound estimate. */ GeomBuffer(int numVerts, int numTexUnit) @@ -132,12 +132,12 @@ class GeomBuffer extends Object{ currPrimCnt = 0; texCoordSetMap = new int[numTexUnit]; - for (int i = 0; i < numTexUnit; i++) + for (int i = 0; i < numTexUnit; i++) texCoordSetMap[i] = 0; } - GeomBuffer(int numVerts) + GeomBuffer(int numVerts) { this(numVerts, 1); } @@ -148,7 +148,7 @@ class GeomBuffer extends Object{ * * @param format vertex format. */ - + GeometryArray getGeom(int format) { GeometryArray obj = null; @@ -182,7 +182,7 @@ class GeomBuffer extends Object{ } - /** + /** * Begins a new primitive given the primitive type. * * @param prim the primitive type (listed above). @@ -197,7 +197,7 @@ class GeomBuffer extends Object{ } - /** + /** * End of primitive. * * @@ -208,17 +208,17 @@ class GeomBuffer extends Object{ currPrimEndVertex[currPrimCnt] = currVertCnt; currPrimCnt++; } - + void vertex3d(double x, double y, double z) { if (debug >= 2) System.out.println("v " + x + " " + - y + " " + + y + " " + z); pts[currVertCnt] = new Point3f((float)x, (float)y, (float)z); currVertCnt++; } - + void normal3d(double x, double y, double z) { if (debug >= 2) System.out.println("n " + x + " " + @@ -228,8 +228,8 @@ class GeomBuffer extends Object{ if (debug >= 2) System.out.println("normalizing"); double root = Math.sqrt(sum); if (root > 0.000001) { - x /= root; - y /= root; + x /= root; + y /= root; z /= root; } else { y = z = 0.0; x = 1.0; @@ -237,20 +237,20 @@ class GeomBuffer extends Object{ } normals[currVertCnt] = new Vector3f((float)x, (float)y, (float)z); } - + void texCoord2d(double s, double t) { - if (debug >= 2) System.out.println("t " + + if (debug >= 2) System.out.println("t " + s + " " + t); tcoords[currVertCnt] = new TexCoord2f((float)s, (float)t); } - + // Return a reference to the texture coordinates of this geom buffer. TexCoord2f[] getTexCoords() { return tcoords; } - + /** * Returns the Java 3D geometry gotten from calling getGeom. * @@ -260,17 +260,17 @@ class GeomBuffer extends Object{ { return geometry; } - + int getNumTris() - { + { return numTris; } int getNumVerts() - { + { return numVerts; } - + private GeometryArray processQuadStrips() { @@ -294,7 +294,7 @@ class GeomBuffer extends Object{ tsaFlags |= TriangleStripArray.TEXTURE_COORDINATE_2; // Create GeometryArray to pass back - obj = new TriangleStripArray(totalVerts, tsaFlags, + obj = new TriangleStripArray(totalVerts, tsaFlags, 1, texCoordSetMap, stripCounts); // Allocate space to store new vertex info @@ -302,7 +302,7 @@ class GeomBuffer extends Object{ Vector3f[] newnormals = new Vector3f[totalVerts]; TexCoord2f[] newtcoords = new TexCoord2f[totalVerts]; int currVert = 0; - + // Repeat for each Quad Strip for (i = 0; i < currPrimCnt; i++){ // Output order for these quad arrays same as java 3d triangle strips @@ -341,24 +341,24 @@ class GeomBuffer extends Object{ if (((flags & Primitive.GENERATE_NORMALS) != 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) != 0)){ obj = new QuadArray(totalVerts, - QuadArray.COORDINATES | + QuadArray.COORDINATES | QuadArray.NORMALS | - QuadArray.TEXTURE_COORDINATE_2, + QuadArray.TEXTURE_COORDINATE_2, 1, texCoordSetMap); } - else + else if (((flags & Primitive.GENERATE_NORMALS) == 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) != 0)){ obj = new QuadArray(totalVerts, - QuadArray.COORDINATES | - QuadArray.TEXTURE_COORDINATE_2, + QuadArray.COORDINATES | + QuadArray.TEXTURE_COORDINATE_2, 1, texCoordSetMap); } - else + else if (((flags & Primitive.GENERATE_NORMALS) != 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) == 0)){ obj = new QuadArray(totalVerts, - QuadArray.COORDINATES | + QuadArray.COORDINATES | QuadArray.NORMALS); } else { @@ -374,7 +374,7 @@ class GeomBuffer extends Object{ if (debug > 1) System.out.println("total prims " + currPrimCnt); for (i = 0; i < currPrimCnt; i++){ - if (debug > 1) System.out.println("start " + currPrimStartVertex[i] + + if (debug > 1) System.out.println("start " + currPrimStartVertex[i] + " end " + currPrimEndVertex[i]); for (int j = currPrimStartVertex[i]; j < currPrimEndVertex[i] - 3;j+=4){ outVertex(newpts, newnormals, newtcoords, currVert++, @@ -415,24 +415,24 @@ class GeomBuffer extends Object{ if (((flags & Primitive.GENERATE_NORMALS) != 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) != 0)){ obj = new TriangleArray(totalVerts, - TriangleArray.COORDINATES | + TriangleArray.COORDINATES | TriangleArray.NORMALS | TriangleArray.TEXTURE_COORDINATE_2, 1, texCoordSetMap); } - else + else if (((flags & Primitive.GENERATE_NORMALS) == 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) != 0)){ obj = new TriangleArray(totalVerts, - TriangleArray.COORDINATES | + TriangleArray.COORDINATES | TriangleArray.TEXTURE_COORDINATE_2, 1, texCoordSetMap); } - else + else if (((flags & Primitive.GENERATE_NORMALS) != 0) && ((flags & Primitive.GENERATE_TEXTURE_COORDS) == 0)){ obj = new TriangleArray(totalVerts, - TriangleArray.COORDINATES | + TriangleArray.COORDINATES | TriangleArray.NORMALS); } else { @@ -444,7 +444,7 @@ class GeomBuffer extends Object{ Vector3f[] newnormals = new Vector3f[totalVerts]; TexCoord2f[] newtcoords = new TexCoord2f[totalVerts]; int currVert = 0; - + for (i = 0; i < currPrimCnt; i++){ for (int j = currPrimStartVertex[i]; j < currPrimEndVertex[i] - 2;j+=3){ outVertex(newpts, newnormals, newtcoords, currVert++, @@ -507,7 +507,7 @@ class GeomBuffer extends Object{ // repeat for each fan for (i = 0; i < currPrimCnt; i++) { for (int j = currPrimStartVertex[i]; j < currPrimEndVertex[i]; j++) { - outVertex(newpts, newnormals, newtcoords, currVert++, pts, + outVertex(newpts, newnormals, newtcoords, currVert++, pts, normals, tcoords, j); } } @@ -517,7 +517,7 @@ class GeomBuffer extends Object{ } numVerts = currVert; - numTris = totalVerts - currPrimCnt * 2; + numTris = totalVerts - currPrimCnt * 2; // set the coordinates on the GeometryArray obj.setCoordinates(0, newpts); @@ -541,7 +541,7 @@ class GeomBuffer extends Object{ int sloc) { if (debug >= 1) System.out.println("v " + spts[sloc].x + " " + - spts[sloc].y + " " + + spts[sloc].y + " " + spts[sloc].z); // PSP: Do we really need new points here? diff --git a/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfo.java b/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfo.java index b69dead..7a51f03 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfo.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfo.java @@ -61,12 +61,12 @@ import javax.media.j3d.J3DBuffer; /** * The GeometryInfo object holds data for processing by the Java3D geometry * utility tools.

    - * + * * The NormalGenerator adds normals to geometry without normals.

    - * + * * The Stripifier combines adjacent triangles into triangle strips for * more efficent rendering.

    - * + * * Also, the GeometryCompressor can take a set of GeometryInfo objects in a * CompressionSteam and generate a CompressedGeometry object from the * geometry.

    @@ -117,7 +117,7 @@ import javax.media.j3d.J3DBuffer; * st.stripify(gi); * GeometryArray result = gi.getGeometryArray(); *

  • - * + * * @see NormalGenerator * @see Stripifier * @see com.sun.j3d.utils.compression.CompressionStream @@ -158,7 +158,7 @@ public class GeometryInfo { * possibly multi-contour, possible non-planar polygons. * The stripCounts array indicates how many vertices to use * for each contour, and the contourCounts array indicates how many - * stripCounts entries to use for each polygon. The first + * stripCounts entries to use for each polygon. The first * contour is the bounding polygon, and subsequent contours are * "holes." If contourCounts is left null, the default is * one contour per polygon. @@ -166,15 +166,15 @@ public class GeometryInfo { public static final int POLYGON_ARRAY = 5; private int prim; - + // 1 Show indexification details private static final int DEBUG = 0; - + private Point3f coordinates[] = null; private Color3f colors3[] = null; private Color4f colors4[] = null; private Vector3f normals[] = null; - private Object texCoordSets[][] = null; + private Object texCoordSets[][] = null; private int coordinateIndices[] = null; private int colorIndices[] = null; @@ -184,7 +184,7 @@ public class GeometryInfo { private int[] texCoordSetMap = null; private int texCoordSetCount = 0; private int texCoordDim = 0; - + private int stripCounts[] = null; private int contourCounts[] = null; @@ -200,11 +200,11 @@ public class GeometryInfo { /** * Constructor. - * Creates an empty GeometryInfo object. + * Creates an empty GeometryInfo object. * @param primitive Tells the GeometryInfo object the type of * primitive data to be stored * in it, so it will know the format of the data. It can be one of - * TRIANGLE_ARRAY, + * TRIANGLE_ARRAY, * QUAD_ARRAY, TRIANGLE_FAN_ARRAY, TRIANGLE_STRIP_ARRAY, or POLYGON_ARRAY. */ public GeometryInfo(int primitive) @@ -222,7 +222,7 @@ public class GeometryInfo { /** * Contructor. Populates the GeometryInfo with the geometry from * the GeometryArray.

    - * If the GeometryArray uses the Initial and + * If the GeometryArray uses the Initial and * Valid GeometryArray methods ( * setInitialVertexIndex() and setValidVertexCount() * and their cousins) then only the needed geometry @@ -252,22 +252,22 @@ public class GeometryInfo { throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo0")); } - + coordinates = null; colors3 = null; colors4 = null; normals = null; - + coordinateIndices = null; colorIndices = null; normalIndices = null; - + stripCounts = null; contourCounts = null; - + oldPrim = 0; oldStripCounts = null; - + texCoordDim = 0; texCoordSetCount = 0; texCoordSets = null; @@ -275,7 +275,7 @@ public class GeometryInfo { texCoordSetMap = null; coordOnly = false; - + } // End of reset(int) @@ -297,7 +297,7 @@ public class GeometryInfo { private int[] expandQuad(int indices[]) { int triangles[] = new int[indices.length / 4 * 6]; - + for (int i = 0 ; i < indices.length / 4 ; i++ ) { triangles[i * 6 + 0] = indices[i * 4]; triangles[i * 6 + 1] = indices[i * 4 + 1]; @@ -306,7 +306,7 @@ public class GeometryInfo { triangles[i * 6 + 4] = indices[i * 4 + 2]; triangles[i * 6 + 5] = indices[i * 4 + 3]; } - + return triangles; } // End of expandQuad @@ -339,12 +339,12 @@ public class GeometryInfo { private int[] expandTriStrip(int numTris, int indices[]) { int triangles[] = new int[numTris * 3]; - + int p = 0; int base = 0; for (int s = 0 ; s < stripCounts.length ; s++) { for (int t = 0 ; t < stripCounts[s] - 2 ; t++) { - + // Use a ping-ponging algorithm to reverse order on every other // triangle to preserve winding if (t % 2 == 0) { @@ -359,7 +359,7 @@ public class GeometryInfo { } base += stripCounts[s]; } - + return triangles; } // End of expandTriStrip @@ -367,7 +367,7 @@ public class GeometryInfo { // Used by the NormalGenerator utility. Informs the GeometryInfo object // to remember its current primitive and stripCounts arrays so that - // they can be used to convert the object back to its original + // they can be used to convert the object back to its original // primitive void rememberOldPrim() { @@ -438,16 +438,16 @@ public class GeometryInfo { public void convertToIndexedTriangles() { int triangles = 0; - + // This calls checkForBadData indexify(); - + if (prim == TRIANGLE_ARRAY) return; - + switch(prim) { - + case QUAD_ARRAY: - + coordinateIndices = expandQuad(coordinateIndices); if (colorIndices != null) colorIndices = expandQuad(colorIndices); if (normalIndices != null) @@ -455,45 +455,45 @@ public class GeometryInfo { for (int i = 0 ; i < texCoordSetCount ; i++) texCoordIndexSets[i] = expandQuad(texCoordIndexSets[i]); break; - + case TRIANGLE_FAN_ARRAY: // Count how many triangles are in the object for (int i = 0 ; i < stripCounts.length ; i++) { triangles += stripCounts[i] - 2; } - + coordinateIndices = expandTriFan(triangles, coordinateIndices); if (colorIndices != null) colorIndices = expandTriFan(triangles, colorIndices); if (normalIndices != null) normalIndices = expandTriFan(triangles, normalIndices); for (int i = 0 ; i < texCoordSetCount ; i++) - texCoordIndexSets[i] = expandTriFan(triangles, + texCoordIndexSets[i] = expandTriFan(triangles, texCoordIndexSets[i]); break; - + case TRIANGLE_STRIP_ARRAY: // Count how many triangles are in the object for (int i = 0 ; i < stripCounts.length ; i++) { triangles += stripCounts[i] - 2; } - + coordinateIndices = expandTriStrip(triangles, coordinateIndices); if (colorIndices != null) colorIndices = expandTriStrip(triangles, colorIndices); if (normalIndices != null) normalIndices = expandTriStrip(triangles, normalIndices); for (int i = 0 ; i < texCoordSetCount ; i++) - texCoordIndexSets[i] = expandTriStrip(triangles, + texCoordIndexSets[i] = expandTriStrip(triangles, texCoordIndexSets[i]); break; - + case POLYGON_ARRAY: if (tr == null) tr = new Triangulator(); tr.triangulate(this); break; } - + prim = TRIANGLE_ARRAY; stripCounts = null; } // End of convertToIndexedTriangles @@ -516,7 +516,7 @@ public class GeometryInfo { * Set the current primitive. Some of the utilities may change the * primitive type of the data stored in the GeometryInfo object * (for example, the stripifyer will change it to TRIANGLE_STRIP_ARRAY). - * But the user can't change the primitive type - it is set in the + * But the user can't change the primitive type - it is set in the * constructor. Therefore, this method has package scope. */ void setPrimitive(int primitive) @@ -532,7 +532,7 @@ public class GeometryInfo { /** - * Sets the coordinates array. + * Sets the coordinates array. * No data copying is done because a reference to user data is used. */ public void setCoordinates(Point3f coordinates[]) @@ -607,7 +607,7 @@ public class GeometryInfo { { return coordinates; } // End of getCoordinates - + /** @@ -620,7 +620,7 @@ public class GeometryInfo { colors3 = colors; colors4 = null; } // End of setColors - + /** @@ -633,7 +633,7 @@ public class GeometryInfo { colors3 = null; colors4 = colors; } // End of setColors - + /** @@ -655,7 +655,7 @@ public class GeometryInfo { } } } // End of setColors - + /** @@ -678,7 +678,7 @@ public class GeometryInfo { } } } // End of setColors - + /** @@ -701,7 +701,7 @@ public class GeometryInfo { } } } // End of setColors3 - + /** @@ -725,7 +725,7 @@ public class GeometryInfo { } } } // End of setColors4 - + /** @@ -847,17 +847,17 @@ public class GeometryInfo { /** - * This method is used to specify the number of texture coordinate sets + * This method is used to specify the number of texture coordinate sets * and the dimensionality of the texture coordinates. * The number of texture coordinate sets must be specified to the GeometryInfo - * class before any of the sets are specified. The dimensionality of the - * texture coordinates may be 2, 3, or 4, corresponding to 2D, 3D, or 4D - * texture coordinates respectively.(All sets must have the same - * dimensionality.) The default is zero, 2D texture coordinate sets. - * This method should be called before any texture coordinate sets are + * class before any of the sets are specified. The dimensionality of the + * texture coordinates may be 2, 3, or 4, corresponding to 2D, 3D, or 4D + * texture coordinates respectively.(All sets must have the same + * dimensionality.) The default is zero, 2D texture coordinate sets. + * This method should be called before any texture coordinate sets are * specified because calling this method will delete all previously - * specified texture coordinate and texture coordinate index arrays - * associated with this GeometryInfo. For example: + * specified texture coordinate and texture coordinate index arrays + * associated with this GeometryInfo. For example: *

        *	geomInfo.setTextureCoordinateParams(2, 3);
        *	geomInfo.setTextureCoordinates(0, tex0);
    @@ -865,14 +865,14 @@ public class GeometryInfo {
        *	geomInfo.setTextureCoordinateParams(1, 2);
        *	geomInfo.getTexCoordSetCount();
        * 
    - * The second call to setTextureCoordinateParams will erase all + * The second call to setTextureCoordinateParams will erase all * the texture coordinate arrays, so the subsequent call to * getTexCoordSetCount will return 1. - * @param numSets The number of texture coordinate sets that will be + * @param numSets The number of texture coordinate sets that will be * specified for this GeometryInfo object. - * @param dim The dimensionality of the texture coordinates. Has to be 2, 3 + * @param dim The dimensionality of the texture coordinates. Has to be 2, 3 * or 4. - * @throws IllegalArgumentException if the dimensionality of the texture + * @throws IllegalArgumentException if the dimensionality of the texture * coordinates is not one of 2, 3 or 4. */ public void setTextureCoordinateParams(int numSets, int dim) @@ -891,7 +891,7 @@ public class GeometryInfo { texCoordDim = dim; texCoordSetCount = numSets; } // End of setTextureCoordinateParams - + /** @@ -916,7 +916,7 @@ public class GeometryInfo { * Returns the number of texture coordinate components that are stored * per vertex. Returns 2 for ST (2D), 3 for STR (3D), * or 4 for STRQ (4D), aslo known as the "dimensionality" of the - * coordinates. This value is set with + * coordinates. This value is set with * setTextureCoordinateParams(). If setTextureCoordinateParams() * has not been called, 0 is returned unless one of the deprecated * texture coordinate methods has been called. Calling one of the @@ -935,12 +935,12 @@ public class GeometryInfo { /** * Sets the mapping between texture coordinate sets and texture units. - * See the + * See the * * GeometryArray constructor for further details. - *

    Note: If the texCoordSetMap is not set, multi-texturing is - * turned off. Only the texture coordinate set at index 0 (if set) will be - * used. Any other sets specified by the GeometryInfo.setTextureCoordinate* + *

    Note: If the texCoordSetMap is not set, multi-texturing is + * turned off. Only the texture coordinate set at index 0 (if set) will be + * used. Any other sets specified by the GeometryInfo.setTextureCoordinate* * methods will be ignored. */ public void setTexCoordSetMap(int map[]) { @@ -951,20 +951,20 @@ public class GeometryInfo { /** * Returns a reference to the texture coordinate set map. - * See the + * See the * * GeometryArray constructor for further details. */ public int[] getTexCoordSetMap() { return texCoordSetMap; } - + /** * Sets the 2D texture coordinates for the specified set. - * No data copying is done - a reference to user data is used. - * @param texCoordSet The texture coordinate set for which these + * No data copying is done - a reference to user data is used. + * @param texCoordSet The texture coordinate set for which these * coordinates are being specified. * @param texCoords Array of 2D texture coordinates. * @throws IllegalArgumentException if texCoordSet < 0 or @@ -983,8 +983,8 @@ public class GeometryInfo { texCoordSets[texCoordSet] = texCoords; } // End of setTextureCoordinates(int, TexCoord3f[]) - - + + /** * Sets the TextureCoordinates array by copying the data @@ -992,7 +992,7 @@ public class GeometryInfo { * This method sets the number of texture coordinate sets to 1, * sets the dimensionality of the texture coordinates to 2, * and sets the coordinates for texture coordinate set 0. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * setTextureCoordinates(int texCoordSet, TexCoord2f coords[]) */ public void setTextureCoordinates(Point2f texCoords[]) @@ -1002,18 +1002,18 @@ public class GeometryInfo { texCoordSets = new TexCoord2f[1][]; if (texCoords != null) { TexCoord2f[] tex = new TexCoord2f[texCoords.length]; - for (int i = 0 ; i < texCoords.length ; i++) + for (int i = 0 ; i < texCoords.length ; i++) tex[i] = new TexCoord2f(texCoords[i]); texCoordSets[0] = tex; } } // End of setTextureCoordinates(Point2f[]) - + /** * Sets the texture coordinates array for the specified set. - * No data copying is done - a reference to user data is used. - * @param texCoordSet The texture coordinate set for which these coordinates + * No data copying is done - a reference to user data is used. + * @param texCoordSet The texture coordinate set for which these coordinates * are being specified. * @param texCoords Array of 3D texture coordinates. * @throws IllegalArgumentException if texCoordSet < 0 or @@ -1029,7 +1029,7 @@ public class GeometryInfo { if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0)) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo18")); - + texCoordSets[texCoordSet] = texCoords; } // End of setTextureCoordinates(int, TexCoord3f[]) @@ -1041,7 +1041,7 @@ public class GeometryInfo { * This method sets the number of texture coordinate sets to 1, * sets the dimensionality of the texture coordinates to 3, * and sets the coordinates for texture coordinate set 0. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * setTextureCoordinates(int texCoordSet, TexCoord3f coords[]) */ public void setTextureCoordinates(Point3f texCoords[]) @@ -1051,18 +1051,18 @@ public class GeometryInfo { texCoordSets = new TexCoord3f[1][]; if (texCoords != null) { TexCoord3f[] tex = new TexCoord3f[texCoords.length]; - for (int i = 0 ; i < texCoords.length ; i++) + for (int i = 0 ; i < texCoords.length ; i++) tex[i] = new TexCoord3f(texCoords[i]); texCoordSets[0] = tex; } } // End of setTextureCoordinates(Point3f[]) - + /** * Sets the texture coordinates array for the specified set. - * No data copying is done - a reference to user data is used. - * @param texCoordSet The texture coordinate set for which these coordinates + * No data copying is done - a reference to user data is used. + * @param texCoordSet The texture coordinate set for which these coordinates * are being specified. * @param texCoords Array of 4D texture coordinates. * @throws IllegalArgumentException if texCoordSet < 0 or @@ -1077,20 +1077,20 @@ public class GeometryInfo { if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0)) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo18")); - + texCoordSets[texCoordSet] = texCoords; } // End of setTextureCoordinates(int, TexCoord4f[]) - + /** * Sets the texture coordinates array by copying the data into the * GeometryInfo object. The number of sets and dimensionality of - * the sets must have been set previously with + * the sets must have been set previously with * setTextureCoordinateParams(texCoordSetCount, dim). - * @param texCoordSet The texture coordinate set for which these coordinates + * @param texCoordSet The texture coordinate set for which these coordinates * are being specified. - * @param texCoords The float array of texture coordinates. For n texture + * @param texCoords The float array of texture coordinates. For n texture * coordinates with dimensionality d, there must be d*n floats in the array. * @throws IllegalArgumentException if texCoordSet < 0 or * texCoordSet >= texCoordSetCount, @@ -1102,24 +1102,24 @@ public class GeometryInfo { if ((texCoords.length % texCoordDim) != 0) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo2")); - + // Copy the texCoords into this GeometryInfo object if (texCoordDim == 2) { TexCoord2f tcoords[] = new TexCoord2f[texCoords.length / 2]; - for (int i = 0 ; i < tcoords.length ; i++) + for (int i = 0 ; i < tcoords.length ; i++) tcoords[i] = new TexCoord2f(texCoords[i * 2], texCoords[i * 2 + 1]); setTextureCoordinates(texCoordSet, tcoords); } else if (texCoordDim == 3) { TexCoord3f tcoords[] = new TexCoord3f[texCoords.length / 3]; - for (int i = 0 ; i < tcoords.length ; i++) + for (int i = 0 ; i < tcoords.length ; i++) tcoords[i] = new TexCoord3f(texCoords[i * 3], texCoords[i * 3 + 1], texCoords[i * 3 + 2]); setTextureCoordinates(texCoordSet, tcoords); } else if (texCoordDim == 4) { TexCoord4f tcoords[] = new TexCoord4f[texCoords.length / 4]; - for (int i = 0 ; i < tcoords.length ; i++) + for (int i = 0 ; i < tcoords.length ; i++) tcoords[i] = new TexCoord4f(texCoords[i * 4], texCoords[i * 4 + 1], texCoords[i * 4 + 2], @@ -1140,7 +1140,7 @@ public class GeometryInfo { * This method sets the number of texture coordinate sets to 1, * sets the dimensionality of the texture coordinates to 2, * and sets the coordinates for texture coordinate set 0. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * setTextureCoordinates(int texCoordSet, float texCoords[]) */ public void setTextureCoordinates2(float texCoords[]) @@ -1150,7 +1150,7 @@ public class GeometryInfo { texCoordSets = new TexCoord2f[1][]; setTextureCoordinates(0, texCoords); } // End of setTextureCoordinates2(float[]) - + /** @@ -1160,7 +1160,7 @@ public class GeometryInfo { * This method sets the number of texture coordinate sets to 1, * sets the dimensionality of the texture coordinates to 3, * and sets the coordinates for texture coordinate set 0. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * setTextureCoordinates(int texCoordSet, float texCoords[]) */ public void setTextureCoordinates3(float texCoords[]) @@ -1176,9 +1176,9 @@ public class GeometryInfo { /** * Returns a reference to the indicated texture coordinate array. * The return type will be TexCoord2f[], TexCoord3f[] - * , or TexCoord4f[] depending on the + * , or TexCoord4f[] depending on the * current dimensionality of the texture coordinates in the GeometryInfo - * object. Use getNumTexCoordComponents() to find out which + * object. Use getNumTexCoordComponents() to find out which * version is returned. * @param texCoordSet The index of the texture coordinate set to * retrieve. @@ -1193,30 +1193,30 @@ public class GeometryInfo { J3dUtilsI18N.getString("GeometryInfo18")); return texCoordSets[texCoordSet]; } // End of getTextureCoordinates(int) - - + + /** * Retrieves a reference to texture coordinate set 0. * The return type will be TexCoord2f[], TexCoord3f[] - * , or TexCoord4f[] depending on the + * , or TexCoord4f[] depending on the * current dimensionality of the texture coordinates in the GeometryInfo - * object. Use getNumTexCoordComponents() to find out which + * object. Use getNumTexCoordComponents() to find out which * version is returned. Equivalent to getTextureCoordinates(0). * @return An array of texture coordinates for set 0. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * getTextureCoordinates(int texCoordSet) */ public Object[] getTextureCoordinates() { return texCoordSets[0]; } // End of getTextureCoordinates() - + /** * Sets the array of indices into the Coordinate array. - * No data copying is done - a reference to user data is used. + * No data copying is done - a reference to user data is used. */ public void setCoordinateIndices(int coordinateIndices[]) { @@ -1247,7 +1247,7 @@ public class GeometryInfo { * primitive type when creating the GeometryArray object to pass * back. However, if your creaseAngle was not Math.PI (no creases - * smooth shading), then the introduction of - * creases into your model may have split primitives, lengthening + * creases into your model may have split primitives, lengthening * the StripCounts and index arrays from your original data. */ public int[] getCoordinateIndices() @@ -1259,7 +1259,7 @@ public class GeometryInfo { /** * Sets the array of indices into the Color array. - * No data copying is done - a reference to user data is used. + * No data copying is done - a reference to user data is used. */ public void setColorIndices(int colorIndices[]) { @@ -1302,12 +1302,12 @@ public class GeometryInfo { /** * Sets the array of indices into the Normal array. - * No data copying is done - a reference to user data is used. + * No data copying is done - a reference to user data is used. */ public void setNormalIndices(int normalIndices[]) { this.normalIndices = normalIndices; - + } // End of setNormalIndices @@ -1341,15 +1341,15 @@ public class GeometryInfo { { return normalIndices; } // End of getNormalIndices - + /** * Sets one of the texture coordinate index arrays. - * No data copying is done - a reference to user data is used. - * @param texCoordSet The texture coordinate set for which these coordinate + * No data copying is done - a reference to user data is used. + * @param texCoordSet The texture coordinate set for which these coordinate * indices are being specified. - * @param texIndices The integer array of indices into the specified texture + * @param texIndices The integer array of indices into the specified texture * coordinate set * @throws IllegalArgumentException If texCoordSet < 0 or * texCoordSet >= texCoordSetCount. @@ -1359,8 +1359,8 @@ public class GeometryInfo { if ((texCoordSet >= texCoordSetCount) || (texCoordSet < 0)) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo18")); - - // Texture coordinates are indexed + + // Texture coordinates are indexed texCoordIndexSets[texCoordSet] = texIndices; } // End of setTextureCoordinateIndices(int, int[]) @@ -1371,13 +1371,13 @@ public class GeometryInfo { * call this method if you are using more than one set of texture * coordinates. * No data is copied - a reference to the user data is used. - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * setTextureCoordinateIndices(int texCoordSet, int indices[]) * @throws IllegalArgumentException If texCoordSetCount > 1. */ public void setTextureCoordinateIndices(int texIndices[]) { - if (texCoordSetCount > 1) + if (texCoordSetCount > 1) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo1")); texCoordIndexSets = new int[1][]; @@ -1424,7 +1424,7 @@ public class GeometryInfo { * Returns a reference to texture coordinate index set 0. * Equivalent to * getTextureCoordinateIndices(0). - * @deprecated As of Java 3D 1.3 replaced by + * @deprecated As of Java 3D 1.3 replaced by * int[] getTextureCoordinateIndices(int texCoordSet) * @return Integer array of the texture coordinate indices for set 0 */ @@ -1433,14 +1433,14 @@ public class GeometryInfo { if (texCoordIndexSets == null) return null; return texCoordIndexSets[0]; } // End of getTextureCoordinateIndices() - - + + /** * Sets the array of strip counts. If index lists have been set for * this GeomteryInfo object then the data is indexed and the stripCounts * are like stripIndexCounts. If no index lists have been set then - * the data is non-indexed and the stripCounts are like + * the data is non-indexed and the stripCounts are like * stripVertexCounts. * @see GeometryStripArray#GeometryStripArray(int, int, * int[] stripVertexCounts) @@ -1451,7 +1451,7 @@ public class GeometryInfo { { this.stripCounts = stripCounts; } // End of setStripCounts - + /** @@ -1482,13 +1482,13 @@ public class GeometryInfo { { return stripCounts; } // End of getStripCounts - + /** * Sets the list of contour counts. Only used with the POLYGON_ARRAY - * primitive. Polygons can be made of several vertex lists - * called contours. The first list is the polygon, and + * primitive. Polygons can be made of several vertex lists + * called contours. The first list is the polygon, and * subsequent lists are "holes" that are removed from the * polygon. All of the holes must be contained entirely * within the polygon. @@ -1517,30 +1517,30 @@ public class GeometryInfo { { // Create list of indices to return int indices[] = new int[list.length]; - + // Create hash table with initial capacity equal to the number // of components (assuming about half will be duplicates) HashMap table = new HashMap(list.length); - + Integer idx; for (int i = 0 ; i < list.length ; i++) { - + // Find index associated with this object idx = (Integer)table.get(list[i]); - + if (idx == null) { // We haven't seen this object before indices[i] = i; - + // Put into hash table and remember the index table.put(list[i], new Integer(i)); - + } else { // We've seen this object indices[i] = idx.intValue(); } } - + return indices; } // End of getListIndices @@ -1585,7 +1585,7 @@ public class GeometryInfo { val = new int[size]; } // End of IndexRow constructor } // End of class IndexRow - + /** @@ -1676,7 +1676,7 @@ public class GeometryInfo { newTexCoordSets[i] = new TexCoord4f[ir.length]; } } - + // Copy data into new arrays n = ir.length; for (int i = 0 ; i < n ; i++) { @@ -1733,12 +1733,12 @@ public class GeometryInfo { if (coordinateIndices != null) return; coordinateIndices = getListIndices(coordinates); - + if (colors3 != null) colorIndices = getListIndices(colors3); else if (colors4 != null) colorIndices = getListIndices(colors4); - + if (normals != null) normalIndices = getListIndices(normals); - + texCoordIndexSets = new int[texCoordSetCount][]; for(int i = 0 ; i < texCoordSetCount ; i++) { texCoordIndexSets[i] = getListIndices(texCoordSets[i]); @@ -1746,7 +1746,7 @@ public class GeometryInfo { coordOnly = false; } - + if ((DEBUG & 1) == 1) { System.out.println("Coordinate Array:"); for (int i = 0 ; i < coordinates.length ; i++) { @@ -1758,7 +1758,7 @@ public class GeometryInfo { System.out.println(" " + i + " " + coordinateIndices[i]); } } - + } // End of indexify @@ -1767,22 +1767,22 @@ public class GeometryInfo { { indexify(false); } // End of indexify() - + /** - * Allocates an array of the same type as the input type. This allows us to + * Allocates an array of the same type as the input type. This allows us to * use a generic compactData method. * * @param data Array of coordinate, color, normal or texture coordinate data - * The data can be in one of the following formats - Point3f, Color3f, + * The data can be in one of the following formats - Point3f, Color3f, * Color4f, TexCoord2f, TexCoord3f, TexCoord4f. * * @param num The size of the array to be allocated * - * @return An array of size num of the same type as the input type + * @return An array of size num of the same type as the input type * - * @exception IllegalArgumentException if the input array is not one of the + * @exception IllegalArgumentException if the input array is not one of the * types listed above. */ Object[] allocateArray(Object data[], int num) { @@ -1808,23 +1808,23 @@ public class GeometryInfo { J3dUtilsI18N.getString("GeometryInfo9")); return newData; } // End of allocateArray - + /** * Generic method that compacts (ie removes unreferenced/duplicate data) - * any type of indexed data. + * any type of indexed data. * Used to compact coordinate, color, normal and texture coordinate data. * @param indices Array of indices * @param data Array of coordinate, color, normal or texture coordinate data - * The data can be in one of the following formats - Point3f, Color3f, - * Color4f, TexCoord2f, TexCoord3f, TexCoord4f. + * The data can be in one of the following formats - Point3f, Color3f, + * Color4f, TexCoord2f, TexCoord3f, TexCoord4f. * @param newInd The new array of indexes after the data has been compacted. - * This must be allocated by the calling method. On return, this array will - * contain the new index data. The size of this array must be equal to + * This must be allocated by the calling method. On return, this array will + * contain the new index data. The size of this array must be equal to * indices.length - * @return Array of the data with unreferenced and duplicate entries removed. - * The return type will be the same as the type that was passed in data. + * @return Array of the data with unreferenced and duplicate entries removed. + * The return type will be the same as the type that was passed in data. */ // TODO: Remove duplicate entries in data lists. private Object[] compactData(int indices[], Object data[], int newInd[]) { @@ -1838,7 +1838,7 @@ public class GeometryInfo { int translationTable[] = new int[data.length]; for (int i = 0 ; i < indices.length ; i++) { if (translationTable[indices[i]] == 0) { - + numUnique++; translationTable[indices[i]] = 1; } @@ -1865,11 +1865,11 @@ public class GeometryInfo { } // End of compactData - + /** * Remove unused data from an indexed dataset. * Indexed data may contain data entries that are never referenced by - * the dataset. This routine will remove those entries where + * the dataset. This routine will remove those entries where * appropriate and renumber the indices to match the new values. * @throws IllegalArgumentException if coordinate data is missing, * if the index lists aren't all the @@ -1899,9 +1899,9 @@ public class GeometryInfo { if (colorIndices != null) { newInd = new int[colorIndices.length]; - if (colors3 != null) + if (colors3 != null) colors3 = (Color3f[])compactData(colorIndices, colors3, newInd); - else if (colors4 != null) + else if (colors4 != null) colors4 = (Color4f[])compactData(colorIndices, colors4, newInd); colorIndices = newInd; } @@ -1935,7 +1935,7 @@ public class GeometryInfo { throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo3")); } - + // // Check for indices with no data // @@ -1945,7 +1945,7 @@ public class GeometryInfo { if ((normals == null) && (normalIndices != null)) throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo11")); - + // // Make sure all TextureCoordinate data is set (indices or not) // @@ -1954,7 +1954,7 @@ public class GeometryInfo { throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo10")); } - + // // Check for Missing Index lists // @@ -1991,10 +1991,10 @@ public class GeometryInfo { // if ((coordinateIndices != null) && (!coordOnly)) { if (((colors3 != null) || (colors4 != null)) && - (colorIndices.length != coordinateIndices.length)) + (colorIndices.length != coordinateIndices.length)) badData = true; else if ((normals != null) && - (normalIndices.length != coordinateIndices.length)) + (normalIndices.length != coordinateIndices.length)) badData = true; else { //Check all texCoord indices have the same length @@ -2010,7 +2010,7 @@ public class GeometryInfo { J3dUtilsI18N.getString("GeometryInfo5")); } } - + // // For stripped primitives, make sure we have strip counts // @@ -2023,12 +2023,12 @@ public class GeometryInfo { throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfo6")); } - + // Find out how much data we have int count; if (coordinateIndices == null) count = coordinates.length; else count = coordinateIndices.length; - + // // Make sure sum of strip counts equals indexCount (or vertexCount) // and check to make sure triangles and quads have the right number @@ -2048,22 +2048,22 @@ public class GeometryInfo { } else if (prim == TRIANGLE_ARRAY) { if (count % 3 != 0) { throw new IllegalArgumentException( - J3dUtilsI18N.getString("GeometryInfo12")); + J3dUtilsI18N.getString("GeometryInfo12")); } } else if (prim == QUAD_ARRAY) { if (count % 4 != 0) { throw new IllegalArgumentException( - J3dUtilsI18N.getString("GeometryInfo13")); + J3dUtilsI18N.getString("GeometryInfo13")); } } - + // // For polygons, make sure the contours add up. // if (prim == POLYGON_ARRAY) { if (contourCounts != null) { int c = 0; - for (int i = 0 ; i < contourCounts.length ; i++) + for (int i = 0 ; i < contourCounts.length ; i++) c += contourCounts[i]; if (c != stripCounts.length) { throw new IllegalArgumentException( @@ -2077,7 +2077,7 @@ public class GeometryInfo { } } } // End of checkForBadData - + /** @@ -2116,18 +2116,18 @@ public class GeometryInfo { normalIndices = null; } - for (int i = 0 ; i < texCoordSetCount ; i++) - texCoordSets[i] = unindexifyData(texCoordSets[i], + for (int i = 0 ; i < texCoordSetCount ; i++) + texCoordSets[i] = unindexifyData(texCoordSets[i], texCoordIndexSets[i]); texCoordIndexSets = new int[texCoordSetCount][]; } } // End of unindexify - + /** - * Generic unindexify method. Can unindex data in any of the following - * formats Point3f, Color3f, Color4f, Vector3f, TexCoord2f, TexCoord3f, + * Generic unindexify method. Can unindex data in any of the following + * formats Point3f, Color3f, Color4f, Vector3f, TexCoord2f, TexCoord3f, * TexCoord4f. */ private Object[] unindexifyData(Object data[], int index[]) @@ -2138,7 +2138,7 @@ public class GeometryInfo { } return newData; } // End of unindexifyData - + /** @@ -2147,22 +2147,22 @@ public class GeometryInfo { private int getVertexFormat() { int vertexFormat = GeometryArray.COORDINATES; - + if (colors3 != null) vertexFormat |= GeometryArray.COLOR_3; else if (colors4 != null) vertexFormat |= GeometryArray.COLOR_4; - + if (normals != null) vertexFormat |= GeometryArray.NORMALS; - + if (texCoordDim == 2) vertexFormat |= GeometryArray.TEXTURE_COORDINATE_2; else if (texCoordDim == 3) vertexFormat |= GeometryArray.TEXTURE_COORDINATE_3; else if (texCoordDim == 4) vertexFormat |= GeometryArray.TEXTURE_COORDINATE_4; - + return vertexFormat; } // End of getVertexFormat - + /** @@ -2171,23 +2171,23 @@ public class GeometryInfo { private int getVertexCount() { int vertexCount = coordinates.length; - + if (colors3 != null) { if (colors3.length > vertexCount) vertexCount = colors3.length; } else if (colors4 != null) { if (colors4.length > vertexCount) vertexCount = colors4.length; } - + if (normals != null) { if (normals.length > vertexCount) vertexCount = normals.length; } - + // Find max length tex coord set for (int i = 0 ; i < texCoordSetCount ; i++) { if (texCoordSets[i].length > vertexCount) - vertexCount = texCoordSets[i].length; + vertexCount = texCoordSets[i].length; } - + return vertexCount; } // End of getVertexCount @@ -2299,7 +2299,7 @@ public class GeometryInfo { // Register reference to array of interleaved data if (nio) { ByteBufferWrapper b = ByteBufferWrapper.allocateDirect(d.length * 4); - FloatBufferWrapper f = + FloatBufferWrapper f = b.order( ByteOrderWrapper.nativeOrder() ).asFloatBuffer(); f.put(d); ga.setInterleavedVertexBuffer(f.getJ3DBuffer()); @@ -2308,7 +2308,7 @@ public class GeometryInfo { ByteBufferWrapper b = ByteBufferWrapper.allocateDirect(coordinates.length * 4 * 3); - FloatBufferWrapper f = + FloatBufferWrapper f = b.order( ByteOrderWrapper.nativeOrder() ).asFloatBuffer(); f.put(vecmathToFloat(coordinates)); ga.setCoordRefBuffer(f.getJ3DBuffer()); @@ -2383,9 +2383,9 @@ public class GeometryInfo { /** * Redo indexes to guarantee connection information. * Use this routine if your original data is in indexed format, but - * you don't trust that the indexing is correct. After this + * you don't trust that the indexing is correct. After this * routine it is guaranteed that two points with the same - * position will have the same coordinate index (for example). + * position will have the same coordinate index (for example). * Try this if you see * glitches in your normals or stripification, to rule out * bad indexing as the source of the problem. Works with normal @@ -2419,9 +2419,9 @@ public class GeometryInfo { private void reverseList(int list[]) { int t; - + if (list == null) return; - + for (int i = 0 ; i < list.length / 2 ; i++) { t = list[i]; list[i] = list[list.length - i - 1]; @@ -2432,7 +2432,7 @@ public class GeometryInfo { /** - * Reverse the order of all lists. If your polygons are formatted with + * Reverse the order of all lists. If your polygons are formatted with * clockwise winding, you will always see the back and never the front. * (Java 3D always wants vertices specified with a counter-clockwise * winding.) @@ -2459,14 +2459,14 @@ public class GeometryInfo { reverseList(coordinateIndices); reverseList(colorIndices); reverseList(normalIndices); - for (int i = 0 ; i < texCoordSetCount ; i++) + for (int i = 0 ; i < texCoordSetCount ; i++) reverseList(texCoordIndexSets[i]); } // End of reverse /** - * Returns true if the data in this GeometryInfo is currently + * Returns true if the data in this GeometryInfo is currently * formatted in the USE_COORD_INDEX_ONLY format where a single * index list is used to index into all data lists. * @see GeometryInfo#indexify(boolean) @@ -2484,7 +2484,7 @@ public class GeometryInfo { * Tells the GeometryInfo that its data is formatted in the * USE_COORD_INDEX_ONLY format with a single index list * (the coordinate index list) that indexes into all data - * lists (coordinates, normals, colors, and texture + * lists (coordinates, normals, colors, and texture * coordinates). NOTE: this will not convert the data * for you. This method is for when you are sending in * data useng the setCoordinates, setNormals, setColors, @@ -2530,14 +2530,14 @@ public class GeometryInfo { boolean nio) { checkForBadData(); - + if (prim == POLYGON_ARRAY) { if (tr == null) tr = new Triangulator(); tr.triangulate(this); } else changeBackToOldPrim(); - + unindexify(); - + int vertexFormat = getVertexFormat(); if (nio) vertexFormat |= (GeometryArray.BY_REFERENCE | GeometryArray.USE_NIO_BUFFER); @@ -2546,9 +2546,9 @@ public class GeometryInfo { if (byRef) vertexFormat |= GeometryArray.BY_REFERENCE; int vertexCount = coordinates.length; - - // If the texCoordSetMap hasn't been set, assume one set of - // texture coordinates only and one texture state unit + + // If the texCoordSetMap hasn't been set, assume one set of + // texture coordinates only and one texture state unit if ((texCoordSetCount > 0) && (texCoordSetMap == null)) { texCoordSetCount = 1; texCoordSetMap = new int[1]; @@ -2559,37 +2559,37 @@ public class GeometryInfo { GeometryArray ga = null; switch (prim) { case TRIANGLE_ARRAY: - TriangleArray ta = new TriangleArray(vertexCount, vertexFormat, + TriangleArray ta = new TriangleArray(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap); ga = (GeometryArray)ta; break; - + case QUAD_ARRAY: - QuadArray qa = new QuadArray(vertexCount, vertexFormat, + QuadArray qa = new QuadArray(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap); ga = (GeometryArray)qa; break; - + case TRIANGLE_STRIP_ARRAY: - TriangleStripArray tsa = new TriangleStripArray(vertexCount, + TriangleStripArray tsa = new TriangleStripArray(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, stripCounts); ga = (GeometryArray)tsa; break; - + case TRIANGLE_FAN_ARRAY: - TriangleFanArray tfa = new TriangleFanArray(vertexCount, + TriangleFanArray tfa = new TriangleFanArray(vertexCount, vertexFormat, texCoordSetCount, texCoordSetMap, stripCounts); ga = (GeometryArray)tfa; break; } - + fillIn(ga, byRef, interleaved, nio); - + return ga; } // End of getGeometryArray(int, int) - + /** @@ -2620,7 +2620,7 @@ public class GeometryInfo { * Creates and returns a IndexedGeometryArray * based on the data in the GeometryInfo object. This object is * suitable to be attached to a Shape3D node for rendering. - * @param compact Remove Coordinates, Colors, Normals, and + * @param compact Remove Coordinates, Colors, Normals, and * TextureCoordinates that aren't referenced by any indices. * @param byRef Create the IndexedGeometryArray using geometry * BY_REFERENCE. @@ -2631,7 +2631,7 @@ public class GeometryInfo { * byRef is true as well. * @param useCoordIndexOnly Create the IndexedGeometryArray using * USE_COORD_INDEX_ONLY. Values from the coordinate index array - * are used as a single set of indices into all vertex + * are used as a single set of indices into all vertex * component arrays (coord, color, normal, and texCoord). * @throws IllegalArgumentException if coordinate data is missing, * if the index lists aren't all the @@ -2651,7 +2651,7 @@ public class GeometryInfo { boolean nio) { indexify(useCoordIndexOnly); - + if (compact) compact(); if (prim == POLYGON_ARRAY) { @@ -2666,43 +2666,43 @@ public class GeometryInfo { if (coordinateIndices != null) { // See if all the array lengths are the same - if (colorIndices != null && + if (colorIndices != null && colorIndices.length != coordinateIndices.length) { canUseCoordIndexOnly = false; } - if (normalIndices != null && + if (normalIndices != null && normalIndices.length != coordinateIndices.length) { canUseCoordIndexOnly = false; } for (i = 0 ; i < texCoordSetCount ; i++) { - if (texCoordIndexSets[i] != null && + if (texCoordIndexSets[i] != null && texCoordIndexSets[i].length != coordinateIndices.length) { canUseCoordIndexOnly = false; break; } } - if (canUseCoordIndexOnly && - ((colorIndices != null) || + if (canUseCoordIndexOnly && + ((colorIndices != null) || (normalIndices != null) || - (texCoordSetCount > 0))) { + (texCoordSetCount > 0))) { // All array lengths are the same. Check their contents for (i=0; i 0) && (texCoordSetMap == null)) { texCoordSetCount = 1; texCoordSetMap = new int[1]; texCoordSetMap[0] = 0; } - + // // Create the IndexedGeometryArray object // - + IndexedGeometryArray ga = null; switch (prim) { case TRIANGLE_ARRAY: - IndexedTriangleArray ta = new IndexedTriangleArray(vertexCount, - vertexFormat, texCoordSetCount, texCoordSetMap, + IndexedTriangleArray ta = new IndexedTriangleArray(vertexCount, + vertexFormat, texCoordSetCount, texCoordSetMap, coordinateIndices.length); ga = (IndexedGeometryArray)ta; break; - + case QUAD_ARRAY: - IndexedQuadArray qa = new IndexedQuadArray(vertexCount, - vertexFormat, texCoordSetCount, texCoordSetMap, + IndexedQuadArray qa = new IndexedQuadArray(vertexCount, + vertexFormat, texCoordSetCount, texCoordSetMap, coordinateIndices.length); ga = (IndexedGeometryArray)qa; break; @@ -2756,7 +2756,7 @@ public class GeometryInfo { texCoordSetMap, coordinateIndices.length, stripCounts); ga = (IndexedGeometryArray)tsa; break; - + case TRIANGLE_FAN_ARRAY: IndexedTriangleFanArray tfa = new IndexedTriangleFanArray( vertexCount, vertexFormat, texCoordSetCount, @@ -2767,19 +2767,19 @@ public class GeometryInfo { // Fill in the GeometryArray object fillIn(ga, byRef, interleaved, nio); - + return ga; } // End of getIndexedGeometryArray(bool, bool, bool, bool, bool) - + /** * Creates and returns an IndexedGeometryArray * based on the data in the GeometryInfo object. This object is * suitable to be attached to a Shape3D node for rendering. - * Equivalent to getIndexedGeometryArray(compact, false, + * Equivalent to getIndexedGeometryArray(compact, false, * false, false, false). - * @param compact Remove Coordinates, Colors, Normals, and + * @param compact Remove Coordinates, Colors, Normals, and * TextureCoordinates that aren't referenced by any indices. * @throws IllegalArgumentException if coordinate data is missing, * if the index lists aren't all the @@ -2796,14 +2796,14 @@ public class GeometryInfo { { return getIndexedGeometryArray(compact, false, false, false, false); } // End of getIndexedGeometryArray(boolean) - + /** * Creates and returns an IndexedGeometryArray * based on the data in the GeometryInfo object. This object is * suitable to be attached to a Shape3D node for rendering. - * Equivalent to getIndexedGeometryArray(false, false, + * Equivalent to getIndexedGeometryArray(false, false, * false, false, false). * @throws IllegalArgumentException if coordinate data is missing, * if the index lists aren't all the @@ -2820,7 +2820,7 @@ public class GeometryInfo { { return getIndexedGeometryArray(false, false, false, false, false); } // End of getIndexedGeometryArray() - + } // End of class GeometryInfo // End of file GeometryInfo.java diff --git a/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfoGenerator.java b/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfoGenerator.java index a4282da..e4a6108 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfoGenerator.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/GeometryInfoGenerator.java @@ -67,7 +67,7 @@ import javax.media.j3d.J3DBuffer; -/** +/** * Populate a GeometryInfo object from the Geometry provided. Used * by GeometryInfo. */ @@ -75,7 +75,7 @@ class GeometryInfoGenerator extends Object { public static void create(GeometryInfo geomInfo, GeometryArray geomArray) { - if (geomArray instanceof GeometryStripArray) + if (geomArray instanceof GeometryStripArray) create(geomInfo, (GeometryStripArray)geomArray); else if (geomArray instanceof TriangleArray) { geomInfo.reset(GeometryInfo.TRIANGLE_ARRAY); @@ -100,8 +100,8 @@ class GeometryInfoGenerator extends Object { geomInfo.reset(GeometryInfo.TRIANGLE_STRIP_ARRAY); } else throw new IllegalArgumentException( J3dUtilsI18N.getString("GeometryInfoGenerator0")); - - processGeometryArray(geomInfo, geomArray); + + processGeometryArray(geomInfo, geomArray); processStripArray(geomInfo, geomArray); } // End of create(GeometryInfo, GeometryStripArray) @@ -121,7 +121,7 @@ class GeometryInfoGenerator extends Object { geomInfo.reset(GeometryInfo.TRIANGLE_STRIP_ARRAY); processIndexStripArray(geomInfo, (IndexedGeometryStripArray)geomArray); } - + processGeometryArray(geomInfo, geomArray); processIndexedArray(geomInfo, geomArray); } // End of create(GeometryInfo, IndexedGeometryArray) @@ -135,7 +135,7 @@ class GeometryInfoGenerator extends Object { int vertexFormat = geomArray.getVertexFormat(); int texSets = geomArray.getTexCoordSetCount(); int valid; - + // Calculate validVertexCount if (geomArray instanceof GeometryStripArray) { // Does not include IndexedGeometryStripArray @@ -158,11 +158,11 @@ class GeometryInfoGenerator extends Object { if ((vertexFormat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) wpv += 4; else if ((vertexFormat & GeometryArray.COLOR_3) != 0) wpv += 3; - if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_2) != 0) + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_2) != 0) wpv += 2 * texSets; - else if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_3) != 0) + else if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_3) != 0) wpv += 3 * texSets; - else if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_4) != 0) + else if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_4) != 0) wpv += 4 * texSets; int initial; @@ -355,7 +355,7 @@ class GeometryInfoGenerator extends Object { geomArray.getCoordinates(initial, coords); } geomInfo.setCoordinates(coords); - + if ((vertexFormat & GeometryArray.NORMALS) != 0) { Vector3f[] normals = null; if (byRef) { @@ -411,7 +411,7 @@ class GeometryInfoGenerator extends Object { } geomInfo.setNormals(normals); } - + if ((vertexFormat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) { Color4f[] colors = null; if (byRef) { @@ -592,7 +592,7 @@ class GeometryInfoGenerator extends Object { } geomInfo.setColors(colors); } - + if ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_4) != 0) { geomInfo.setTextureCoordinateParams(texSets, 4); for (i = 0 ; i < texSets ; i++) { @@ -768,7 +768,7 @@ class GeometryInfoGenerator extends Object { } } } // End of processGeometryArray - + private static void processIndexedArray(GeometryInfo geomInfo, @@ -814,14 +814,14 @@ class GeometryInfoGenerator extends Object { geomArray.getNormalIndices(initial, normalI); geomInfo.setNormalIndices(normalI); } - + if (((vertexFormat & GeometryArray.COLOR_3) != 0) || ((vertexFormat & GeometryArray.COLOR_4) != 0)) { int[] colorI = new int[valid]; geomArray.getColorIndices(initial, colorI); geomInfo.setColorIndices(colorI); } - + if (((vertexFormat & GeometryArray.TEXTURE_COORDINATE_2) != 0) || ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_3) != 0) || ((vertexFormat & GeometryArray.TEXTURE_COORDINATE_4) != 0)) { @@ -833,17 +833,17 @@ class GeometryInfoGenerator extends Object { } } } // End of processIndexedArray - - private static void processStripArray(GeometryInfo geomInfo, + + private static void processStripArray(GeometryInfo geomInfo, GeometryStripArray geomArray) { int[] strips = new int[geomArray.getNumStrips()]; geomArray.getStripVertexCounts(strips); geomInfo.setStripCounts(strips); } // End of processStripArray - + private static void processIndexStripArray( diff --git a/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java b/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java index dd7e4f6..8c0ff88 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/NormalGenerator.java @@ -66,7 +66,7 @@ import javax.vecmath.Point3f; *

    * Of course, sometimes your model *has* a crease in it. That's what * creaseAngle is. If two triangles' normals differ by more than - * creaseAngle, then the vertex will get two separate normals, creating a + * creaseAngle, then the vertex will get two separate normals, creating a * discontinuous crease in the model. This is perfect for the edge * of a table or the corner of a cube, for instance. */ @@ -128,7 +128,7 @@ public class NormalGenerator { } } } else { - // For quads, the facet normal of both triangles is the cross + // For quads, the facet normal of both triangles is the cross // product of the two vectors that make an 'X' across the quad. for (int t = 0 ; t < coordInds.length ; t += 6) { a.sub(coordinates[coordInds[t + 2]], coordinates[coordInds[t + 0]]); @@ -160,7 +160,7 @@ public class NormalGenerator { // of groups of triangles sharing the vertex. At the end of this routine // the groups of coordinate indexes will all be made, and the normal // indices will point to these groups. - // + // // The routine works by going through each vertex of each triangle. // Starting at a triangle, we see if the vertex normal can be shared // with the neighbor triangle (their facet normals differ by less than @@ -173,7 +173,7 @@ public class NormalGenerator { // Each time we step from one triangle to the next around the center // vertex, the triangle is added to the group of triangles whose normals // will be averaged to make the vertex normal. - // + // // Returns the largest number of triangles that share a single normal. // private int createHardEdges() @@ -279,7 +279,7 @@ public class NormalGenerator { } } else if ((DEBUG & 32) != 0) System.out.println("Hard Edge!"); } - + if (!smooth && goingRight) { // We've hit an impasse going right, so now try going left @@ -293,7 +293,7 @@ public class NormalGenerator { if ((DEBUG & 32) != 0) System.out.println( " Left edge: " + edge); } - + } while (smooth && ((goingRight && (edge.v2 != endVertex)) || !goingRight)); @@ -330,12 +330,12 @@ public class NormalGenerator { // This routine has something of a hack in it. We found that our // method of breaking up data into individual triangles before // calculating normals was causing a bug. If a polygon was broken - // into two triangles at a particular vertex, then that facet's + // into two triangles at a particular vertex, then that facet's // normal would get averaged into the vertex normal *twice*, // skewing the normal toward the decomposed facet. So what we did // was to check for duplicate facet normals as we're averaging, - // not allowing the same facet normal to be counted twice. - // + // not allowing the same facet normal to be counted twice. + // // What should be done is to put the facets' normals into a separate, // indexed, table. That way, to tell if two triangles have the // same normal, we just need to compare indexes. This would speed up @@ -455,7 +455,7 @@ public class NormalGenerator { // The original data was in quads. We converted it to triangles to - // calculate normals. Now we need to convert it back to quads. + // calculate normals. Now we need to convert it back to quads. private void convertTriToQuad(GeometryInfo geom) { // Create the new arrays @@ -477,7 +477,7 @@ public class NormalGenerator { // calculate the normals. Now we are converting it back to fans. // We have already calculated the new stripCounts, so now we need // to change the index lists so they match up with the stripCounts. - // It's a very simple algorithm. The paramater oldList is the + // It's a very simple algorithm. The paramater oldList is the // index list being compressed back into fans (could be coordinate, // color, normal, or texCoord indices) and numVerts is the pre- // calculated total of all entries of the stripCounts array. @@ -507,7 +507,7 @@ public class NormalGenerator { // // The original data was in fans. We converted it to triangles to - // calculate normals. Now we need to convert it back to fans. + // calculate normals. Now we need to convert it back to fans. // The hard part is that, if we found a hard edge in the middle of // a fan, we need to split the fan into two. To tell if there's // a hard edge there, we compare the normal indices of both @@ -571,7 +571,7 @@ public class NormalGenerator { geom.setNormalIndices(triToFanIndices(sc, geom.getNormalIndices(), c)); int num = geom.getTexCoordSetCount(); for (int i = 0 ; i < num ; i++) { - geom.setTextureCoordinateIndices(i, + geom.setTextureCoordinateIndices(i, triToFanIndices(sc, geom.getTextureCoordinateIndices(i), c)); } @@ -598,7 +598,7 @@ public class NormalGenerator { // calculate the normals. Now we are converting it back to strips. // We have already calculated the new stripCounts, so now we need // to change the index lists so they match up with the stripCounts. - // It's a very simple algorithm. The paramater oldList is the + // It's a very simple algorithm. The paramater oldList is the // index list being compressed back into strips (could be coordinate, // color, normal, or texCoord indices) and numVerts is the pre- // calculated total of all entries of the stripCounts array. @@ -669,7 +669,7 @@ public class NormalGenerator { } } } else { - // The middle vertex of this triangle must match the middle + // The middle vertex of this triangle must match the middle // vertex of the next, AND the third vertex of this triangle // must match the first vertex of the next if ((ni[tri * 3 + 1] == ni[(tri+1) * 3 + 1]) && @@ -709,7 +709,7 @@ public class NormalGenerator { geom.setNormalIndices(triToStripIndices(sc, geom.getNormalIndices(), c)); int num = geom.getTexCoordSetCount(); for (int i = 0 ; i < num ; i++) { - geom.setTextureCoordinateIndices(i, + geom.setTextureCoordinateIndices(i, triToStripIndices(sc, geom.getTextureCoordinateIndices(i), c)); } @@ -770,7 +770,7 @@ public class NormalGenerator { * Generate normals for the GeometryInfo object. If the GeometryInfo * object didn't previously contain indexed data, indexes are made * by collapsing identical positions into a single index. Any - * normal information previously contained in the GeometryInfo + * normal information previously contained in the GeometryInfo * object is lost. Strips and Fans are converted into individual * triangles for Normal generation, but are stitched back together * if GeometryInfo.getGeometryArray() (or getIndexedGeometryArray()) @@ -813,21 +813,21 @@ public class NormalGenerator { System.out.println("Convert to triangles: " + t1 + " ms"); time = System.currentTimeMillis(); } - + calculatefacetNorms(); if ((DEBUG & 16) != 0) { t2 += System.currentTimeMillis() - time; System.out.println("Calculate Facet Normals: " + t2 + " ms"); time = System.currentTimeMillis(); } - + int maxShare = createHardEdges(); if ((DEBUG & 16) != 0) { t3 += System.currentTimeMillis() - time; System.out.println("Hard Edges: " + t3 + " ms"); time = System.currentTimeMillis(); } - + calculateVertexNormals(maxShare); if ((DEBUG & 16) != 0) { t5 += System.currentTimeMillis() - time; @@ -841,7 +841,7 @@ public class NormalGenerator { System.out.println(i + " " + coordInds[i] + " " + normalInds[i]); } } - + // We have been caching some info from the GeometryInfo, so we need // to update it. gi.setCoordinateIndices(coordInds); @@ -856,9 +856,9 @@ public class NormalGenerator { /** - * Set the crease angle. + * Set the crease angle. * If two triangles' normals differ by more than - * creaseAngle, then the vertex will get two separate normals, creating a + * creaseAngle, then the vertex will get two separate normals, creating a * discontinuous crease in the model. This is perfect for the edge * of a table or the corner of a cube, for instance. Clamped to * 0 <= creaseAngle <= PI. Optimizations are made for creaseAngle == 0 diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Primitive.java b/src/classes/share/com/sun/j3d/utils/geometry/Primitive.java index f564c5f..96bcd9d 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Primitive.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Primitive.java @@ -60,18 +60,18 @@ import java.math.*; * geometry are shared, and once one of the shared nodes is live, the * capabilities cannot be set. Use the GEOMETRY_NOT_SHARED flag if * you do not wish to share geometry among primitives with the same - * parameters. + * parameters. */ public abstract class Primitive extends Group { /** - * Specifies that normals are generated along with the positions. + * Specifies that normals are generated along with the positions. */ public static final int GENERATE_NORMALS = 0x01; /** * Specifies that texture coordinates are generated along with the - * positions. + * positions. */ public static final int GENERATE_TEXTURE_COORDS = 0x02; @@ -85,11 +85,11 @@ public abstract class Primitive extends Group { * * @since Java 3D 1.5.1 */ - // Fix to Issue 411. Java 3D prefers images used for texture mapping to be Y-up + // Fix to Issue 411. Java 3D prefers images used for texture mapping to be Y-up public static final int GENERATE_TEXTURE_COORDS_Y_UP = 0x08; - - - /** + + + /** * Specifies that the geometry being created will not be shared by * another scene graph node. By default all primitives created with * the same parameters share their geometry (e.g., you can have 50 @@ -108,7 +108,7 @@ public abstract class Primitive extends Group { public static final int ENABLE_GEOMETRY_PICKING = 0x20; /** - * Specifies that the ALLOW_APPEARANCE_READ and + * Specifies that the ALLOW_APPEARANCE_READ and * ALLOW_APPEARANCE_WRITE bits are to be set on the generated * geometry's Shape3D nodes. */ @@ -132,7 +132,7 @@ public abstract class Primitive extends Group { */ int flags; - + /** * Constructs a default primitive. */ @@ -142,7 +142,7 @@ public abstract class Primitive extends Group { setCapability(ENABLE_PICK_REPORTING); setCapability(ALLOW_CHILDREN_READ); } - + /** * Returns the total number of triangles in this primitive. * @return the total number of triangles in this primitive @@ -219,13 +219,13 @@ public abstract class Primitive extends Group { getShape(partid).setAppearance(ap); } - /** Sets the main appearance of the primitive (all subparts) to + /** Sets the main appearance of the primitive (all subparts) to * same appearance. */ public abstract void setAppearance(Appearance ap); - - /** Sets the main appearance of the primitive (all subparts) to + + /** Sets the main appearance of the primitive (all subparts) to * a default white appearance. */ public void setAppearance(){ @@ -242,15 +242,15 @@ public abstract class Primitive extends Group { setAppearance(a); } - static Hashtable geomCache = new Hashtable(); + static Hashtable geomCache = new Hashtable(); String strfloat(float x) { return (new Float(x)).toString(); } - protected void cacheGeometry(int kind, float a, float b, - float c, int d, int e, int flags, + protected void cacheGeometry(int kind, float a, float b, + float c, int d, int e, int flags, GeomBuffer geo) { String key = new String(kind+strfloat(a)+strfloat(b)+ @@ -267,10 +267,10 @@ public abstract class Primitive extends Group { return((GeomBuffer) cache); } - + /** * Clear the shared geometry cache for all Primitive types. - * Existing Shapes with shared geometry will continue to share + * Existing Shapes with shared geometry will continue to share * the geometry. New Primitives will create new shared geometry. * * @since Java 3D 1.3.2 diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Quadrics.java b/src/classes/share/com/sun/j3d/utils/geometry/Quadrics.java index 4159529..ab81ac6 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Quadrics.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Quadrics.java @@ -52,33 +52,33 @@ import javax.vecmath.*; import java.math.*; class Quadrics extends Object { - + Quadrics(){ } - + // new disk code to remove transforms in the primitive code GeomBuffer disk(double r, int xdiv, double y, boolean outside, boolean texCoordYUp) { - + double theta, dtheta, sign, sinTheta, cosTheta; - + if (outside) sign = 1.0; else sign = -1.0; - + dtheta = 2.0*Math.PI / xdiv; - + GeomBuffer gbuf = new GeomBuffer(xdiv+2); - + gbuf.begin(GeomBuffer.TRIANGLE_FAN); gbuf.normal3d(0.0, 1.0*sign, 0.0); gbuf.texCoord2d(0.5, 0.5); gbuf.vertex3d(0.0, y, 0.0); - + // create the disk by evaluating points along the unit circle. // theta is the angle around the y-axis. Then we obtain // (cos(theta), sin(theta)) = (x,z) sample points. The y value // was passed in as a parameter. // texture coordinates are obtain from the unit circle centered at // (.5, .5) in s, t space. thus portions of the texture are not used. - + if (!outside) { for (int i = 0; i <= xdiv; i++) { theta = i * dtheta; @@ -87,7 +87,7 @@ class Quadrics extends Object { cosTheta = Math.cos(theta - Math.PI/2.0); gbuf.normal3d(0.0, 1.0*sign, 0.0); if (texCoordYUp) { - gbuf.texCoord2d(0.5+cosTheta*0.5, 1.0 - (0.5+sinTheta*0.5)); + gbuf.texCoord2d(0.5+cosTheta*0.5, 1.0 - (0.5+sinTheta*0.5)); } else { gbuf.texCoord2d(0.5+cosTheta*0.5, 0.5+sinTheta*0.5); @@ -102,7 +102,7 @@ class Quadrics extends Object { cosTheta = Math.cos(theta - Math.PI/2.0); gbuf.normal3d(0.0, 1.0*sign, 0.0); if (texCoordYUp) { - gbuf.texCoord2d(0.5+cosTheta*0.5, 1.0 - (0.5-sinTheta*0.5)); + gbuf.texCoord2d(0.5+cosTheta*0.5, 1.0 - (0.5-sinTheta*0.5)); } else { gbuf.texCoord2d(0.5+cosTheta*0.5, 0.5-sinTheta*0.5); @@ -110,37 +110,37 @@ class Quadrics extends Object { gbuf.vertex3d(cosTheta*r, y, sinTheta*r); } } - + gbuf.end(); return gbuf; } - - + + // new cylinder to remove transforms in the cylinder code and to optimize // by using triangle strip GeomBuffer cylinder(double height, double radius, int xdiv, int ydiv, boolean outside, boolean texCoordYUp) { - + double sign; - + if (outside) sign = 1.0; else sign = -1.0; - + // compute the deltas double dtheta = 2.0*Math.PI / (double)xdiv; double dy = height / (double)ydiv; double du = 1.0/(double)xdiv; double dv = 1.0/(double)ydiv; - + GeomBuffer gbuf = new GeomBuffer(ydiv*2*(xdiv+1)); - + double s = 0.0, t = 0.0; double px, pz, qx, qz; double py = -height/2.0; double qy; - + gbuf.begin(GeomBuffer.QUAD_STRIP); - + for (int i = 0; i < ydiv; i++) { qy = py+dy; if (outside) { @@ -148,17 +148,17 @@ class Quadrics extends Object { pz = Math.sin(xdiv*dtheta - Math.PI/2.0); qx = Math.cos((xdiv-1)*dtheta - Math.PI/2.0); qz = Math.sin((xdiv-1)*dtheta - Math.PI/2.0); - + // vert 2 gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*radius, qy, pz*radius); - + // vert 1 gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { @@ -167,72 +167,72 @@ class Quadrics extends Object { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*radius, py, pz*radius); - + // vert 4 gbuf.normal3d(qx*sign, 0.0, qz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s+du, 1.0 - (t + dv)); + gbuf.texCoord2d(s+du, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s+du, t+dv); } gbuf.vertex3d(qx*radius, qy, qz*radius); - + // vert 3 gbuf.normal3d(qx*sign, 0.0, qz*sign); - if (texCoordYUp) { + if (texCoordYUp) { gbuf.texCoord2d(s+du, 1.0 - t); } else { - gbuf.texCoord2d(s+du, t); + gbuf.texCoord2d(s+du, t); } gbuf.vertex3d(qx*radius, py, qz*radius); - + s += (du*2.0); - + for (int j = xdiv-2; j >=0; j--) { px = Math.cos(j*dtheta - Math.PI/2.0); pz = Math.sin(j*dtheta - Math.PI/2.0); - + // vert 6 gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*radius, qy, pz*radius); - + // vert 5 gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*radius, py, pz*radius); - + s += du; } - + } else { // c = 0; px = Math.cos(-Math.PI/2.0); pz = Math.sin(-Math.PI/2.0); qx = Math.cos(dtheta - Math.PI/2.0); qz = Math.sin(dtheta - Math.PI/2.0); - + gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*radius, qy, pz*radius); - + // vert 1 gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { @@ -242,73 +242,73 @@ class Quadrics extends Object { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*radius, py, pz*radius); - + gbuf.normal3d(qx*sign, 0.0, qz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s+du, 1.0 - (t + dv)); + gbuf.texCoord2d(s+du, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s+du, t+dv); } gbuf.vertex3d(qx*radius, qy, qz*radius); - + gbuf.normal3d(qx*sign, 0.0, qz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s+du, 1.0 - t); + gbuf.texCoord2d(s+du, 1.0 - t); } else { gbuf.texCoord2d(s+du, t); } gbuf.vertex3d(qx*radius, py, qz*radius); - + s += (du*2.0); - + for (int j = 2; j <= xdiv; j++) { px = Math.cos(j*dtheta - Math.PI/2.0); pz = Math.sin(j*dtheta - Math.PI/2.0); - + gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*radius, qy, pz*radius); - + gbuf.normal3d(px*sign, 0.0, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*radius, py, pz*radius); - + s += du; } - + } s = 0.0; t += dv; py += dy; } - + gbuf.end(); - + return gbuf; } - + // new coneBody method to remove transform in the Cone primitive // and to optimize by using triangle strip GeomBuffer coneBody(double bottom, double top, double bottomR, double topR, int xdiv, int ydiv, double dv, boolean outside, boolean texCoordYUp) { - + double r, sign; - + if (outside) sign = 1.0; else sign = -1.0; - + // compute the deltas double dtheta = 2.0*Math.PI/(double)xdiv; double dr = (topR-bottomR)/(double)ydiv; @@ -317,17 +317,17 @@ class Quadrics extends Object { double ynormal = (bottomR-topR)/height; double du = 1.0/(double)xdiv; // double dv = 1.0/(double)(ydiv+1); - + GeomBuffer gbuf = new GeomBuffer(ydiv*2*(xdiv+1)); - + double s = 0.0, t = 0.0; double px, pz, qx, qz; double py = bottom; double qy; r = bottomR; - + gbuf.begin(GeomBuffer.QUAD_STRIP); - + for (int i = 0; i < ydiv; i++) { qy = py+dy; if (outside) { @@ -335,37 +335,37 @@ class Quadrics extends Object { pz = Math.sin(xdiv*dtheta - Math.PI/2.0); qx = Math.cos((xdiv-1)*dtheta - Math.PI/2.0); qz = Math.sin((xdiv-1)*dtheta - Math.PI/2.0); - + // vert2 gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*(r+dr), qy, pz*(r+dr)); - + // vert1 gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*r, py, pz*r); - + // vert4 gbuf.normal3d(qx*sign, ynormal*sign, qz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s+du, 1.0 - (t + dv)); + gbuf.texCoord2d(s+du, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s+du, t+dv); } gbuf.vertex3d(qx*(r+dr), qy, qz*(r+dr)); - + // vert3 gbuf.normal3d(qx*sign, ynormal*sign, qz*sign); if (texCoordYUp) { @@ -375,13 +375,13 @@ class Quadrics extends Object { gbuf.texCoord2d(s+du, t); } gbuf.vertex3d(qx*r, py, qz*r); - + s += (du*2.0); - + for (int j = xdiv-2; j >= 0; j--) { px = Math.cos(j*dtheta - Math.PI/2.0); pz = Math.sin(j*dtheta - Math.PI/2.0); - + // vert 6 gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { @@ -390,17 +390,17 @@ class Quadrics extends Object { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*(r+dr), qy, pz*(r+dr)); - + // vert 5 gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*r, py, pz*r); - + s += du; } } else { @@ -408,26 +408,26 @@ class Quadrics extends Object { pz = Math.sin(-Math.PI/2.0); qx = Math.cos(dtheta - Math.PI/2.0); qz = Math.sin(dtheta - Math.PI/2.0); - + // vert1 gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*(r+dr), qy, pz*(r+dr)); - + gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*r, py, pz*r); - + gbuf.normal3d(qx*sign, ynormal*sign, qz*sign); if (texCoordYUp) { gbuf.texCoord2d(s+du, 1.0 - (t + dv)); @@ -436,31 +436,31 @@ class Quadrics extends Object { gbuf.texCoord2d(s+du, t+dv); } gbuf.vertex3d(qx*(r+dr), qy, qz*(r+dr)); - + gbuf.normal3d(qx*sign, ynormal*sign, qz*sign); - if (texCoordYUp) { + if (texCoordYUp) { gbuf.texCoord2d(s+du, 1.0 - t); } else { - gbuf.texCoord2d(s+du, t); + gbuf.texCoord2d(s+du, t); } gbuf.vertex3d(qx*r, py, qz*r); - + s += (du*2.0); - + for (int j = 2; j <= xdiv; j++) { px = Math.cos(j*dtheta - Math.PI/2.0); pz = Math.sin(j*dtheta - Math.PI/2.0); - + gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - (t + dv)); + gbuf.texCoord2d(s, 1.0 - (t + dv)); } else { gbuf.texCoord2d(s, t+dv); } gbuf.vertex3d(px*(r+dr), qy, pz*(r+dr)); - + gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { gbuf.texCoord2d(s, 1.0 - t); @@ -469,7 +469,7 @@ class Quadrics extends Object { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*r, py, pz*r); - + s += du; } } @@ -479,39 +479,39 @@ class Quadrics extends Object { r += dr; } gbuf.end(); - + return gbuf; } - + // new coneTop method to remove transforms in the cone code GeomBuffer coneTop(double bottom, double radius, double height, int xdiv,double t, boolean outside, boolean texCoordYUp) { - + double sign; - + if (outside) sign = 1.0; else sign = -1.0; - + // compute the deltas double dtheta = 2.0*Math.PI/(double)xdiv; double ynormal = radius/height; double du = 1.0/(double)xdiv; double top = bottom + height; - + // initialize the geometry buffer GeomBuffer gbuf = new GeomBuffer(xdiv + 2); gbuf.begin(GeomBuffer.TRIANGLE_FAN); - + // add the tip, which is the center of the fan gbuf.normal3d(0.0, ynormal*sign, 0.0); if (texCoordYUp) { - gbuf.texCoord2d(.5, 0.0); + gbuf.texCoord2d(.5, 0.0); } else { gbuf.texCoord2d(.5, 1.0); } gbuf.vertex3d(0.0, top, 0.0); - + // go around the circle and add the rest of the fan double s = 0.0; double px, pz; @@ -521,12 +521,12 @@ class Quadrics extends Object { pz = Math.sin(i*dtheta - Math.PI/2.0); gbuf.normal3d(px*sign, ynormal*sign, pz*sign); if (texCoordYUp) { - gbuf.texCoord2d(s, 1.0 - t); + gbuf.texCoord2d(s, 1.0 - t); } else { gbuf.texCoord2d(s, t); } gbuf.vertex3d(px*radius, bottom, pz*radius); - + s += du; } } else { diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Sphere.java b/src/classes/share/com/sun/j3d/utils/geometry/Sphere.java index 770d9e4..43afd08 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Sphere.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Sphere.java @@ -83,7 +83,7 @@ public class Sphere extends Primitive { /** * Constructs a Sphere of a given radius. Normals are generated - * by default, texture coordinates are not. The resolution defaults to + * by default, texture coordinates are not. The resolution defaults to * 15 divisions along sphere's axes. Appearance defaults to white. * @param radius Radius */ @@ -91,7 +91,7 @@ public class Sphere extends Primitive { this(radius, GENERATE_NORMALS, MID_REZ_DIV); } - /** + /** * Constructs a default Sphere of radius of 1.0. Normals are generated * by default, texture coordinates are not. * Resolution defaults to 15 divisions. Appearance defaults to white. @@ -100,7 +100,7 @@ public class Sphere extends Primitive { this(1.0f, GENERATE_NORMALS, MID_REZ_DIV); } - /** + /** * Constructs a Sphere of a given radius and appearance. * Normals are generated by default, texture coordinates are not. * @param radius Radius @@ -111,18 +111,18 @@ public class Sphere extends Primitive { this(radius, GENERATE_NORMALS, MID_REZ_DIV, ap); } - /** + /** * Constructs a Sphere of a given radius and appearance with * additional parameters specified by the Primitive flags. * @param radius Radius - * @param primflags + * @param primflags * @param ap appearance */ public Sphere(float radius, int primflags, Appearance ap) { this(radius, primflags, MID_REZ_DIV, ap); } - /** + /** * Constructs a Sphere of a given radius and number of divisions * with additional parameters specified by the Primitive flags. * Appearance defaults to white. @@ -178,12 +178,12 @@ public class Sphere extends Primitive { } - /** - * Constructs a customized Sphere of a given radius, + /** + * Constructs a customized Sphere of a given radius, * number of divisions, and appearance, with additional parameters * specified by the Primitive flags. The resolution is defined in * terms of number of subdivisions along the sphere's axes. More - * divisions lead to more finely tesselated objects. + * divisions lead to more finely tesselated objects. *

    * If the appearance is null, the sphere defaults to a white appearance. */ @@ -196,25 +196,25 @@ public class Sphere extends Primitive { this.radius = radius; this.divisions = divisions; - /* + /* * The sphere algorithm evaluates spherical angles along regular * units. For each spherical coordinate, (theta, rho), a (x,y,z) is * evaluated (along with the normals and texture coordinates). - * + * * The spherical angles theta varies from 0 to 2pi and rho from 0 * to pi. Sample points depends on the number of divisions. */ flags = primflags; - boolean texCoordYUp = (flags & GENERATE_TEXTURE_COORDS_Y_UP) != 0; - + boolean texCoordYUp = (flags & GENERATE_TEXTURE_COORDS_Y_UP) != 0; + //Depending on whether normal inward bit is set. if ((flags & GENERATE_NORMALS_INWARD) != 0) { sign = -1; } else { sign = 1; } - + if (divisions < 4) { nstep = 1; n = 4; @@ -227,10 +227,10 @@ public class Sphere extends Primitive { } nstep = n/4; } - + GeomBuffer cache = getCachedGeometry(Primitive.SPHERE, - radius, 0.0f, 0.0f, + radius, 0.0f, 0.0f, divisions, 0, primflags); Shape3D shape; @@ -243,13 +243,13 @@ public class Sphere extends Primitive { // buffer size = 8*(1 + 2E{i} + (nstep+1)) // where E{i} = sum of i = 2 ... nstep GeomBuffer gbuf = new GeomBuffer(8*nstep*(nstep+2)); - + for (int i=0; i < 4; i++) { buildQuadrant(gbuf, i*Math.PI/2, (i+1)*Math.PI/2, sign, nstep, n, true); buildQuadrant(gbuf, i*Math.PI/2, (i+1)*Math.PI/2, sign, nstep, n, false); } - // Fix to Issue 411. Java 3D prefers images used for texture mapping to be Y-up + // Fix to Issue 411. Java 3D prefers images used for texture mapping to be Y-up if (texCoordYUp) { TexCoord2f[] texCoords = gbuf.getTexCoords(); if (texCoords != null) { @@ -258,14 +258,14 @@ public class Sphere extends Primitive { } } } - + shape = new Shape3D(gbuf.getGeom(flags)); numVerts = gbuf.getNumVerts(); - numTris = gbuf.getNumTris(); - + numTris = gbuf.getNumTris(); + if ((primflags & Primitive.GEOMETRY_NOT_SHARED) == 0) { cacheGeometry(Primitive.SPHERE, - radius, 0.0f, 0.0f, + radius, 0.0f, 0.0f, divisions, 0, primflags, gbuf); } } @@ -278,7 +278,7 @@ public class Sphere extends Primitive { if ((flags & ENABLE_GEOMETRY_PICKING) != 0) { shape.setCapability(Shape3D.ALLOW_GEOMETRY_READ); } - + this.addChild(shape); if (ap == null) { @@ -368,7 +368,7 @@ public class Sphere extends Primitive { void buildQuadrant(GeomBuffer gbuf, double startDelta, double endDelta, int sign, int nstep, int n, boolean upperSphere) { - + double ds, dt, theta, delta; int i, j, index, i2; double h, r, vx, vz; @@ -391,7 +391,7 @@ public class Sphere extends Primitive { starth = -1; leftToRight = (sign < 0); } - + for (i = 1; i <= nstep; i++) { h = Math.cos(theta); @@ -406,7 +406,7 @@ public class Sphere extends Primitive { // subdivision decreases towards the pole ds = (endDelta - startDelta) / i; - gbuf.begin(GeomBuffer.TRIANGLE_STRIP); + gbuf.begin(GeomBuffer.TRIANGLE_STRIP); if (leftToRight) { // Build triangle strips from left to right @@ -432,21 +432,21 @@ public class Sphere extends Primitive { } else { gbuf.normal3d(0, sign*starth, 0); if (sign > 0) { - gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), + gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), 1.0 - (theta - dt)/Math.PI); } else { - gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), + gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), (theta - dt)/Math.PI); } - gbuf.vertex3d( 0, starth*radius, 0); - + gbuf.vertex3d( 0, starth*radius, 0); + } delta += ds; } // Put the last vertex in that row, // for numerical accuracy we don't use delta - // compute from above. + // compute from above. delta = endDelta; vx = r*Math.cos(delta); vz = r*Math.sin(delta); @@ -459,10 +459,10 @@ public class Sphere extends Primitive { for (j=i; j > 0; j--) { vx = r*Math.cos(delta); vz = r*Math.sin(delta); - + gbuf.normal3d( vx*sign, h*sign, vz*sign ); // Convert texture coordinate back to one - // set in previous version + // set in previous version gbuf.texCoord2d(0.75 - delta/(2*Math.PI), t); gbuf.vertex3d( vx*radius, h*radius, vz*radius ); if (i > 1) { @@ -477,13 +477,13 @@ public class Sphere extends Primitive { } else { gbuf.normal3d(0, sign*starth, 0); if (sign > 0) { - gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), + gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), 1.0 - (theta - dt)/Math.PI); } else { - gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), - (theta - dt)/Math.PI); + gbuf.texCoord2d(0.75 - (startDelta + endDelta)/(4*Math.PI), + (theta - dt)/Math.PI); } - gbuf.vertex3d( 0, starth*radius, 0); + gbuf.vertex3d( 0, starth*radius, 0); } delta -= ds; @@ -491,15 +491,15 @@ public class Sphere extends Primitive { // Put the last vertex in that row, // for numerical accuracy we don't use delta - // compute from above. + // compute from above. delta = startDelta; vx = r*Math.cos(delta); vz = r*Math.sin(delta); gbuf.normal3d( vx*sign, h*sign, vz*sign ); gbuf.texCoord2d(0.75 - delta/(2*Math.PI), t); - gbuf.vertex3d( vx*radius, h*radius, vz*radius ); + gbuf.vertex3d( vx*radius, h*radius, vz*radius ); - } + } gbuf.end(); diff --git a/src/classes/share/com/sun/j3d/utils/geometry/Text2D.java b/src/classes/share/com/sun/j3d/utils/geometry/Text2D.java index 3ec93fb..0537494 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/Text2D.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/Text2D.java @@ -83,19 +83,19 @@ public class Text2D extends Shape3D { // This table caches FontMetrics objects to avoid the huge cost // of re-retrieving metrics for a font we've already seen. - private static Hashtable metricsTable = new Hashtable(); + private static Hashtable metricsTable = new Hashtable(); private float rectangleScaleFactor = 1f/256f; - - private boolean enableTextureWrite = false; + + private boolean enableTextureWrite = false; private Color3f color = new Color3f(); private String fontName; private int fontSize, fontStyle; private String text; - + // max texture dimension, as some font size can be greater than // video card max texture size. 2048 is a conservative value. - private int MAX_TEXTURE_DIM = 2048; + private int MAX_TEXTURE_DIM = 2048; // vWidth is the virtual width texture. Value set by setupImage() private int vWidth; @@ -133,12 +133,12 @@ public class Text2D extends Shape3D { // issue 655 private Text2D() { - + setCapability(Shape3D.ALLOW_GEOMETRY_WRITE); setCapability(Shape3D.ALLOW_APPEARANCE_READ); setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); } - + // issue 655 public Node cloneNode(boolean forceDuplicate) { Text2D t2d = new Text2D(); @@ -152,7 +152,7 @@ public class Text2D extends Shape3D { t2d.duplicateNode(this, forceDuplicate); return t2d; } - + /* * Changes text of this Text2D to 'text'. All other * parameters (color, fontName, fontSize, fontStyle @@ -161,17 +161,17 @@ public class Text2D extends Shape3D { */ public void setString(String text){ this.text = text; - + Texture tex = getAppearance().getTexture(); - + // mcneillk: JAVA3D-657 if (tex == null) { tex = getAppearance().getTextureUnitState(0).getTexture(); } - + int width = tex.getWidth(); - int height = tex.getHeight(); - int oldVW = vWidth; + int height = tex.getHeight(); + int oldVW = vWidth; int oldVH = vHeight; ImageComponent imageComponent = setupImage(text, color, fontName, @@ -182,12 +182,12 @@ public class Text2D extends Shape3D { } else { Texture2D newTex = setupTexture(imageComponent); // Copy texture attributes except those related to - // mipmap since Texture only set base imageComponent. + // mipmap since Texture only set base imageComponent. newTex.setBoundaryModeS(tex.getBoundaryModeS()); newTex.setBoundaryModeT(tex.getBoundaryModeT()); newTex.setMinFilter(tex.getMinFilter()); - newTex.setMagFilter(tex.getMagFilter()); + newTex.setMagFilter(tex.getMagFilter()); newTex.setEnable(tex.getEnable()); newTex.setAnisotropicFilterMode(tex.getAnisotropicFilterMode()); newTex.setAnisotropicFilterDegree(tex.getAnisotropicFilterDegree()); @@ -199,14 +199,14 @@ public class Text2D extends Shape3D { } Color4f c = new Color4f(); tex.getBoundaryColor(c); - newTex.setBoundaryColor(c); + newTex.setBoundaryColor(c); newTex.setUserData(tex.getUserData()); - + // mcneillk: JAVA3D-657 if (getAppearance().getTexture() != null) { - getAppearance().setTexture(newTex); + getAppearance().setTexture(newTex); } else { - getAppearance().getTextureUnitState(0).setTexture(newTex); + getAppearance().getTextureUnitState(0).setTexture(newTex); } } // Does the new text requires a new geometry ? @@ -251,7 +251,7 @@ public class Text2D extends Shape3D { public float getRectangleScaleFactor() { return rectangleScaleFactor; } - + /** * Create the ImageComponent and Texture object. */ @@ -268,9 +268,9 @@ public class Text2D extends Shape3D { t2d.setCapability(Texture.ALLOW_SIZE_READ); t2d.setCapability(Texture.ALLOW_ENABLE_READ); t2d.setCapability(Texture.ALLOW_BOUNDARY_MODE_READ); - t2d.setCapability(Texture.ALLOW_FILTER_READ); - t2d.setCapability(Texture.ALLOW_BOUNDARY_COLOR_READ); - t2d.setCapability(Texture.ALLOW_ANISOTROPIC_FILTER_READ); + t2d.setCapability(Texture.ALLOW_FILTER_READ); + t2d.setCapability(Texture.ALLOW_BOUNDARY_COLOR_READ); + t2d.setCapability(Texture.ALLOW_ANISOTROPIC_FILTER_READ); t2d.setCapability(Texture.ALLOW_FILTER4_READ); return t2d; } @@ -331,16 +331,16 @@ public class Text2D extends Shape3D { offscreenGraphics.setColor(myTextColor); offscreenGraphics.drawString(text, 0, height - descent); offscreenGraphics.dispose(); - //store virtual size + //store virtual size vWidth = width; vHeight = height; // rescale down big images if(width > MAX_TEXTURE_DIM || height > MAX_TEXTURE_DIM){ - bImage = rescaleImage(bImage); + bImage = rescaleImage(bImage); } ImageComponent imageComponent = - new ImageComponent2D(ImageComponent.FORMAT_RGBA, + new ImageComponent2D(ImageComponent.FORMAT_RGBA, bImage); imageComponent.setCapability(ImageComponent.ALLOW_SIZE_READ); @@ -351,19 +351,19 @@ public class Text2D extends Shape3D { private BufferedImage rescaleImage(BufferedImage bImage){ int width = bImage.getWidth(); int height = bImage.getHeight(); - + float sx = (width > MAX_TEXTURE_DIM) ? (float) MAX_TEXTURE_DIM / (float)width : 1.0f; float sy = (height > MAX_TEXTURE_DIM)? (float) MAX_TEXTURE_DIM / (float)height : 1.0f; - + width = Math.round((float) width * sx); height = Math.round((float)height * sy); - + Image scaledImage = bImage.getScaledInstance(width, height, Image.SCALE_AREA_AVERAGING); bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); Graphics2D g = bImage.createGraphics(); g.drawImage(scaledImage, 0,0, null); g.dispose(); - + return bImage; } @@ -388,12 +388,12 @@ public class Text2D extends Shape3D { (-1f), 0f, (-1f), -1f }; - + QuadArray rect = new QuadArray(4, QuadArray.COORDINATES | QuadArray.TEXTURE_COORDINATE_2); rect.setCoordinates(0, verts1); rect.setTextureCoordinates(0, 0, texCoords); - + return rect; } @@ -406,7 +406,7 @@ public class Text2D extends Shape3D { */ private Appearance setupAppearance(Texture2D t2d) { Appearance appearance = getAppearance(); - + if (appearance == null) { TransparencyAttributes transp = new TransparencyAttributes(); transp.setTransparencyMode(TransparencyAttributes.BLENDED); @@ -421,10 +421,10 @@ public class Text2D extends Shape3D { appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE); appearance.setCapability(Appearance.ALLOW_TEXTURE_READ); appearance.setCapabilityIsFrequent(Appearance.ALLOW_TEXTURE_READ); - }else{ + }else{ appearance.setTexture(t2d); } - + return appearance; } @@ -463,7 +463,7 @@ public class Text2D extends Shape3D { public int getFontSize() { return fontSize; } - + /** * Returns the font style * @@ -472,7 +472,7 @@ public class Text2D extends Shape3D { public int getFontStyle() { return fontStyle; } - + } diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CommandStream.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CommandStream.java index 030c753..4f39f26 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CommandStream.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CommandStream.java @@ -115,17 +115,17 @@ class CommandStream { /** * Add a compression command to this instance.

    - * + * * A compression command includes an 8-bit header and can range up to 72 * bits in length. The command with the maximum length is a 2-bit color * command with a 6-bit tag in the header, followed by four 16-bit color * components of data.

    - * + * * A subcommand is either a position, normal, or color, though in practice * a position subcommand can only be part of a vertex command. Normal and * color subcommands can be parts of separate global normal and color * commands as well as parts of a vertex command.

    - * + * * A subcommand includes a 6-bit header. Its length is 2 bits less than * the length of the corresponding command. * @@ -147,7 +147,7 @@ class CommandStream { // // Add the rightmost bitCount bits of b to the end of the command stream. - // + // private void addByte(int b, int bitCount) { int bitsEmpty = 8 - bitOffset ; b &= (int)CompressionStreamElement.lengthMask[bitCount] ; @@ -173,14 +173,14 @@ class CommandStream { // // Add the rightmost bitCount bits of l to the end of the command stream. - // + // private void addLong(long l, int bitCount) { int byteCount = bitCount / 8 ; int excessBits = bitCount - byteCount * 8 ; if (excessBits > 0) addByte((int)(l >>> (byteCount * 8)), excessBits) ; - + while (byteCount > 0) { addByte((int)((l >>> ((byteCount - 1) * 8)) & 0xff), 8) ; byteCount-- ; @@ -214,7 +214,7 @@ class CommandStream { int fillBytes = 8 - excessBytes ; padBits = (8 * fillBytes) + (8 - bitOffset) ; } - + // The minimum length for a no-op command body is 5 bits. if (padBits < 5) // Have to cross the next 64-bit boundary. @@ -227,7 +227,7 @@ class CommandStream { addLong((padBits - 5) << (padBits - 5), padBits) ; return ; } - + // The number of bits to pad at this point is [37..68]. Knock off 24 // bits with the body of the 1st no-op to reduce the number of pad // bits to [13..44], which can be filled with 1 more no-op. diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryData.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryData.java index d19129c..4d8b494 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryData.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryData.java @@ -111,7 +111,7 @@ public class CompressedGeometryData extends Object { * * @exception IllegalArgumentException if a problem is detected with the * header. - */ + */ public CompressedGeometryData(Header hdr, byte[] compressedGeometry) { @@ -226,7 +226,7 @@ public class CompressedGeometryData extends Object { * Retrieves the compressed geometry associated with the * CompressedGeometryData object. Copies the compressed * geometry from the CompressedGeometryData node into the given array. - * The array must be large enough to hold all of the bytes. + * The array must be large enough to hold all of the bytes. * The individual array elements must be allocated by the caller. * * @param compressedGeometry the array into which to copy the compressed @@ -285,7 +285,7 @@ public class CompressedGeometryData extends Object { /** * Retrieves the data access mode for this CompressedGeometryData object. - * + * * @return true if the data access mode for this * CompressedGeometryData object is by-reference; * false if the data access mode is by-copying. @@ -317,7 +317,7 @@ public class CompressedGeometryData extends Object { * Gets the compressed geometry data buffer reference, which is * always null since NIO buffers are not supported for * CompressedGeometryData objects. - * + * * @return null */ public J3DBuffer getCompressedGeometryBuffer() { diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryFile.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryFile.java index 9bca01c..d9c07d7 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryFile.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryFile.java @@ -266,7 +266,7 @@ public class CompressedGeometryFile { public CompressedGeometryFile(RandomAccessFile file) throws IOException { // Copy the file reference. cgFile = file ; - + // Set up the file fields. initialize() ; } @@ -278,7 +278,7 @@ public class CompressedGeometryFile { * must be removed manually before it can be rewritten. The close() * method must be called sometime after invoking clear() in order to write * out the new directory structure. - * + * * @exception IOException if clear fails */ public void clear() throws IOException { @@ -361,8 +361,8 @@ public class CompressedGeometryFile { * index is incremented by 1 after the read. When the last object is read * the index becomes invalid and an immediately subsequent call to * readNext() returns null. - * - * + * + * * @return a CompressedGeometryData node component, or null if the last object * has been read * @exception IOException if read fails @@ -375,14 +375,14 @@ public class CompressedGeometryFile { * Read all compressed geometry objects contained in the instance. The * current object index becomes invalid; an immediately following call * to readNext() will return null. - * + * * @return an array of CompressedGeometryData node components. * @exception IOException if read fails */ public CompressedGeometryData[] read() throws IOException { long startTime = 0 ; CompressedGeometryData cg[] = new CompressedGeometryData[objectCount] ; - + if (benchmark) startTime = System.currentTimeMillis() ; @@ -409,7 +409,7 @@ public class CompressedGeometryFile { * current object index is set to the subsequent object unless the last * object has been read, in which case the index becomes invalid and an * immediately following call to readNext() will return null. - * + * * @param index compressed geometry object to read * @return a CompressedGeometryData node component * @exception IndexOutOfBoundsException if object index is @@ -475,7 +475,7 @@ public class CompressedGeometryFile { (cgh.size+BLOCK_HEADER_SIZE) + " bytes") ; } - + cg.getCompressedGeometry(cgBuffer) ; write(cgh, cgBuffer) ; } @@ -486,7 +486,7 @@ public class CompressedGeometryFile { * following call to readNext() will return null. The close() method must * be called at some later time in order to create a valid compressed * geometry file. - * + * * @param cgh a CompressedGeometryData.Header object describing the data. * @param geometry the compressed geometry data * @exception IOException if write fails @@ -503,7 +503,7 @@ public class CompressedGeometryFile { (cgh.size+BLOCK_HEADER_SIZE) + " bytes") ; } - + // Assuming backward compatibility, the version number of the file // should be the maximum of all individual compressed object versions. if ((cgh.majorVersionNumber > majorVersionNumber) @@ -555,12 +555,12 @@ public class CompressedGeometryFile { if (objectCount == directory.length) { long newDirectory[] = new long[2*objectCount] ; int newObjectSizes[] = new int[2*objectCount] ; - + System.arraycopy(directory, 0, newDirectory, 0, objectCount) ; System.arraycopy(objectSizes, 0, newObjectSizes, 0, objectCount) ; - + directory = newDirectory ; objectSizes = newObjectSizes ; @@ -658,7 +658,7 @@ public class CompressedGeometryFile { // Reset number of objects that can be read sequentially from cache. bufferNextObjectCount = 0 ; } - + // // Initialize directory, object size array, read/write buffer, and the // shared compressed geometry header. @@ -738,7 +738,7 @@ public class CompressedGeometryFile { // // Read the file header. - // + // void readFileHeader() throws IOException { byte header[] = new byte[HEADER_SIZE] ; @@ -815,7 +815,7 @@ public class CompressedGeometryFile { } catch (IOException e) { throw new IOException - (e.getMessage() + + (e.getMessage() + "\ncould not write file header for " + fileName) ; } } @@ -842,7 +842,7 @@ public class CompressedGeometryFile { } for (int i = 0 ; i < directory.length ; i++) { - directory[i] = + directory[i] = ((long)(buff[i*8+0] & 0xff) << 56) | ((long)(buff[i*8+1] & 0xff) << 48) | ((long)(buff[i*8+2] & 0xff) << 40) | @@ -879,7 +879,7 @@ public class CompressedGeometryFile { } directoryOffset += 8-directoryAlign ; } - + try { for (int i = 0 ; i < objectCount ; i++) cgFile.writeLong(directory[i]) ; @@ -897,7 +897,7 @@ public class CompressedGeometryFile { // // Get the next compressed object in the file, either from the read-ahead // cache or from the file itself. - // + // CompressedGeometryData readNext(int bufferReadLimit) throws IOException { if (objectIndex == objectCount) @@ -924,7 +924,7 @@ public class CompressedGeometryFile { } catch (IOException e) { throw new IOException - (e.getMessage() + + (e.getMessage() + "\nfailed to read " + curSize + " bytes, object " + objectIndex + " in file " + fileName) ; } @@ -968,7 +968,7 @@ public class CompressedGeometryFile { return newCG(geomSize, geomStart, geomDataType) ; } - + // // Construct and return a compressed geometry node. // @@ -984,17 +984,17 @@ public class CompressedGeometryFile { cgh.bufferType = CompressedGeometryData.Header.LINE_BUFFER ; else if ((geomDataType & TYPE_MASK) == TYPE_TRIANGLE) cgh.bufferType = CompressedGeometryData.Header.TRIANGLE_BUFFER ; - + cgh.bufferDataPresent = 0 ; if ((geomDataType & NORMAL_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryData.Header.NORMAL_IN_BUFFER ; - + if ((geomDataType & COLOR_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryData.Header.COLOR_IN_BUFFER ; - + if ((geomDataType & ALPHA_PRESENT_MASK) != 0) cgh.bufferDataPresent |= CompressedGeometryData.Header.ALPHA_IN_BUFFER ; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryRetained.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryRetained.java index 50fedd0..d5b78df 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryRetained.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressedGeometryRetained.java @@ -123,7 +123,7 @@ class CompressedGeometryRetained extends Object { geoBounds.setUpper( 1.0, 1.0, 1.0) ; geoBounds.setLower(-1.0,-1.0,-1.0) ; } - + /** * Return true if the data access mode is by-reference. */ @@ -137,7 +137,7 @@ class CompressedGeometryRetained extends Object { // GL_SUNX_geometry_compression extension. The header is unnecessary // if only the newer GL_SUN_geometry_compression API needs support. compressedGeometry = new byte[HEADER_LENGTH + this.size] ; - + compressedGeometry[HEADER_MAJOR_VERSION_OFFSET] = (byte)this.majorVersionNumber ; @@ -152,7 +152,7 @@ class CompressedGeometryRetained extends Object { compressedGeometry[HEADER_BUFFER_DATA_OFFSET] = (byte)this.bufferContents ; - + System.arraycopy(geometry, this.offset, compressedGeometry, HEADER_LENGTH, this.size) ; @@ -231,7 +231,7 @@ class CompressedGeometryRetained extends Object { if ((bufferContents & CompressedGeometryData.Header.NORMAL_IN_BUFFER) != 0) { vertexFormat |= GeometryArray.NORMALS; } - + if ((bufferContents & CompressedGeometryData.Header.COLOR_IN_BUFFER) != 0) { if ((bufferContents & CompressedGeometryData.Header.ALPHA_IN_BUFFER) != 0) { vertexFormat |= GeometryArray.COLOR_4; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStream.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStream.java index 21fe296..d257ea8 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStream.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStream.java @@ -280,7 +280,7 @@ public class CompressionStream { * At 0 bits of quantization normals are represented only as 6 bit * sextant/octant pairs and 14 specially encoded normals (the 6 axis * normals and the 8 octant midpoint normals); since U and V can only be 0 - * at the minimum quantization, the totally number of unique normals is + * at the minimum quantization, the totally number of unique normals is * 12 + 14 = 26. */ int normalQuant ; @@ -423,7 +423,7 @@ public class CompressionStream { /** * Creates a new CompressionStream for the specified geometry type and * vertex format.

    - * + * * @param streamType type of data in this stream, either * CompressedGeometryData.Header.POINT_BUFFER, * CompressedGeometryData.Header.LINE_BUFFER, or @@ -528,7 +528,7 @@ public class CompressionStream { * whenever possible. Each geometric element is mapped to a HuffmanNode * object containing its resulting bit length, right shift (trailing 0 * count), and absolute or relative status.

    - * + * * Positions are normalized to span a unit cube via an offset and a * uniform scale factor that maps the midpoint of the object extents along * each dimension to the origin, and the longest dimension of the object to @@ -537,7 +537,7 @@ public class CompressionStream { * position quantization of 6 bits, an object would be normalized so that * its most negative dimension is at (-1 + 1/64) and the most positive is * at (1 - 1/64).

    - * + * * Normals are assumed to be of unit length. Color components are clamped * to the [0..1) range, where the right endpoint is one quantum less * than 1.0.

    @@ -698,7 +698,7 @@ public class CompressionStream { } /** - * Retrieve the number of mesh buffer references created for this stream. + * Retrieve the number of mesh buffer references created for this stream. * @return mesh buffer reference count */ int getMeshReferenceCount() { @@ -1000,7 +1000,7 @@ public class CompressionStream { void addVertex(Point3f pos, Vector3f norm, Object color, int stripFlag, int meshFlag) { - if (vertexColor3) + if (vertexColor3) stream.add(new CompressionStreamVertex (this, pos, norm, (Color3f)color, stripFlag, meshFlag)) ; else @@ -1079,16 +1079,16 @@ public class CompressionStream { /** * Interface to access GeometryArray vertex components and add them to the * compression stream. - * + * * A processVertex() implementation retrieves vertex components using the * appropriate access semantics of a particular GeometryArray, and adds * them to the compression stream. - * + * * The implementation always pushes vertices into the mesh buffer unless * they match ones already there; if they do, it generates mesh buffer * references instead. This reduces the number of vertices when * non-stripped abutting facets are added to the stream. - * + * * Note: Level II geometry compression semantics allow the mesh buffer * normals to be substituted with the value of an immediately * preceding SetNormal command, but this is unavailable in Level I. @@ -1231,7 +1231,7 @@ public class CompressionStream { /** * Class which holds indices for a specific vertex of an - * IndexedGeometryArray. + * IndexedGeometryArray. */ private static class VertexIndices { int pi, ni, ci ; @@ -1285,7 +1285,7 @@ public class CompressionStream { if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r)) addColor(colors3[vi.ci]) ; - + else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r)) addColor(colors4[vi.ci]) ; @@ -1296,7 +1296,7 @@ public class CompressionStream { // // NOTE: For now, copies are made of all GeometryArray vertex components - // even when by-reference access is available. + // even when by-reference access is available. // private static class VertexCopy { Object c = null ; @@ -1320,7 +1320,7 @@ public class CompressionStream { if (vertexNormals && !noMeshNormalSubstitution && (! vc.n.equals(meshBuffer.getNormal(r)))) addNormal(vc.n) ; - + if (vertexColor3 && (! vc.c3.equals(meshBuffer.getColor3(r)))) addColor(vc.c3) ; @@ -1351,7 +1351,7 @@ public class CompressionStream { if (vertexColor3 && vi.ci != meshBuffer.getColorIndex(r)) addColor(vc.c3) ; - + else if (vertexColor4 && vi.ci != meshBuffer.getColorIndex(r)) addColor(vc.c4) ; @@ -1413,7 +1413,7 @@ public class CompressionStream { */ private class InterleavedGeometryFloat extends InterleavedGeometry { float[] vdata = null ; - + InterleavedGeometryFloat(GeometryArray ga) { super(ga) ; vdata = ga.getInterleavedVertices() ; @@ -1473,7 +1473,7 @@ public class CompressionStream { } /** - * This class implements the GeometryAccessor interface for + * This class implements the GeometryAccessor interface for * interleaved NIO geometry arrays. */ private class InterleavedGeometryNIO extends InterleavedGeometry { @@ -1599,7 +1599,7 @@ public class CompressionStream { if (normals == null) throw new UnsupportedOperationException ("\nby-reference access to Normal3f array") ; - + initialNormalIndex = ga.getInitialNormalIndex() ; } } @@ -1726,7 +1726,7 @@ public class CompressionStream { if (vertexColors) { buffer = ga.getColorRefBuffer() ; initialColorIndex = ga.getInitialColorIndex() ; - + switch (BufferWrapper.getBufferType(buffer)) { case BufferWrapper.TYPE_BYTE: colorsB = new ByteBufferWrapper(buffer) ; @@ -1952,7 +1952,7 @@ public class CompressionStream { } else if (ga instanceof TriangleFanArray || ga instanceof IndexedTriangleFanArray) { - + strips = true ; replaceCode = REPLACE_MIDDLE ; if (debug) System.out.println("fans") ; @@ -2291,8 +2291,8 @@ public class CompressionStream { /** * Get the original bounds of the coordinate data, in modeling coordinates. * Coordinate data is positioned and scaled to a normalized cube after - * compression. - * + * compression. + * * @return Point3d array of length 2, where the 1st Point3d is the lower * bounds and the 2nd Point3d is the upper bounds. * @since Java 3D 1.3 @@ -2307,7 +2307,7 @@ public class CompressionStream { /** * Get the bounds of the compressed object in normalized coordinates. * These have an maximum bounds by [-1.0 .. +1.0] across each axis. - * + * * @return Point3d array of length 2, where the 1st Point3d is the lower * bounds and the 2nd Point3d is the upper bounds. * @since Java 3D 1.3 diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamColor.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamColor.java index dd98ed9..e3d5530 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamColor.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamColor.java @@ -57,7 +57,7 @@ class CompressionStreamColor extends CompressionStreamElement { private boolean color3 ; private boolean color4 ; private float colorR, colorG, colorB, colorA ; - + int rAbsolute, gAbsolute, bAbsolute, aAbsolute ; /** @@ -96,7 +96,7 @@ class CompressionStreamColor extends CompressionStreamElement { * Quantize a floating point color to fixed point integer components of * the specified number of bits. The bit length can range from a maximum * of 16 to a minimum of 2 bits since negative colors are not defined.

    - * + * * The bit length is the total number of bits in the signed version of the * fixed point representation of the input color, which is assumed to * be normalized into the [0..1) range. With the maximum bit length of @@ -109,7 +109,7 @@ class CompressionStreamColor extends CompressionStreamElement { */ void quantize(CompressionStream stream, HuffmanTable huffmanTable) { // Clamp quantization. - int quant = + int quant = (stream.colorQuant < 2? 2 : (stream.colorQuant > 16? 16 : stream.colorQuant)) ; @@ -142,7 +142,7 @@ class CompressionStreamColor extends CompressionStreamElement { G = (G > 32767? 32767: (G < 0? 0: G)) ; B = (B > 32767? 32767: (B < 0? 0: B)) ; A = (A > 32767? 32767: (A < 0? 0: A)) ; - + // Compute quantized values. R &= quantizationMask[quant] ; G &= quantizationMask[quant] ; @@ -173,11 +173,11 @@ class CompressionStreamColor extends CompressionStreamElement { else if (color4) computeLengthShift(R, G, B, A) ; - + // 0-length components are allowed only for normals. if (length == 0) length = 1 ; - + // Add this element to the Huffman table associated with this stream. huffmanTable.addColorEntry(length, shift, absolute) ; } @@ -206,7 +206,7 @@ class CompressionStreamColor extends CompressionStreamElement { } // - // Output the final compressed bits to the output command stream. + // Output the final compressed bits to the output command stream. // private void outputColor(HuffmanTable table, CommandStream output, int header, int headerLength) { @@ -228,7 +228,7 @@ class CompressionStreamColor extends CompressionStreamElement { G = (G >> t.shift) & (int)lengthMask[componentLength] ; B = (B >> t.shift) & (int)lengthMask[componentLength] ; - long colorSubcommand = + long colorSubcommand = (((long)t.tag) << (3 * componentLength)) | (((long)R) << (2 * componentLength)) | (((long)G) << (1 * componentLength)) | diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamElement.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamElement.java index 93d00cf..ee4d654 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamElement.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamElement.java @@ -76,7 +76,7 @@ abstract class CompressionStreamElement { 0xFFFFFFF0, 0xFFFFFFF8, 0xFFFFFFFC, 0xFFFFFFFE, 0xFFFFFFFF } ; - + /** * Array with elements that can be used as masks to retain the number of * trailing bits of data indicated by the referencing index [0..64]. Used @@ -148,7 +148,7 @@ abstract class CompressionStreamElement { * this includes the first 0 starting from the left, plus a 1 sign bit. * 0 is a special case returning 0; however, 0-length components are valid * ONLY for normals. - * + * * The decompressor uses the data length to determine how many bits of * sign extension to add to the data coming in from the compressed stream * in order to create a 16-bit signed 2's complement integer. E.g., a data @@ -243,7 +243,7 @@ abstract class CompressionStreamElement { int s1 = n1 & 0x8000 ; // equal sign optimization - if (s0 == s1) + if (s0 == s1) if (s0 == 0) this.length = getLength(n0 | n1) ; else @@ -253,7 +253,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1) ; } - + /** * Computes common length and shift of 3 numbers. @@ -295,7 +295,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1 | n2) ; } - + /** * Computes common length and shift of 4 numbers. @@ -306,7 +306,7 @@ abstract class CompressionStreamElement { this.shift = getShift(n0 | n1 | n2 | n3) ; } - + /** * Finds the maximum of two integers. diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamNormal.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamNormal.java index a9905a7..1d66e83 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamNormal.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamNormal.java @@ -59,7 +59,7 @@ class CompressionStreamNormal extends CompressionStreamElement { int octant, sextant ; boolean specialNormal ; int uAbsolute, vAbsolute ; - + /** * Create a CompressionStreamNormal. * @@ -75,7 +75,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // // Normal Encoding Parameterization - // + // // A floating point normal is quantized to a desired number of bits by // comparing it to candidate entries in a table of every possible normal // at that quantization and finding the closest match. This table of @@ -85,52 +85,52 @@ class CompressionStreamNormal extends CompressionStreamElement { // th and psi, using usual spherical coordinates. th is the angle about // the y axis, psi is the inclination to the plane containing the point. // The mapping between rectangular and spherical coordinates is: - // + // // x = cos(th)*cos(psi) // y = sin(psi) // z = sin(th)*cos(psi) - // + // // Points on sphere are folded first by octant, and then by sort order // of xyz into one of six sextants. All the table encoding takes place in // the positive octant, in the region bounded by the half spaces: - // + // // x >= z // z >= y // y >= 0 - // + // // This triangular shaped patch runs from 0 to 45 degrees in th, and // from 0 to as much as 0.615479709 (MAX_Y_ANG) in psi. The xyz bounds // of the patch is: - // + // // (1, 0, 0) (1/sqrt(2), 0, 1/sqrt(2)) (1/sqrt(3), 1/sqrt(3), 1/sqrt(3)) - // + // // When dicing this space up into discrete points, the choice for y is // linear quantization in psi. This means that if the y range is to be // divided up into n segments, the angle of segment j is: - // + // // psi(j) = MAX_Y_ANG*(j/n) - // + // // The y height of the patch (in arc length) is *not* the same as the xz // dimension. However, the subdivision quantization needs to treat xz and // y equally. To achieve this, the th angles are re-parameterized as // reflected psi angles. That is, the i-th point's th is: - // + // // th(i) = asin(tan(psi(i))) = asin(tan(MAX_Y_ANG*(i/n))) - // + // // To go the other direction, the angle th corresponds to the real index r // (in the same 0-n range as i): - // + // // r(th) = n*atan(sin(th))/MAX_Y_ANG - // + // // Rounded to the nearest integer, this gives the closest integer index i // to the xz angle th. Because the triangle has a straight edge on the // line x=z, it is more intuitive to index the xz angles in reverse // order. Thus the two equations above are replaced by: - // + // // th(i) = asin(tan(psi(i))) = asin(tan(MAX_Y_ANG*((n-i)/n))) - // + // // r(th) = n*(1 - atan(sin(th))/MAX_Y_ANG) - // + // // Each level of quantization subdivides the triangular patch twice as // densely. The case in which only the three vertices of the triangle are // present is the first logical stage of representation, but because of @@ -191,7 +191,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // An inverse sine table is used for each quantization level to take the Y // component of a normal (which is the sine of the inclination angle) and // obtain the closest quantized Y angle. - // + // // At any level of compression, there are a fixed number of different Y // angles (between 0 and MAX_Y_ANG). The inverse table is built to have // slightly more than twice as many entries as y angles at any particular @@ -199,19 +199,19 @@ class CompressionStreamNormal extends CompressionStreamElement { // of the right one. The size of the table should be as small as // possible, but with its delta sine still smaller than the delta sine // between the last two angles to be encoded. - // + // // Example: the inverse sine table has a maximum angle of 0.615479709. At // the maximum resolution of 6 bits there are 65 discrete angles used, // but twice as many are needed for thresholding between angles, so the // delta angle is 0.615479709/128. The difference then between the last // two angles to be encoded is: // sin(0.615479709*128.0/128.0) - sin(0.615479709*127.0/128.0) = 0.003932730 - // + // // Using 8 significent bits below the binary point, fixed point can // represent sines in increments of 0.003906250, just slightly smaller. // However, because the maximum Y angle sine is 0.577350269, only 148 // instead of 256 table entries are needed. - // + // private static final short inverseSine[][] = new short[MAX_UV_BITS+1][] ; // UNITY_14 * sin(MAX_Y_ANGLE) @@ -236,54 +236,54 @@ class CompressionStreamNormal extends CompressionStreamElement { // Bits below binary point for fixed point delta sine: 8 // Integer delta sine: 64 // Inverse sine table size: 148 entries - deltaSin = 1 << (14 - 8) ; + deltaSin = 1 << (14 - 8) ; break ; case 5: // Delta angle: MAX_Y_ANGLE/64.0 // Bits below binary point for fixed point delta sine: 7 // Integer delta sine: 128 // Inverse sine table size: 74 entries - deltaSin = 1 << (14 - 7) ; + deltaSin = 1 << (14 - 7) ; break ; case 4: // Delta angle: MAX_Y_ANGLE/32.0 // Bits below binary point for fixed point delta sine: 6 // Integer delta sine: 256 // Inverse sine table size: 37 entries - deltaSin = 1 << (14 - 6) ; + deltaSin = 1 << (14 - 6) ; break ; case 3: // Delta angle: MAX_Y_ANGLE/16.0 // Bits below binary point for fixed point delta sine: 5 // Integer delta sine: 512 // Inverse sine table size: 19 entries - deltaSin = 1 << (14 - 5) ; + deltaSin = 1 << (14 - 5) ; break ; case 2: // Delta angle: MAX_Y_ANGLE/8.0 // Bits below binary point for fixed point delta sine: 4 // Integer delta sine: 1024 // Inverse sine table size: 10 entries - deltaSin = 1 << (14 - 4) ; + deltaSin = 1 << (14 - 4) ; break ; case 1: // Delta angle: MAX_Y_ANGLE/4.0 // Bits below binary point for fixed point delta sine: 3 // Integer delta sine: 2048 // Inverse sine table size: 5 entries - deltaSin = 1 << (14 - 3) ; + deltaSin = 1 << (14 - 3) ; break ; case 0: // Delta angle: MAX_Y_ANGLE/2.0 // Bits below binary point for fixed point delta sine: 2 // Integer delta sine: 4096 // Inverse sine table size: 3 entries - deltaSin = 1 << (14 - 2) ; + deltaSin = 1 << (14 - 2) ; break ; } inverseSine[quant] = new short[(MAX_SIN_14BIT/deltaSin) + 1] ; - + intSin = 0 ; for (int i = 0 ; i < inverseSine[quant].length ; i++) { // Compute float representation of integer sine with desired @@ -335,7 +335,7 @@ class CompressionStreamNormal extends CompressionStreamElement { double nx, ny, nz, t ; // Clamp UV quantization. - int quant = + int quant = (stream.normalQuant < 0? 0 : (stream.normalQuant > 6? 6 : stream.normalQuant)) ; @@ -452,7 +452,7 @@ class CompressionStreamNormal extends CompressionStreamElement { specialNormal = true ; u = v = 0 ; } - + // Compute deltas if possible. // Use the non-normalized ii and jj indices. int du = 0 ; @@ -460,7 +460,7 @@ class CompressionStreamNormal extends CompressionStreamElement { int uv64 = 64 >> (6 - quant) ; absolute = false ; - if (stream.firstNormal || stream.normalQuantChanged || + if (stream.firstNormal || stream.normalQuantChanged || stream.lastSpecialNormal || specialNormal) { // The first normal by definition is absolute, and normals cannot // be represented as deltas to or from special normals, nor from @@ -488,7 +488,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // sextant has. du = ii - stream.lastU ; dv = -jj - stream.lastV ; - + // Can't delta by less than -64. if (dv < -uv64) absolute = true ; @@ -553,7 +553,7 @@ class CompressionStreamNormal extends CompressionStreamElement { // truncate the 0 sign bit for values > 0x001f. length = 6 ; } - + // Add this element to the Huffman table associated with this stream. huffmanTable.addNormalEntry(length, shift, absolute) ; @@ -647,7 +647,7 @@ class CompressionStreamNormal extends CompressionStreamElement { header |= (int)(normalSubcommand >>> (subcommandLength - 6)) ; subcommandLength -= 6 ; } - + // Add the header and body to the output buffer. output.addCommand(header, headerLength, normalSubcommand, subcommandLength) ; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamVertex.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamVertex.java index 76fe185..455b96d 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamVertex.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/CompressionStreamVertex.java @@ -66,7 +66,7 @@ class CompressionStreamVertex extends CompressionStreamElement { int xAbsolute, yAbsolute, zAbsolute ; CompressionStreamColor color = null ; CompressionStreamNormal normal = null ; - + /** * Create a CompressionStreamVertex with the given parameters. * @@ -133,7 +133,7 @@ class CompressionStreamVertex extends CompressionStreamElement { stream.byteCount += 12 ; stream.vertexCount++ ; - + if (p.x < stream.mcBounds[0].x) stream.mcBounds[0].x = p.x ; if (p.y < stream.mcBounds[0].y) stream.mcBounds[0].y = p.y ; if (p.z < stream.mcBounds[0].z) stream.mcBounds[0].z = p.z ; @@ -158,7 +158,7 @@ class CompressionStreamVertex extends CompressionStreamElement { double px, py, pz ; // Clamp quantization. - int quant = + int quant = (stream.positionQuant < 1? 1 : (stream.positionQuant > 16? 16 : stream.positionQuant)) ; @@ -227,7 +227,7 @@ class CompressionStreamVertex extends CompressionStreamElement { // 0-length components are allowed only for normals. if (length == 0) length = 1 ; - + // Add this element to the Huffman table associated with this stream. huffmanTable.addPositionEntry(length, shift, absolute) ; @@ -271,12 +271,12 @@ class CompressionStreamVertex extends CompressionStreamElement { Y = (Y >> t.shift) & (int)lengthMask[componentLength] ; Z = (Z >> t.shift) & (int)lengthMask[componentLength] ; - long positionSubcommand = + long positionSubcommand = (((long)t.tag) << (3 * componentLength)) | (((long)X) << (2 * componentLength)) | (((long)Y) << (1 * componentLength)) | (((long)Z) << (0 * componentLength)) ; - + if (subcommandLength < 6) { // The header will have some empty bits. The Huffman tag // computation will prevent this if necessary. @@ -316,7 +316,7 @@ class CompressionStreamVertex extends CompressionStreamElement { "fixed point " + d + + X + " " + Y + " " + Z + "\n" + "length " + length + " shift " + shift + (absolute? " absolute" : " relative") + "\n" + - "strip flag " + stripFlag + " mesh flag " + meshFlag + + "strip flag " + stripFlag + " mesh flag " + meshFlag + c + n ; } } diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStrip.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStrip.java index b433321..8d000a4 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStrip.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStrip.java @@ -165,7 +165,7 @@ class GeneralizedStrip { /** * A list of indices into the vertices of the original generalized * strip. It specifies the order in which vertices in the original - * strip should be followed to build GeometryArray objects. + * strip should be followed to build GeometryArray objects. */ IntList vertices ; @@ -299,7 +299,7 @@ class GeneralizedStrip { } } } - + // Finish off the last strip or fan. // If v > size then the strip is degenerate. if (v == size) @@ -318,7 +318,7 @@ class GeneralizedStrip { if (v > size) System.out.println(" ended with a degenerate triangle:" + " number of vertices: " + (v-size)) ; - + System.out.println("\n number of strips: " + stripCounts.count) ; if (stripCounts.count > 0) { System.out.println(" number of vertices: " + stripVerts.count) ; @@ -337,7 +337,7 @@ class GeneralizedStrip { // System.out.println(" indices: " + fanVerts.toString()) ; } System.out.println("\n total vertices: " + - (stripVerts.count + fanVerts.count) + + (stripVerts.count + fanVerts.count) + "\n original number of vertices: " + size + "\n") ; } @@ -348,7 +348,7 @@ class GeneralizedStrip { // have counter-clockwise (CCW) winding order when projected to // the view surface. Polygons with clockwise (CW) vertex winding // will be culled as back-facing by default. - // + // // Generalized triangle strips can flip the orientation of their // triangles with the RESTART_CW and RESTART_CCW vertex flags. // Strips flagged with an orientation opposite to what has been @@ -398,7 +398,7 @@ class GeneralizedStrip { } } } - + private static void addFan(IntList fanVerts, IntList fanCounts, int start, int length, @@ -477,12 +477,12 @@ class GeneralizedStrip { StripArray sa = new StripArray(stripVerts, stripCounts) ; if (debug) { - System.out.println("GeneralizedStrip.toTriangleStrips" + + System.out.println("GeneralizedStrip.toTriangleStrips" + "\n number of strips: " + sa.stripCounts.count) ; if (sa.stripCounts.count > 0) { System.out.println(" number of vertices: " + - sa.vertices.count + + sa.vertices.count + "\n vertices/strip: " + ((float)sa.vertices.count / (float)sa.stripCounts.count)) ; @@ -504,7 +504,7 @@ class GeneralizedStrip { // Construct a strip by criss-crossing across the interior. stripCounts.add(length) ; stripVerts.add(fans[v]) ; - + int j = v + 1 ; int k = v + (length - 1) ; while (j <= k) { @@ -715,7 +715,7 @@ class GeneralizedStrip { System.out.print(" long strip counts: [") ; for (int i = 0 ; i < longStripCount-1 ; i++) System.out.print(newStripCounts[i++] + ", ") ; - + System.out.println (newStripCounts[longStripCount-1] + "]\n") ; } @@ -730,7 +730,7 @@ class GeneralizedStrip { * * RESTART_CW and RESTART_CCW are treated as equivalent, as are * REPLACE_MIDDLE and REPLACE_OLDEST. - * + * * @param vertices an object implementing GeneralizedStripFlags * @return a StripArray representing an array of line strips */ @@ -767,7 +767,7 @@ class GeneralizedStrip { v += 2 ; } } - + // Finish off the last strip. // If v > size then the strip is degenerate. if (v == size) { @@ -802,7 +802,7 @@ class GeneralizedStrip { /** * Counts the number of lines defined by arrays of line strips. - * + * * @param stripCounts array of strip counts, as used by the * GeometryStripArray object * @return number of lines in the strips @@ -845,7 +845,7 @@ class GeneralizedStrip { /** * Breaks up triangle strips into separate triangles. - * + * * @param stripCounts array of strip counts, as used by the * GeometryStripArray object * @return array of ints which index into the original vertex array; each @@ -866,7 +866,7 @@ class GeneralizedStrip { /** * Breaks up triangle fans into separate triangles. - * + * * @param stripCounts array of strip counts, as used by the * GeometryStripArray object * @return array of ints which index into the original vertex array; each @@ -887,7 +887,7 @@ class GeneralizedStrip { /** * Takes a fan and converts it to one or more strips. - * + * * @param v index into the fans array of the first vertex in the fan * @param length number of vertices in the fan * @param fans array of vertex indices representing one or more fans diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStripFlags.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStripFlags.java index 008f15c..35b876a 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStripFlags.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedStripFlags.java @@ -58,7 +58,7 @@ interface GeneralizedStripFlags { /** * This flag indicates that a vertex starts a new strip with clockwise - * winding. + * winding. */ static final int RESTART_CW = 0 ; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedVertexList.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedVertexList.java index 73abcc5..5f6a6e8 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedVertexList.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeneralizedVertexList.java @@ -77,10 +77,10 @@ class GeneralizedVertexList implements GeneralizedStripFlags { private boolean hasColor3 = false ; private boolean hasColor4 = false ; private boolean hasNormals = false ; - + // Indicates the vertex winding of front-facing triangles in this strip. private int frontFace ; - + /** * Count of number of strips generated after conversion to GeometryArray. */ @@ -114,7 +114,7 @@ class GeneralizedVertexList implements GeneralizedStripFlags { GeneralizedVertexList(int vertexFormat, int frontFace, int initSize) { this.frontFace = frontFace ; setVertexFormat(vertexFormat) ; - + if (initSize == 0) vertices = new ArrayList() ; else @@ -153,7 +153,7 @@ class GeneralizedVertexList implements GeneralizedStripFlags { else if ((vertexFormat & GeometryArray.COLOR_3) == GeometryArray.COLOR_3) hasColor3 = true ; } - + /** * A class with fields corresponding to all the data that can be bundled * with the vertices of generalized strips. @@ -164,11 +164,11 @@ class GeneralizedVertexList implements GeneralizedStripFlags { Color3f color3 ; Color4f color4 ; Vector3f normal ; - + Vertex(Point3f p, Vector3f n, Color4f c, int flag) { this.flag = flag ; coord = new Point3f(p) ; - + if (hasNormals) normal = new Vector3f(n) ; @@ -186,7 +186,7 @@ class GeneralizedVertexList implements GeneralizedStripFlags { void addVertex(Point3f pos, Vector3f norm, Color4f color, int flag) { vertices.add(new Vertex(pos, norm, color, flag)) ; } - + /** * Return the number of vertices in this list. */ @@ -253,7 +253,7 @@ class GeneralizedVertexList implements GeneralizedStripFlags { c3f[i] = v.color3 ; } ga.setColors(0, c3f) ; - + } else if (hasColor4) { Color4f c4f[] = new Color4f[indices.count] ; for (int i = 0 ; i < indices.count ; i++) { diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryCompressor.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryCompressor.java index 691ede1..3309e9b 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryCompressor.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryCompressor.java @@ -72,7 +72,7 @@ public class GeometryCompressor { private long startTime ; public GeometryCompressor() { - // Create a compressed geometry header. + // Create a compressed geometry header. cgHeader = new CompressedGeometryData.Header() ; // v1.0.0 - pre-FCS @@ -85,8 +85,8 @@ public class GeometryCompressor { /** * Compress a stream into a CompressedGeometryData node component. - * - * + * + * * @param stream CompressionStream containing the geometry to be compressed * @return a CompressedGeometryData node component */ @@ -153,11 +153,11 @@ public class GeometryCompressor { if (stream.vertexNormals) cgHeader.bufferDataPresent |= CompressedGeometryData.Header.NORMAL_IN_BUFFER ; - + if (stream.vertexColor3 || stream.vertexColor4) cgHeader.bufferDataPresent |= CompressedGeometryData.Header.COLOR_IN_BUFFER ; - + if (stream.vertexColor4) cgHeader.bufferDataPresent |= CompressedGeometryData.Header.ALPHA_IN_BUFFER ; @@ -176,20 +176,20 @@ public class GeometryCompressor { int totalVertices = meshReferenceCount + vertexCount ; float meshPercent = 100f * meshReferenceCount/(float)totalVertices ; - float compressionRatio = + float compressionRatio = stream.getByteCount() / ((float)outputBuffer.getByteCount()) ; - int vertexBytes = + int vertexBytes = 12 + (stream.vertexColor3 ? 12 : 0) + (stream.vertexColor4 ? 16 : 0) + (stream.vertexNormals ? 12 : 0) ; float compressedVertexBytes = outputBuffer.getByteCount() / (float)totalVertices ; - + System.out.println ("\nGeometryCompressor:\n" + totalVertices + " total vertices\n" + vertexCount + " streamed vertices\n" + meshReferenceCount + - " mesh buffer references (" + meshPercent + "%)\n" + + " mesh buffer references (" + meshPercent + "%)\n" + stream.getByteCount() + " bytes streamed geometry compressed to " + outputBuffer.getByteCount() + " in " + (t/1000f) + " sec\n" + (stream.getByteCount()/(float)t) + " kbytes/sec, " + diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressor.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressor.java index 7696149..d05bf67 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressor.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressor.java @@ -68,7 +68,7 @@ abstract class GeometryDecompressor { /** * This method is called when a SetState command is encountered in the - * decompression stream. + * decompression stream. * * @param bundlingNorm true indicates normals are bundled with vertices * @param bundlingColor true indicates colors are bundled with vertices @@ -82,11 +82,11 @@ abstract class GeometryDecompressor { * This method captures the vertex output of the decompressor. The normal * or color references may be null if the corresponding data is not * bundled with the vertices in the compressed geometry buffer. Alpha - * values may be included in the color. - * + * values may be included in the color. + * * @param position The coordinates of the vertex. * @param normal The normal bundled with the vertex. May be null. - * @param color The color bundled with the vertex. May be null. + * @param color The color bundled with the vertex. May be null. * Alpha may be present. * @param vertexReplaceCode Specifies the generalized strip flag * that is bundled with each vertex. @@ -146,7 +146,7 @@ abstract class GeometryDecompressor { " shift: " + rightShift + " abs/rel: " + absolute ; } - } + } // A 16-entry mesh buffer is used. private MeshBufferEntry meshBuffer[] ; @@ -203,7 +203,7 @@ abstract class GeometryDecompressor { 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, - 0xFFFFFFFF, + 0xFFFFFFFF, } ; // A reference to the compressed data and the current offset. @@ -284,7 +284,7 @@ abstract class GeometryDecompressor { gctables[1][i] = new HuffmanTableEntry() ; gctables[2][i] = new HuffmanTableEntry() ; } - + meshBuffer = new MeshBufferEntry[16] ; for (int i = 0 ; i < 16 ; i++) meshBuffer[i] = new MeshBufferEntry() ; @@ -314,9 +314,9 @@ abstract class GeometryDecompressor { " start: " + start + " length: " + length + " data array size: " + data.length) ; - if (benchmark) + if (benchmark) benchmarkStart(length) ; - + if (start+length > data.length) throw new ArrayIndexOutOfBoundsException (J3dUtilsI18N.getString("GeometryDecompressor0")) ; @@ -364,7 +364,7 @@ abstract class GeometryDecompressor { if (debug) System.out.println(": got 0x0") ; return 0 ; } - + if (bitBufferCount == 0) { bitBuffer = (((gcData[gcIndex++] & 0xff) << 24) | ((gcData[gcIndex++] & 0xff) << 16) | @@ -471,7 +471,7 @@ abstract class GeometryDecompressor { // // Decode the opcode in currentHeader, and dispatch to the appropriate - // processing method. + // processing method. // private int processDecompressionOpcode(int mbp) { if ((currentHeader & 0xC0) == GC_SET_NORM) @@ -507,7 +507,7 @@ abstract class GeometryDecompressor { processPassThrough() ; else if ((currentHeader & 0xFF) == GC_SKIP_8) processSkip8() ; - + return 0 ; } @@ -924,12 +924,12 @@ abstract class GeometryDecompressor { ny = (float)gcNormals[v][u][1] ; nz = (float)gcNormals[v][u][2] ; - // reverse the swap + // reverse the swap if ((sex & 0x4) != 0) { t = nx ; nx = nz ; nz = t ; } if ((sex & 0x2) != 0) { t = ny ; ny = nz ; nz = t ; } if ((sex & 0x1) != 0) { t = nx ; nx = ny ; ny = t ; } - // reverse the sign flip + // reverse the sign flip if ((oct & 0x1) != 0) nz = -nz ; if ((oct & 0x2) != 0) ny = -ny ; if ((oct & 0x4) != 0) nx = -nx ; @@ -1007,7 +1007,7 @@ abstract class GeometryDecompressor { a = (a << (dataLength - (6-gct.tagLength - 3*dataLength))) | ii ; } - } + } } else { ii = getBits(dataLength - (6 - gct.tagLength - 2*dataLength), "b") ; @@ -1155,7 +1155,7 @@ abstract class GeometryDecompressor { curColor.w = curA ; curColor.w /= 32768.0 ; } if (debug) - System.out.println(" retrieved color " + curColor.x + + System.out.println(" retrieved color " + curColor.x + " " + curColor.y + " " + curColor.z + " " + curColor.w) ; } @@ -1208,7 +1208,7 @@ abstract class GeometryDecompressor { float t = (System.currentTimeMillis() - startTime) / 1000.0f ; System.out.println (" done in " + t + " sec." + "\n" + - " decompressed " + vertexCount + " vertices at " + + " decompressed " + vertexCount + " vertices at " + (vertexCount/t) + " vertices/sec\n") ; System.out.print(" vertex data present: coords") ; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressorShape3D.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressorShape3D.java index 1bda235..ba7c38e 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressorShape3D.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/GeometryDecompressorShape3D.java @@ -106,17 +106,17 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { private static final int TRI_STRIP_AND_TRI_SET = 3 ; // Private convenience copies of various constants. - private static final int TYPE_POINT = + private static final int TYPE_POINT = CompressedGeometryRetained.TYPE_POINT ; - private static final int TYPE_LINE = + private static final int TYPE_LINE = CompressedGeometryRetained.TYPE_LINE ; - private static final int TYPE_TRIANGLE = + private static final int TYPE_TRIANGLE = CompressedGeometryRetained.TYPE_TRIANGLE ; - private static final int FRONTFACE_CCW = + private static final int FRONTFACE_CCW = GeneralizedStripFlags.FRONTFACE_CCW ; /** - * Decompress the given compressed geometry. + * Decompress the given compressed geometry. * @param cgr CompressedGeometryRetained object with compressed geometry * @return an array of Shape3D with TriangleArray geometry if compressed * data contains triangles; otherwise, Shape3D array containing PointArray @@ -130,7 +130,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { /** - * Decompress the given compressed geometry. + * Decompress the given compressed geometry. * @param cgr CompressedGeometryRetained object with compressed geometry * @return an array of Shape3D with TriangleStripArray geometry if * compressed data contains triangles; otherwise, Shape3D array containing @@ -144,7 +144,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { /** - * Decompress the given compressed geometry. + * Decompress the given compressed geometry. * @param cgr CompressedGeometryRetained object with compressed geometry * @return an array of Shape3D with TriangleStripArray and * TriangleFanArray geometry if compressed data contains triangles; @@ -159,7 +159,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { /** - * Decompress the given compressed geometry. + * Decompress the given compressed geometry. * @param cgr CompressedGeometryRetained object with compressed geometry * @return an array of Shape3D with TriangleStripArray and * TriangleArray geometry if compressed data contains triangles; @@ -177,7 +177,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { * return an array of Shape3D objects using the specified triangle output * type. The triangle output type is ignored if the compressed data * contains points or lines. - */ + */ private Shape3D[] decompress(CompressedGeometryRetained cgr, int triOutputType) { @@ -221,7 +221,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { if (vlist != null) // Construct shapes using the current vertex format. addShape3D() ; - + int vertexFormat = GeometryArray.COORDINATES ; if (bundlingNorm) { @@ -293,7 +293,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { if (vlist.size() > 0) // Construct Shape3D using the current vertex format. addShape3D() ; - + // Start a new vertex list with the new format. vlist = new GeneralizedVertexList (vlist.vertexFormat|GeometryArray.NORMALS, FRONTFACE_CCW) ; @@ -429,7 +429,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { if (benchmark || statistics) printBench() ; - + if (statistics) printStats() ; } @@ -486,11 +486,11 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { System.out.println(vertexCount) ; } else if (triOutputType == TRI_STRIP_AND_TRI_SET) { - System.out.println((vertexCount + triangleCount*3) + + System.out.println((vertexCount + triangleCount*3) + "\n number of strips: " + stripCount + "\n number of individual triangles: " + triangleCount) ; - if (stripCount > 0) + if (stripCount > 0) System.out.println (" vertices/strip: " + (float)vertexCount/stripCount + "\n triangles represented in strips: " + @@ -499,7 +499,7 @@ class GeometryDecompressorShape3D extends GeometryDecompressor { else { System.out.println(vertexCount + "\n number of strips: " + stripCount) ; - if (stripCount > 0) + if (stripCount > 0) System.out.println (" vertices/strip: " + (float)vertexCount/stripCount) ; } diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanNode.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanNode.java index e025878..da7fb4b 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanNode.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanNode.java @@ -168,7 +168,7 @@ class HuffmanNode { } else return false ; } - + int incrementLength() { if (shift > 0) shift-- ; diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanTable.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanTable.java index 4963ef4..1da0bae 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanTable.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/HuffmanTable.java @@ -56,7 +56,7 @@ import java.util.ListIterator; * HuffmanNode objects. A HuffmanNode contains a tag describing the * associated token's data length, right shift value, and absolute/relative * status.

    - * + * * The tags are computed using Huffman's algorithm to build a binary tree with * a minimal total weighted path length. The frequency of each token is * used as its node's weight when building the tree. The path length from the @@ -82,7 +82,7 @@ class HuffmanTable { // lookup tables are therefore 2*17*16=544 entries in length to // account for all possible combinations of data lengths, shifts, // and relative or absolute status. - // + // colors = new HuffmanNode[544] ; positions = new HuffmanNode[544] ; @@ -264,7 +264,7 @@ class HuffmanTable { getEntries(normals, nodeList) ; computeTags(nodeList, 2) ; } - + // // Compute tags for a list of Huffman tokens. // @@ -305,7 +305,7 @@ class HuffmanTable { // Tokens need to be merged and the tree rebuilt with the new // combined frequencies. merge(nodes) ; - + } else { // Increase tag length + data length if they're too small. expand(nodes, minComponentCount) ; @@ -390,7 +390,7 @@ class HuffmanTable { // private void addNodeInOrder(LinkedList l, HuffmanNode node, Comparator c) { ListIterator i = l.listIterator(0) ; - + while (i.hasNext()) { HuffmanNode n = (HuffmanNode)i.next() ; if (c.compare(n, node) > 0) { @@ -423,7 +423,7 @@ class HuffmanTable { // // Output a setTable command for each unique token. - // + // private void outputCommands(Collection nodes, CommandStream output, int tableId) { diff --git a/src/classes/share/com/sun/j3d/utils/geometry/compression/MeshBuffer.java b/src/classes/share/com/sun/j3d/utils/geometry/compression/MeshBuffer.java index 05498c1..b71a669 100644 --- a/src/classes/share/com/sun/j3d/utils/geometry/compression/MeshBuffer.java +++ b/src/classes/share/com/sun/j3d/utils/geometry/compression/MeshBuffer.java @@ -54,11 +54,11 @@ import javax.vecmath.Vector3f; * compression semantics. */ class MeshBuffer { - // + // // The fixed-length mesh buffer stack is represented by circular buffers. // Three stack representations are provided: vertices, positions, and // indices. - // + // // The vertex representation stores references to CompressionStreamVertex // objects. The position representation stores references to Point3f, // Vector3f, Color3f, and Color4f objects, while the index representation diff --git a/src/classes/share/com/sun/j3d/utils/image/TextureLoader.java b/src/classes/share/com/sun/j3d/utils/image/TextureLoader.java index fdde9af..0609636 100644 --- a/src/classes/share/com/sun/j3d/utils/image/TextureLoader.java +++ b/src/classes/share/com/sun/j3d/utils/image/TextureLoader.java @@ -66,13 +66,13 @@ import javax.imageio.ImageIO; * Methods are provided to retrieve the Texture object and the associated * ImageComponent object or a scaled version of the ImageComponent object. * - * Default format is RGBA. Other legal formats are: RGBA, RGBA4, RGB5_A1, + * Default format is RGBA. Other legal formats are: RGBA, RGBA4, RGB5_A1, * RGB, RGB4, RGB5, R3_G3_B2, LUM8_ALPHA8, LUM4_ALPHA4, LUMINANCE and ALPHA */ public class TextureLoader extends Object { /** - * Optional flag - specifies that mipmaps are generated for all levels + * Optional flag - specifies that mipmaps are generated for all levels */ public static final int GENERATE_MIPMAP = 0x01; @@ -83,7 +83,7 @@ public class TextureLoader extends Object { * @since Java 3D 1.2 */ public static final int BY_REFERENCE = 0x02; - + /** * Optional flag - specifies that the ImageComponent2D will * have a y-orientation of y up, meaning the origin of the image is the @@ -113,7 +113,7 @@ public class TextureLoader extends Object { /* * Private declaration for BufferedImage allocation */ - private static ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); + private static ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB); private static int[] nBits = {8, 8, 8, 8}; private static int[] bandOffset = { 0, 1, 2, 3}; private static ComponentColorModel colorModel = new ComponentColorModel(cs, nBits, true, false, Transparency.TRANSLUCENT, 0); @@ -129,9 +129,9 @@ public class TextureLoader extends Object { private boolean forcePowerOfTwo = true; /** - * Contructs a TextureLoader object using the specified BufferedImage + * Contructs a TextureLoader object using the specified BufferedImage * and default format RGBA - * @param bImage The BufferedImage used for loading the texture + * @param bImage The BufferedImage used for loading the texture * * @exception NullPointerException if bImage is null */ @@ -140,9 +140,9 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified BufferedImage + * Contructs a TextureLoader object using the specified BufferedImage * and format - * @param bImage The BufferedImage used for loading the texture + * @param bImage The BufferedImage used for loading the texture * @param format The format specifies which channels to use * * @exception NullPointerException if bImage is null @@ -165,8 +165,8 @@ public class TextureLoader extends Object { /** * Contructs a TextureLoader object using the specified BufferedImage, - * format and option flags - * @param bImage The BufferedImage used for loading the texture + * format and option flags + * @param bImage The BufferedImage used for loading the texture * @param format The format specifies which channels to use * @param flags The flags specify what options to use in texture loading (generate mipmap etc) * @@ -182,7 +182,7 @@ public class TextureLoader extends Object { bufferedImage = bImage; if (format==null) chooseFormat(bufferedImage); - + if ((flags & BY_REFERENCE) != 0) { byRef = true; } @@ -195,7 +195,7 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified Image + * Contructs a TextureLoader object using the specified Image * and default format RGBA * @param image The Image used for loading the texture * @param observer The associated image observer @@ -208,9 +208,9 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified Image + * Contructs a TextureLoader object using the specified Image * and format - * @param image The Image used for loading the texture + * @param image The Image used for loading the texture * @param format The format specifies which channels to use * @param observer The associated image observer * @@ -222,9 +222,9 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified Image + * Contructs a TextureLoader object using the specified Image * flags and default format RGBA - * @param image The Image used for loading the texture + * @param image The Image used for loading the texture * @param flags The flags specify what options to use in texture loading (generate mipmap etc) * @param observer The associated image observer * @@ -234,11 +234,11 @@ public class TextureLoader extends Object { public TextureLoader(Image image, int flags, Component observer) { this(image, null, flags, observer); } - + /** - * Contructs a TextureLoader object using the specified Image - * format and option flags - * @param image The Image used for loading the texture + * Contructs a TextureLoader object using the specified Image + * format and option flags + * @param image The Image used for loading the texture * @param format The format specifies which channels to use * @param flags The flags specify what options to use in texture loading (generate mipmap etc) * @param observer The associated image observer @@ -246,7 +246,7 @@ public class TextureLoader extends Object { * @exception NullPointerException if image is null * @exception ImageException if there is a problem loading the image */ - public TextureLoader(Image image, String format, int flags, + public TextureLoader(Image image, String format, int flags, Component observer) { if (image == null) { @@ -267,7 +267,7 @@ public class TextureLoader extends Object { if (format==null) chooseFormat(bufferedImage); - + if ((flags & BY_REFERENCE) != 0) { byRef = true; } @@ -280,7 +280,7 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified file + * Contructs a TextureLoader object using the specified file * and default format RGBA * @param fname The file that specifies an Image to load the texture with * @param observer The associated image observer @@ -293,7 +293,7 @@ public class TextureLoader extends Object { /** * Contructs a TextureLoader object using the specified file, - * and format + * and format * @param fname The file that specifies an Image to load the texture with * @param format The format specifies which channels to use * @param observer The associated image observer @@ -305,7 +305,7 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified file, + * Contructs a TextureLoader object using the specified file, * option flags and default format RGBA * @param fname The file that specifies an Image to load the texture with * @param flags The flags specify what options to use in texture loading (generate mipmap etc) @@ -318,8 +318,8 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified file, - * format and option flags + * Contructs a TextureLoader object using the specified file, + * format and option flags * @param fname The file that specifies an Image to load the texture with * @param format The format specifies which channels to use * @param flags The flags specify what options to use in texture loading (generate mipmap etc) @@ -369,7 +369,7 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified URL + * Contructs a TextureLoader object using the specified URL * and default format RGBA * @param url The URL that specifies an Image to load the texture with * @param observer The associated image observer @@ -382,7 +382,7 @@ public class TextureLoader extends Object { /** * Contructs a TextureLoader object using the specified URL, - * and format + * and format * @param url The URL that specifies an Image to load the texture with * @param format The format specifies which channels to use * @param observer The associated image observer @@ -394,7 +394,7 @@ public class TextureLoader extends Object { } /** - * Contructs a TextureLoader object using the specified URL, + * Contructs a TextureLoader object using the specified URL, * option flags and default format RGBA * @param url The URL that specifies an Image to load the texture with * @param flags The flags specify what options to use in texture loading (generate mipmap etc) @@ -406,8 +406,8 @@ public class TextureLoader extends Object { this(url, null, flags, observer); } /** - * Contructs a TextureLoader object using the specified URL, - * format and option flags + * Contructs a TextureLoader object using the specified URL, + * format and option flags * @param url The url that specifies an Image to load the texture with * @param format The format specifies which channels to use * @param flags The flags specify what options to use in texture loading (generate mipmap etc) @@ -459,29 +459,29 @@ public class TextureLoader extends Object { /** * Returns the associated ImageComponent2D object - * + * * @return The associated ImageComponent2D object - */ + */ public ImageComponent2D getImage() { - if (imageComponent == null) - imageComponent = new ImageComponent2D(imageComponentFormat, + if (imageComponent == null) + imageComponent = new ImageComponent2D(imageComponentFormat, bufferedImage, byRef, yUp); return imageComponent; } /** * Returns the scaled ImageComponent2D object - * + * * @param xScale The X scaling factor * @param yScale The Y scaling factor * * @return The scaled ImageComponent2D object - */ + */ public ImageComponent2D getScaledImage(float xScale, float yScale) { if (xScale == 1.0f && yScale == 1.0f) return getImage(); else - return(new ImageComponent2D(imageComponentFormat, + return(new ImageComponent2D(imageComponentFormat, getScaledImage(bufferedImage, xScale, yScale), byRef, yUp)); @@ -489,7 +489,7 @@ public class TextureLoader extends Object { /** * Returns the scaled ImageComponent2D object - * + * * @param width The desired width * @param height The desired height * @@ -497,11 +497,11 @@ public class TextureLoader extends Object { */ public ImageComponent2D getScaledImage(int width, int height) { - if (bufferedImage.getWidth() == width && - bufferedImage.getHeight() == height) + if (bufferedImage.getWidth() == width && + bufferedImage.getHeight() == height) return getImage(); - else - return(new ImageComponent2D(imageComponentFormat, + else + return(new ImageComponent2D(imageComponentFormat, getScaledImage(bufferedImage, width, height), byRef, yUp)); @@ -509,7 +509,7 @@ public class TextureLoader extends Object { /** * Returns the associated Texture object. - * + * * @return The associated Texture object */ public Texture getTexture() { @@ -529,7 +529,7 @@ public class TextureLoader extends Object { } if ((flags & GENERATE_MIPMAP) != 0) { - + BufferedImage origImage = bufferedImage; int newW = width; int newH = height; @@ -544,7 +544,7 @@ public class TextureLoader extends Object { scaledImageComponents[i] = new ImageComponent2D( imageComponentFormat, scaledBufferedImages[i], byRef, yUp); - + tex.setImage(i, scaledImageComponents[i]); if (forcePowerOfTwo) { if (newW > 1) newW >>= 1; @@ -565,7 +565,7 @@ public class TextureLoader extends Object { scaledBufferedImages = new BufferedImage[1]; // Create texture from image - scaledBufferedImages[0] = getScaledImage(bufferedImage, + scaledBufferedImages[0] = getScaledImage(bufferedImage, width, height); scaledImageComponents[0] = new ImageComponent2D( imageComponentFormat, scaledBufferedImages[0], @@ -587,7 +587,7 @@ public class TextureLoader extends Object { Component observer) { int status; - + observer.prepareImage(image, null); while(true) { status = observer.checkImage(image, null); @@ -595,25 +595,25 @@ public class TextureLoader extends Object { return null; } else if ((status & ImageObserver.ALLBITS) != 0) { break; - } + } try { Thread.sleep(100); } catch (InterruptedException e) {} } int width = image.getWidth(observer); - int height = image.getHeight(observer); - + int height = image.getHeight(observer); + WritableRaster wr = java.awt.image.Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height, width * 4, 4, bandOffset, null); BufferedImage bImage = new BufferedImage(colorModel, wr, false, null); - + java.awt.Graphics g = bImage.getGraphics(); g.drawImage(image, 0, 0, observer); - + return bImage; } @@ -623,14 +623,14 @@ public class TextureLoader extends Object { */ private void chooseFormat(BufferedImage image) { switch (image.getType()) { - case BufferedImage.TYPE_4BYTE_ABGR : + case BufferedImage.TYPE_4BYTE_ABGR : case BufferedImage.TYPE_INT_ARGB : imageComponentFormat = ImageComponent.FORMAT_RGBA; textureFormat = Texture.RGBA; break; case BufferedImage.TYPE_3BYTE_BGR : case BufferedImage.TYPE_INT_BGR: - case BufferedImage.TYPE_INT_RGB: + case BufferedImage.TYPE_INT_RGB: imageComponentFormat = ImageComponent.FORMAT_RGB; textureFormat = Texture.RGB; break; @@ -655,7 +655,7 @@ public class TextureLoader extends Object { textureFormat = Texture.RGBA; break; } - } + } private boolean is4ByteRGBAOr3ByteRGB(RenderedImage ri) { boolean value = false; @@ -673,7 +673,7 @@ public class TextureLoader extends Object { if (sm.getDataType() == DataBuffer.TYPE_BYTE) { if (cm instanceof ComponentColorModel && sm instanceof PixelInterleavedSampleModel) { - PixelInterleavedSampleModel csm = + PixelInterleavedSampleModel csm = (PixelInterleavedSampleModel) sm; int[] offs = csm.getBandOffsets(); ComponentColorModel ccm = (ComponentColorModel)cm; @@ -701,7 +701,7 @@ public class TextureLoader extends Object { } return value; } - + private int getImageType(RenderedImage ri) { int imageType = BufferedImage.TYPE_CUSTOM; int i; @@ -731,7 +731,7 @@ public class TextureLoader extends Object { if (sm.getDataType() == DataBuffer.TYPE_BYTE) { if (cm instanceof ComponentColorModel && sm instanceof PixelInterleavedSampleModel) { - PixelInterleavedSampleModel csm = + PixelInterleavedSampleModel csm = (PixelInterleavedSampleModel) sm; int[] offs = csm.getBandOffsets(); ComponentColorModel ccm = (ComponentColorModel)cm; @@ -761,25 +761,25 @@ public class TextureLoader extends Object { } return imageType; } - + // initialize appropriate format for ImageComponent and Texture private void parseFormat(String format) { if (format==null) return; - + if (format.equals("RGBA")) { imageComponentFormat = ImageComponent.FORMAT_RGBA; textureFormat = Texture.RGBA; - } else if (format.equals("RGBA4")) { + } else if (format.equals("RGBA4")) { imageComponentFormat = ImageComponent.FORMAT_RGBA4; textureFormat = Texture.RGBA; - } else if (format.equals("RGB5_A1")) { + } else if (format.equals("RGB5_A1")) { imageComponentFormat = ImageComponent.FORMAT_RGB5_A1; textureFormat = Texture.RGBA; - } else if (format.equals("RGB")) { + } else if (format.equals("RGB")) { imageComponentFormat = ImageComponent.FORMAT_RGB; textureFormat = Texture.RGB; @@ -787,14 +787,14 @@ public class TextureLoader extends Object { imageComponentFormat = ImageComponent.FORMAT_RGB4; textureFormat = Texture.RGB; - } else if (format.equals("RGB5")) { + } else if (format.equals("RGB5")) { imageComponentFormat = ImageComponent.FORMAT_RGB5; textureFormat = Texture.RGB; - } else if (format.equals("R3_G3_B2")) { + } else if (format.equals("R3_G3_B2")) { imageComponentFormat = ImageComponent.FORMAT_R3_G3_B2; textureFormat = Texture.RGB; - + } else if (format.equals("LUM8_ALPHA8")) { imageComponentFormat = ImageComponent.FORMAT_LUM8_ALPHA8; textureFormat = Texture.LUMINANCE_ALPHA; @@ -802,11 +802,11 @@ public class TextureLoader extends Object { } else if (format.equals("LUM4_ALPHA4")) { imageComponentFormat = ImageComponent.FORMAT_LUM4_ALPHA4; textureFormat = Texture.LUMINANCE_ALPHA; - + } else if (format.equals("LUMINANCE")) { imageComponentFormat = ImageComponent.FORMAT_CHANNEL8; textureFormat = Texture.LUMINANCE; - + } else if (format.equals("ALPHA")) { imageComponentFormat = ImageComponent.FORMAT_CHANNEL8; textureFormat = Texture.ALPHA; @@ -854,14 +854,14 @@ public class TextureLoader extends Object { bandOffset[ii] = ii; nBits[ii] = 8; } - + wr = java.awt.image.Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, scaleW, scaleH, scaleW * numComponents, numComponents, bandOffset, null); int imageType; - + switch (numComponents) { case 1: imageType = BufferedImage.TYPE_BYTE_GRAY; @@ -874,12 +874,12 @@ public class TextureLoader extends Object { break; default: throw new ImageException("Illegal number of bands : " + numComponents); - + } - + scaledImage = new BufferedImage(scaleW, scaleH, imageType); } - + scaledImage.setData(wr); java.awt.Graphics2D g2 = scaledImage.createGraphics(); AffineTransform at = AffineTransform.getScaleInstance(xScale, @@ -896,7 +896,7 @@ public class TextureLoader extends Object { if (value == 0) return -1; for (;;) { - if (value == 1) + if (value == 1) return i; value >>= 1; i++; @@ -907,7 +907,7 @@ public class TextureLoader extends Object { if (value < 1) return value; - + int powerValue = 1; for (;;) { powerValue *= 2; diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/PickCanvas.java b/src/classes/share/com/sun/j3d/utils/pickfast/PickCanvas.java index 49b8189..72b184b 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/PickCanvas.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/PickCanvas.java @@ -50,20 +50,20 @@ import javax.media.j3d.*; import com.sun.j3d.utils.geometry.*; // Cone, Cylinder /** - * A subclass of PickTool, simplifies picking using mouse events from a canvas. - * This class allows picking using canvas x,y locations by generating the - * appropriate pick shape. + * A subclass of PickTool, simplifies picking using mouse events from a canvas. + * This class allows picking using canvas x,y locations by generating the + * appropriate pick shape. *

    * The pick tolerance specifies the distance from the - * pick center to include in the pick shape. A tolerance of 0.0 may speedup + * pick center to include in the pick shape. A tolerance of 0.0 may speedup * picking slightly, but also make it very difficult to pick points and lines. - *

    - * The pick canvas can be used to make a series of picks. For example, to + *

    + * The pick canvas can be used to make a series of picks. For example, to * initialize the pick canvas: *

      *     PickCanvas pickCanvas = new PickCanvas(canvas, scene);
    - *     pickCanvas.setMode(PickInfo.PICK_GEOMETRY); 
    - *     pickCanvas.setFlags(PickInfo.NODE | PickInfo.CLOSEST_INTERSECTION_POINT); 
    + *     pickCanvas.setMode(PickInfo.PICK_GEOMETRY);
    + *     pickCanvas.setFlags(PickInfo.NODE | PickInfo.CLOSEST_INTERSECTION_POINT);
      *     pickCanvas.setTolerance(4.0f);
      * 
    *

    @@ -91,7 +91,7 @@ public class PickCanvas extends PickTool { float tolerance = 2.0f; int save_xpos; int save_ypos; - + /** Constructor with Canvas3D for mouse events and BranchGroup to be picked. */ public PickCanvas (Canvas3D c, BranchGroup b) { @@ -114,7 +114,7 @@ public class PickCanvas extends PickTool { } /** Set the picking tolerance. Objects within this distance - * (in pixels) + * (in pixels) * to the mouse x,y location will be picked. The default tolerance is 2.0. * @param t The tolerance * @exception IllegalArgumentException if the tolerance is less than 0. @@ -129,10 +129,10 @@ public class PickCanvas extends PickTool { // reset pickShape pickShape = null; setShapeLocation(save_xpos, save_ypos); - } + } } - /** Get the pick tolerance. + /** Get the pick tolerance. */ public float getTolerance() { return tolerance; @@ -158,7 +158,7 @@ public class PickCanvas extends PickTool { boolean isParallel = false; double radius = 0.0; double spreadAngle = 0.0; - + this.save_xpos = xpos; this.save_ypos = ypos; canvas.getCenterEyeInImagePlate(eyePosn); @@ -203,7 +203,7 @@ public class PickCanvas extends PickTool { /* System.out.println(motion + "\n"); - System.out.println("after, mouse " + mousePosn + " eye " + eyePosn + + System.out.println("after, mouse " + mousePosn + " eye " + eyePosn + " mouseVec " + mouseVec); */ @@ -219,12 +219,12 @@ public class PickCanvas extends PickTool { if (isParallel) { // Parallel projection, use a PickCylinderRay distancePtToDelta *= motion.getScale(); - if ((pickShape != null) && + if ((pickShape != null) && (pickShape instanceof PickCylinderRay)) { - ((PickCylinderRay)pickShape).set (eyePosn, mouseVec, + ((PickCylinderRay)pickShape).set (eyePosn, mouseVec, distancePtToDelta); } else { - pickShape = (PickShape) new PickCylinderRay (eyePosn, + pickShape = (PickShape) new PickCylinderRay (eyePosn, mouseVec, distancePtToDelta); } } else { @@ -233,13 +233,13 @@ public class PickCanvas extends PickTool { // Calculate spread angle spreadAngle = Math.atan (distancePtToDelta/distanceEyeToCanvas); - if ((pickShape != null) && + if ((pickShape != null) && (pickShape instanceof PickConeRay)) { - ((PickConeRay)pickShape).set (eyePosn, mouseVec, + ((PickConeRay)pickShape).set (eyePosn, mouseVec, spreadAngle); } else { - pickShape = (PickShape) new PickConeRay (eyePosn, mouseVec, - spreadAngle); + pickShape = (PickShape) new PickConeRay (eyePosn, mouseVec, + spreadAngle); } } } diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/PickIntersection.java b/src/classes/share/com/sun/j3d/utils/pickfast/PickIntersection.java index 525d7ad..5436eae 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/PickIntersection.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/PickIntersection.java @@ -49,23 +49,23 @@ import javax.media.j3d.*; import com.sun.j3d.utils.geometry.Primitive; /** - * Holds information about an intersection of a PickShape with a Node + * Holds information about an intersection of a PickShape with a Node * as part of a PickInfo.IntersectionInfo. Information about - * the intersected geometry, intersected primitive, intersection point, and - * closest vertex can be inquired. + * the intersected geometry, intersected primitive, intersection point, and + * closest vertex can be inquired. *

    * The intersected primitive indicates which primitive out of the GeometryArray - * was intersected (where the primitive is a point, line, triangle or quad, + * was intersected (where the primitive is a point, line, triangle or quad, * not a - * com.sun.j3d.utils.geometry.Primitive). - * For example, the intersection would indicate which triangle out of a + * com.sun.j3d.utils.geometry.Primitive). + * For example, the intersection would indicate which triangle out of a * triangle strip was intersected. - * The methods which return primitive data will have one value if the primitive + * The methods which return primitive data will have one value if the primitive * is * a point, two values if the primitive is a line, three values if the primitive * is a triangle and four values if the primitive is quad. *

    - * The primitive's VWorld coordinates are saved when then intersection is + * The primitive's VWorld coordinates are saved when then intersection is * calculated. The local coordinates, normal, color and texture coordinates * for the primitive can also be inquired if they are present and readable. *

    @@ -76,7 +76,7 @@ import com.sun.j3d.utils.geometry.Primitive; * intersection can be interpolated if they are present and readable. *

    * The closest vertex is the vertex of the primitive closest to the intersection - * point. The vertex index, VWorld coordinates and local coordinates of the + * point. The vertex index, VWorld coordinates and local coordinates of the * closest vertex can be inquired. The normal, color and texture coordinate * of the closest vertex can be inquired from the geometry array: *

    @@ -95,23 +95,23 @@ import com.sun.j3d.utils.geometry.Primitive;
      * 
    *

    * The color, normal - * and texture coordinate information for the intersected primitive and the + * and texture coordinate information for the intersected primitive and the * intersection point * can be inquired - * the geometry includes them and the corresponding READ capibility bits are + * the geometry includes them and the corresponding READ capibility bits are * set. */ public class PickIntersection { - + /* The intersection point */ // Point3d getIntersectionPoint() - + /* Distance between start point of pickShape and intersection point */ // double getDistance() - - /* The vertex indices of the intersected primitive in the geometry */ + + /* The vertex indices of the intersected primitive in the geometry */ // int[] getVertexIndices() /*************************/ @@ -148,7 +148,7 @@ public class PickIntersection { private int[] primitiveNormalIndices; private int[] primitiveColorIndices; private int[] primitiveTexCoordIndices; - + /** Indices of the intersected primitive */ private int[] primitiveVertexIndices = null; @@ -190,19 +190,19 @@ public class PickIntersection { /** Coordinates of the closest vertex */ private Point3d closestVertexCoordinates = null; - /** Coordinates of the closest vertex (World coordinates) */ - private Point3d closestVertexCoordinatesVW = null; + /** Coordinates of the closest vertex (World coordinates) */ + private Point3d closestVertexCoordinatesVW = null; /* =================== METHODS ======================= */ - /** - * Constructor + /** + * Constructor * @param intersectionInfo The IntersectionInfo this intersection is part of. */ public PickIntersection (Transform3D localToVWorld, PickInfo.IntersectionInfo intersectionInfo) { - // Should check and throw NPE if the following is null. + // Should check and throw NPE if the following is null. // localToVWorld can't be null. l2vw = localToVWorld; // intersectionInfo can't be null. @@ -215,7 +215,7 @@ public class PickIntersection { primitiveVertexIndices = iInfo.getVertexIndices(); if (geometry instanceof GeometryArray) { - + int vertexFormat = ((GeometryArray)geometry).getVertexFormat(); hasColors = (0 != (vertexFormat & (GeometryArray.COLOR_3 | GeometryArray.COLOR_4))); @@ -223,23 +223,23 @@ public class PickIntersection { hasTexCoords = (0 != (vertexFormat & (GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.TEXTURE_COORDINATE_3))); - + if (geometry instanceof IndexedGeometryArray) { geometryIsIndexed = true; } } } - - /** - * Returns true if the geometry is indexed + + /** + * Returns true if the geometry is indexed * */ public boolean geometryIsIndexed() { return geometryIsIndexed; } - /** - * Get coordinates of closest vertex (local) + /** + * Get coordinates of closest vertex (local) * @return the coordinates of the vertex closest to the intersection point * */ @@ -251,7 +251,7 @@ public class PickIntersection { int vertexIndex = getClosestVertexIndex(); int vformat = geom.getVertexFormat(); int val; - + int[] indices = getPrimitiveCoordinateIndices(); if ((vformat & GeometryArray.BY_REFERENCE) == 0) { closestVertexCoordinates = new Point3d(); @@ -271,15 +271,15 @@ public class PickIntersection { } else { val = indices[vertexIndex] * 3; // for x,y,z - closestVertexCoordinates = new Point3d(floatData[val], - floatData[val+1], + closestVertexCoordinates = new Point3d(floatData[val], + floatData[val+1], floatData[val+2]); } } else { val = indices[vertexIndex] * 3; // for x,y,z - closestVertexCoordinates = new Point3d(doubleData[val], - doubleData[val+1], + closestVertexCoordinates = new Point3d(doubleData[val], + doubleData[val+1], doubleData[val+2]); } } @@ -288,18 +288,18 @@ public class PickIntersection { int offset = getInterleavedVertexOffset(geom); int stride = offset + 3; // for the vertices . val = stride * indices[vertexIndex]+offset; - closestVertexCoordinates = new Point3d(floatData[val], - floatData[val+1], + closestVertexCoordinates = new Point3d(floatData[val], + floatData[val+1], floatData[val+2]); } } } - + return closestVertexCoordinates; } /** - * Get coordinates of closest vertex (world) + * Get coordinates of closest vertex (world) * @return the coordinates of the vertex closest to the intersection point * */ @@ -312,11 +312,11 @@ public class PickIntersection { return closestVertexCoordinatesVW; } - /** - * Get index of closest vertex + /** + * Get index of closest vertex * @return the index of the closest vertex */ - public int getClosestVertexIndex() { + public int getClosestVertexIndex() { if (closestVertexIndex == -1) { double maxDist = Double.MAX_VALUE; double curDist = Double.MAX_VALUE; @@ -327,15 +327,15 @@ public class PickIntersection { // System.out.println("PI.getClosestVertexIndex : primitiveCoordinates.length " + // primitiveCoordinates.length); - + for (int i=0;i1 then we have the wrong triangle of a - quad and we return false. - + then find the interp factor, midFactor, for P between IL and IR. If + this is outside the range 0->1 then we have the wrong triangle of a + quad and we return false. + Else, the weighting is: IP = midFactor * IL + (1 - midFactor) * IR; @@ -1068,7 +1068,7 @@ public class PickIntersection { Solving for weights for the formula: IP = BaseWeight * Base + LeftWeight * L + RightWeight * R; We get: - BaseWeight = 1 - midFactor * leftFactor + BaseWeight = 1 - midFactor * leftFactor - rightFactor + midFactor * rightFactor; LeftWeight = midFactor * leftFactor; RightWeight = righFactor - midFactor * rightFactor; @@ -1076,7 +1076,7 @@ public class PickIntersection { */ boolean - interpTriangle(int index0, int index1, int index2, Point3d[] coords, + interpTriangle(int index0, int index1, int index2, Point3d[] coords, Point3d intPt) { // find the longest edge, we'll use that to pick the axis */ @@ -1103,27 +1103,27 @@ public class PickIntersection { /* System.out.println("index0 = " + index0 + " index1 = " + index1 + " index2 = " + index2); - + System.out.println("coords[index0] = " + coords[index0]); System.out.println("coords[index1] = " + coords[index1]); System.out.println("coords[index2] = " + coords[index2]); System.out.println("intPt = " + intPt); - + System.out.println("delta0 = " + delta0 + " len0 " + len0); System.out.println("delta1 = " + delta1 + " len1 " + len1); System.out.println("delta2 = " + delta2 + " len2 " + len2); */ - + /* now project the intersection point along the axis onto the edges */ - double[] factor = new double[3]; + double[] factor = new double[3]; /* the factor is for the projection opposide the vertex 0 = 1->2, etc*/ - factor[0] = + factor[0] = getInterpFactorForBase(intPt, coords[index1], coords[index2], mainAxis); - factor[1] = + factor[1] = getInterpFactorForBase(intPt, coords[index2], coords[index0], mainAxis); - factor[2] = + factor[2] = getInterpFactorForBase(intPt, coords[index0], coords[index1], mainAxis); - + if (debug) { System.out.println("intPt = " + intPt); switch(mainAxis) { @@ -1255,7 +1255,7 @@ public class PickIntersection { } - /* Get the interpolation weights for each of the verticies of the + /* Get the interpolation weights for each of the verticies of the * primitive. */ double[] getInterpWeights() { @@ -1288,7 +1288,7 @@ public class PickIntersection { case 3: // triangle if (!interpTriangle(0, 1, 2, coordinates, pt)) { throw new RuntimeException ("Interp point outside triangle"); - } + } break; case 4: // quad if (!interpTriangle(0, 1, 2, coordinates, pt)) { @@ -1303,10 +1303,10 @@ public class PickIntersection { return interpWeights; } - /** + /** Calculate the interpolation factor for point p by projecting it along - an axis (x,y,z) onto the edge between p1 and p2. If the result is - in the 0->1 range, point is between p1 and p2 (0 = point is at p1, + an axis (x,y,z) onto the edge between p1 and p2. If the result is + in the 0->1 range, point is between p1 and p2 (0 = point is at p1, 1 => point is at p2). */ private static float getInterpFactor (Point3d p, Point3d p1, Point3d p2, @@ -1335,15 +1335,15 @@ public class PickIntersection { t = (float)((p1.z - p.z) / (p1.z - p2.z)); break; default: - throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); + throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); } return t; } - /** + /** Calculate the interpolation factor for point p by projecting it along - an axis (x,y,z) onto the edge between p1 and p2. If the result is - in the 0->1 range, point is between p1 and p2 (0 = point is at p1, + an axis (x,y,z) onto the edge between p1 and p2. If the result is + in the 0->1 range, point is between p1 and p2 (0 = point is at p1, 1 => point is at p2). return MAX_VALUE if component of vertices are the same. */ @@ -1370,10 +1370,10 @@ public class PickIntersection { t = (float)((p1.z - p.z) / (p1.z - p2.z)); break; default: - throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); + throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); } return t; } - + } // PickIntersection diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/PickTool.java b/src/classes/share/com/sun/j3d/utils/pickfast/PickTool.java index fee6767..b629e6b 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/PickTool.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/PickTool.java @@ -49,28 +49,28 @@ import javax.vecmath.*; import javax.media.j3d.*; import com.sun.j3d.internal.*; -/** +/** * The base class for optimized picking operations. - * The picking methods will return a PickInfo object for each object picked, - * which can then be queried to + * The picking methods will return a PickInfo object for each object picked, + * which can then be queried to * obtain more detailed information about the specific objects that were - * picked. + * picked. *

    * The pick mode specifies the detail level of picking before the PickInfo * is returned: *

    *

      - *
    • PickInfo.PICK_BOUNDS - Pick using the only bounds of the pickable nodes. + *
    • PickInfo.PICK_BOUNDS - Pick using the only bounds of the pickable nodes. *
    • *
    • PickInfo.PICK_GEOMETRY will pick using the geometry of the pickable nodes. * Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for * this mode.
    • *

      - * The pick flags specifies the content of the PickInfo(s) returned by the - * pick methods. This is specified as one or more individual bits that are + * The pick flags specifies the content of the PickInfo(s) returned by the + * pick methods. 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.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.
        @@ -80,8 +80,8 @@ import com.sun.j3d.internal.*; *
      *
    *

    - * When using pickAllSorted or pickClosest methods, the picks - * will be sorted by the distance from the start point of the pick shape to + * When using pickAllSorted or pickClosest methods, the picks + * will be sorted by the distance from the start point of the pick shape to * the intersection point. * * @see Locale#pickClosest(int,int,javax.media.j3d.PickShape) @@ -90,80 +90,80 @@ public class PickTool { /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Shape3D node from - * the SceneGraphPath. + * Shape3D node from + * the SceneGraphPath. */ public static final int TYPE_SHAPE3D = 0x1; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Morph node from - * the SceneGraphPath. + * Morph node from + * the SceneGraphPath. */ public static final int TYPE_MORPH = 0x2; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Primitive node from - * the SceneGraphPath. + * Primitive node from + * the SceneGraphPath. */ public static final int TYPE_PRIMITIVE = 0x4; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Link node from - * the SceneGraphPath. + * Link node from + * the SceneGraphPath. */ public static final int TYPE_LINK = 0x8; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Group node from - * the SceneGraphPath. + * Group node from + * the SceneGraphPath. */ public static final int TYPE_GROUP = 0x10; - + /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * TransformGroup node from - * the SceneGraphPath. + * TransformGroup node from + * the SceneGraphPath. */ public static final int TYPE_TRANSFORM_GROUP = 0x20; - + /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * BranchGroup node from - * the SceneGraphPath. + * BranchGroup node from + * the SceneGraphPath. */ public static final int TYPE_BRANCH_GROUP = 0x40; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Switch node from - * the SceneGraphPath. + * Switch node from + * the SceneGraphPath. */ public static final int TYPE_SWITCH = 0x80; - private static final int ALL_FLAGS = + private static final int ALL_FLAGS = PickInfo.SCENEGRAPHPATH | PickInfo.NODE | PickInfo.LOCAL_TO_VWORLD | @@ -183,7 +183,7 @@ public class PickTool { Locale pickRootL = null; /** Used to store a reference point used in determining how "close" points - are. + are. */ Point3d start = null; @@ -192,14 +192,14 @@ public class PickTool { /* ============================ METHODS ============================ */ - /** + /** * Constructor with BranchGroup to be picked. */ public PickTool (BranchGroup b) { pickRootBG = b; } - /** + /** * Constructor with the Locale to be picked. */ public PickTool (Locale l) { @@ -207,13 +207,13 @@ public class PickTool { } /** Returns the BranchGroup to be picked if the tool was initialized - with a BranchGroup, null otherwise. + with a BranchGroup, null otherwise. */ public BranchGroup getBranchGroup() { return pickRootBG; } - /** + /** * Returns the Locale to be picked if the tool was initialized with * a Locale, null otherwise. */ @@ -223,7 +223,7 @@ public class PickTool { // Methods used to define the pick shape - /** Sets the pick shape to a user-provided PickShape object + /** Sets the pick shape to a user-provided PickShape object * @param ps The pick shape to pick against. * @param startPt The start point to use for distance calculations */ @@ -233,7 +233,7 @@ public class PickTool { userDefineShape = (ps != null); } - /** Sets the pick shape to use a user-provided Bounds object + /** Sets the pick shape to use a user-provided Bounds object * @param bounds The bounds to pick against. * @param startPt The start point to use for distance calculations */ @@ -244,7 +244,7 @@ public class PickTool { } /** Sets the picking detail mode. The default is PickInfo.PICK_BOUNDS. - * @param mode One of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY. + * @param mode One of PickInfo.PICK_BOUNDS or PickInfo.PICK_GEOMETRY. * @exception IllegalArgumentException if mode is not a legal value */ public void setMode (int mode) { @@ -261,10 +261,10 @@ public class PickTool { } /** Sets the PickInfo content flags. The default is PickInfo.NODE. - * @param flags specified as one or more individual bits that are - * bitwise "OR"ed together : + * @param flags specified as one or more individual bits that are + * bitwise "OR"ed together : *

      - * PickInfo.SCENEGRAPHPATH - request for computed SceneGraphPath.
      + * 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.
      @@ -287,7 +287,7 @@ public class PickTool { return flags; } - /** Sets the pick shape to a PickRay. + /** Sets the pick shape to a PickRay. * @param start The start of the ray * @param dir The direction of the ray */ @@ -307,14 +307,14 @@ public class PickTool { userDefineShape = true; } - /** Sets the pick shape to a capped PickCylinder + /** Sets the pick shape to a capped PickCylinder * @param start The start of axis of the cylinder * @param end The end of the axis of the cylinder * @param radius The radius of the cylinder */ - public void setShapeCylinderSegment (Point3d start, Point3d end, + public void setShapeCylinderSegment (Point3d start, Point3d end, double radius) { - this.pickShape = (PickShape) + this.pickShape = (PickShape) new PickCylinderSegment (start, end, radius); this.start = start; userDefineShape = true; @@ -325,31 +325,31 @@ public class PickTool { * @param dir The direction of the axis of the cylinder * @param radius The radius of the cylinder */ - public void setShapeCylinderRay (Point3d start, Vector3d dir, + public void setShapeCylinderRay (Point3d start, Vector3d dir, double radius) { this.pickShape = (PickShape) new PickCylinderRay (start, dir, radius); this.start = start; userDefineShape = true; } - /** Sets the pick shape to a capped PickCone + /** Sets the pick shape to a capped PickCone * @param start The start of axis of the cone * @param end The end of the axis of the cone * @param angle The angle of the cone */ - public void setShapeConeSegment (Point3d start, Point3d end, + public void setShapeConeSegment (Point3d start, Point3d end, double angle) { this.pickShape = (PickShape) new PickConeSegment (start, end, angle); this.start = start; userDefineShape = true; } - /** Sets the pick shape to an infinite PickCone. + /** Sets the pick shape to an infinite PickCone. * @param start The start of axis of the cone * @param dir The direction of the axis of the cone * @param angle The angle of the cone */ - public void setShapeConeRay (Point3d start, Vector3d dir, + public void setShapeConeRay (Point3d start, Vector3d dir, double angle) { this.pickShape = (PickShape) new PickConeRay (start, dir, angle); this.start = start; @@ -367,10 +367,10 @@ public class PickTool { } /** Selects all the nodes that intersect the PickShape. - @return An array of PickInfo objects which will contain - information about the picked instances. null if nothing was + @return An array of PickInfo objects which will contain + information about the picked instances. null if nothing was picked. - */ + */ public PickInfo[] pickAll () { PickInfo[] pickInfos = null; if (pickRootBG != null) { @@ -382,10 +382,10 @@ public class PickTool { } /** Select one of the nodes that intersect the PickShape - @return A PickInfo object which will contain - information about the picked instance. null if nothing + @return A PickInfo object which will contain + information about the picked instance. null if nothing was picked. - */ + */ public PickInfo pickAny () { PickInfo pickInfo = null; if (pickRootBG != null) { @@ -396,12 +396,12 @@ public class PickTool { return pickInfo; } - /** Select all the nodes that intersect the + /** Select all the nodes that intersect the PickShape, returned sorted. The "closest" object will be returned first. - See note above to see how "closest" is determined. + See note above to see how "closest" is determined.

      - @return An array of PickInfo objects which will contain - information + @return An array of PickInfo objects which will contain + information about the picked instances. null if nothing was picked. */ public PickInfo[] pickAllSorted () { @@ -414,12 +414,12 @@ public class PickTool { return pickInfos; } - /** Select the closest node that - intersects the PickShape. See note above to see how "closest" is + /** Select the closest node that + intersects the PickShape. See note above to see how "closest" is determined.

      - @return A PickInfo object which will contain - information about the picked instance. null if nothing + @return A PickInfo object which will contain + information about the picked instance. null if nothing was picked. */ public PickInfo pickClosest () { @@ -431,11 +431,11 @@ public class PickTool { pickInfo = pickRootL.pickClosest(mode, flags, pickShape); } // System.out.println(" -- pickInfo is " + pickInfo); - + return pickInfo; } - /** Get the first node of a certain type up the SceneGraphPath + /** Get the first node of a certain type up the SceneGraphPath *@param type the type of node we are interested in *@return a Node object * @@ -443,37 +443,37 @@ public class PickTool { * Scenegraphpath or a picked node */ - public Node getNode (PickInfo pickInfo, int type) { + public Node getNode (PickInfo pickInfo, int type) { // System.out.println("pickInfo is " + pickInfo); if (pickInfo == null) { return null; } - + SceneGraphPath sgp = pickInfo.getSceneGraphPath(); Node pickedNode = pickInfo.getNode(); // System.out.println("sgp = " + sgp + " pickedNode = " + pickedNode); - /* + /* * Do not check for null for pickNode and sgp. - * Will throw NPE if pickedNode or sgp isn't set in pickInfo + * Will throw NPE if pickedNode or sgp isn't set in pickInfo */ - + if ((pickedNode instanceof Shape3D) && ((type & TYPE_SHAPE3D) != 0)){ if (debug) System.out.println("Shape3D found"); return pickedNode; - } + } else if ((pickedNode instanceof Morph) && ((type & TYPE_MORPH) != 0)){ - if (debug) System.out.println("Morph found"); + if (debug) System.out.println("Morph found"); return pickedNode; } else { for (int j=sgp.nodeCount()-1; j>=0; j--){ - Node pNode = sgp.getNode(j); + Node pNode = sgp.getNode(j); if (debug) System.out.println("looking at node " + pNode); - + if ((pNode instanceof Primitive) && ((type & TYPE_PRIMITIVE) != 0)){ if (debug) System.out.println("Primitive found"); @@ -500,7 +500,7 @@ public class PickTool { else if ((pNode instanceof Group) && ((type & TYPE_GROUP) != 0)){ if (debug) System.out.println("Group found"); return pNode; - } + } } } return null; // should not be reached diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickMouseBehavior.java b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickMouseBehavior.java index 22c11ba..886ef20 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickMouseBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickMouseBehavior.java @@ -60,7 +60,7 @@ import javax.vecmath.*; */ public abstract class PickMouseBehavior extends Behavior { - + protected PickCanvas pickCanvas; protected WakeupCriterion[] conditions; @@ -70,8 +70,8 @@ public abstract class PickMouseBehavior extends Behavior { protected TransformGroup currGrp; protected static final boolean debug = false; protected MouseEvent mevent; - - /** + + /** * Creates a PickMouseBehavior given current canvas, root of the tree to * operate on, and the bounds. */ @@ -85,9 +85,9 @@ public abstract class PickMouseBehavior extends Behavior { } /** - * Sets the pick mode + * Sets the pick mode * @see PickTool#setMode - **/ + **/ public void setMode(int pickMode) { pickCanvas.setMode(pickMode); } @@ -95,16 +95,16 @@ public abstract class PickMouseBehavior extends Behavior { /** * Returns the pickMode * @see PickTool#getMode - */ + */ public int getMode() { return pickCanvas.getMode(); } /** - * Sets the pick tolerance + * Sets the pick tolerance * @see PickCanvas#setTolerance - */ + */ public void setTolerance(float tolerance) { pickCanvas.setTolerance(tolerance); } @@ -112,7 +112,7 @@ public abstract class PickMouseBehavior extends Behavior { /** * Returns the pick tolerance * @see PickCanvas#getTolerance - */ + */ public float getTolerance() { return pickCanvas.getTolerance(); } @@ -126,7 +126,7 @@ public abstract class PickMouseBehavior extends Behavior { wakeupOn(wakeupCondition); } - + private void processMouseEvent(MouseEvent evt) { buttonPress = false; @@ -139,7 +139,7 @@ public abstract class PickMouseBehavior extends Behavior { // Process mouse move event } } - + public void processStimulus (Enumeration criteria) { WakeupCriterion wakeup; AWTEvent[] evt = null; @@ -150,7 +150,7 @@ public abstract class PickMouseBehavior extends Behavior { if (wakeup instanceof WakeupOnAWTEvent) evt = ((WakeupOnAWTEvent)wakeup).getAWTEvent(); } - + if (evt[0] instanceof MouseEvent){ mevent = (MouseEvent) evt[0]; @@ -160,10 +160,10 @@ public abstract class PickMouseBehavior extends Behavior { xpos = mevent.getPoint().x; ypos = mevent.getPoint().y; } - + if (debug) System.out.println("mouse position " + xpos + " " + ypos); - + if (buttonPress){ updateScene(xpos, ypos); } @@ -171,7 +171,7 @@ public abstract class PickMouseBehavior extends Behavior { } - /** Subclasses shall implement this update function + /** Subclasses shall implement this update function */ public abstract void updateScene(int xpos, int ypos); diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickRotateBehavior.java b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickRotateBehavior.java index c256e4e..64fff73 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickRotateBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickRotateBehavior.java @@ -55,7 +55,7 @@ import javax.vecmath.*; /** * A mouse behavior that allows user to pick and rotate scene graph objects. - * Common usage: + * Common usage: *

      * 1. Create your scene graph. *

      @@ -79,7 +79,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** * Creates a pick/rotate behavior that waits for user mouse events for - * the scene graph. This method has its pickMode set to BOUNDS picking. + * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -100,11 +100,11 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. - * @param pickMode specifys PickTool.PICK_BOUNDS or PickTool.PICK_GEOMETRY. + * @param pickMode specifys PickTool.PICK_BOUNDS or PickTool.PICK_GEOMETRY. * @see PickTool#setMode **/ - public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, + public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode){ super(canvas, root, bounds); rotate = new MouseRotate(MouseRotate.MANUAL_WAKEUP); @@ -117,32 +117,32 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos) { TransformGroup tg = null; - + if (!mevent.isMetaDown() && !mevent.isAltDown()){ // System.out.println("PickRotateBeh : using pickfast pkg : PickInfo ..."); pickCanvas.setFlags(PickInfo.NODE | PickInfo.SCENEGRAPHPATH); - + pickCanvas.setShapeLocation(xpos, ypos); PickInfo pickInfo = pickCanvas.pickClosest(); if(pickInfo != null) { // System.out.println("Intersected!"); tg = (TransformGroup) pickCanvas.getNode(pickInfo, PickTool.TYPE_TRANSFORM_GROUP); if((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) { rotate.setTransformGroup(tg); rotate.wakeup(); - currentTG = tg; + currentTG = tg; } } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); @@ -156,7 +156,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ROTATE, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickTranslateBehavior.java b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickTranslateBehavior.java index 7cea98f..8d5ba47 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickTranslateBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickTranslateBehavior.java @@ -55,7 +55,7 @@ import javax.vecmath.*; /** * A mouse behavior that allows user to pick and translate scene graph objects. * Common usage: 1. Create your scene graph. 2. Create this behavior with - * the root and canvas. See PickRotateBehavior for more details. + * the root and canvas. See PickRotateBehavior for more details. */ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBehaviorCallback { @@ -65,7 +65,7 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Creates a pick/translate behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -82,7 +82,7 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Creates a pick/translate behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -102,40 +102,40 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if(!mevent.isAltDown() && mevent.isMetaDown()){ - + pickCanvas.setShapeLocation(xpos, ypos); // System.out.println("PickTranslateBeh : using pickfast pkg : PickInfo ..."); pickCanvas.setFlags(PickInfo.NODE | PickInfo.SCENEGRAPHPATH); PickInfo pickInfo = pickCanvas.pickClosest(); - + if(pickInfo != null) { // System.out.println("Intersected!"); tg = (TransformGroup) pickCanvas.getNode(pickInfo, PickTool.TYPE_TRANSFORM_GROUP); if((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) { translate.setTransformGroup(tg); translate.wakeup(); - currentTG = tg; + currentTG = tg; } } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); - + } - + } /** diff --git a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickZoomBehavior.java b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickZoomBehavior.java index 5ba718a..1db8d16 100644 --- a/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickZoomBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/pickfast/behaviors/PickZoomBehavior.java @@ -56,7 +56,7 @@ import javax.vecmath.*; /** * A mouse behavior that allows user to pick and zoom scene graph objects. * Common usage: 1. Create your scene graph. 2. Create this behavior with - * the root and canvas. See PickRotateBehavior for more details. + * the root and canvas. See PickRotateBehavior for more details. */ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehaviorCallback { @@ -66,7 +66,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior /** * Creates a pick/zoom behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -83,14 +83,14 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior /** * Creates a pick/zoom behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickTool.PICK_BOUNDS or PickTool.PICK_GEOMETRY. * @see PickTool#setMode */ - public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, + public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode) { super(canvas, root, bounds); zoom = new MouseZoom(MouseBehavior.MANUAL_WAKEUP); @@ -102,19 +102,19 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior } /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (mevent.isAltDown() && !mevent.isMetaDown()){ - + pickCanvas.setShapeLocation(xpos, ypos); // System.out.println("PickZoomBeh : using pickfast pkg : PickInfo ..."); @@ -125,15 +125,15 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior // System.out.println("Intersected!"); tg = (TransformGroup) pickCanvas.getNode(pickInfo, PickTool.TYPE_TRANSFORM_GROUP); if((tg != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))) { zoom.setTransformGroup(tg); zoom.wakeup(); - currentTG = tg; + currentTG = tg; } } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); - + } } @@ -145,7 +145,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ZOOM, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/picking/PickCanvas.java b/src/classes/share/com/sun/j3d/utils/picking/PickCanvas.java index c73de15..efe7708 100644 --- a/src/classes/share/com/sun/j3d/utils/picking/PickCanvas.java +++ b/src/classes/share/com/sun/j3d/utils/picking/PickCanvas.java @@ -50,19 +50,19 @@ import javax.media.j3d.*; import com.sun.j3d.utils.geometry.*; // Cone, Cylinder /** - * A subclass of PickTool, simplifies picking using mouse events from a canvas. - * This class allows picking using canvas x,y locations by generating the - * appropriate pick shape. + * A subclass of PickTool, simplifies picking using mouse events from a canvas. + * This class allows picking using canvas x,y locations by generating the + * appropriate pick shape. *

      * The pick tolerance specifies the distance from the - * pick center to include in the pick shape. A tolerance of 0.0 may speedup + * pick center to include in the pick shape. A tolerance of 0.0 may speedup * picking slightly, but also make it very difficult to pick points and lines. - *

      - * The pick canvas can be used to make a series of picks. For example, to + *

      + * The pick canvas can be used to make a series of picks. For example, to * initialize the pick canvas: *

        *     PickCanvas pickCanvas = new PickCanvas(canvas, scene);
      - *     pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO); 
      + *     pickCanvas.setMode(PickTool.GEOMETRY_INTERSECT_INFO);
        *     pickCanvas.setTolerance(4.0f);
        * 
      *

      @@ -90,7 +90,7 @@ public class PickCanvas extends PickTool { float tolerance = 2.0f; int save_xpos; int save_ypos; - + /** Constructor with Canvas3D for mouse events and BranchGroup to be picked. */ public PickCanvas (Canvas3D c, BranchGroup b) { @@ -113,7 +113,7 @@ public class PickCanvas extends PickTool { } /** Set the picking tolerance. Objects within this distance - * (in pixels) + * (in pixels) * to the mouse x,y location will be picked. The default tolerance is 2.0. * @param t The tolerance * @exception IllegalArgumentException if the tolerance is less than 0. @@ -128,10 +128,10 @@ public class PickCanvas extends PickTool { // reset pickShape pickShape = null; setShapeLocation(save_xpos, save_ypos); - } + } } - /** Get the pick tolerance. + /** Get the pick tolerance. */ public float getTolerance() { return tolerance; @@ -157,7 +157,7 @@ public class PickCanvas extends PickTool { boolean isParallel = false; double radius = 0.0; double spreadAngle = 0.0; - + this.save_xpos = xpos; this.save_ypos = ypos; canvas.getCenterEyeInImagePlate(eyePosn); @@ -202,7 +202,7 @@ public class PickCanvas extends PickTool { /* System.out.println(motion + "\n"); - System.out.println("after, mouse " + mousePosn + " eye " + eyePosn + + System.out.println("after, mouse " + mousePosn + " eye " + eyePosn + " mouseVec " + mouseVec); */ @@ -218,12 +218,12 @@ public class PickCanvas extends PickTool { if (isParallel) { // Parallel projection, use a PickCylinderRay distancePtToDelta *= motion.getScale(); - if ((pickShape != null) && + if ((pickShape != null) && (pickShape instanceof PickCylinderRay)) { - ((PickCylinderRay)pickShape).set (eyePosn, mouseVec, + ((PickCylinderRay)pickShape).set (eyePosn, mouseVec, distancePtToDelta); } else { - pickShape = (PickShape) new PickCylinderRay (eyePosn, + pickShape = (PickShape) new PickCylinderRay (eyePosn, mouseVec, distancePtToDelta); } } else { @@ -232,13 +232,13 @@ public class PickCanvas extends PickTool { // Calculate spread angle spreadAngle = Math.atan (distancePtToDelta/distanceEyeToCanvas); - if ((pickShape != null) && + if ((pickShape != null) && (pickShape instanceof PickConeRay)) { - ((PickConeRay)pickShape).set (eyePosn, mouseVec, + ((PickConeRay)pickShape).set (eyePosn, mouseVec, spreadAngle); } else { - pickShape = (PickShape) new PickConeRay (eyePosn, mouseVec, - spreadAngle); + pickShape = (PickShape) new PickConeRay (eyePosn, mouseVec, + spreadAngle); } } } diff --git a/src/classes/share/com/sun/j3d/utils/picking/PickIntersection.java b/src/classes/share/com/sun/j3d/utils/picking/PickIntersection.java index 93024b9..756e126 100644 --- a/src/classes/share/com/sun/j3d/utils/picking/PickIntersection.java +++ b/src/classes/share/com/sun/j3d/utils/picking/PickIntersection.java @@ -49,27 +49,27 @@ import javax.media.j3d.*; import com.sun.j3d.utils.geometry.Primitive; /** - * Holds information about an intersection of a PickShape with a Node + * Holds information about an intersection of a PickShape with a Node * as part of a PickResult. Information about - * the intersected geometry, intersected primitive, intersection point, and - * closest vertex can be inquired. + * the intersected geometry, intersected primitive, intersection point, and + * closest vertex can be inquired. *

      - * The intersected geometry is indicated by an index into the list of + * The intersected geometry is indicated by an index into the list of * geometry arrays on the PickResult. It can also be inquired from this * object. *

      * The intersected primitive indicates which primitive out of the GeometryArray - * was intersected (where the primitive is a point, line, triangle or quad, + * was intersected (where the primitive is a point, line, triangle or quad, * not a - * com.sun.j3d.utils.geometry.Primitive). - * For example, the intersection would indicate which triangle out of a + * com.sun.j3d.utils.geometry.Primitive). + * For example, the intersection would indicate which triangle out of a * triangle strip was intersected. - * The methods which return primitive data will have one value if the primitive + * The methods which return primitive data will have one value if the primitive * is * a point, two values if the primitive is a line, three values if the primitive * is a triangle and four values if the primitive is quad. *

      - * The primitive's VWorld coordinates are saved when then intersection is + * The primitive's VWorld coordinates are saved when then intersection is * calculated. The local coordinates, normal, color and texture coordinates * for the primitive can also be inquired if they are present and readable. *

      @@ -80,7 +80,7 @@ import com.sun.j3d.utils.geometry.Primitive; * intersection can be interpolated if they are present and readable. *

      * The closest vertex is the vertex of the primitive closest to the intersection - * point. The vertex index, VWorld coordinates and local coordinates of the + * point. The vertex index, VWorld coordinates and local coordinates of the * closest vertex can be inquired. The normal, color and texture coordinate * of the closest vertex can be inquired from the geometry array: *

      @@ -99,13 +99,13 @@ import com.sun.j3d.utils.geometry.Primitive;
        * 
      *

      * The color, normal - * and texture coordinate information for the intersected primitive and the + * and texture coordinate information for the intersected primitive and the * intersection point * can be inquired - * the geometry includes them and the corresponding READ capibility bits are + * the geometry includes them and the corresponding READ capibility bits are * set. * - * PickTool.setCapabilties(Node, int) + * PickTool.setCapabilties(Node, int) * can be used to set the capability bits * to allow this data to be inquired. */ @@ -189,8 +189,8 @@ public class PickIntersection { /** Coordinates of the closest vertex */ Point3d closestVertexCoordinates = null; - /** Coordinates of the closest vertex (World coordinates) */ - Point3d closestVertexCoordinatesVW = null; + /** Coordinates of the closest vertex (World coordinates) */ + Point3d closestVertexCoordinatesVW = null; /** Weight factors for interpolation, values correspond to vertex indices, * sum == 1 @@ -206,10 +206,10 @@ public class PickIntersection { // Tolerance for numerical stability static final double TOL = 1.0e-5; - + /* =================== METHODS ======================= */ - /** Constructor + /** Constructor @param pickResult The pickResult this intersection is part of. */ PickIntersection (PickResult pr, GeometryArray geomArr) { @@ -222,7 +222,7 @@ public class PickIntersection { geom = ga[geomIndex]; } - + if (geom instanceof IndexedGeometryArray) { iGeom = (IndexedGeometryArray)geom; } @@ -234,7 +234,7 @@ public class PickIntersection { (GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.TEXTURE_COORDINATE_3))); } - + /** String representation of this object */ @@ -273,7 +273,7 @@ public class PickIntersection { rt += " "+primitiveTexCoordIndices[i] + "\n"; } } - + if (closestVertexCoordinates != null) { rt += " clos. vert:" + closestVertexCoordinates + "\n"; } @@ -324,7 +324,7 @@ public class PickIntersection { rt += " "+primitiveTexCoordIndices[i] + "\n"; } } - + if (closestVertexCoordinates != null) { rt += " clos. vert:" + closestVertexCoordinates + "\n"; } @@ -347,14 +347,14 @@ public class PickIntersection { } /** - Sets the geom index into the pick result + Sets the geom index into the pick result */ void setGeomIndex(int gi) { - + if (geomIndex != gi) { GeometryArray[] ga = pickResult.getGeometryArrays(); geom = ga[gi]; - + if (geom instanceof IndexedGeometryArray) { iGeom = (IndexedGeometryArray)geom; } @@ -366,11 +366,11 @@ public class PickIntersection { (GeometryArray.TEXTURE_COORDINATE_2 | GeometryArray.TEXTURE_COORDINATE_3))); } - + geomIndex = gi; } - /** + /** Sets the coordinates of the intersection point (world coordinates). @param pt the coordinates */ @@ -382,9 +382,9 @@ public class PickIntersection { pointCoordinatesVW.y = pt.y; pointCoordinatesVW.z = pt.z; } - + /** - Returns the coordinates of the intersection point (world coordinates), + Returns the coordinates of the intersection point (world coordinates), if available. @return coordinates of the point */ @@ -393,7 +393,7 @@ public class PickIntersection { } - /** + /** Get the distance from the PickShape start point to the intersection point @return the distance to the intersection point, if available. */ @@ -401,8 +401,8 @@ public class PickIntersection { return distance; } - /** - Set the distance to intersection point + /** + Set the distance to intersection point @param dist the distance to the intersection point */ void setDistance (double dist) { @@ -418,8 +418,8 @@ public class PickIntersection { System.arraycopy (coords, 0, primitiveCoordinatesVW, 0, coords.length); } - /** - Get VWorld coordinates of the intersected primitive + /** + Get VWorld coordinates of the intersected primitive @return an array of Point3d's for the primitive that was picked */ public Point3d[] getPrimitiveCoordinatesVW () { @@ -427,7 +427,7 @@ public class PickIntersection { } - /** Set vertex indices of primitive's vertices + /** Set vertex indices of primitive's vertices @param verts array of coordinate indices */ void setVertexIndices (int [] verts) { @@ -435,7 +435,7 @@ public class PickIntersection { System.arraycopy (verts, 0, primitiveVertexIndices, 0, verts.length); } - /** + /** Get vertex indices of the intersected primitive @return an array which contains the list of indices */ @@ -450,11 +450,11 @@ public class PickIntersection { public int getGeometryArrayIndex() { return geomIndex; } - + /* ================================================================== */ /* Derived Data: GeometryArray */ - /* ================================================================== */ - + /* ================================================================== */ + /** Returns the GeometryArray for the intersection */ public GeometryArray getGeometryArray() { if (geom == null) { @@ -490,7 +490,7 @@ public class PickIntersection { /* ================================================================== */ - /** Get coordinates of closest vertex (local) + /** Get coordinates of closest vertex (local) @return the coordinates of the vertex closest to the intersection point */ public Point3d getClosestVertexCoordinates () { @@ -499,7 +499,7 @@ public class PickIntersection { int vertexIndex = getClosestVertexIndex(); int vformat = geom.getVertexFormat(); int val; - + int[] indices = getPrimitiveCoordinateIndices(); if ((vformat & GeometryArray.BY_REFERENCE) == 0) { closestVertexCoordinates = new Point3d(); @@ -544,12 +544,12 @@ public class PickIntersection { } } } - + return closestVertexCoordinates; } - /** Get coordinates of closest vertex (world) + /** Get coordinates of closest vertex (world) @return the coordinates of the vertex closest to the intersection point */ public Point3d getClosestVertexCoordinatesVW () { @@ -561,7 +561,7 @@ public class PickIntersection { return closestVertexCoordinatesVW; } - /** Get index of closest vertex + /** Get index of closest vertex @return the index of the closest vertex */ public int getClosestVertexIndex () { @@ -595,12 +595,12 @@ public class PickIntersection { closestVertexIndex = closestIndex; } } - + /* ================================================================== */ /* Derived Data: Primitive */ /* ================================================================== */ - /** + /** Get the coordinates indices for the intersected primitive. For a non-indexed primitive, this will be the same as the primitive vertex indices @return an array indices @@ -609,10 +609,10 @@ public class PickIntersection { if (primitiveCoordinateIndices == null) { if (geometryIsIndexed()) { - primitiveCoordinateIndices = + primitiveCoordinateIndices = new int[primitiveVertexIndices.length]; for (int i = 0; i < primitiveVertexIndices.length; i++) { - primitiveCoordinateIndices[i] = + primitiveCoordinateIndices[i] = iGeom.getCoordinateIndex(primitiveVertexIndices[i]); } } else { @@ -622,8 +622,8 @@ public class PickIntersection { return primitiveCoordinateIndices; } - /** - Get the local coordinates intersected primitive + /** + Get the local coordinates intersected primitive @return an array of Point3d's for the primitive that was intersected */ public Point3d[] getPrimitiveCoordinates () { @@ -632,7 +632,7 @@ public class PickIntersection { int[] indices = getPrimitiveCoordinateIndices(); int vformat = geom.getVertexFormat(); int val; - + // System.out.println("PickIntersection : indices.length - " + indices.length); if ((vformat & GeometryArray.BY_REFERENCE) == 0) { for (int i = 0; i < indices.length; i++) { @@ -660,7 +660,7 @@ public class PickIntersection { primitiveCoordinates[i] = new Point3d(p3fData[indices[i]].x, p3fData[indices[i]].y, p3fData[indices[i]].z); } } - + } else { for (int i = 0; i < indices.length; i++) { @@ -673,7 +673,7 @@ public class PickIntersection { for (int i = 0; i < indices.length; i++) { val = indices[i] * 3; primitiveCoordinates[i] = new Point3d(doubleData[val], doubleData[val+1], doubleData[val+2]); - } + } } } else { @@ -727,10 +727,10 @@ public class PickIntersection { else if ((vformat & GeometryArray.TEXTURE_COORDINATE_3) == GeometryArray.TEXTURE_COORDINATE_3) { offset += 3 * geo.getTexCoordSetCount(); } - + return offset; } - + int getInterleavedColorOffset(GeometryArray geo) { int offset = 0; @@ -764,9 +764,9 @@ public class PickIntersection { } - - - /** + + + /** Get the normal indices for the intersected primitive. For a non-indexed primitive, this will be the same as the primitive vertex indices If the geometry array does not contain normals this will return null @@ -775,10 +775,10 @@ public class PickIntersection { public int[] getPrimitiveNormalIndices () { if (hasNormals && (primitiveNormalIndices == null)) { if (geometryIsIndexed()) { - primitiveNormalIndices = + primitiveNormalIndices = new int[primitiveVertexIndices.length]; for (int i = 0; i < primitiveVertexIndices.length; i++) { - primitiveNormalIndices[i] = + primitiveNormalIndices[i] = iGeom.getNormalIndex(primitiveVertexIndices[i]); } } else { @@ -788,7 +788,7 @@ public class PickIntersection { return primitiveNormalIndices; } - /** + /** Get the normals of the intersected primitive. This will return null if the primitive does not contain normals. @return an array of Point3d's for the primitive that was intersected @@ -837,7 +837,7 @@ public class PickIntersection { return primitiveNormals; } - /** + /** Get the color indices for the intersected primitive. For a non-indexed primitive, this will be the same as the primitive vertex indices If the geometry array does not contain colors this will return null. @@ -846,10 +846,10 @@ public class PickIntersection { public int[] getPrimitiveColorIndices () { if (hasColors && (primitiveColorIndices == null)) { if (geometryIsIndexed()) { - primitiveColorIndices = + primitiveColorIndices = new int[primitiveVertexIndices.length]; for (int i = 0; i < primitiveVertexIndices.length; i++) { - primitiveColorIndices[i] = + primitiveColorIndices[i] = iGeom.getColorIndex(primitiveVertexIndices[i]); } } else { @@ -859,7 +859,7 @@ public class PickIntersection { return primitiveColorIndices; } - /** + /** Get the colors of the intersected primitive. This will return null if the primitive does not contain colors. If the geometry was defined using GeometryArray.COLOR_3, the 'w' value of the color will be set to 1.0. @@ -871,7 +871,7 @@ public class PickIntersection { int[] indices = getPrimitiveColorIndices(); int vformat = geom.getVertexFormat(); if ((vformat & GeometryArray.BY_REFERENCE) == 0) { - if ((vformat & GeometryArray.COLOR_4) == + if ((vformat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) { for (int i = 0; i < indices.length; i++) { primitiveColors[i] = new Color4f(); @@ -918,7 +918,7 @@ public class PickIntersection { else { for (int i = 0; i < indices.length; i++) { primitiveColors[i] = new Color4f(c4fData[indices[i]].x,c4fData[indices[i]].y,c4fData[indices[i]].z,c4fData[indices[i]].w); - } + } } } else { @@ -931,7 +931,7 @@ public class PickIntersection { else { // Could be color3 or color4 int val; - if ((vformat & GeometryArray.COLOR_4) == + if ((vformat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) { for (int i = 0; i < indices.length; i++) { val = indices[i] << 2; // for color4f @@ -951,7 +951,7 @@ public class PickIntersection { else { // Could be color3 or color4 int val; - if ((vformat & GeometryArray.COLOR_4) == + if ((vformat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) { for (int i = 0; i < indices.length; i++) { val = indices[i] << 2; // for color4f @@ -971,10 +971,10 @@ public class PickIntersection { else { float[] floatData = geom.getInterleavedVertices(); int offset = getInterleavedColorOffset(geom); - int stride = getInterleavedStride(geom); + int stride = getInterleavedStride(geom); for (int i = 0; i < indices.length; i++) { int val = stride * indices[i]+offset; - if ((vformat & GeometryArray.COLOR_4) == + if ((vformat & GeometryArray.COLOR_4) == GeometryArray.COLOR_4) { primitiveColors[i] = new Color4f(floatData[val],floatData[val+1],floatData[val+2],floatData[val+3]); } @@ -988,22 +988,22 @@ public class PickIntersection { return primitiveColors; } - /** - Get the texture coordinate indices for the intersected primitive at the specifed + /** + Get the texture coordinate indices for the intersected primitive at the specifed index in the specified texture coordinate set. For a non-indexed primitive, this will be the same as the primitive vertex indices - If the geometry array does not contain texture coordinates, this will + If the geometry array does not contain texture coordinates, this will return null. @return an array indices */ public int[] getPrimitiveTexCoordIndices (int index) { if (hasTexCoords && (primitiveTexCoordIndices == null)) { if (geometryIsIndexed()) { - primitiveTexCoordIndices = + primitiveTexCoordIndices = new int[primitiveVertexIndices.length]; for (int i = 0; i < primitiveVertexIndices.length; i++) { - primitiveTexCoordIndices[i] = - iGeom.getTextureCoordinateIndex(index, + primitiveTexCoordIndices[i] = + iGeom.getTextureCoordinateIndex(index, primitiveVertexIndices[i]); } } else { @@ -1013,10 +1013,10 @@ public class PickIntersection { return primitiveTexCoordIndices; } - /** - Get the texture coordinates of the intersected primitive at the specifed + /** + Get the texture coordinates of the intersected primitive at the specifed index in the specified texture coordinate set. - null if the primitive does not contain texture coordinates. + null if the primitive does not contain texture coordinates. If the geometry was defined using GeometryArray.TEXTURE_COORDINATE_2, the 'z' value of the texture coordinate will be set to 0.0. @@ -1078,7 +1078,7 @@ public class PickIntersection { texCoord3f[indices[i]].z); } } - + } } else { @@ -1095,7 +1095,7 @@ public class PickIntersection { } for (int i = 0; i < indices.length; i++) { int val = stride * indices[i]; - if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) == + if ((vformat & GeometryArray.TEXTURE_COORDINATE_2) == GeometryArray.TEXTURE_COORDINATE_2) { primitiveTexCoords[i] = new TexCoord3f(floatData[val +offset ],floatData[val+1+offset],0.0f); } @@ -1109,7 +1109,7 @@ public class PickIntersection { return primitiveTexCoords; } - + /* ================================================================== */ @@ -1138,7 +1138,7 @@ public class PickIntersection { /** Returns the normal of the intersection point. Returns null if the geometry does not contain normals. - @return normal at the intersection point. + @return normal at the intersection point. */ public Vector3f getPointNormal() { if (hasNormals && (pointNormal == null)) { @@ -1157,9 +1157,9 @@ public class PickIntersection { /** Returns the color of the intersection point. Returns null if the geometry does not contain colors. If the geometry was defined with - GeometryArray.COLOR_3, the 'w' component of the color will initialized to + GeometryArray.COLOR_3, the 'w' component of the color will initialized to 1.0 - @return color at the intersection point. + @return color at the intersection point. */ public Color4f getPointColor() { if (hasColors && (pointColor == null)) { @@ -1177,13 +1177,13 @@ public class PickIntersection { } /** - Returns the texture coordinate of the intersection point at the specifed + Returns the texture coordinate of the intersection point at the specifed index in the specified texture coordinate set. Returns null if the geometry does not contain texture coordinates. If the geometry was defined with GeometryArray.TEXTURE_COORDINATE_3, the 'z' component of the texture coordinate will initialized to 0.0 - @return texture coordinate at the intersection point. + @return texture coordinate at the intersection point. */ public TexCoord3f getPointTextureCoordinate(int index) { if (hasTexCoords && (pointTexCoord == null)) { @@ -1204,7 +1204,7 @@ public class PickIntersection { /* ================================================================== */ /* absolute value */ - double + double abs(double value) { if (value < 0.0) { return -value; @@ -1215,7 +1215,7 @@ public class PickIntersection { /* return the axis corresponding to the largest component of delta */ - int + int maxAxis(Vector3d delta) { int axis = X_AXIS; double max = abs(delta.x); @@ -1229,7 +1229,7 @@ public class PickIntersection { return axis; } - /* Triangle interpolation. Basic idea: + /* Triangle interpolation. Basic idea: * Map the verticies of the triangle to the form: * * L--------R @@ -1245,10 +1245,10 @@ public class PickIntersection { IL = leftFactor * L + (1- leftFactor) * Base IR = rightFactor * R + (1-rightFactor) * Base - then find the interp factor, midFactor, for P between IL and IR. If - this is outside the range 0->1 then we have the wrong triangle of a - quad and we return false. - + then find the interp factor, midFactor, for P between IL and IR. If + this is outside the range 0->1 then we have the wrong triangle of a + quad and we return false. + Else, the weighting is: IP = midFactor * IL + (1 - midFactor) * IR; @@ -1256,7 +1256,7 @@ public class PickIntersection { Solving for weights for the formula: IP = BaseWeight * Base + LeftWeight * L + RightWeight * R; We get: - BaseWeight = 1 - midFactor * leftFactor + BaseWeight = 1 - midFactor * leftFactor - rightFactor + midFactor * rightFactor; LeftWeight = midFactor * leftFactor; RightWeight = righFactor - midFactor * rightFactor; @@ -1264,7 +1264,7 @@ public class PickIntersection { */ boolean - interpTriangle(int index0, int index1, int index2, Point3d[] coords, + interpTriangle(int index0, int index1, int index2, Point3d[] coords, Point3d intPt) { // find the longest edge, we'll use that to pick the axis */ @@ -1291,27 +1291,27 @@ public class PickIntersection { /* System.out.println("index0 = " + index0 + " index1 = " + index1 + " index2 = " + index2); - + System.out.println("coords[index0] = " + coords[index0]); System.out.println("coords[index1] = " + coords[index1]); System.out.println("coords[index2] = " + coords[index2]); System.out.println("intPt = " + intPt); - + System.out.println("delta0 = " + delta0 + " len0 " + len0); System.out.println("delta1 = " + delta1 + " len1 " + len1); System.out.println("delta2 = " + delta2 + " len2 " + len2); */ - + /* now project the intersection point along the axis onto the edges */ - double[] factor = new double[3]; + double[] factor = new double[3]; /* the factor is for the projection opposide the vertex 0 = 1->2, etc*/ - factor[0] = + factor[0] = getInterpFactorForBase(intPt, coords[index1], coords[index2], mainAxis); - factor[1] = + factor[1] = getInterpFactorForBase(intPt, coords[index2], coords[index0], mainAxis); - factor[2] = + factor[2] = getInterpFactorForBase(intPt, coords[index0], coords[index1], mainAxis); - + if (debug) { System.out.println("intPt = " + intPt); switch(mainAxis) { @@ -1443,7 +1443,7 @@ public class PickIntersection { } - /* Get the interpolation weights for each of the verticies of the + /* Get the interpolation weights for each of the verticies of the * primitive. */ double[] getInterpWeights() { @@ -1476,7 +1476,7 @@ public class PickIntersection { case 3: // triangle if (!interpTriangle(0, 1, 2, coordinates, pt)) { throw new RuntimeException ("Interp point outside triangle"); - } + } break; case 4: // quad if (!interpTriangle(0, 1, 2, coordinates, pt)) { @@ -1491,10 +1491,10 @@ public class PickIntersection { return interpWeights; } - /** + /** Calculate the interpolation factor for point p by projecting it along - an axis (x,y,z) onto the edge between p1 and p2. If the result is - in the 0->1 range, point is between p1 and p2 (0 = point is at p1, + an axis (x,y,z) onto the edge between p1 and p2. If the result is + in the 0->1 range, point is between p1 and p2 (0 = point is at p1, 1 => point is at p2). */ private static float getInterpFactor (Point3d p, Point3d p1, Point3d p2, @@ -1523,15 +1523,15 @@ public class PickIntersection { t = (float)((p1.z - p.z) / (p1.z - p2.z)); break; default: - throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); + throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); } return t; } - /** + /** Calculate the interpolation factor for point p by projecting it along - an axis (x,y,z) onto the edge between p1 and p2. If the result is - in the 0->1 range, point is between p1 and p2 (0 = point is at p1, + an axis (x,y,z) onto the edge between p1 and p2. If the result is + in the 0->1 range, point is between p1 and p2 (0 = point is at p1, 1 => point is at p2). return MAX_VALUE if component of vertices are the same. */ @@ -1558,12 +1558,12 @@ public class PickIntersection { t = (float)((p1.z - p.z) / (p1.z - p2.z)); break; default: - throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); + throw new RuntimeException ("invalid axis parameter "+axis+" (must be 0-2)"); } return t; } - + } // PickIntersection diff --git a/src/classes/share/com/sun/j3d/utils/picking/PickResult.java b/src/classes/share/com/sun/j3d/utils/picking/PickResult.java index 047d46f..71a29c6 100644 --- a/src/classes/share/com/sun/j3d/utils/picking/PickResult.java +++ b/src/classes/share/com/sun/j3d/utils/picking/PickResult.java @@ -52,13 +52,13 @@ import com.sun.j3d.internal.*; /** * Stores information about a pick hit. - * Detailed information about the pick and each intersection of the PickShape + * Detailed information about the pick and each intersection of the PickShape * with the picked Node can be inquired. The PickResult is constructed with * basic information and more detailed information is generated as needed. The - * additional information is only available if capability bits on the scene - * graph Nodes are set properly; + * additional information is only available if capability bits on the scene + * graph Nodes are set properly; * - * PickTool.setCapabilties(Node, int) + * PickTool.setCapabilties(Node, int) * can * be used to ensure correct capabilites are set. Inquiring data which is not * available due to capabilties not being set will generate a @@ -69,7 +69,7 @@ import com.sun.j3d.internal.*; * transformation for the Node. *

      * Pick hits on TriangleStrip primitives will store the triangle points in the - * PickIntersection with + * PickIntersection with * the verticies in counter-clockwise order. For triangles which start with * an odd numbered vertex this will be the the opposite of the * order of the points in the TriangleStrip. @@ -79,7 +79,7 @@ import com.sun.j3d.internal.*; *

      * If the Shape3D being picked has multiple geometry arrays, the arrays are * stored in the PickResult and referred to by a geometry index. - *

      + *

      * If the Shape3D refers to a CompressedGeometry, the geometry is decompressed * into an array of Shape3D nodes which can be inquired. The geometry * NodeComponents for the Shape3D nodes are stored and used as if the Shape3D @@ -87,19 +87,19 @@ import com.sun.j3d.internal.*; * Shape3D, the decompressed Shape3Ds and GeometryArrays will be stored * sequentially. *

      - * The intersection point for Morph nodes cannot be calculated using the - * displayed geometry + * The intersection point for Morph nodes cannot be calculated using the + * displayed geometry * due to limitations in the current Java3D core API (the current - * geometry of the the Morph cannot be inquired). Instead + * geometry of the the Morph cannot be inquired). Instead * the geometry at index 0 in the Morph is used. This limitation may * be eliminated in a future release of Java3D. - */ + */ public class PickResult { - - /* OPEN ISSUES: - -- getInterpolatedTextureCoordinates uses the depricated API faor + + /* OPEN ISSUES: + -- getInterpolatedTextureCoordinates uses the depricated API faor getTextureCoordinate(), need to update. - -- Bounds tests don't fill in any picking info. + -- Bounds tests don't fill in any picking info. -- Can't do any intersections with the PickPoint shape. */ @@ -107,82 +107,82 @@ public class PickResult { // Externally used constants /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Shape3D node from - * the SceneGraphPath. + * Shape3D node from + * the SceneGraphPath. */ public static final int SHAPE3D = 0x1; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Morph node from - * the SceneGraphPath. + * Morph node from + * the SceneGraphPath. */ public static final int MORPH = 0x2; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Primitive node from - * the SceneGraphPath. + * Primitive node from + * the SceneGraphPath. */ public static final int PRIMITIVE = 0x4; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Link node from - * the SceneGraphPath. + * Link node from + * the SceneGraphPath. */ public static final int LINK = 0x8; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Group node from - * the SceneGraphPath. + * Group node from + * the SceneGraphPath. */ public static final int GROUP = 0x10; - + /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * TransformGroup node from - * the SceneGraphPath. + * TransformGroup node from + * the SceneGraphPath. */ public static final int TRANSFORM_GROUP = 0x20; - + /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * BranchGroup node from - * the SceneGraphPath. + * BranchGroup node from + * the SceneGraphPath. */ public static final int BRANCH_GROUP = 0x40; /** - * Flag to pass to + * Flag to pass to * getNode(int) * to return a - * Switch node from - * the SceneGraphPath. + * Switch node from + * the SceneGraphPath. */ public static final int SWITCH = 0x80; /* =================== ATTRIBUTES ======================= */ - static boolean debug = false; + static boolean debug = false; /** if true, find only the first intersection */ private boolean firstIntersectOnly = false; @@ -217,7 +217,7 @@ public class PickResult { * Used in PickTool */ ArrayList intersections = null; - + // internal constants used for intersections static final double FUZZ = 1E-6; /* fuzziness factor used to determine if two lines are parallel */ @@ -239,7 +239,7 @@ public class PickResult { PickResult () { } /** Construct a PickResult using a SceneGraphPath - @param sgp SceneGraphPath associated with this PickResult + @param sgp SceneGraphPath associated with this PickResult @param ps The pickShape to intersect against */ public PickResult (SceneGraphPath sgp, PickShape ps) { @@ -258,7 +258,7 @@ public class PickResult { @throws IllegalArgumentException If the node is not a Morph or Shape3D. */ public PickResult (Node pn, Transform3D l2vw, PickShape ps) { - if ((pn instanceof Shape3D) || (pn instanceof Morph)) { + if ((pn instanceof Shape3D) || (pn instanceof Morph)) { pickedNode = pn; localToVWorld = l2vw; pickShape = ps; @@ -279,7 +279,7 @@ public class PickResult { if (pickShapeEnd == null) pickShapeEnd = new Point3d(); if (pickShapeDir == null) pickShapeDir = new Vector3d(); ((PickSegment)pickShape).get(pickShapeStart, pickShapeEnd); - pickShapeDir.set (pickShapeEnd.x - pickShapeStart.x, + pickShapeDir.set (pickShapeEnd.x - pickShapeStart.x, pickShapeEnd.y - pickShapeStart.y, pickShapeEnd.z - pickShapeStart.z); pickShapeType = PICK_SHAPE_SEGMENT; @@ -290,7 +290,7 @@ public class PickResult { else if( pickShapeBounds instanceof BoundingSphere ) pickShapeType = PICK_SHAPE_BOUNDING_SPHERE; else if( pickShapeBounds instanceof BoundingPolytope ) - pickShapeType = PICK_SHAPE_BOUNDING_POLYTOPE; + pickShapeType = PICK_SHAPE_BOUNDING_POLYTOPE; } else if(pickShape instanceof PickPoint) { throw new RuntimeException ("PickPoint doesn't make sense for geometry-based picking. Java 3D doesn't have spatial information of the surface. Should use PickBounds with BoundingSphere and set radius to a epsilon tolerance."); } else if (pickShape instanceof PickCylinder) { @@ -298,8 +298,8 @@ public class PickResult { } else if (pickShape instanceof PickCone) { pickShapeType = PICK_SHAPE_CONE; } else { - throw new - RuntimeException("PickShape not supported for intersection"); + throw new + RuntimeException("PickShape not supported for intersection"); } } @@ -312,7 +312,7 @@ public class PickResult { } - /** Get the localToVworld transform for the Node + /** Get the localToVworld transform for the Node */ public Transform3D getLocalToVworld() { return localToVWorld; @@ -373,14 +373,14 @@ public class PickResult { } } - /** Get the PickShape used for intersections + /** Get the PickShape used for intersections */ public PickShape getPickShape() { return pickShape; } /** Set the PickResult to find only the first intersection of the PickShape - * with the Node. The default is false (all intersections are + * with the Node. The default is false (all intersections are * found) */ public void setFirstIntersectOnly(boolean flag) { @@ -431,7 +431,7 @@ public class PickResult { } for (int i=0;i=0; j--){ - Node pNode = pickedSceneGraphPath.getNode(j); + Node pNode = pickedSceneGraphPath.getNode(j); if (debug) System.out.println("looking at node " + pNode); - + if ((pNode instanceof Primitive) && ((flags & PRIMITIVE) != 0)){ if (debug) System.out.println("Primitive found"); @@ -584,7 +584,7 @@ public class PickResult { else if ((pNode instanceof Group) && ((flags & GROUP) != 0)){ if (debug) System.out.println("Group found"); return pNode; - } + } } } return null; // should not be reached @@ -600,7 +600,7 @@ public class PickResult { /** Fill in the intersections of the Node with the PickShape */ boolean generateIntersections() { - if (geometryArrays == null) { + if (geometryArrays == null) { storeGeometry(); } intersections = new ArrayList(); @@ -620,7 +620,7 @@ public class PickResult { - /* Takes a GeometryArray object, determines what actual type + /* Takes a GeometryArray object, determines what actual type * it is (RTTI) and casts it to call the appropriate intersect method. */ final boolean intersect(int geomIndex, boolean firstpick) { @@ -659,7 +659,7 @@ public class PickResult { } - Point3d[] pnts = new Point3d[numPts]; + Point3d[] pnts = new Point3d[numPts]; /* System.out.println("geomIndex : " + geomIndex); @@ -668,7 +668,7 @@ public class PickResult { System.out.println("localToVWorld : "); System.out.println(localToVWorld); */ - + if (debug) { System.out.println("localToVWorld = " + localToVWorld); } @@ -760,7 +760,7 @@ public class PickResult { } else if (geom instanceof LineArray) { retFlag = intersectLA ((LineArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof LineStripArray) { - retFlag = intersectLSA ((LineStripArray)geom, geomIndex, pnts, + retFlag = intersectLSA ((LineStripArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof IndexedLineArray) { pi.iGeom = (IndexedGeometryArray) geom; @@ -768,10 +768,10 @@ public class PickResult { firstpick, pi); } else if (geom instanceof IndexedLineStripArray) { pi.iGeom = (IndexedGeometryArray) geom; - retFlag = intersectILSA ((IndexedLineStripArray)geom, geomIndex, pnts, + retFlag = intersectILSA ((IndexedLineStripArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof TriangleArray) { - retFlag = intersectTA ((TriangleArray)geom, geomIndex, pnts, + retFlag = intersectTA ((TriangleArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof TriangleStripArray) { retFlag = intersectTSA ((TriangleStripArray)geom, geomIndex, pnts, @@ -785,11 +785,11 @@ public class PickResult { firstpick, pi); } else if (geom instanceof IndexedTriangleStripArray) { pi.iGeom = (IndexedGeometryArray) geom; - retFlag = intersectITSA ((IndexedTriangleStripArray)geom, geomIndex, + retFlag = intersectITSA ((IndexedTriangleStripArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof IndexedTriangleFanArray) { pi.iGeom = (IndexedGeometryArray) geom; - retFlag = intersectITFA ((IndexedTriangleFanArray)geom, geomIndex, + retFlag = intersectITFA ((IndexedTriangleFanArray)geom, geomIndex, pnts, firstpick, pi); } else if (geom instanceof QuadArray) { retFlag = intersectQA ((QuadArray)geom, geomIndex, pnts, firstpick, pi); @@ -810,7 +810,7 @@ public class PickResult { /* INTERSECT METHODS BY PRIMITIVE TYPE */ /* ==================================================================== */ - boolean intersectPoint(int[] vertidx, int[] coordidx, int geomIndex, + boolean intersectPoint(int[] vertidx, int[] coordidx, int geomIndex, Point3d[] pnts, PickIntersection pi) { // PickIntersection pi = new PickIntersection(this); @@ -824,7 +824,7 @@ public class PickResult { boolean intersect = false; switch(pickShapeType) { case PICK_SHAPE_RAY: - intersect = intersectPntAndRay(point[0], pickShapeStart, + intersect = intersectPntAndRay(point[0], pickShapeStart, pickShapeDir, pi); break; case PICK_SHAPE_SEGMENT: @@ -863,7 +863,7 @@ public class PickResult { newpi.iGeom = pi.iGeom; newpi.setDistance(pi.distance); newpi.setPointCoordinatesVW(pi.getPointCoordinatesVW()); - + // Set PickIntersection parameters newpi.setGeomIndex(geomIndex); newpi.setVertexIndices (vertidx); @@ -872,23 +872,23 @@ public class PickResult { return true; } return false; - } + } - boolean intersectLine(int[] vertidx, int[] coordidx, int geomIndex, + boolean intersectLine(int[] vertidx, int[] coordidx, int geomIndex, Point3d[] pnts, PickIntersection pi) { - + Point3d[] linePts = new Point3d[2]; linePts[0] = pnts[coordidx[0]]; linePts[1] = pnts[coordidx[1]]; - + boolean intersect = false; switch(pickShapeType) { case PICK_SHAPE_RAY: - intersect = intersectLineAndRay(linePts[0], linePts[1], + intersect = intersectLineAndRay(linePts[0], linePts[1], pickShapeStart, pickShapeDir, pi); break; case PICK_SHAPE_SEGMENT: - if (intersectLineAndRay(linePts[0], linePts[1], pickShapeStart, + if (intersectLineAndRay(linePts[0], linePts[1], pickShapeStart, pickShapeDir, pi)) { if (pi.getDistance() <= 1.0) { intersect = true; @@ -896,10 +896,10 @@ public class PickResult { } break; /* case PICK_SHAPE_POINT: - dir.x = linePts[1].x - linePts[0].x; - dir.y = linePts[1].y - linePts[0].y; - dir.z = linePts[1].z - linePts[0].z; - if (intersectPntAndRay(((PickPoint)pickShape).location, + dir.x = linePts[1].x - linePts[0].x; + dir.y = linePts[1].y - linePts[0].y; + dir.z = linePts[1].z - linePts[0].z; + if (intersectPntAndRay(((PickPoint)pickShape).location, pnts[0], dir, dist)) { if(dist[0] <= 1.0) { intersect = true; @@ -913,7 +913,7 @@ public class PickResult { pi.setPointCoordinatesVW(zeroPnt); break; case PICK_SHAPE_BOUNDING_SPHERE: - intersect = intersectBoundingSphere(linePts, + intersect = intersectBoundingSphere(linePts, (BoundingSphere)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; @@ -921,7 +921,7 @@ public class PickResult { intersect = intersectBoundingPolytope(linePts, (BoundingPolytope)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); - break; + break; case PICK_SHAPE_CYLINDER: intersect = intersectCylinder (linePts, (PickCylinder)pickShape,pi); break; @@ -945,15 +945,15 @@ public class PickResult { return false; } - boolean intersectTri(int[] vertidx, int[] coordidx, int geomIndex, + boolean intersectTri(int[] vertidx, int[] coordidx, int geomIndex, Point3d[] pnts, PickIntersection pi) { Point3d[] triPts = new Point3d[3]; - + triPts[0] = pnts[coordidx[0]]; triPts[1] = pnts[coordidx[1]]; triPts[2] = pnts[coordidx[2]]; - + boolean intersect = false; switch(pickShapeType) { @@ -965,21 +965,21 @@ public class PickResult { break; /* case PICK_SHAPE_POINT: if(inside(triPts, (PickPoint) pickShape, ccw)==false) - return false; + return false; break; */ case PICK_SHAPE_BOUNDING_BOX: - intersect = intersectBoundingBox (triPts, + intersect = intersectBoundingBox (triPts, (BoundingBox)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; case PICK_SHAPE_BOUNDING_SPHERE: - intersect = intersectBoundingSphere (triPts, + intersect = intersectBoundingSphere (triPts, (BoundingSphere)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; case PICK_SHAPE_BOUNDING_POLYTOPE: - intersect = intersectBoundingPolytope (triPts, + intersect = intersectBoundingPolytope (triPts, (BoundingPolytope)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; @@ -1007,11 +1007,11 @@ public class PickResult { return false; } - boolean intersectQuad(int[] vertidx, int[] coordidx, int geomIndex, + boolean intersectQuad(int[] vertidx, int[] coordidx, int geomIndex, Point3d[] pnts, PickIntersection pi) { Point3d[] quadPts = new Point3d[4]; - + quadPts[0] = pnts[coordidx[0]]; quadPts[1] = pnts[coordidx[1]]; quadPts[2] = pnts[coordidx[2]]; @@ -1029,21 +1029,21 @@ public class PickResult { break; /* case PICK_SHAPE_POINT: if(inside(quadPts, (PickPoint) pickShape, ccw)==false) - return false; + return false; break; */ case PICK_SHAPE_BOUNDING_BOX: - intersect = intersectBoundingBox (quadPts, + intersect = intersectBoundingBox (quadPts, (BoundingBox)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; case PICK_SHAPE_BOUNDING_SPHERE: - intersect = intersectBoundingSphere (quadPts, + intersect = intersectBoundingSphere (quadPts, (BoundingSphere)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; case PICK_SHAPE_BOUNDING_POLYTOPE: - intersect = intersectBoundingPolytope (quadPts, + intersect = intersectBoundingPolytope (quadPts, (BoundingPolytope)pickShapeBounds); pi.setPointCoordinatesVW(zeroPnt); break; @@ -1054,12 +1054,12 @@ public class PickResult { intersect = intersectCone (quadPts, (PickCone)pickShape, pi); break; } - if (intersect) { + if (intersect) { PickIntersection newpi = new PickIntersection(this, pi.geom); newpi.iGeom = pi.iGeom; newpi.setDistance(pi.distance); newpi.setPointCoordinatesVW(pi.getPointCoordinatesVW()); - + // Set PickIntersection parameters newpi.setGeomIndex(geomIndex); newpi.setVertexIndices (vertidx); @@ -1074,10 +1074,10 @@ public class PickResult { /* INTERSECT METHODS BY GEOMETRY TYPE */ /* ==================================================================== */ - /** - Intersect method for PointArray + /** + Intersect method for PointArray */ - boolean intersectPA (PointArray geom, int geomIndex, Point3d[] pnts, + boolean intersectPA (PointArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { if (debug) System.out.println ("intersect: PointArray"); @@ -1096,8 +1096,8 @@ public class PickResult { return false; } - /** - Intersect method for IndexedPointArray + /** + Intersect method for IndexedPointArray */ boolean intersectIPA (IndexedPointArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { @@ -1109,7 +1109,7 @@ public class PickResult { int numint = 0; int indexCount = geom.getIndexCount(); - + for (int i=0; i< indexCount; i++) { pntVertIdx[0] = i; pntCoordIdx[0] = geom.getCoordinateIndex(i); @@ -1123,11 +1123,11 @@ public class PickResult { } - /** - Intersect method for LineArray + /** + Intersect method for LineArray */ - /** - Intersect method for LineArray + /** + Intersect method for LineArray */ boolean intersectLA (LineArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { @@ -1146,13 +1146,13 @@ public class PickResult { numint++; if (firstpick) return true; } - } + } if (numint > 0) return true; return false; } - /** - Intersect method for LineStripArray + /** + Intersect method for LineStripArray */ boolean intersectLSA (LineStripArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { @@ -1161,15 +1161,15 @@ public class PickResult { int[] stripVertexCounts = new int [geom.getNumStrips()]; geom.getStripVertexCounts (stripVertexCounts); int stripStart = 0; - + if (debug) System.out.println ("intersect: LineStripArray"); int[] lineVertIdx = new int[2]; - for (int i=0; i < stripVertexCounts.length; i++) { + for (int i=0; i < stripVertexCounts.length; i++) { lineVertIdx[0] = stripStart; int end = stripStart + stripVertexCounts[i]; - + for (int j=stripStart+1; j 0) return true; return false; } - /** - Intersect method for IndexedTriangleArray + /** + Intersect method for IndexedTriangleArray */ - boolean intersectITA (IndexedTriangleArray geom, int geomIndex, + boolean intersectITA (IndexedTriangleArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { - + if (debug) System.out.println ("intersect: IndexedTriangleArray"); int[] triVertIdx = new int[3]; int[] triCoordIdx = new int[3]; - + int numint = 0; int indexCount = geom.getIndexCount(); for (int i=0; i 0) return true; return false; } - /** - Intersect method for TriangleStripArray + /** + Intersect method for TriangleStripArray */ - boolean intersectTSA (TriangleStripArray geom, int geomIndex, + boolean intersectTSA (TriangleStripArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { - if (debug) + if (debug) System.out.println ("intersect: TriangleStripArray"); boolean ccw; @@ -1320,7 +1320,7 @@ public class PickResult { int start; int[] triVertIdx = new int[3]; - for (int i=0; i 0) return true; return false; } - /** - Intersect method for IndexedTriangleFanArray + /** + Intersect method for IndexedTriangleFanArray */ - boolean intersectITFA (IndexedTriangleFanArray geom, int geomIndex, + boolean intersectITFA (IndexedTriangleFanArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { if (debug) System.out.println ("intersect: IndexedTriangleFanArray"); @@ -1485,7 +1485,7 @@ public class PickResult { int start; int[] triVertIdx = new int[3]; int[] triCoordIdx = new int[3]; - + for (int i=0; i 0) return true; return false; } - /** - Intersect method for QuadArray + /** + Intersect method for QuadArray */ boolean intersectQA (QuadArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { @@ -1531,16 +1531,16 @@ public class PickResult { numint++; if (firstpick) return true; } - } + } if (numint > 0) return true; return false; } - /** - Intersect method for IndexedQuadArray + /** + Intersect method for IndexedQuadArray */ - final boolean intersectIQA (IndexedQuadArray geom, int geomIndex, + final boolean intersectIQA (IndexedQuadArray geom, int geomIndex, Point3d[] pnts, boolean firstpick, PickIntersection pi) { @@ -1566,7 +1566,7 @@ public class PickResult { numint++; if (firstpick) return true; } - } + } if (numint > 0) return true; return false; @@ -1576,47 +1576,47 @@ public class PickResult { /* ==================================================================== */ /* GENERAL INTERSECT METHODS */ /* ==================================================================== */ - static boolean intersectBoundingBox (Point3d coordinates[], + static boolean intersectBoundingBox (Point3d coordinates[], BoundingBox box) { int i, j; - int out[] = new int[6]; + int out[] = new int[6]; Point3d lower = new Point3d(); Point3d upper = new Point3d(); box.getLower (lower); box.getUpper (upper); - + //Do trivial vertex test. for (i=0; i<6; i++) out[i] = 0; for (i=0; i= lower.x) && + if ((coordinates[i].x >= lower.x) && (coordinates[i].x <= upper.x) && - (coordinates[i].y >= lower.y) && + (coordinates[i].y >= lower.y) && (coordinates[i].y <= upper.y) && - (coordinates[i].z >= lower.z) && + (coordinates[i].z >= lower.z) && (coordinates[i].z <= upper.z)) { // We're done! It's inside the boundingbox. - return true; + return true; } else { if (coordinates[i].x < lower.x) out[0]++; // left if (coordinates[i].y < lower.y) out[1]++; // bottom if (coordinates[i].z < lower.z) out[2]++; // back if (coordinates[i].x > upper.x) out[3]++; // right if (coordinates[i].y > upper.y) out[4]++; // top - if (coordinates[i].z > upper.z) out[5]++; // front + if (coordinates[i].z > upper.z) out[5]++; // front } } - + if ((out[0] == coordinates.length) || (out[1] == coordinates.length) || (out[2] == coordinates.length) || (out[3] == coordinates.length) || (out[4] == coordinates.length) || (out[5] == coordinates.length)){ // we're done. primitive is outside of boundingbox. return false; - } + } // Setup bounding planes. Point3d pCoor[] = new Point3d[4]; for (i=0; i<4; i++) pCoor[i] = new Point3d(); - + // left plane. pCoor[0].set(lower.x, lower.y, lower.z); pCoor[1].set(lower.x, lower.y, upper.z); @@ -1651,7 +1651,7 @@ public class PickResult { pCoor[2].set(lower.x, lower.y, upper.z); pCoor[3].set(upper.x, lower.y, upper.z); if (intersectPolygon(pCoor, coordinates, false) == true) return true; - + // back plane. pCoor[0].set(upper.x, upper.y, lower.z); pCoor[1].set(upper.x, lower.y, lower.z); @@ -1662,7 +1662,7 @@ public class PickResult { return false; } - static boolean intersectBoundingSphere (Point3d coordinates[], + static boolean intersectBoundingSphere (Point3d coordinates[], BoundingSphere sphere) { @@ -1678,7 +1678,7 @@ public class PickResult { tempV3D.x = coordinates[i].x - center.x; tempV3D.y = coordinates[i].y - center.y; tempV3D.z = coordinates[i].z - center.z; - + if (tempV3D.length() <= radius) { // We're done! It's inside the boundingSphere. return true; @@ -1687,10 +1687,10 @@ public class PickResult { for (i=0; i 0.0) break; } - + for (j=i; j 0.0) break; } - + if (j == (coordinates.length-1)) { // System.out.println("(1) Degenerated polygon."); return false; // Degenerated polygon. } /* - for (i=0; i radius) return false; @@ -1765,11 +1765,11 @@ public class PickResult { return pointIntersectPolygon2D( pNrm, coordinates, q); } - static boolean intersectBoundingPolytope (Point3d coordinates[], + static boolean intersectBoundingPolytope (Point3d coordinates[], BoundingPolytope polytope) { - - boolean debug = false; - + + boolean debug = false; + // this is a multiplier to the halfplane distance coefficients double distanceSign = -1.0; // Variable needed for intersection. @@ -1790,39 +1790,39 @@ public class PickResult { } // It is a triangle or a quad. - + // first test to see if any of the coordinates are all inside of the // intersection polytope's half planes // essentially do a matrix multiply of the constraintMatrix K*3 with // the input coordinates 3*1 = K*1 vector - if (debug) { + if (debug) { System.out.println("The value of the input vertices are: "); for (int i=0; i < coordinates.length; i++) { System.out.println("The " +i+ " th vertex is: " + coordinates[i]); } - + System.out.println("The value of the input bounding Polytope's planes ="); for (int i=0; i < planes.length; i++) { System.out.println("The " +i+ " th plane is: " + planes[i]); } - + } - + // the direction for the intersection cost function double centers[] = new double[4]; centers[0] = 0.8; centers[1] = 0.9; centers[2] = 1.1; centers[3] = 1.2; - + boolean intersection = true; boolean PreTest = false; - + if (PreTest) { // for each coordinate, test it with each half plane for (int i=0; i < coordinates.length; i++) { for (int j=0; j < planes.length; j++) { if ((planes[j].x * coordinates[i].x + planes[j].y * coordinates[i].y + - planes[j].z*coordinates[i].z) <= + planes[j].z*coordinates[i].z) <= (distanceSign)*planes[j].w){ // the point satisfies this particular hyperplane intersection = true; @@ -1838,15 +1838,15 @@ public class PickResult { } } } // end of pretest - + // at this point all points are outside of the bounding hull // build the problem tableau for the linear program - + int numberCols = planes.length + 2 + coordinates.length + 1; int numberRows = 1 + coordinates.length; - + double problemTableau[][] = new double[numberRows][numberCols]; - + // compute -Mtrans = -A*P for ( int i = 0; i < planes.length; i++) { for ( int j=0; j < coordinates.length; j++) { @@ -1855,27 +1855,27 @@ public class PickResult { planes[i].z*coordinates[j].z); } } - + // add the other rows for (int i = 0; i < coordinates.length; i++) { problemTableau[i][planes.length] = -1.0; problemTableau[i][planes.length + 1] = 1.0; - + for (int j=0; j < coordinates.length; j++) { if ( i==j ) { problemTableau[i][j + planes.length + 2] = 1.0; } else { problemTableau[i][j + planes.length + 2] = 0.0; } - + // place the last column elements the Ci's problemTableau[i][numberCols - 1] = centers[i]; } } - + // place the final rows value for (int j = 0; j < planes.length; j++) { - problemTableau[numberRows - 1][j] = + problemTableau[numberRows - 1][j] = (distanceSign)*planes[j].w; } problemTableau[numberRows - 1][planes.length] = 1.0; @@ -1883,7 +1883,7 @@ public class PickResult { for (int j = 0; j < coordinates.length; j++) { problemTableau[numberRows - 1][planes.length+2+j] = 0.0; } - + if (debug) { System.out.println("The value of the problem tableau is: " ); for (int i=0; i < problemTableau.length; i++) { @@ -1893,8 +1893,8 @@ public class PickResult { System.out.println(); } } - - double distance = generalStandardSimplexSolver(problemTableau, + + double distance = generalStandardSimplexSolver(problemTableau, Float.NEGATIVE_INFINITY); if (debug) { System.out.println("The value returned by the general standard simplex = " + @@ -1902,7 +1902,7 @@ public class PickResult { } if (distance == Float.POSITIVE_INFINITY) { return false; - } + } return true; } @@ -1911,7 +1911,7 @@ public class PickResult { // method to solve the LP tableau. This version has not been optimized to // work with a particular size input tableau and is much slower than some // of the other variants...supposedly - static double generalStandardSimplexSolver(double problemTableau[][], + static double generalStandardSimplexSolver(double problemTableau[][], double stopingValue) { boolean debug = false; int numRow = problemTableau.length; @@ -1921,12 +1921,12 @@ public class PickResult { double maxElement, element, endElement, ratio, prevRatio; int count = 0; double multiplier; - + if (debug) { System.out.println("The number of rows is : " + numRow); System.out.println("The number of columns is : " + numCol); } - + // until the optimal solution is found continue to do // iterations of the simplex method while(!optimal) { @@ -1940,7 +1940,7 @@ public class PickResult { } } } - + // test to see if the current solution is optimal // check all bottom row elements except the right most one and // if all positive or zero its optimal @@ -1952,7 +1952,7 @@ public class PickResult { pivotColIndex = i; } } - + // if there is no negative non-zero element then we // have found an optimal solution (the last row of the tableau) if (pivotColIndex == -1) { @@ -1960,24 +1960,24 @@ public class PickResult { //System.out.println("Found an optimal solution"); optimal = true; } - + //System.out.println("The value of maxElement is:" + maxElement); - + if (!optimal) { // Case when the solution is not optimal but not known to be // either unbounded or infeasable - + // from the above we have found the maximum negative element in // bottom row, we have also found the column for this value // the pivotColIndex represents this - + // initialize the values for the algorithm, -1 for pivotRowIndex // indicates no solution - + prevRatio = Float.POSITIVE_INFINITY; ratio = 0.0; pivotRowIndex = -1; - + // note if all of the elements in the pivot column are zero or // negative the problem is unbounded. for (i = 0; i < numRow - 1; i++) { @@ -2007,7 +2007,7 @@ public class PickResult { System.out.println("The value of endElement is: " + endElement); System.out.println("The value of ratio is: " + ratio); System.out.println("The value of prevRatio is: " + prevRatio); - System.out.println("Value of ratio <= prevRatio is :" + + System.out.println("Value of ratio <= prevRatio is :" + (ratio <= prevRatio)); } if (ratio <= prevRatio) { @@ -2019,7 +2019,7 @@ public class PickResult { } } } - + // if the pivotRowIndex is still -1 then we know the pivotColumn // has no viable pivot points and the solution is unbounded or // infeasable (all pivot elements were either zero or negative or @@ -2031,16 +2031,16 @@ public class PickResult { } return(Float.POSITIVE_INFINITY); } - + // we now have the pivot row and col all that remains is // to divide through by this value and subtract the appropriate // multiple of the pivot row from all other rows to obtain // a tableau which has a column of all zeros and one 1 in the // intersection of pivot row and col - + // divide through by the pivot value double pivotValue = problemTableau[pivotRowIndex][pivotColIndex]; - + if (debug) { System.out.println("The value of row index is: " + pivotRowIndex); System.out.println("The value of col index is: " + pivotColIndex); @@ -2051,7 +2051,7 @@ public class PickResult { problemTableau[pivotRowIndex][i] = problemTableau[pivotRowIndex][i] / pivotValue; } - + // subtract appropriate multiple of pivot row from all other rows // to zero out all rows except the final row and the pivot row for (i = 0; i < numRow; i++) { @@ -2069,8 +2069,8 @@ public class PickResult { return(problemTableau[numRow - 1][numCol - 1]); } - static boolean edgeIntersectSphere (BoundingSphere sphere, Point3d start, - Point3d end) { + static boolean edgeIntersectSphere (BoundingSphere sphere, Point3d start, + Point3d end) { double abLenSq, acLenSq, apLenSq, abDotAp, radiusSq; Vector3d ab = new Vector3d(); @@ -2079,17 +2079,17 @@ public class PickResult { Point3d center = new Point3d(); sphere.getCenter (center); double radius = sphere.getRadius (); - + ab.x = end.x - start.x; ab.y = end.y - start.y; ab.z = end.z - start.z; - + ap.x = center.x - start.x; ap.y = center.y - start.y; ap.z = center.z - start.z; - + abDotAp = ab.dot(ap); - + if (abDotAp < 0.0) return false; // line segment points away from sphere. @@ -2101,21 +2101,21 @@ public class PickResult { radiusSq = radius * radius; apLenSq = ap.lengthSquared(); - + if ((apLenSq - acLenSq) <= radiusSq) - return true; + return true; return false; } static double det2D(Point2d a, Point2d b, Point2d p) { - return (((p).x - (a).x) * ((a).y - (b).y) + + return (((p).x - (a).x) * ((a).y - (b).y) + ((a).y - (p).y) * ((a).x - (b).x)); } // Assume coord is CCW. - static boolean pointIntersectPolygon2D(Vector3d normal, Point3d[] coord, + static boolean pointIntersectPolygon2D(Vector3d normal, Point3d[] coord, Point3d point) { double absNrmX, absNrmY, absNrmZ; @@ -2123,52 +2123,52 @@ public class PickResult { Point2d pnt = new Point2d(); int i, j, axis; - + // Project 3d points onto 2d plane. // Note : Area of polygon is not preserve in this projection, but - // it doesn't matter here. - + // it doesn't matter here. + // Find the axis of projection. absNrmX = Math.abs(normal.x); absNrmY = Math.abs(normal.y); absNrmZ = Math.abs(normal.z); - + if (absNrmX > absNrmY) axis = 0; - else + else axis = 1; - + if (axis == 0) { if (absNrmX < absNrmZ) axis = 2; - } + } else if (axis == 1) { if (absNrmY < absNrmZ) axis = 2; - } - + } + // System.out.println("Normal " + normal + " axis " + axis ); - + for (i=0; i 1.0 )) { @@ -2247,7 +2247,7 @@ public class PickResult { } // Assume coord is CCW. - static boolean edgeIntersectPolygon2D(Vector3d normal, Point3d[] coord, + static boolean edgeIntersectPolygon2D(Vector3d normal, Point3d[] coord, Point3d[] seg) { double absNrmX, absNrmY, absNrmZ; @@ -2255,52 +2255,52 @@ public class PickResult { Point2d seg2D[] = new Point2d[2]; int i, j, axis; - + // Project 3d points onto 2d plane. // Note : Area of polygon is not preserve in this projection, but - // it doesn't matter here. - + // it doesn't matter here. + // Find the axis of projection. absNrmX = Math.abs(normal.x); absNrmY = Math.abs(normal.y); absNrmZ = Math.abs(normal.z); - + if (absNrmX > absNrmY) axis = 0; - else + else axis = 1; - + if (axis == 0) { if (absNrmX < absNrmZ) axis = 2; - } + } else if (axis == 1) { if (absNrmY < absNrmZ) axis = 2; - } - + } + // System.out.println("Normal " + normal + " axis " + axis ); - + for (i=0; i 0.0) break; } - + for (j=i; j 0.0) break; } - + if (j == (coord1.length-1)) { // System.out.println("(1) Degenerated polygon."); return false; // Degenerated polygon. } /* - for (i=0; i EPS) || (v < -EPS)); - + } - static boolean intersectRay(Point3d coordinates[], + static boolean intersectRay(Point3d coordinates[], PickRay ray, PickIntersection pi) { - Point3d origin = new Point3d(); - Vector3d direction = new Vector3d(); + Point3d origin = new Point3d(); + Vector3d direction = new Vector3d(); boolean result; ray.get (origin, direction); result = intersectRayOrSegment(coordinates, direction, origin, pi, false); @@ -2470,10 +2470,10 @@ public class PickResult { } /** - * Return true if triangle or quad intersects with ray and the distance is + * Return true if triangle or quad intersects with ray and the distance is * stored in pr. * */ - static boolean intersectRayOrSegment(Point3d coordinates[], + static boolean intersectRayOrSegment(Point3d coordinates[], Vector3d direction, Point3d origin, PickIntersection pi, boolean isSegment) { Vector3d vec0, vec1, pNrm, tempV3d; @@ -2484,7 +2484,7 @@ public class PickResult { pNrm = new Vector3d(); double absNrmX, absNrmY, absNrmZ, pD = 0.0; - double pNrmDotrDir = 0.0; + double pNrmDotrDir = 0.0; boolean isIntersect = false; int i, j, k=0, l = 0; @@ -2503,7 +2503,7 @@ public class PickResult { break; } } - + for (j=l; j 0.0) { break; } - } + } pNrm.cross(vec0,vec1); @@ -2528,17 +2528,17 @@ public class PickResult { isIntersect = intersectLineAndRay(coordinates[l], coordinates[k], origin, - direction, + direction, pi); return isIntersect; } - // It is possible that Quad is degenerate to Triangle + // It is possible that Quad is degenerate to Triangle // at this point pNrmDotrDir = pNrm.dot(direction); - // Ray is parallel to plane. + // Ray is parallel to plane. if (pNrmDotrDir == 0.0) { // Ray is parallel to plane // Check line/triangle intersection on plane. @@ -2551,7 +2551,7 @@ public class PickResult { if (intersectLineAndRay(coordinates[i], coordinates[k], origin, - direction, + direction, pi)) { isIntersect = true; break; @@ -2568,7 +2568,7 @@ public class PickResult { // Substitute Ray equation: // p = origin + pi.distance*direction - // into the above Plane equation + // into the above Plane equation double dist = (pD - pNrm.dot(tempV3d))/ pNrmDotrDir; @@ -2576,7 +2576,7 @@ public class PickResult { if ((dist < -EPS ) || (isSegment && (dist > 1.0+EPS))) { // Ray intersects the plane behind the ray's origin - // or intersect point not fall in Segment + // or intersect point not fall in Segment return false; } @@ -2594,10 +2594,10 @@ public class PickResult { absNrmZ = Math.abs(pNrm.z); // Check out - // http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/ + // http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/ // Solution 3: // All sign of (y - y0) (x1 - x0) - (x - x0) (y1 - y0) - // must agree. + // must agree. double sign, t, lastSign = 0; Point3d p0 = coordinates[coordinates.length-1]; Point3d p1 = coordinates[0]; @@ -2609,7 +2609,7 @@ public class PickResult { for (i=0; i < coordinates.length; i++) { p0 = coordinates[i]; p1 = (i != coordinates.length-1 ? coordinates[i+1]: coordinates[0]); - sign = (iPnt.y - p0.y)*(p1.x - p0.x) - + sign = (iPnt.y - p0.y)*(p1.x - p0.x) - (iPnt.x - p0.x)*(p1.y - p0.y); if (isNonZero(sign)) { if (sign*lastSign < 0) { @@ -2634,12 +2634,12 @@ public class PickResult { } } } - } + } } else { for (i=0; i 0.0) break; } - + for (j=i; j 0.0) break; } - + if (j == (coordinates.length-1)) { // System.out.println("(1) Degenerated polygon."); return false; // Degenerated polygon. } - /* + /* System.out.println("Ray orgin : " + origin + " dir " + direction); System.out.println("Triangle/Quad :"); - for (i=0; i (temp + Double.MIN_VALUE))) - return false; + return false; } - + if (flag < 2) { temp = ori.z + dist * dir.z; if ((pnt.z < (temp - Double.MIN_VALUE)) || (pnt.z > (temp + Double.MIN_VALUE))) @@ -2889,13 +2889,13 @@ public class PickResult { pi.setDistance (dist); return true; - + } - static boolean intersectLineAndRay(Point3d start, Point3d end, - Point3d ori, Vector3d dir, + static boolean intersectLineAndRay(Point3d start, Point3d end, + Point3d ori, Vector3d dir, PickIntersection pi) { - + double m00, m01, m10, m11; double mInv00, mInv01, mInv10, mInv11; double dmt, t, s, tmp1, tmp2; @@ -2905,10 +2905,10 @@ public class PickResult { // System.out.println("Intersect : intersectLineAndRay"); // System.out.println("start " + start + " end " + end ); // System.out.println("ori " + ori + " dir " + dir); - + lDir = new Vector3d(end.x - start.x, end.y - start.y, end.z - start.z); - + m00 = lDir.x; m01 = -dir.x; m10 = lDir.y; @@ -2942,7 +2942,7 @@ public class PickResult { t = mInv00 * tmp1 + mInv01 * tmp2; s = mInv10 * tmp1 + mInv11 * tmp2; - + if (s<0.0) { // Before the origin of ray. // System.out.println("Before the origin of ray " + s); return false; @@ -2954,8 +2954,8 @@ public class PickResult { tmp1 = ori.z + s * dir.z; tmp2 = start.z + t * lDir.z; - - if ((tmp1 < (tmp2 - Double.MIN_VALUE)) || + + if ((tmp1 < (tmp2 - Double.MIN_VALUE)) || (tmp1 > (tmp2 + Double.MIN_VALUE))) { // System.out.println("No intersection : tmp1 " + tmp1 + " tmp2 " + tmp2); return false; @@ -2966,18 +2966,18 @@ public class PickResult { Point3d iPnt = new Point3d (); iPnt.scaleAdd (s, dir, ori); pi.setPointCoordinatesVW (iPnt); - + // System.out.println("Intersected : tmp1 " + tmp1 + " tmp2 " + tmp2); return true; } /** - Return true if triangle or quad intersects with cylinder and the + Return true if triangle or quad intersects with cylinder and the distance is stored in pr. */ - static boolean intersectCylinder (Point3d coordinates[], + static boolean intersectCylinder (Point3d coordinates[], PickCylinder cyl, PickIntersection pi) { - + Point3d origin = new Point3d(); Point3d end = new Point3d(); Vector3d direction = new Vector3d(); @@ -3013,14 +3013,14 @@ public class PickResult { double sqDistToEdge; for (int i=0; i * The pick mode specifies the detail level of picking before the PickResult * is returned: *

      *

        - *
      • PickTool.BOUNDS - Pick using the bounds of the pickable nodes. The + *
      • PickTool.BOUNDS - Pick using the bounds of the pickable nodes. The * PickResult returned will contain the SceneGraphPath to the picked Node. *
      • *
      • PickTool.GEOMETRY will pick using the geometry of the pickable nodes. * The PickResult returned will contain the SceneGraphPath to the picked Node. * Geometry nodes in the scene must have the ALLOW_INTERSECT capability set for * this mode.
      • - *
      • PickTool.GEOMETRY_INTERSECT_INFO -is the same as GEOMETRY, but the + *
      • PickTool.GEOMETRY_INTERSECT_INFO -is the same as GEOMETRY, but the * the PickResult will also include information on each intersection * of the pick shape with the geometry. The intersection information includes - * the sub-primitive picked (that is, the point, line, triangle or quad), - * the closest vertex to the center of the pick shape, and + * the sub-primitive picked (that is, the point, line, triangle or quad), + * the closest vertex to the center of the pick shape, and * the intersection's coordinate, normal, color and texture coordinates. - * To allow this information to be generated, Shape3D and Morph nodes must have - * the ALLOW_GEOMETRY_READ capability set and GeometryArrays must have the + * To allow this information to be generated, Shape3D and Morph nodes must have + * the ALLOW_GEOMETRY_READ capability set and GeometryArrays must have the * ALLOW_FORMAT_READ, * ALLOW_COUNT_READ, and ALLOW_COORDINATE_READ capabilities set, plus the - * ALLOW_COORDINATE_INDEX_READ capability for indexed geometry. + * ALLOW_COORDINATE_INDEX_READ capability for indexed geometry. * To inquire - * the intersection color, normal or texture coordinates + * the intersection color, normal or texture coordinates * the corresponding READ capability bits must be set on the GeometryArray. *
      • *
      - *

      The utility method + *

      The utility method * - * PickTool.setCapabilities(Node, int) + * PickTool.setCapabilities(Node, int) * can be used before the scene graph is - * made live to set the + * made live to set the * capabilities of Shape3D, Morph or Geometry * nodes to allow picking. *

      * A PickResult from a lower level of detail pick can be used to - * inquire more detailed information if the capibility bits are set. + * inquire more detailed information if the capibility bits are set. * This can be used to filter the PickResults - * before the more computationally intensive intersection processing. + * before the more computationally intensive intersection processing. * For example, * the application can do a BOUNDS pick and then selectively inquire - * intersections on some of the PickResults. This will save the effort of - * doing intersection computation on the other PickResults. - * However, inquiring the intersections from a GEOMETRY pick will make + * intersections on some of the PickResults. This will save the effort of + * doing intersection computation on the other PickResults. + * However, inquiring the intersections from a GEOMETRY pick will make * the intersection computation happen twice, use GEOMETRY_INTERSECT_INFO * if you want to inquire the intersection information on all the PickResults. *

      - * When using pickAllSorted or pickClosest methods, the picks - * will be sorted by the distance from the start point of the pick shape to + * When using pickAllSorted or pickClosest methods, the picks + * will be sorted by the distance from the start point of the pick shape to * the intersection point. *

      - * Morph nodes cannot be picked using the displayed geometry in - * GEOMETRY_INTERSECT_INFO mode due to limitations in the current Java3D core + * Morph nodes cannot be picked using the displayed geometry in + * GEOMETRY_INTERSECT_INFO mode due to limitations in the current Java3D core * API (the current - * geometry of the the Morph cannot be inquired). Instead they are picked - * using + * geometry of the the Morph cannot be inquired). Instead they are picked + * using * the geometry at index 0 in the Morph, this limitation may be eliminated in a * future release of Java3D. *

      @@ -136,7 +136,7 @@ public class PickTool { Locale pickRootL = null; /** Used to store a reference point used in determining how "close" points - are. + are. */ Point3d start = null; @@ -144,16 +144,16 @@ public class PickTool { int mode = BOUNDS; /** Use this mode to pick by bounds and get basic information - on the pick. + on the pick. */ public static final int BOUNDS = 0x200; - /** Use this mode to pick by geometry and get basic - information on the pick. + /** Use this mode to pick by geometry and get basic + information on the pick. */ public static final int GEOMETRY = 0x100; - /** Use this mode to pick by geometry and save + /** Use this mode to pick by geometry and save information about the intersections (intersected primitive, intersection point and closest vertex). */ @@ -165,15 +165,15 @@ public class PickTool { * Flag to pass to setCapabilities(Node, int) to set * the Node's capabilities to allow intersection tests, but not * inquire information about the intersections (use for GEOMETRY mode). - * @see PickTool#setCapabilities + * @see PickTool#setCapabilities */ public static final int INTERSECT_TEST = 0x1001; /** * Flag to pass to setCapabilities(Node, int) to set * the Node's capabilities to allow inquiry of the intersection - * coordinate information. - * @see PickTool#setCapabilities + * coordinate information. + * @see PickTool#setCapabilities */ public static final int INTERSECT_COORD = 0x1002; @@ -181,13 +181,13 @@ public class PickTool { * Flag to pass to setCapabilities(Node, int) to set * the Node's capabilities to allow inquiry of all intersection * information. - * @see PickTool#setCapabilities + * @see PickTool#setCapabilities */ public static final int INTERSECT_FULL = 0x1004; /* ============================ METHODS ============================ */ - /** + /** * Constructor with BranchGroup to be picked. */ public PickTool (BranchGroup b) { @@ -195,29 +195,29 @@ public class PickTool { } /** Returns the BranchGroup to be picked if the tool was initialized - with a BranchGroup, null otherwise. + with a BranchGroup, null otherwise. */ public BranchGroup getBranchGroup() { return pickRootBG; } - /** + /** * Constructor with the Locale to be picked. */ public PickTool (Locale l) { pickRootL = l; } - /** + /** * Returns the Locale to be picked if the tool was initialized with * a Locale, null otherwise. */ public Locale getLocale () { return pickRootL; } - - /** + + /** * @deprecated This method does nothing other than return its * input parameter. */ @@ -225,10 +225,10 @@ public class PickTool { return l; } - /** + /** * Sets the capabilities on the Node and it's components to allow - * picking at the specified detail level. - *

      + * picking at the specified detail level. + *

      * Note that by default all com.sun.j3d.utils.geometry.Primitive * objects with the same parameters share their geometry (e.g., * you can have 50 spheres in your scene, but the geometry is @@ -244,7 +244,7 @@ public class PickTool { * INTERSECT_COORD or INTERSECT_FULL * @throws IllegalArgumentException if Node is not a Shape3D or Morph or * if the flag value is not valid. - * @throws javax.media.j3d.RestrictedAccessException if the node is part + * @throws javax.media.j3d.RestrictedAccessException if the node is part * of a live or compiled scene graph. */ static public void setCapabilities(Node node, int level) { if (node instanceof Morph) { @@ -342,7 +342,7 @@ public class PickTool { // Methods used to define the pick shape - /** Sets the pick shape to a user-provided PickShape object + /** Sets the pick shape to a user-provided PickShape object * @param ps The pick shape to pick against. * @param startPt The start point to use for distance calculations */ @@ -352,7 +352,7 @@ public class PickTool { userDefineShape = (ps != null); } - /** Sets the pick shape to use a user-provided Bounds object + /** Sets the pick shape to use a user-provided Bounds object * @param bounds The bounds to pick against. * @param startPt The start point to use for distance calculations */ @@ -363,11 +363,11 @@ public class PickTool { } /** Sets the picking detail mode. The default is BOUNDS. - * @param mode One of BOUNDS, GEOMETRY, GEOMETRY_INTERSECT_INFO, or + * @param mode One of BOUNDS, GEOMETRY, GEOMETRY_INTERSECT_INFO, or * @exception IllegalArgumentException if mode is not a legal value */ public void setMode (int mode) { - if ((mode != BOUNDS) && (mode != GEOMETRY) && + if ((mode != BOUNDS) && (mode != GEOMETRY) && (mode != GEOMETRY_INTERSECT_INFO)) { throw new java.lang.IllegalArgumentException(); } @@ -380,7 +380,7 @@ public class PickTool { return mode; } - /** Sets the pick shape to a PickRay. + /** Sets the pick shape to a PickRay. * @param start The start of the ray * @param dir The direction of the ray */ @@ -400,14 +400,14 @@ p @param end The end of the segment userDefineShape = true; } - /** Sets the pick shape to a capped PickCylinder + /** Sets the pick shape to a capped PickCylinder * @param start The start of axis of the cylinder * @param end The end of the axis of the cylinder * @param radius The radius of the cylinder */ - public void setShapeCylinderSegment (Point3d start, Point3d end, + public void setShapeCylinderSegment (Point3d start, Point3d end, double radius) { - this.pickShape = (PickShape) + this.pickShape = (PickShape) new PickCylinderSegment (start, end, radius); this.start = start; userDefineShape = true; @@ -418,31 +418,31 @@ p @param end The end of the segment * @param dir The direction of the axis of the cylinder * @param radius The radius of the cylinder */ - public void setShapeCylinderRay (Point3d start, Vector3d dir, + public void setShapeCylinderRay (Point3d start, Vector3d dir, double radius) { this.pickShape = (PickShape) new PickCylinderRay (start, dir, radius); this.start = start; userDefineShape = true; } - /** Sets the pick shape to a capped PickCone + /** Sets the pick shape to a capped PickCone * @param start The start of axis of the cone * @param end The end of the axis of the cone * @param angle The angle of the cone */ - public void setShapeConeSegment (Point3d start, Point3d end, + public void setShapeConeSegment (Point3d start, Point3d end, double angle) { this.pickShape = (PickShape) new PickConeSegment (start, end, angle); this.start = start; userDefineShape = true; } - /** Sets the pick shape to an infinite PickCone. + /** Sets the pick shape to an infinite PickCone. * @param start The start of axis of the cone * @param dir The direction of the axis of the cone * @param angle The angle of the cone */ - public void setShapeConeRay (Point3d start, Vector3d dir, + public void setShapeConeRay (Point3d start, Vector3d dir, double angle) { this.pickShape = (PickShape) new PickConeRay (start, dir, angle); this.start = start; @@ -460,10 +460,10 @@ p @param end The end of the segment } /** Selects all the nodes that intersect the PickShape. - @return An array of PickResult objects which will contain - information about the picked instances. null if nothing was + @return An array of PickResult objects which will contain + information about the picked instances. null if nothing was picked. - */ + */ public PickResult[] pickAll () { PickResult[] retval = null; switch (mode) { @@ -483,10 +483,10 @@ p @param end The end of the segment } /** Select one of the nodes that intersect the PickShape - @return A PickResult object which will contain - information about the picked instance. null if nothing + @return A PickResult object which will contain + information about the picked instance. null if nothing was picked. - */ + */ public PickResult pickAny () { PickResult retval = null; switch (mode) { @@ -505,12 +505,12 @@ p @param end The end of the segment return retval; } - /** Select all the nodes that intersect the + /** Select all the nodes that intersect the PickShape, returned sorted. The "closest" object will be returned first. - See note above to see how "closest" is determined. + See note above to see how "closest" is determined.

      - @return An array of PickResult objects which will contain - information + @return An array of PickResult objects which will contain + information about the picked instances. null if nothing was picked. */ public PickResult[] pickAllSorted () { @@ -534,7 +534,7 @@ p @param end The end of the segment // The current Shape3D.intersect() API does't return the closest intersected // geometry. retval = pickGeomAllSorted(pickShape); - + break; case GEOMETRY_INTERSECT_INFO: // System.out.println ("PickShape " + pickShape); @@ -547,12 +547,12 @@ p @param end The end of the segment return retval; } - /** Select the closest node that - intersects the PickShape. See note above to see how "closest" is + /** Select the closest node that + intersects the PickShape. See note above to see how "closest" is determined.

      - @return A PickResult object which will contain - information about the picked instance. null if nothing + @return A PickResult object which will contain + information about the picked instance. null if nothing was picked. */ public PickResult pickClosest () { @@ -572,7 +572,7 @@ p @param end The end of the segment // The current Shape3D.intersect() API does't return the closest intersected // geometry. retval = pickGeomClosest(pickShape); - + break; case GEOMETRY_INTERSECT_INFO: // System.out.println ("PickShape " + pickShape); @@ -684,9 +684,9 @@ p @param end The end of the segment if (obj[i] instanceof Shape3D) { found[i] = ((Shape3D) obj[i]).intersect(sgp[i], pickShape); } else if (obj[i] instanceof Morph) { - found[i] = ((Morph) obj[i]).intersect(sgp[i], pickShape); + found[i] = ((Morph) obj[i]).intersect(sgp[i], pickShape); } - if (found[i] == true) cnt++; + if (found[i] == true) cnt++; } if (cnt == 0) return null; // no match @@ -706,7 +706,7 @@ p @param end The end of the segment Node[] obj = null; int i, cnt=0; double[] dist = new double[1]; - + // First pass if (pickRootBG != null) { sgp = pickRootBG.pickAll(pickShape); @@ -724,20 +724,20 @@ p @param end The end of the segment double[] distArr = new double[sgp.length]; obj = new Node [sgp.length]; PickResult[] pr = new PickResult [sgp.length]; - + for (i=0; i 1) { + if (cnt > 1) { return sortPickResults (npr, distance); } else { // Don't have to sort if only one item return npr; @@ -855,12 +855,12 @@ p @param end The end of the segment // System.out.println ("PickTool.pickGeomAllSortedIntersect: bounds " + // " picking found "+sgp.length+" nodes"); - - + + // Second pass, check to see if geometries intersected boolean[] found = new boolean[sgp.length]; double[] distArr = new double[sgp.length]; - + PickResult[] pr = new PickResult[sgp.length]; for (i=0; i tempDist) { minDist = tempDist; - minIndex = j; + minIndex = j; needToSwap = true; } } - + //Swap if necc. if(needToSwap) { // System.out.println ("Swap is needed"); @@ -894,17 +894,17 @@ p @param end The end of the segment pr[i].intersections.set(0, piMin); pr[i].intersections.set(minIndex, pi0); } - + distArr[i] = pr[i].getIntersection(0).getDistance(); cnt++; } } - - + + // System.out.println ("PickTool.pickGeomAllSortedIntersect: geometry intersect check " // + " cnt " + cnt); - - + + if (cnt == 0) return null; // no match PickResult[] npr = new PickResult[cnt]; @@ -916,14 +916,14 @@ p @param end The end of the segment npr[cnt++] = pr[i]; } } - + if (cnt > 1) { return sortPickResults (npr, distance); } else { // Don't have to sort if only one item return npr; } } - + private PickResult pickGeomClosestIntersect(PickShape pickShape) { PickResult[] pr = pickGeomAllSortedIntersect(pickShape); /* @@ -940,7 +940,7 @@ p @param end The end of the segment return pr[0]; } } - private PickResult pickGeomAnyIntersect(PickShape pickShape) { + private PickResult pickGeomAnyIntersect(PickShape pickShape) { Node obj = null; int i; SceneGraphPath[] sgpa = null; @@ -968,7 +968,7 @@ p @param end The end of the segment private PickResult[] sortPickResults (PickResult[] pr, double[] dist) { int[] pos = new int [pr.length]; PickResult[] prsorted = new PickResult [pr.length]; - + // Initialize position array for (int i=0; i * 1. Create your scene graph. *

      @@ -80,7 +80,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** * Creates a pick/rotate behavior that waits for user mouse events for - * the scene graph. This method has its pickMode set to BOUNDS picking. + * the scene graph. This method has its pickMode set to BOUNDS picking. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -102,11 +102,11 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or - * PickTool.GEOMETRY_INTERSECT_INFO. + * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode **/ - public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, + public PickRotateBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode){ super(canvas, root, bounds); drag = new MouseRotate(MouseRotate.MANUAL_WAKEUP); @@ -119,30 +119,30 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (!mevent.isMetaDown() && !mevent.isAltDown()){ - + pickCanvas.setShapeLocation(xpos, ypos); PickResult pr = pickCanvas.pickClosest(); if ((pr != null) && - ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) + ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ drag.setTransformGroup(tg); drag.wakeup(); currentTG = tg; // free the PickResult - // Need to clean up Issue 123 --- Chien + // Need to clean up Issue 123 --- Chien // freePickResult(pr); } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); @@ -156,7 +156,7 @@ public class PickRotateBehavior extends PickMouseBehavior implements MouseBehavi public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ROTATE, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickTranslateBehavior.java b/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickTranslateBehavior.java index f90641b..c040c5a 100644 --- a/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickTranslateBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickTranslateBehavior.java @@ -55,7 +55,7 @@ import javax.vecmath.*; /** * A mouse behavior that allows user to pick and translate scene graph objects. * Common usage: 1. Create your scene graph. 2. Create this behavior with - * the root and canvas. See PickRotateBehavior for more details. + * the root and canvas. See PickRotateBehavior for more details. */ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBehaviorCallback { @@ -65,7 +65,7 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Creates a pick/translate behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -82,12 +82,12 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** * Creates a pick/translate behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or - * PickTool.GEOMETRY_INTERSECT_INFO. + * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode **/ public PickTranslateBehavior(BranchGroup root, Canvas3D canvas, @@ -103,35 +103,35 @@ public class PickTranslateBehavior extends PickMouseBehavior implements MouseBeh /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (!mevent.isAltDown() && mevent.isMetaDown()){ - + pickCanvas.setShapeLocation(xpos, ypos); PickResult pr = pickCanvas.pickClosest(); if ((pr != null) && - ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) + ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ - + translate.setTransformGroup(tg); translate.wakeup(); currentTG = tg; - // Need to clean up Issue 123 --- Chien + // Need to clean up Issue 123 --- Chien // freePickResult(pr); } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); } - + } /** diff --git a/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickZoomBehavior.java b/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickZoomBehavior.java index 8a2bee3..4fef813 100644 --- a/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickZoomBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/picking/behaviors/PickZoomBehavior.java @@ -56,7 +56,7 @@ import javax.vecmath.*; /** * A mouse behavior that allows user to pick and zoom scene graph objects. * Common usage: 1. Create your scene graph. 2. Create this behavior with - * the root and canvas. See PickRotateBehavior for more details. + * the root and canvas. See PickRotateBehavior for more details. */ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehaviorCallback { @@ -66,7 +66,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior /** * Creates a pick/zoom behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. @@ -83,15 +83,15 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior /** * Creates a pick/zoom behavior that waits for user mouse events for - * the scene graph. + * the scene graph. * @param root Root of your scene graph. * @param canvas Java 3D drawing canvas. * @param bounds Bounds of your scene. * @param pickMode specifys PickTool.BOUNDS, PickTool.GEOMETRY or - * PickTool.GEOMETRY_INTERSECT_INFO. + * PickTool.GEOMETRY_INTERSECT_INFO. * @see PickTool#setMode */ - public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, + public PickZoomBehavior(BranchGroup root, Canvas3D canvas, Bounds bounds, int pickMode) { super(canvas, root, bounds); zoom = new MouseZoom(MouseBehavior.MANUAL_WAKEUP); @@ -103,30 +103,30 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior } /** - * Update the scene to manipulate any nodes. This is not meant to be - * called by users. Behavior automatically calls this. You can call + * Update the scene to manipulate any nodes. This is not meant to be + * called by users. Behavior automatically calls this. You can call * this only if you know what you are doing. - * + * * @param xpos Current mouse X pos. * @param ypos Current mouse Y pos. **/ public void updateScene(int xpos, int ypos){ TransformGroup tg = null; - + if (mevent.isAltDown() && !mevent.isMetaDown()){ - + pickCanvas.setShapeLocation(xpos, ypos); PickResult pr = pickCanvas.pickClosest(); if ((pr != null) && - ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) + ((tg = (TransformGroup)pr.getNode(PickResult.TRANSFORM_GROUP)) != null) && - (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && + (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_READ)) && (tg.getCapability(TransformGroup.ALLOW_TRANSFORM_WRITE))){ zoom.setTransformGroup(tg); zoom.wakeup(); currentTG = tg; - // Need to clean up Issue 123 --- Chien + // Need to clean up Issue 123 --- Chien // freePickResult(pr); } else if (callback!=null) callback.transformChanged( PickingCallback.NO_PICK, null ); @@ -140,7 +140,7 @@ public class PickZoomBehavior extends PickMouseBehavior implements MouseBehavior public void transformChanged( int type, Transform3D transform ) { callback.transformChanged( PickingCallback.ZOOM, currentTG ); } - + /** * Register the class @param callback to be called each * time the picked object moves diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileReader.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileReader.java index 5546ae8..db0e20d 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileReader.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileReader.java @@ -63,7 +63,7 @@ import com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl; public class SceneGraphFileReader extends java.lang.Object { private RandomAccessFileControl fileControl; - + /** * Creates new SceneGraphFileReader. */ @@ -87,7 +87,7 @@ public class SceneGraphFileReader extends java.lang.Object { return fileControl.readUniverse( attachBranchGraphs, null ); } - /** + /** * Set the ClassLoader used to load the scene graph objects and * deserialize user data */ @@ -95,14 +95,14 @@ public class SceneGraphFileReader extends java.lang.Object { fileControl.setClassLoader( classLoader ); } - /** + /** * Get the ClassLoader used to load the scene graph objects and * deserialize user data */ public ClassLoader getClassLoader() { return fileControl.getClassLoader(); } - + /** * Create and return a ConfiguredUniverse with the PlatformGeometry, ViewerAvatar, * and Locales saved in the file. The MultiTransformGroup between the ViewingPlatform @@ -117,28 +117,28 @@ public class SceneGraphFileReader extends java.lang.Object { Canvas3D canvas) throws IOException { return fileControl.readUniverse( attachBranchGraphs, canvas ); } - + /** * Get the UserData in the File header */ public Object readUserData() throws IOException { return fileControl.getUserData(); } - + /** * Get the Description of this file's contents */ public String readDescription() throws IOException { return fileControl.readFileDescription(); } - + /** * Return the number of BranchGraphs in the file */ public int getBranchGraphCount() { return fileControl.getBranchGraphCount(); } - + /** * Read the BranchGraph at index in the file. If the graph * contains references to nodes in other BranchGraphs that have not already been @@ -156,14 +156,14 @@ public class SceneGraphFileReader extends java.lang.Object { public BranchGroup[] readBranchGraph(int index) throws IOException { return fileControl.readBranchGraph( index ); } - + /** * Read and return all the branchgraphs in the file */ public BranchGroup[] readAllBranchGraphs() throws IOException { return fileControl.readAllBranchGraphs(); } - + /** * Remove the IO system's reference to this branchgraph and all its nodes.

      * @@ -177,7 +177,7 @@ public class SceneGraphFileReader extends java.lang.Object { public void dereferenceBranchGraph( BranchGroup graph ) { throw new RuntimeException("Not implemented"); } - + /** * Given a BranchGraph that has been loaded return the index of the * graph in the file. The the Branchgroup isn't found, -1 is returned. @@ -185,7 +185,7 @@ public class SceneGraphFileReader extends java.lang.Object { public int getBranchGraphPosition( BranchGroup graph ) { return fileControl.getBranchGraphPosition( graph ); } - + /** * Read the userdata for the branchgraph at 'index' in the file * @@ -194,16 +194,16 @@ public class SceneGraphFileReader extends java.lang.Object { public Object readBranchGraphUserData( int index ) throws IOException { return fileControl.readBranchGraphUserData( index ); } - + /** * Return the names of all the named objects */ public String[] getNames() { return fileControl.getNames(); } - + /** - * Return the named object. + * Return the named object. * * @param name The name of the object * @@ -213,12 +213,12 @@ public class SceneGraphFileReader extends java.lang.Object { public SceneGraphObject getNamedObject( String name ) throws NamedObjectException, ObjectNotLoadedException { return fileControl.getNamedObject( name ); } - + /** * Close the file and cleanup internal data structures */ public void close() throws IOException { fileControl.close(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileWriter.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileWriter.java index 7894894..c8d9cb2 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileWriter.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphFileWriter.java @@ -57,11 +57,11 @@ import com.sun.j3d.utils.scenegraph.io.retained.RandomAccessFileControl; import com.sun.j3d.utils.universe.SimpleUniverse; /** - * Write a (set) of Java3D BranchGraphs and/or Universe to a file. The BranchGraphs + * Write a (set) of Java3D BranchGraphs and/or Universe to a file. The BranchGraphs * are stored in the order in which they are written, they can be read in any order * using SceneGraphFileReader. * - * The API handles Nodes and NodeComponents that are shared between seperate + * The API handles Nodes and NodeComponents that are shared between seperate * graphs. It will handle all Java3D 1.3 core classes and any user * subclass of a Node or NodeComponent that implements the SceneGraphIO * interface. @@ -70,10 +70,10 @@ public class SceneGraphFileWriter extends java.lang.Object { private RandomAccessFileControl fileControl; private File file; - + /** Creates new SceneGraphFileWriter and opens the file for writing. * - *

      Writes the + *

      Writes the * Java3D Universe structure to the file. This includes the number and position of * the Locales, PlatformGeometry, ViewerAvatar, and the MultitransformGroup between * the ViewingPlatform and the View. However this @@ -81,7 +81,7 @@ public class SceneGraphFileWriter extends java.lang.Object { * universe may be null. * This call will overwrite any existing universe, fileDescription and * userData in the file.

      - * + * *

      close() MUST be called when IO is complete. If close() is not called * the file contents will be undefined.

      * @@ -105,13 +105,13 @@ public class SceneGraphFileWriter extends java.lang.Object { fileControl = new RandomAccessFileControl(); this.file = file; file.createNewFile(); - + if (!file.canWrite()) throw new IOException( "Can not Write to File" ); - + fileControl.createFile( file, universe, writeUniverseContent, fileDescription, fileUserData ); } - + /** * Write the graph to the end of the file. * @@ -121,7 +121,7 @@ public class SceneGraphFileWriter extends java.lang.Object { public void writeBranchGraph( BranchGroup graph ) throws IOException { writeBranchGraph( graph, null ); } - + /** * Write a branch graph and some user associated data to the * end of the file. @@ -133,7 +133,7 @@ public class SceneGraphFileWriter extends java.lang.Object { java.io.Serializable data ) throws IOException { fileControl.writeBranchGraph( graph, data ); } - + /** * Add a named reference to a SceneGraphObject in the file. * @@ -146,12 +146,12 @@ public class SceneGraphFileWriter extends java.lang.Object { public void addObjectName( String name, SceneGraphObject object ) throws NamedObjectException { fileControl.addNamedObject( name, object ); } - + /** * Close the file and cleanup internal data structures. */ public void close() throws IOException { fileControl.close(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphIO.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphIO.java index 57b8635..836c153 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphIO.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphIO.java @@ -66,7 +66,7 @@ public interface SceneGraphIO { * @param ref provides methods to create references to a SceneGraphObject */ public void createSceneGraphObjectReferences( SceneGraphObjectReferenceControl ref ); - + /** * Within this method the user should restore references to the SceneGraphObjects * whose nodeID's were created with createSceneGraphObjectReferences @@ -76,18 +76,18 @@ public interface SceneGraphIO { * @param ref provides methods to resolve references to a SceneGraphObject */ public void restoreSceneGraphObjectReferences( SceneGraphObjectReferenceControl ref ); - + /** * This method should store all the local state of the object and any references * to other SceneGraphObjects into out. * * This is called after data for the parent SceneGraphObject has been written to - * the out. + * the out. * * @param out the output stream */ public void writeSceneGraphObject( java.io.DataOutput out ) throws java.io.IOException; - + /** * This is called after the object has been constructed and the superclass SceneGraphObject * data has been read from in. @@ -97,7 +97,7 @@ public interface SceneGraphIO { * @param in the input stream */ public void readSceneGraphObject( java.io.DataInput in ) throws java.io.IOException; - + /** * Flag indicating for children of this object should be saved * diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphObjectReferenceControl.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphObjectReferenceControl.java index b8ace79..4bc63fb 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphObjectReferenceControl.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphObjectReferenceControl.java @@ -50,7 +50,7 @@ package com.sun.j3d.utils.scenegraph.io; * the SceneGraphIO interface. */ public interface SceneGraphObjectReferenceControl { - + /** * Add a reference to the scenegraph object specified and return * the nodeID for the object diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStateProvider.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStateProvider.java index f694005..54ae254 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStateProvider.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStateProvider.java @@ -48,18 +48,18 @@ import com.sun.j3d.utils.scenegraph.io.state.javax.media.j3d.SceneGraphObjectSta /** * This interface allows developers to provide their own custom IO control for - * subclasses of SceneGraphObjects. As the Scene Graph is being saved any - * SceneGraphObject in the graph that implements this interface must provide - * it's state class which is responsible for saving the entire state of + * subclasses of SceneGraphObjects. As the Scene Graph is being saved any + * SceneGraphObject in the graph that implements this interface must provide + * it's state class which is responsible for saving the entire state of * that object. */ public interface SceneGraphStateProvider { - + /** - * Returns the State class + * Returns the State class * * @return Class that will perform the IO for the SceneGraphObject */ public Class getStateClass(); - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamReader.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamReader.java index b14bffa..f711096 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamReader.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamReader.java @@ -59,7 +59,7 @@ import com.sun.j3d.utils.universe.ConfiguredUniverse; * Read and create a (set) of Java3D BranchGraphs or Universe from a Java Stream. */ public class SceneGraphStreamReader extends java.lang.Object { - + private StreamControl control; private DataInputStream in; @@ -69,7 +69,7 @@ public class SceneGraphStreamReader extends java.lang.Object { control = new StreamControl( in ); control.readStreamHeader(); } - + /** * Read and create the universe. If the BranchGraphs were written then * they will be added to the universe before it is returned. @@ -77,7 +77,7 @@ public class SceneGraphStreamReader extends java.lang.Object { public ConfiguredUniverse readUniverse() throws IOException { return control.readUniverse(in, true, null); } - + /** * Read and create the universe. If the BranchGraphs were written then * they will be added to the universe before it is returned. @@ -86,7 +86,7 @@ public class SceneGraphStreamReader extends java.lang.Object { public ConfiguredUniverse readUniverse(Canvas3D canvas) throws IOException { return control.readUniverse(in, true, canvas); } - + /** * Read and return the graph from the stream. * namedObjects map will be updated with any objects that @@ -96,7 +96,7 @@ public class SceneGraphStreamReader extends java.lang.Object { return control.readBranchGraph( namedObjects ); } - /** + /** * Set the ClassLoader used to load the scene graph objects and * deserialize user data */ @@ -104,14 +104,14 @@ public class SceneGraphStreamReader extends java.lang.Object { control.setClassLoader( classLoader ); } - /** + /** * Get the ClassLoader used to load the scene graph objects and * deserialize user data */ public ClassLoader getClassLoader() { return control.getClassLoader(); } - + /** * Close the SceneGraphStreamReader stream * @@ -121,6 +121,6 @@ public class SceneGraphStreamReader extends java.lang.Object { in.close(); control.close(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamWriter.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamWriter.java index 70e471c..2c1389a 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamWriter.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/SceneGraphStreamWriter.java @@ -62,7 +62,7 @@ import com.sun.j3d.utils.universe.SimpleUniverse; * SceneGraphFileWriter instead to achieve maximum performance and flexibility. */ public class SceneGraphStreamWriter extends java.lang.Object { - + private StreamControl control; private DataOutputStream out; @@ -72,7 +72,7 @@ public class SceneGraphStreamWriter extends java.lang.Object { control = new StreamControl( out ); control.writeStreamHeader(); } - + /** * Write universe to the Stream.

      @@ -97,7 +97,7 @@ public class SceneGraphStreamWriter extends java.lang.Object { public void writeUniverse( SimpleUniverse universe, boolean writeContent ) throws IOException, UnsupportedUniverseException { control.writeUniverse( out, universe, writeContent ); } - + /** * Write the entire graph to the stream.

      * @@ -117,8 +117,8 @@ public class SceneGraphStreamWriter extends java.lang.Object { control.addNamedObjects( namedObjects ); control.writeBranchGraph( graph, null ); } - - /** + + /** * Close the SceneGraphStreamWriter and the associated stream */ public void close() throws IOException { diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java index e8e81b6..cdd5b42 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/retained/Controller.java @@ -91,12 +91,12 @@ import com.sun.j3d.utils.universe.ConfiguredUniverse; import com.sun.j3d.utils.universe.SimpleUniverse; /** - * Provides code to control the reading and writing of Java3D objects to and + * Provides code to control the reading and writing of Java3D objects to and * from any Java IO mechanism. */ public abstract class Controller extends java.lang.Object { - - + + protected static final long SYMBOL_TABLE_PTR = 30; // long - 8 bytes protected static final long BG_DIR_PTR = 38; // long - 8 bytes protected static final long NAMES_OBJECTS_TABLE_PTR = 46; // long - 8 bytes @@ -107,19 +107,19 @@ public abstract class Controller extends java.lang.Object { protected SymbolTable symbolTable; protected NullSceneGraphObjectState nullObject = new NullSceneGraphObjectState( null, this ); - + /** * The currentFileVersion being read */ protected int currentFileVersion; - + /** * The File version which will be written * * 1 = Java3D 1.3 beta 1 - * 2 = Java3D 1.3 FCS, 1) fix to allow skipping user data written via + * 2 = Java3D 1.3 FCS, 1) fix to allow skipping user data written via SceneGraphIO interface - 2) Add missing duplicateOnCloneTree flag + 2) Add missing duplicateOnCloneTree flag (bug 4690159) * 3 = Java3D 1.5.1 1) Add support for SceneGraphObject Name field * 4 = Java3D 1.5.2 issue 532, for saving Background Geometry @@ -128,7 +128,7 @@ public abstract class Controller extends java.lang.Object { protected int outputFileVersion = 5; /** - * When running the application within webstart this may not be the + * When running the application within webstart this may not be the * correct ClassLoader. If Java 3D is not installed in the local vm and * is instead installed by webstart then this definitely is NOT the correct * classloader, in this case Thread.getCurrent().getClass().getClassLoader() @@ -136,7 +136,7 @@ public abstract class Controller extends java.lang.Object { * classloader by calling setClassLoader in SceneGraph[Stream|File]Reader. */ protected ClassLoader classLoader = ClassLoader.getSystemClassLoader(); - + /** * If true when loading a scenegraph that contains nodes who's classes * are not in the classpath then use then first Java3D core superclass @@ -146,15 +146,15 @@ public abstract class Controller extends java.lang.Object { * located */ private boolean useSuperClass = false; - + private int imageCompression = ImageComponentState.NO_COMPRESSION; - + /** Creates new Controller */ public Controller() { try { if ( System.getProperty("j3d.io.UseSuperClassIfNoChildClass")!=null) useSuperClass = true; - + String imageC = System.getProperty("j3d.io.ImageCompression"); if (imageC!=null) { if (imageC.equalsIgnoreCase("None")) @@ -165,27 +165,27 @@ public abstract class Controller extends java.lang.Object { imageCompression = ImageComponentState.JPEG_COMPRESSION; } } catch( Exception e ) {} - + } - + public final SymbolTable getSymbolTable() { return symbolTable; } - + /** * Get the file version that we should write */ public int getOutputFileVersion() { return outputFileVersion; } - + /** * Get the file version of the file we are reading */ public int getCurrentFileVersion() { return currentFileVersion; } - + /** * Create a new state object and check for a pre-existing symbol table * entry @@ -193,7 +193,7 @@ public abstract class Controller extends java.lang.Object { public SceneGraphObjectState createState( SceneGraphObject obj ) { return createState( obj, symbolTable.getSymbol( obj ) ); } - + /** * Given a scene graph object instantiate the correct State class * for that object. If the symbol already exists (is not null) then @@ -201,7 +201,7 @@ public abstract class Controller extends java.lang.Object { */ public SceneGraphObjectState createState( SceneGraphObject obj, SymbolTableData symbol ) { if (obj==null) return nullObject; - + if (symbol!=null) { symbol.incrementReferenceCount(); symbolTable.setBranchGraphID( symbol ); @@ -209,10 +209,10 @@ public abstract class Controller extends java.lang.Object { return symbol.getNodeState(); } else symbol = symbolTable.createSymbol( obj ); - + return createState( symbol ); } - + /** * Return the state class for the SceneGraphObject, creating one if it does * not already exist @@ -220,15 +220,15 @@ public abstract class Controller extends java.lang.Object { public SceneGraphObjectState createState( SymbolTableData symbol ) { SceneGraphObject obj = symbol.getJ3dNode(); if (obj==null) return nullObject; - + String name = obj.getClass().getName(); SceneGraphObjectState ret; - + try { Class state; if (obj instanceof SceneGraphStateProvider) state = ((SceneGraphStateProvider)obj).getStateClass(); - else + else state = Class.forName( "com.sun.j3d.utils.scenegraph.io.state."+name+"State" ); ret = constructStateObj( symbol, state, obj.getClass() ); } catch(ClassNotFoundException e) { @@ -239,17 +239,17 @@ public abstract class Controller extends java.lang.Object { throw new SGIORuntimeException( "No State class for "+ obj.getClass().getName() ); } - + symbol.nodeState = ret; - + return ret; } private SceneGraphObjectState constructStateObj( SymbolTableData symbol, Class state, Class objClass ) { - + SceneGraphObjectState ret = null; - + try { Constructor construct = state.getConstructor( new Class[] { com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData.class, @@ -257,7 +257,7 @@ public abstract class Controller extends java.lang.Object { } ); ret = (SceneGraphObjectState)construct.newInstance( new Object[]{ symbol, this } ); - + } catch( NoSuchMethodException ex ) { System.out.println("Looking for Constructor ("+symbol.j3dNode.getClass().getName()+", Controller )"); throw new SGIORuntimeException( "1 Broken State class for "+ @@ -273,21 +273,21 @@ public abstract class Controller extends java.lang.Object { throw new SGIORuntimeException( "4 Broken State class for "+ state.getName() ); } - + return ret; } - + /** * Check to see if any of the superclasses of obj are * known to the Java3D IO package */ private SceneGraphObjectState checkSuperClasses( SymbolTableData symbol ) { - + Class cl = symbol.j3dNode.getClass().getSuperclass(); Class state = null; boolean finished = false; - - + + while( cl != null & !finished ) { String name = cl.getName(); //System.out.println("Got superclass "+name); @@ -296,48 +296,48 @@ public abstract class Controller extends java.lang.Object { } catch(ClassNotFoundException e) { state = null; } - + if (state!=null) finished = true; else cl = cl.getSuperclass(); } - + if (cl==null) throw new SGIORuntimeException( "Unsupported class "+symbol.j3dNode.getClass().getName() ); - + return constructStateObj( symbol, state, cl ); - } - - + } + + public void writeObject( DataOutput out, SceneGraphObjectState obj ) throws IOException { int classID = getStateID( obj ); - - out.writeInt( classID ); // Node class id - + + out.writeInt( classID ); // Node class id + if (classID==0) { out.writeUTF( obj.getClass().getName() ); } - - obj.writeObject( out ); + + obj.writeObject( out ); } - + public SceneGraphObjectState readObject( DataInput in ) throws IOException { int classID = in.readInt(); SceneGraphObjectState state = null; - + if (classID==-1) return nullObject; - else if (classID==0) { + else if (classID==0) { String stateClassName = in.readUTF(); try { Class cl = Class.forName( stateClassName, true, classLoader ); // System.out.println("Got class "+cl ); Constructor construct = cl.getConstructor( - new Class[] { + new Class[] { com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData.class, com.sun.j3d.utils.scenegraph.io.retained.Controller.class} ); @@ -361,19 +361,19 @@ public abstract class Controller extends java.lang.Object { } catch( InstantiationException excep ) { throw new java.io.IOException( "4 Broken State class for "+ stateClassName ); - } + } } else { state = createCoreState( classID ); } - + state.readObject( in ); - + return state; } - /** + /** * Set the class loader used to load the Scene Graph Objects and - * the serialized user data. The default is + * the serialized user data. The default is * ClassLoader.getSystemClassLoader() */ public void setClassLoader( ClassLoader classLoader ) { @@ -381,9 +381,9 @@ public abstract class Controller extends java.lang.Object { } - /** + /** * Get the class loader used to load the Scene Graph Objects and - * the serialized user data. The default is + * the serialized user data. The default is * ClassLoader.getSystemClassLoader() */ public ClassLoader getClassLoader() { @@ -398,35 +398,35 @@ public abstract class Controller extends java.lang.Object { // This method is overridden by RandomAccessFileControl // The RandomAccessFileControl version sets the pointer to // the next NodeComponent correclty - + ListIterator list = symbolTable.getUnsavedNodeComponents(); out.writeInt( symbolTable.getUnsavedNodeComponentsSize() ); while( list.hasNext() ) { SymbolTableData symbol = (SymbolTableData)list.next(); - + out.writeInt( symbol.nodeID ); out.writeLong( 0L ); // Pointer to next NodeComponent - + writeObject( out, symbol.getNodeState() ); } } - + /** - * Read in all the node components in this block + * Read in all the node components in this block */ protected void readNodeComponents( DataInput in ) throws IOException { int count = in.readInt(); - + for(int i=0; i outputFileVersion ) { throw new IOException("Unsupported file version. This file was written using a new version of the SceneGraph IO API, please update your installtion to the latest version"); } - + // readFileDescription sets user_data String description = readFileDescription(); - + raf.seek( BRANCH_GRAPH_COUNT ); branchGraphCount = raf.readInt(); //System.out.println("BranchGraph count : "+branchGraphCount ); - + raf.seek( UNIVERSE_CONFIG_PTR ); universe_config = raf.readLong(); raf.seek( SYMBOL_TABLE_PTR ); symbol_table = raf.readLong(); - + ConfiguredUniverse universe; - + raf.seek( symbol_table ); symbolTable.readTable( raf, false ); - raf.seek(user_data); + raf.seek(user_data); userData = readSerializedData(raf); } - + public ConfiguredUniverse readUniverse( boolean attachBranchGraphs, Canvas3D canvas) throws IOException { raf.seek( universe_config ); return readUniverse( raf, attachBranchGraphs, canvas ); } - + public Object getUserData() { return userData; } - + /** * Read the set of branchgraps. * @@ -191,14 +191,14 @@ public class RandomAccessFileControl extends Controller { readBranchGraph( graphs[i] ); } } - + /** * Return the number of branchgraphs in the file */ public int getBranchGraphCount() { return symbolTable.getBranchGraphCount(); } - + public void writeBranchGraph( BranchGroup bg, java.io.Serializable userData ) throws IOException { long filePointer = raf.getFilePointer(); raf.writeInt( 0 ); // Node count @@ -214,14 +214,14 @@ public class RandomAccessFileControl extends Controller { symbol.branchGraphID = -1; // This is a new BranchGraph so set the ID to -1 } // which will cause setBranchGraphRoot to assign a new ID. - symbolTable.setBranchGraphRoot( symbol, filePointer ); + symbolTable.setBranchGraphRoot( symbol, filePointer ); symbolTable.startUnsavedNodeComponentFrame(); SceneGraphObjectState state = createState( bg, symbol ); //System.out.println(state); try { writeObject( raf, state ); - writeNodeComponents( raf ); + writeNodeComponents( raf ); } catch( IOException e ) { e.printStackTrace(); } @@ -229,9 +229,9 @@ public class RandomAccessFileControl extends Controller { } catch( SGIORuntimeException e ) { throw new IOException( e.getMessage() ); } - + } - + public BranchGroup[] readBranchGraph( int graphID ) throws IOException { //System.out.print("Loading graph "+graphID+" : "); // TODO - remove try { @@ -259,13 +259,13 @@ public class RandomAccessFileControl extends Controller { } symbolTable.clearUnshared(); // Remove all unshared symbols - + return ret; } catch( SGIORuntimeException e ) { throw new IOException( e.getMessage() ); - } + } } - + /** * Read and return all the graphs in the file */ @@ -273,7 +273,7 @@ public class RandomAccessFileControl extends Controller { int size = getBranchGraphCount(); BranchGroupState[] states = new BranchGroupState[ size ]; BranchGroup[] ret = new BranchGroup[ size ]; - + try { for( int i=0; i outputFileVersion ) { throw new IOException("Unsupported file version. This file was written using a new version of the SceneGraph IO API, please update your installtion to the latest version"); } } - + /** * Add the named objects to the symbol table */ public void addNamedObjects( HashMap namedObjects ) { symbolTable.addNamedObjects( namedObjects ); } - - /** + + /** * The BranchGraph userData is not supported in a stream and will be * ignored. * @@ -131,7 +131,7 @@ public class StreamControl extends Controller { symbol.branchGraphID = -1; // This is a new BranchGraph so set the ID to -1 } // which will cause setBranchGraphRoot to assign a new ID. - symbolTable.setBranchGraphRoot( symbol, 0 ); + symbolTable.setBranchGraphRoot( symbol, 0 ); symbolTable.startUnsavedNodeComponentFrame(); SceneGraphObjectState state = createState( bg, symbol ); writeObject( outputStream, state ); @@ -145,9 +145,9 @@ public class StreamControl extends Controller { symbolTable.writeTable( outputStream ); } catch( SGIORuntimeException e ) { throw new IOException( e.getMessage() ); - } + } } - + public BranchGroup readBranchGraph( HashMap namedObjects ) throws IOException { try { SceneGraphObjectState state = readObject( inputStream ); @@ -164,9 +164,9 @@ public class StreamControl extends Controller { return (BranchGroup)state.getNode(); } catch( SGIORuntimeException e ) { throw new IOException( e.getMessage() ); - } + } } - + /** * Read the set of branchgraps. * @@ -180,7 +180,7 @@ public class StreamControl extends Controller { for(int i=0; i1) sharedNodes.add( symbol ); nodeIDIndex.set( symbol.nodeID, symbol ); } - + branchGraphs.set( j, symbol ); } - - + + for(int i=0; isymbol * * Only nodes (not nodeComponents) affect intergraph dependencies @@ -475,10 +475,10 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef set = new HashSet(); branchGraphDependencies.set( currentBranchGraphID, set ); } - + set.add(symbol); } - + /** * Update the reference count for the node component. * @@ -486,25 +486,25 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef */ public void incNodeComponentRefCount( int nodeID ) { if (nodeID==0) return; - + SymbolTableData symbol = getSymbol( nodeID ); - + ((NodeComponentState)symbol.nodeState).addSubReference(); - + if (symbol.referenceCount==1) sharedNodes.add( symbol ); symbol.referenceCount++; } - + /** * Add a refernce to the specified node * Also returns the nodes id */ public int addReference( SceneGraphObject node ) { if (node==null) return 0; - + SymbolTableData symbol = getSymbol( node ); - + if (symbol==null) { if (node instanceof javax.media.j3d.Node) { symbol = createDanglingSymbol( node ); @@ -521,23 +521,23 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef return addReference( symbol ); } } - + /** * Add a refernce to the specified node * Also returns the nodes id */ public int addReference( SymbolTableData symbol ) { - + if (symbol!=null) { if (symbol.referenceCount==1) sharedNodes.add( symbol ); symbol.referenceCount++; - + if (symbol.j3dNode instanceof javax.media.j3d.NodeComponent && symbol.referenceCount>1) { ((NodeComponentState)symbol.nodeState).addSubReference(); } - - if (symbol.branchGraphID != currentBranchGraphID && + + if (symbol.branchGraphID != currentBranchGraphID && symbol.j3dNode instanceof javax.media.j3d.Node ) { // System.out.println("------------- Adding Reference "+symbol.nodeID+" "+symbol.j3dNode ); // TODO - remove addInterGraphDependency( symbol ); @@ -545,10 +545,10 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef } else { throw new SGIORuntimeException("Null Symbol"); } - + return symbol.nodeID; } - + /** * Add a refernce to the BranchGraph root * Also returns the nodes id @@ -558,9 +558,9 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef */ public int addBranchGraphReference( SceneGraphObject node, int branchGraphID ) { if (node==null) return 0; - + SymbolTableData symbol = getSymbol( node ); - + if (symbol!=null) { if (symbol.referenceCount==1) sharedNodes.add( symbol ); @@ -571,7 +571,7 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef nodeIDIndex.add( symbol ); danglingReferences.put( node, symbol ); } - + symbol.branchGraphID = branchGraphID; for(int i=branchGraphs.size(); inodeIDIndex.size() ) return null; - else + else return (SymbolTableData)nodeIDIndex.get( nodeID ); } - + /** Get the symbol for the shared group * If the sharedgroup has not been loaded then load it before * returning (if we are using RandomAccessFileControl */ public SymbolTableData getSharedGroup( int nodeID ) { SymbolTableData symbol = getSymbol( nodeID ); - + if (symbol.nodeState==null && control instanceof RandomAccessFileControl) { try { ((RandomAccessFileControl)control).loadSharedGroup( symbol ); @@ -673,27 +673,27 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef throw new SGIORuntimeException("Internal error in getSharedGroup"); } } - + return symbol; } - - /** + + /** * Set the position of the object referenced by state */ public void setFilePosition( long ptr, SceneGraphObjectState state ) { if (state instanceof NullSceneGraphObjectState) return; - + SymbolTableData symbol = getSymbol( state.getNodeID() ); - + symbol.filePosition = ptr; } /** - * Associate the name with the scene graph object + * Associate the name with the scene graph object */ public void addNamedObject( String name, SceneGraphObject object ) { namedObjects.put( name, object ); } - + /** * Add all the named objects in map */ @@ -701,7 +701,7 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef if (map!=null) namedObjects.putAll( map ); } - + /** * Return the SceneGraphObject associated with the name */ @@ -709,7 +709,7 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef Object obj = namedObjects.get( name ); if (obj==null) throw new NamedObjectException( "Unknown name :"+name ); - + if (obj instanceof SceneGraphObject) return (SceneGraphObject)obj; else { @@ -719,51 +719,51 @@ public class SymbolTable extends java.lang.Object implements SceneGraphObjectRef return symbol.j3dNode; } } - + /** * Get all the names of the named objects */ public String[] getNames() { return (String[])namedObjects.keySet().toArray( new String[] {} ); } - + /** * Add the namedObject mappings to map */ public void getNamedObjectMap( HashMap map ) { map.putAll( namedObjects ); } - + public String toString() { StringBuffer buf = new StringBuffer(); - + for(int i=0; i0) // TODO - remove if, workaround for bug in daily app.setTextureUnitState( texUnitState ); - + app.setTransparencyAttributes( (TransparencyAttributes)control.getSymbolTable().getJ3dNode(transparencyAttributes) ); super.buildGraph(); // Must be last call in method } - + protected javax.media.j3d.SceneGraphObject createNode() { return new Appearance(); } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/AuralAttributesState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/AuralAttributesState.java index 4e44830..bc433de 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/AuralAttributesState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/AuralAttributesState.java @@ -57,24 +57,24 @@ public class AuralAttributesState extends NodeComponentState { public AuralAttributesState(SymbolTableData symbol,Controller control) { super( symbol, control ); - + } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); - + out.writeFloat( ((AuralAttributes)node).getAttributeGain() ); - + float[] distance = new float[ ((AuralAttributes)node).getDistanceFilterLength() ]; float[] cutoff = new float[ distance.length ]; - + ((AuralAttributes)node).getDistanceFilter( distance, cutoff ); out.writeInt( distance.length ); for(int i=0; i1) ((NodeComponent)this.node).setDuplicateOnCloneTree(in.readBoolean()); } - public void writeObject( DataOutput out ) throws IOException { + public void writeObject( DataOutput out ) throws IOException { super.writeObject(out); out.writeBoolean(((NodeComponent)this.node).getDuplicateOnCloneTree()); } - + /** * Called when this component reference count is incremented. * Allows this component to update the reference count of any components @@ -80,6 +80,6 @@ public abstract class NodeComponentState extends SceneGraphObjectState { */ public void addSubReference() { } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NodeState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NodeState.java index e358d4f..7e46f41 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NodeState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NodeState.java @@ -57,18 +57,18 @@ public class NodeState extends SceneGraphObjectState { public NodeState( SymbolTableData symbol, Controller control ) { super(symbol, control); } - - public void writeObject( DataOutput out ) throws + + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); - + control.writeBounds( out, ((Node)node).getBounds() ); out.writeBoolean( ((Node)node).getPickable() ); out.writeBoolean( ((Node)node).getCollidable() ); out.writeBoolean( ((Node)node).getBoundsAutoCompute() ); - + } public void readObject( DataInput in ) throws @@ -76,13 +76,13 @@ public class NodeState extends SceneGraphObjectState { super.readObject(in); ((Node)node).setBounds( control.readBounds(in) ); - + ((Node)node).setPickable( in.readBoolean() ); ((Node)node).setCollidable( in.readBoolean() ); ((Node)node).setBoundsAutoCompute( in.readBoolean() ); } - - + + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NullSceneGraphObjectState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NullSceneGraphObjectState.java index 01cf3ea..90b702e 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NullSceneGraphObjectState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/NullSceneGraphObjectState.java @@ -60,9 +60,9 @@ import com.sun.j3d.utils.scenegraph.io.retained.Controller; import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; public class NullSceneGraphObjectState extends SceneGraphObjectState { - + SymbolTableData symbolTableData; - + /** * Dummy class to represent a null object in the scene graph * @@ -71,32 +71,32 @@ public class NullSceneGraphObjectState extends SceneGraphObjectState { super( null, control ); symbolTableData = new SymbolTableData( -1, null, this, -1 ); } - + /** * DO NOT call symbolTable.addReference in writeObject as this (may) * result in a concurrentModificationException. * * All references should be created in the constructor */ - public void writeObject( DataOutput out ) throws IOException { + public void writeObject( DataOutput out ) throws IOException { } public void readObject( DataInput in ) throws IOException { } - + public SceneGraphObject getNode() { return null; } - + public int getNodeID() { return -1; } - + public SymbolTableData getSymbol() { return symbolTableData; } - - + + protected javax.media.j3d.SceneGraphObject createNode() { return null; } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrderedGroupState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrderedGroupState.java index c621da0..7413c2d 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrderedGroupState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrderedGroupState.java @@ -77,7 +77,7 @@ public class OrderedGroupState extends GroupState { } ((OrderedGroup)node).setChildIndexOrder( childIndexOrder ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new OrderedGroup(); } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrientedShape3DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrientedShape3DState.java index d8764a2..de0590b 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrientedShape3DState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/OrientedShape3DState.java @@ -55,42 +55,42 @@ import com.sun.j3d.utils.scenegraph.io.retained.Controller; import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; public class OrientedShape3DState extends Shape3DState { - + public OrientedShape3DState(SymbolTableData symbol,Controller control) { super( symbol, control ); - + } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); - + out.writeInt( ((OrientedShape3D)node).getAlignmentMode() ); - + Vector3f vec = new Vector3f(); ((OrientedShape3D)node).getAlignmentAxis( vec ); - + Point3f point = new Point3f(); ((OrientedShape3D)node).getRotationPoint( point ); - + control.writeVector3f( out, vec ); control.writePoint3f( out, point ); out.writeBoolean( ((OrientedShape3D)node).getConstantScaleEnable() ); out.writeDouble( ((OrientedShape3D)node).getScale() ); } - + public void readObject( DataInput in ) throws IOException { super.readObject( in ); - + ((OrientedShape3D)node).setAlignmentMode( in.readInt() ); ((OrientedShape3D)node).setAlignmentAxis( control.readVector3f( in ) ); ((OrientedShape3D)node).setRotationPoint( control.readPoint3f( in ) ); ((OrientedShape3D)node).setConstantScaleEnable( in.readBoolean() ); ((OrientedShape3D)node).setScale( in.readDouble() ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new OrientedShape3D(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/PathInterpolatorState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/PathInterpolatorState.java index f9caf1f..9c680ce 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/PathInterpolatorState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/PathInterpolatorState.java @@ -55,14 +55,14 @@ import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; public abstract class PathInterpolatorState extends TransformInterpolatorState { protected float[] knots; - + public PathInterpolatorState( SymbolTableData symbol,Controller control ) { super( symbol, control ); } // PathInterpolator.setKnots(float[]) is protected so we can only set the // knots in the constructor - + public void writeConstructorParams( DataOutput out ) throws IOException { super.writeConstructorParams( out ); knots = new float[ ((PathInterpolator)node).getArrayLengths() ]; @@ -71,7 +71,7 @@ public abstract class PathInterpolatorState extends TransformInterpolatorState { for(int i=0; i2) { @@ -186,34 +186,34 @@ public abstract class SceneGraphObjectState { readCapabilities( in ); } - + public SceneGraphObject getNode() { return node; } - + public int getNodeID() { return symbol.nodeID; } - + public SymbolTableData getSymbol() { return symbol; } - + private void readUserData( DataInput in ) throws IOException { - + node.setUserData( control.readSerializedData( in )); } - + private void writeUserData( DataOutput out ) throws IOException { Object obj = node.getUserData(); if (obj != null && !(obj instanceof java.io.Serializable)) { System.err.println("UserData is not Serializable and will not be saved"); obj = null; } - + control.writeSerializedData( out, (Serializable)obj ); } - + /* * NOTE: This implementation assumes a maximum of 64 capability * bits per node class. If this changes in the future, this @@ -230,7 +230,7 @@ public abstract class SceneGraphObjectState { out.writeLong( capabilities ); out.writeLong( frequentCapabilities ); } - + private void readCapabilities( DataInput in ) throws IOException { long capabilities = in.readLong(); long frequentCapabilities = in.readLong(); @@ -254,7 +254,7 @@ public abstract class SceneGraphObjectState { protected void readConstructorParams( DataInput in ) throws IOException { } - + /** * Create a new Java3D node for this object. * @@ -269,10 +269,10 @@ public abstract class SceneGraphObjectState { protected SceneGraphObject createNode() { throw new SGIORuntimeException("createNode() not implemented in class "+this.getClass().getName()); } - + /** * Create a new Java3D node from the supplied class using the parameterless constructor - * + * * For Java3D nodes which do not have a default constructor you must * overload this method and create the object using createNode( className, parameters ) * This will correctly handle subclasses of Java3D classes @@ -293,11 +293,11 @@ public abstract class SceneGraphObjectState { } return ret; - } - + } + /** * Create a new Java3D node from the supplied class name using the parameterless constructor - * + * * For Java3D nodes which do not have a default constructor you must * overload this method and create the object using createNode( className, parameters ) * This will correctly handle subclasses of Java3D classes @@ -307,7 +307,7 @@ public abstract class SceneGraphObjectState { try { Class state = Class.forName( className, true, control.getClassLoader() ); - + ret = createNode( state ); //System.err.println("Created J3D node for "+className ); @@ -321,7 +321,7 @@ public abstract class SceneGraphObjectState { return ret; } - + /** * If createNode cannot locate the correct class to instantiate * the node this method is called and will instantiate the @@ -329,15 +329,15 @@ public abstract class SceneGraphObjectState { */ private SceneGraphObject createNodeFromSuper( String className ) { SceneGraphObject ret; - + String tmp = this.getClass().getName(); String superClass = tmp.substring( tmp.indexOf("state")+6, tmp.length()-5 ); System.err.println("Unable to create node "+className+" attempting Java3D superclass "+superClass ); - + try { Class state = Class.forName( superClass ); - + ret = (SceneGraphObject)state.newInstance(); } catch(ClassNotFoundException e) { @@ -350,10 +350,10 @@ public abstract class SceneGraphObjectState { throw new SGIORuntimeException( "Unable to instantiate class "+ className ); } - + return ret; } - + /** * Create a Java3D node which does not have a default constructor * @@ -393,7 +393,7 @@ public abstract class SceneGraphObjectState { throw new SGIORuntimeException( "Invalid constructor for "+ className ); } - + return ret; } @@ -429,10 +429,10 @@ public abstract class SceneGraphObjectState { throw new SGIORuntimeException( "Invalid constructor for "+ j3dClass.getClass().getName() ); } - + return ret; } - + /** * If createNode cannot locate the correct class to instantiate * the node this method is called and will instantiate the @@ -440,7 +440,7 @@ public abstract class SceneGraphObjectState { */ private SceneGraphObject createNodeFromSuper( String className, Class[] parameterTypes, Object[] parameters ) { SceneGraphObject ret; - + String tmp = this.getClass().getName(); String superClass = tmp.substring( tmp.indexOf("state")+6, tmp.length()-5 ); Constructor constructor; @@ -468,7 +468,7 @@ public abstract class SceneGraphObjectState { throw new SGIORuntimeException( "Invalid constructor for "+ className ); } - + return ret; } @@ -501,28 +501,28 @@ public abstract class SceneGraphObjectState { if (node instanceof com.sun.j3d.utils.scenegraph.io.SceneGraphIO) ((com.sun.j3d.utils.scenegraph.io.SceneGraphIO)node).restoreSceneGraphObjectReferences( control.getSymbolTable() ); } - + public void cleanup() { control = null; node = null; } - + /** * Read and return a possibly null string */ protected String readString(DataInput in) throws IOException { if (in.readBoolean()) return (in.readUTF()); - return null; + return null; } - + /** * Write a possibly null string to the stream */ protected void writeString(String str, DataOutput out) throws IOException { out.writeBoolean(str!=null); if (str!=null) - out.writeUTF(str); + out.writeUTF(str); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Shape3DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Shape3DState.java index 1fd16a5..657f1d7 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Shape3DState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Shape3DState.java @@ -58,10 +58,10 @@ public class Shape3DState extends LeafState { private int[] geometry; private int appearance; - + public Shape3DState( SymbolTableData symbol, Controller control ) { super( symbol, control ); - + if (node!=null) { appearance = control.getSymbolTable().addReference( ((Shape3D)node).getAppearance() ); int length = ((Shape3D)node).numGeometries(); @@ -70,24 +70,24 @@ public class Shape3DState extends LeafState { geometry[i] = control.getSymbolTable().addReference( ((Shape3D)node).getGeometry(i) ); } } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); - + control.writeBounds( out, ((Shape3D)node).getCollisionBounds() ); - + out.writeInt( appearance ); - + out.writeInt( geometry.length ); for(int i=0; i= 5) { diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchState.java index c41d9df..64a428a 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchState.java @@ -53,30 +53,30 @@ import javax.media.j3d.SceneGraphObject; import javax.media.j3d.Switch; public class SwitchState extends GroupState { - + public SwitchState(SymbolTableData symbol,Controller control) { super(symbol, control); } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); Switch attr = (Switch)node; control.writeSerializedData( out, attr.getChildMask() ); out.writeInt( attr.getWhichChild() ); } - + public void readObject( DataInput in ) throws IOException { super.readObject( in ); Switch attr = (Switch)node; - + attr.setChildMask( (java.util.BitSet)control.readSerializedData(in) ); attr.setWhichChild( in.readInt() ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new Switch(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchValueInterpolatorState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchValueInterpolatorState.java index 92d7ec6..4281c1e 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchValueInterpolatorState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/SwitchValueInterpolatorState.java @@ -59,43 +59,43 @@ import com.sun.j3d.utils.scenegraph.io.retained.SymbolTableData; public class SwitchValueInterpolatorState extends InterpolatorState { private int target; - + public SwitchValueInterpolatorState(SymbolTableData symbol,Controller control) { super( symbol, control ); - + if (node!=null) target = control.getSymbolTable().addReference( ((SwitchValueInterpolator)node).getTarget() ); } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); - + out.writeInt( target ); out.writeInt( ((SwitchValueInterpolator)node).getFirstChildIndex() ); out.writeInt( ((SwitchValueInterpolator)node).getLastChildIndex() ); } - + public void readObject( DataInput in ) throws IOException { super.readObject( in ); - + target = in.readInt(); ((SwitchValueInterpolator)node).setFirstChildIndex( in.readInt() ); ((SwitchValueInterpolator)node).setLastChildIndex( in.readInt() ); } - - + + public void buildGraph() { ((SwitchValueInterpolator)node).setTarget( (Switch)control.getSymbolTable().getJ3dNode( target )); super.buildGraph(); // Must be last call in method } - + public SceneGraphObject createNode( Class j3dClass ) { return createNode( j3dClass, new Class[] { javax.media.j3d.Alpha.class, javax.media.j3d.Switch.class }, new Object[] { null, null } ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new SwitchValueInterpolator( null, null ); } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TexCoordGenerationState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TexCoordGenerationState.java index 5e7142f..7f9b3a2 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TexCoordGenerationState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TexCoordGenerationState.java @@ -54,11 +54,11 @@ import javax.media.j3d.TexCoordGeneration; import javax.vecmath.Vector4f; public class TexCoordGenerationState extends NodeComponentState { - + public TexCoordGenerationState( SymbolTableData symbol, Controller control ) { super(symbol, control); } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); TexCoordGeneration attr = (TexCoordGeneration)node; @@ -75,7 +75,7 @@ public class TexCoordGenerationState extends NodeComponentState { attr.getPlaneQ( vec ); control.writeVector4f( out, vec ); } - + public void readObject( DataInput in ) throws IOException { super.readObject( in ); TexCoordGeneration attr = (TexCoordGeneration)node; @@ -87,11 +87,11 @@ public class TexCoordGenerationState extends NodeComponentState { attr.setPlaneT( control.readVector4f( in )); attr.setPlaneQ( control.readVector4f( in )); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new TexCoordGeneration(); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture2DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture2DState.java index 6eb847a..95bdc53 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture2DState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture2DState.java @@ -56,7 +56,7 @@ import javax.media.j3d.ImageComponent2D; public class Texture2DState extends TextureState { private int detailImage=0; - + public Texture2DState( SymbolTableData symbol, Controller control ) { super(symbol, control); @@ -118,7 +118,7 @@ public class Texture2DState extends TextureState { t.setDetailImage( (ImageComponent2D)control.getSymbolTable().getJ3dNode( detailImage ) ); super.buildGraph(); // Must be last call in method } - + public SceneGraphObject createNode( Class j3dClass ) { return createNode( j3dClass, new Class[] { Integer.TYPE, Integer.TYPE, @@ -131,10 +131,10 @@ public class Texture2DState extends TextureState { new Integer( height ), new Integer( boundaryWidth ) } ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new Texture2D( mipMapMode, format, width, height, boundaryWidth ); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture3DState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture3DState.java index 1aab1ef..535eb78 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture3DState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/Texture3DState.java @@ -53,33 +53,33 @@ import javax.media.j3d.SceneGraphObject; import javax.media.j3d.Texture3D; public class Texture3DState extends TextureState { - + private int depth; - + public Texture3DState( SymbolTableData symbol, Controller control ) { super(symbol, control); } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); out.writeInt( ((Texture3D)node).getBoundaryModeR() ); } - + public void readObject( DataInput in ) throws IOException { super.readObject( in ); ((Texture3D)node).setBoundaryModeR( in.readInt() ); } - + public void writeConstructorParams( DataOutput out ) throws IOException { super.writeConstructorParams( out ); out.writeInt( ((Texture3D)node).getDepth() ); } - + public void readConstructorParams( DataInput in ) throws IOException { super.readConstructorParams( in ); depth = in.readInt(); } - + public SceneGraphObject createNode( Class j3dClass ) { return createNode( j3dClass, new Class[] { Integer.TYPE, Integer.TYPE, @@ -94,10 +94,10 @@ public class Texture3DState extends TextureState { new Integer( depth ), new Integer( boundaryWidth ) } ); } - + protected javax.media.j3d.SceneGraphObject createNode() { return new Texture3D( mipMapMode, format, width, height, depth, boundaryWidth ); } - + } diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TextureAttributesState.java b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TextureAttributesState.java index b0fcb90..58ac801 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TextureAttributesState.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/io/state/javax/media/j3d/TextureAttributesState.java @@ -58,11 +58,11 @@ import javax.vecmath.Matrix4d; public class TextureAttributesState extends NodeComponentState { private static final int MAX_COLOR_OPERANDS = 2; - + public TextureAttributesState( SymbolTableData symbol, Controller control ) { super(symbol, control); } - + public void writeObject( DataOutput out ) throws IOException { super.writeObject( out ); TextureAttributes attr = (TextureAttributes)node; @@ -72,17 +72,17 @@ public class TextureAttributesState extends NodeComponentState { int tableComponents = attr.getNumTextureColorTableComponents(); int tableSize = attr.getTextureColorTableSize(); int[][] colorTable = new int[tableComponents][tableSize]; - + out.writeInt( attr.getPerspectiveCorrectionMode() ); attr.getTextureBlendColor( clr ); control.writeColor4f( out, clr ); out.writeInt( tableComponents ); out.writeInt( tableSize ); - attr.getTextureColorTable( colorTable ); + attr.getTextureColorTable( colorTable ); for(int i=0; i comparators = new WeakHashMap(); - /** + /** * Set the comparator for the specified view. * * The comparators compare method will be called with 2 objects of type @@ -79,7 +79,7 @@ public class TransparencySortController { public static void setComparator(View view, Comparator comparator) { comparators.put(view, comparator); } - + /** * Returns the comparator for the specified view * diff --git a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java index 828545a..b241341 100644 --- a/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java +++ b/src/classes/share/com/sun/j3d/utils/scenegraph/transparency/TransparencySortGeom.java @@ -58,32 +58,32 @@ import javax.media.j3d.Transform3D; * @since Java 3D 1.4 */ public interface TransparencySortGeom { - + /** * Returns the Geometry for this object. * * @return geometry for this object */ public Geometry getGeometry(); - + /** * Returns the distance squared of this object to the viewer. * * @return distancesquared to viewer */ public double getDistanceSquared(); - + /** * Returns the LocalToVWorld transform for this object * * @param localToVW variable in which transform will be returned */ public void getLocalToVWorld(Transform3D localToVW); - + /** * Returns the Shape3D being rendered using this geometry. * - * @return the Shape3D being rendered using this geometry + * @return the Shape3D being rendered using this geometry */ public Shape3D getShape3D(); diff --git a/src/classes/share/com/sun/j3d/utils/timer/J3DTimer.java b/src/classes/share/com/sun/j3d/utils/timer/J3DTimer.java index 02b2f7c..a67157d 100644 --- a/src/classes/share/com/sun/j3d/utils/timer/J3DTimer.java +++ b/src/classes/share/com/sun/j3d/utils/timer/J3DTimer.java @@ -45,9 +45,9 @@ package com.sun.j3d.utils.timer; /** - * A High Resolution interval timer. The timer resolution is - * operating system dependent and can be queried using - * getTimerResolution(). + * A High Resolution interval timer. The timer resolution is + * operating system dependent and can be queried using + * getTimerResolution(). * * These methods are not reentrant and should not * be called concurrently from multiple threads. diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigCommand.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigCommand.java index 49789d1..f286f38 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigCommand.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigCommand.java @@ -268,7 +268,7 @@ class ConfigCommand { /** * Sets the given Java system property if allowed by the security manager. - * + * * @param key property name * @param value property value * @return previous property value if any @@ -284,7 +284,7 @@ class ConfigCommand { /** * Evaluates the specified Java property string if allowed by the security - * manager. + * manager. * * @param key string containing a Java property name * @return string containing the Java property valaue @@ -382,7 +382,7 @@ class ConfigCommand { /** * Returns the String representation of this command. - * + * * @return string representing this command */ public String toString() { @@ -410,7 +410,7 @@ class ConfigCommand { sb.append(argv[i].toString()) ; } } - + sb.append(")") ; return sb.toString() ; } diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java index 303681c..e5bee2f 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java @@ -56,7 +56,7 @@ import com.sun.j3d.utils.behaviors.vp.ViewPlatformBehavior ; * that will effect the viewing configuration specified in the file. These * can include Viewers, ViewingPlatforms, ViewPlatformBehaviors, InputDevices, * Sensors, and other objects.

      - * + * * Clients can construct the view side of a scene graph by retrieving these * objects using the accessor methods provided by this class. This could * involve as little as just attaching ViewingPlatforms to a Locale, depending @@ -89,7 +89,7 @@ public class ConfigContainer { // must be evaluated in the order in which they were created. // LinkedHashMap is available in JDK 1.4 but currently this code must run // under JDK 1.3.1 as well. - // + // private Map baseNameMap = new HashMap() ; // Map containing named canvases for each view. @@ -120,7 +120,7 @@ public class ConfigContainer { // The visibility status of Viewer AWT components. private boolean setVisible = false ; - + private ClassLoader classLoader = ClassLoader.getSystemClassLoader(); /** @@ -170,7 +170,7 @@ public class ConfigContainer { this(userConfig, setVisible, transformCount, true) ; } - + /** * Creates a new ConfigContainer and loads the configuration file at the * specified URL. Any ViewingPlatform instantiated by the configuration @@ -207,7 +207,7 @@ public class ConfigContainer { * setViewingPlatform in order to look up the actual Sensor, * Viewer, Behavior, etc., instances associated with the names provided * them from the configuration file.

      - * + * * The preferred methods to retrieve instances of specific objects defined * in the configuration file are to either 1) get the ConfiguredUniverse * instance when the behavior's initialize method is called, @@ -234,7 +234,7 @@ public class ConfigContainer { loadConfig(userConfig) ; processConfig(setVisible, transformCount, attachBehaviors) ; } - + /** * Package scoped constructor that adds the ability to set the ClassLoader * which will be used to load any app specific classes specified in the @@ -249,14 +249,14 @@ public class ConfigContainer { /** * Open, parse, and load the contents of a configuration file. - * + * * @param userConfig location of the configuration file */ private void loadConfig(URL userConfig) { InputStream inputStream = null ; StreamTokenizer streamTokenizer = null ; String lastFileName = currentFileName ; - + currentFileName = userConfig.toString() ; try { inputStream = userConfig.openStream() ; @@ -270,7 +270,7 @@ public class ConfigContainer { // // Set up syntax tables for the tokenizer. - // + // // It would be nice to allow '/' as a word constituent for URL strings // and Unix paths, but then the scanner won't ignore "//" and "/* */" // comment style syntax. Treating '/' as an ordinary character will @@ -282,7 +282,7 @@ public class ConfigContainer { // should still be treated as an ordinary character however, so that a // non-quoted URL string or Unix path will be treated as a syntax // error instead of a comment. - // + // streamTokenizer.ordinaryChar('/') ; streamTokenizer.wordChars('_', '_') ; streamTokenizer.wordChars('$', '$') ; // for ${...} Java property @@ -372,7 +372,7 @@ public class ConfigContainer { * are processed here, at which point the subclass implementation of * initialize() is called. Subclasses must override initialize() if they * need to process more than what is processed by default here. - * + * * @param cmd configuration command that creates a new ConfigObject */ private ConfigObject createConfigObject(ConfigCommand cmd) { @@ -441,7 +441,7 @@ public class ConfigContainer { * information. The command is of the form:

      * * ({baseName}Alias {aliasName} {originalName}) - * + * * @param cmd configuration command that creates a new alias * @return the new ConfigObject with alias information */ @@ -452,11 +452,11 @@ public class ConfigContainer { throw new IllegalArgumentException ("Command \"" + cmd.commandName + "\" requires an instance name as second argument") ; - + original = findConfigObject(cmd.baseName, (String)cmd.argv[2]) ; return new ConfigAlias(cmd.baseName, cmd.instanceName, original) ; } - + /** * A class that does nothing but reference another ConfigObject. Once * created, the alias name can be used in all commands that would accept @@ -476,7 +476,7 @@ public class ConfigContainer { /** * Adds the specified ConfigObject instance into this container using the * given ConfigCommand's base name and instance name. - * + * * @param object the ConfigObject instance to add into the database */ private void addConfigObject(ConfigObject object) { @@ -590,7 +590,7 @@ public class ConfigContainer { * after the config file has already been parsed. The parser won't catch * any of the exceptions generated by this method, so the error messages * are wrapped accordingly. - * + * * @param basename base name of the config object * @param cmd command containing the name in argv[1] * @return the found ConfigObject @@ -613,7 +613,7 @@ public class ConfigContainer { * This method gets called from a ConfigObject to evaluate a retained * built-in command nested within a property command. These are commands * that can't be evaluated until the entire config file is parsed. - * + * * @param cmd the built-in command * @return object representing result of evaluation */ @@ -698,7 +698,7 @@ public class ConfigContainer { } // Process config physical environments into Java 3D physical - // environments. + // environments. private void processPhysicalEnvironments(Collection c) { Iterator i = c.iterator() ; while (i.hasNext()) { @@ -753,10 +753,10 @@ public class ConfigContainer { if (! cd.j3dInputDevice.initialize()) throw new RuntimeException (cd.errorMessage(cd.creatingCommand, - "could not initialize device \"" + + "could not initialize device \"" + cd.instanceName + "\"")) ; } - + // An InputDevice implementation will have created all its Sensors by // the time initialize() returns. Retrieve and configure them here. if (s != null) { @@ -809,7 +809,7 @@ public class ConfigContainer { } } - // Process generic objects. + // Process generic objects. private void processGenericObjects(Collection objects) { Iterator i = objects.iterator() ; while (i.hasNext()) { @@ -865,13 +865,13 @@ public class ConfigContainer { * (NewPhysicalBody <instance name> * [Alias <alias name>]) * - * + * * The PhysicalBody is configured through the following command:

      *

      * (PhysicalBodyProperty <instance name> * <property name> <property value>) *
      - * + * * @return read-only Set of all unique instances, or null */ public Set getPhysicalBodies() { @@ -883,7 +883,7 @@ public class ConfigContainer { /** * Returns a read-only Map that maps PhysicalBody names to instances. * Names may be aliases and if so will map to the original instances. - * + * * @return read-only Map from names to PhysicalBody instances, or null if * no instances */ @@ -896,19 +896,19 @@ public class ConfigContainer { /** * Returns a read-only Set of all configured PhysicalEnvironment instances * in the order they were defined in the configuration file.

      - * + * * PhysicalEnvironment instances are created with the following command:

      *

      * (NewPhysicalEnvironment <instance name> * [Alias <alias name>]) *
      - * + * * The PhysicalEnvironment is configured through the following command:

      *

      * (PhysicalEnvironmentProperty <instance name> * <property name> <property value>) *
      - * + * * @return read-only Set of all unique instances, or null */ public Set getPhysicalEnvironments() { @@ -921,7 +921,7 @@ public class ConfigContainer { * Returns a read-only Map that maps PhysicalEnvironment names to * instances. Names may be aliases and if so will map to the original * instances. - * + * * @return read-only Map from names to PhysicalEnvironment instances, or * null if no instances */ @@ -937,12 +937,12 @@ public class ConfigContainer { * incorporated any PhysicalEnvironment and PhysicalBody objects specfied * for them in the configuration file, and will be attached to any * ViewingPlatforms specified for them.

      - * + * * Viewer instances are created with the following command:

      *

      * (NewView <instance name> [Alias <alias name>]) *
      - * + * * The Viewer is configured through the following command:

      *

      * (ViewProperty <instance name> @@ -963,7 +963,7 @@ public class ConfigContainer { * The Viewers will have incorporated any PhysicalEnvironment and * PhysicalBody objects specfied for them in the configuration file, and * will be attached to any ViewingPlatforms specified for them.

      - * + * * @return read-only Map from names to Viewer instances, or * null if no instances */ @@ -984,7 +984,7 @@ public class ConfigContainer { * (NewDevice <instanceName> <className> * [Alias <alias name>]) *

      - * + * * className must be the fully-qualified name of a class that * implements the InputDevice interface. The implementation * must provide a parameterless constructor.

      @@ -994,14 +994,14 @@ public class ConfigContainer { * (DeviceProperty <instanceName> <propertyName> * <arg0> ... <argn>) * - * + * * propertyName must be the name of a input device method that * takes an array of Objects as its only parameter; the array is populated * with the values of arg0 through argn when the method is * invoked to set the property. These additional requirements for * configurable input devices can usually be fulfilled by extending or * wrapping available InputDevice implementations. - * + * * @return read-only Set of all unique instances, or null */ public Set getInputDevices() { @@ -1015,7 +1015,7 @@ public class ConfigContainer { * Names may be aliases and if so will map to the original instances. All * InputDevice instances in the map are initialized and registered with * any PhysicalEnvironments that reference them. - * + * * @return read-only Map from names to InputDevice instances, or * null if no instances * @see #getInputDevices @@ -1031,13 +1031,13 @@ public class ConfigContainer { * they were defined in the configuration file. The associated * InputDevices are all initialized and registered with any * PhysicalEnvironments that reference them.

      - * + * * Sensor instances are named with the following command:

      *

      - * (NewSensor <instance name> <device name> + * (NewSensor <instance name> <device name> * <sensor index> [Alias <alias name>]) *
      - * + * * device name is the instance name of a previously defined * InputDevice, and sensor index is the index of the Sensor to be * bound to instance name. The InputDevice implementation is @@ -1046,13 +1046,13 @@ public class ConfigContainer { * * The Sensor is configured through the SensorProperty command:

      *

      - * (SensorProperty <instance name> <property name> + * (SensorProperty <instance name> <property name> * <property value>) *
      - * + * * With the sole exception of the Sensor assigned to the head tracker, * none of the Sensors defined in the configuration file are placed into - * the Sensor array maintained by a PhysicalEnvironment. + * the Sensor array maintained by a PhysicalEnvironment. * * @return read-only Set of all unique instances, or null */ @@ -1067,11 +1067,11 @@ public class ConfigContainer { * be aliases and if so will map to the original instances. The * associated InputDevices are all initialized and registered with any * PhysicalEnvironments that reference them.

      - * + * * With the sole exception of the Sensor assigned to the head tracker, * none of the Sensors defined in the configuration file are placed into - * the Sensor array maintained by a PhysicalEnvironment. - * + * the Sensor array maintained by a PhysicalEnvironment. + * * @return read-only Map from names to Sensor instances, or * null if no instances */ @@ -1093,7 +1093,7 @@ public class ConfigContainer { * (NewViewPlatform <instance name> * [Alias <alias name>]) * - * + * * The ViewingPlatform is configured through the following command:

      *

      * (ViewPlatformProperty <instance name> <property name> @@ -1114,7 +1114,7 @@ public class ConfigContainer { * ConfigContainer class itself does not attach the ViewingPlatform * instances to any scengraph components or universe Locales; they are not * "live" until made so by a separate client such as ConfiguredUniverse. - * + * * @return read-only Map from names to ViewingPlatform instances, or * null if no instances */ @@ -1127,7 +1127,7 @@ public class ConfigContainer { /** * Returns a read-only Set of all configured ViewPlatformBehavior * instances in the order they were defined in the configuration file.

      - * + * * The behaviors are attached to any ViewingPlatforms that specified them; * that is, the setViewPlatformBehavior and * setViewingPlatform methods of ViewingPlatform and @@ -1139,7 +1139,7 @@ public class ConfigContainer { *

      * (NewViewPlatformBehavior <instanceName> <className>) *
      - * + * * className must be the fully qualified name of a concrete class * that extends the abstract ViewPlatformBehavior class. The * implementation must provide a parameterless constructor.

      @@ -1149,7 +1149,7 @@ public class ConfigContainer { * (ViewPlatformBehaviorProperty <instanceName> * <propertyName> <arg0> ... <argn>) *

      - * + * * ViewPlatformBehavior subclasses inherit a number of pre-defined * properties that can be directly specified with the propertyName * string; see the configuration file documentation for details.

      @@ -1175,14 +1175,14 @@ public class ConfigContainer { * Returns a read-only Map that maps ViewPlatformBehavior names to * instances. Names may be aliases and if so will map to the original * instances.

      - * + * * The behaviors are attached to any ViewingPlatforms that specified them; * that is, the setViewPlatformBehavior and * setViewingPlatform methods of ViewingPlatform and * ViewPlatformBehavior have been called if appropriate. However, a * behavior's initialize method is not called until the * ViewingPlatform to which it is attached is made live.

      - * + * * @return read-only Map from names to ViewPlatformBehavior instances, or * null if no instances * @see #getViewPlatformBehaviors @@ -1199,14 +1199,14 @@ public class ConfigContainer { * original instances. The set of unique Canvas3D instances used by a * Viewer may be obtained by calling the Viewer's accessor methods * directly.

      - * + * * A named Canvas3D is created and added to a Viewer whenever any of the * following configuration commands are used:

      *

      * (ViewProperty <view> Screen <screenName>)
      * (ViewProperty <view> Window <windowName>) *
      - * + * * view is the name of a Viewer created with the NewView command. * The screenName and windowName parameters of the above * commands are the keys to use when looking up the associated Canvas3D @@ -1229,7 +1229,7 @@ public class ConfigContainer { ConfigScreen cs = (ConfigScreen)i.next() ; m.put(cs.instanceName, cs.j3dCanvas) ; - // The aliases list contains all alias strings for the canvas. + // The aliases list contains all alias strings for the canvas. Iterator j = cs.aliases.iterator() ; while (j.hasNext()) m.put(j.next(), cs.j3dCanvas) ; } @@ -1246,7 +1246,7 @@ public class ConfigContainer { *
      * (NewObject <instanceName> <className>) *
      - * + * * className must be the fully-qualified name of a class that * provides a parameterless constructor.

      * @@ -1255,7 +1255,7 @@ public class ConfigContainer { * (ObjectProperty <instanceName> <propertyName> * <arg0> ... <argn>) * - * + * * propertyName must be the name of a method provided by object * instanceName. It must take an array of Objects as its only * parameter; the array is populated with the values of arg0 @@ -1275,7 +1275,7 @@ public class ConfigContainer { * Returns a read-only Map that maps generic object names to * instances. Names may be aliases and if so will map to the original * instances. - * + * * @return read-only Map from names to generic object instances, or * null if no instances * @see #getGenericObjects @@ -1301,11 +1301,11 @@ public class ConfigContainer { * Returns whether Viewers should be created with their AWT components * initially visible or invisible. This is useful for clients that wish * to provide a default Viewer if the configuration file doesn't specify - * one. + * one. * * @return true if Viewer components should be initially visible; false - * otherwise - */ + * otherwise + */ public boolean getViewerVisibility() { return setVisible ; } @@ -1395,7 +1395,7 @@ public class ConfigContainer { genericObjectMap.map.clear() ; genericObjectMap = null ; } - + } /** diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java index 102701c..f4fe88a 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java @@ -53,7 +53,7 @@ import java.util.ArrayList ; * configuration parameters for a target object, which is instantiated after * the configuration file is parsed. The ConfigObject then applies its * configuration properties to the target object.

      - * + * * Generic base implementations are provided for the initialize(), * setProperty(), and processProperties() methods. These implementations * assume target objects that are unknown and thus instantiated via @@ -75,13 +75,13 @@ class ConfigObject { * base name. */ String baseName = null ; - + /** * The instance name of this object, as specified in the configuration * file. */ String instanceName = null ; - + /** * The corresponding target object which this ConfigObject is configuring. */ @@ -107,7 +107,7 @@ class ConfigObject { * The ConfigContainer in which this ConfigObject is contained. */ ConfigContainer configContainer = null ; - + /** * The command that created this class. */ @@ -127,7 +127,7 @@ class ConfigObject { * List of alias Strings for this object if it's not an alias itself. */ List aliases = new ArrayList() ; - + protected ClassLoader classLoader; /** @@ -137,7 +137,7 @@ class ConfigObject { void setClassLoader( ClassLoader classLoader ) { this.classLoader = classLoader; } - + /** * The base initialize() implementation. This takes a ConfigCommand with * three arguments: the command name, the instance name, and the name of @@ -145,7 +145,7 @@ class ConfigObject { * configuration file should have the form:

      * * (New{configType} {instanceName} {className})

      - * + * * For example, (NewDevice tracker com.sun.j3d.input.LogitechTracker) will * first cause ConfigDevice to be instantiated, which will then be * initialized with this method. After all the properties are collected, @@ -159,7 +159,7 @@ class ConfigObject { * ConfigPhysicalBody, and ConfigPhysicalEnvironment) target a concrete * core Java 3D class and will instantiate them directly, so they override * this method. - * + * * @param c the command that created this ConfigObject */ protected void initialize(ConfigCommand c) { @@ -179,7 +179,7 @@ class ConfigObject { targetClassName = (String)c.argv[2] ; } - + /** * The base setProperty() implementation. This implementation assumes the * property needs to be set by introspection on the property name as a @@ -187,17 +187,17 @@ class ConfigObject { * configuration file is of the form:

      * * ({type}Property {instance name} {method name} {arg0} ... {argn})

      - * + * * For example, (DeviceProperty tracker SerialPort "/dev/ttya") will * invoke the method named "SerialPort" in the object referenced by * "tracker" with an array of 1 Object containing the String - * "/dev/ttya".

      - * + * "/dev/ttya".

      + * * The property is stored as the original ConfigCommand and is evaluated * after the configuration file has been parsed. It is overridden by * subclasses that instantiate concrete core Java 3D classes with known * method names. - * + * * @param c the command that invoked this method */ protected void setProperty(ConfigCommand c) { @@ -232,7 +232,7 @@ class ConfigObject { } /** - * Return the class for the specified class name string. + * Return the class for the specified class name string. * * @param className the name of the class * @return the object representing the class @@ -257,7 +257,7 @@ class ConfigObject { /** * Return an instance of the class specified by the given class object. - * + * * @param objectClass the object representing the class * @return a new instance of the class */ @@ -290,7 +290,7 @@ class ConfigObject { } /** - * Evaluate properties for the the given class instance. + * Evaluate properties for the the given class instance. * * @param objectClass the class object representing the given class * @param objectInstance the class instance whose methods will be invoked @@ -303,7 +303,7 @@ class ConfigObject { // Holds the single parameter passed to the class instance methods. Object[] parameters = new Object[1] ; - // Specifies the class of the single method parameter. + // Specifies the class of the single method parameter. Class[] parameterTypes = new Class[1] ; // All property methods use Object[] as their single parameter, which @@ -330,7 +330,7 @@ class ConfigObject { parameters[0] = argv ; try { - Method objectMethod = + Method objectMethod = objectClass.getMethod(methodName, parameterTypes) ; objectMethod.invoke(objectInstance, parameters) ; @@ -375,7 +375,7 @@ class ConfigObject { /** * Check if the argument is a name string. - * + * * @param o the object to be checked * @return true if the object is an instance of String */ diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalBody.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalBody.java index c0546d9..0d2cda3 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalBody.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalBody.java @@ -171,7 +171,7 @@ class ConfigPhysicalBody extends ConfigObject { j3dPhysicalBody.setNominalEyeHeightFromGround( nominalEyeHeightFromGround); j3dPhysicalBody.setNominalEyeOffsetFromNominalScreen( - nominalEyeOffsetFromNominalScreen); + nominalEyeOffsetFromNominalScreen); return j3dPhysicalBody ; } diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalEnvironment.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalEnvironment.java index 338a404..d8dc024 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalEnvironment.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigPhysicalEnvironment.java @@ -75,7 +75,7 @@ class ConfigPhysicalEnvironment extends ConfigObject { * Handles the commands * (PhysicalEnvironmentAttribute {instance} {attrName} {attrValue}) and * (PhysicalEnvironmentProperty {instance} {attrName} {attrValue}). - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand command) { @@ -90,7 +90,7 @@ class ConfigPhysicalEnvironment extends ConfigObject { } if (!isName(argv[1])) { - syntaxError("The first argument to " + command.commandName + + syntaxError("The first argument to " + command.commandName + " must be a name") ; } @@ -135,7 +135,7 @@ class ConfigPhysicalEnvironment extends ConfigObject { syntaxError("HeadTracker must be a Sensor name") ; sval = (String)val ; - headTracker = + headTracker = (ConfigSensor)configContainer.findConfigObject("Sensor", sval); } else { @@ -153,7 +153,7 @@ class ConfigPhysicalEnvironment extends ConfigObject { j3dPhysicalEnvironment.setCoexistenceCenterInPworldPolicy (coexistenceCenterInPworldPolicy) ; - + if (coexistenceToTrackerBase != null) j3dPhysicalEnvironment.setCoexistenceToTrackerBase (new Transform3D(coexistenceToTrackerBase)) ; diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigScreen.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigScreen.java index 371d7e4..f2d69b0 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigScreen.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigScreen.java @@ -167,7 +167,7 @@ class ConfigScreen extends ConfigObject { * (ScreenProperty {instanceName} {attrName} {attrValue}) * (DisplayAttribute {instanceName} {attrName} {attrValue}) * (DisplayProperty {instanceName} {attrName} {attrValue}) - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand command) { @@ -182,7 +182,7 @@ class ConfigScreen extends ConfigObject { } if (!isName(command.argv[2])) { - syntaxError("The second argument to " + command.commandName + + syntaxError("The second argument to " + command.commandName + " must be a property name") ; } @@ -288,7 +288,7 @@ class ConfigScreen extends ConfigObject { /** * Initializes this object. Handles commands of the form:

      * (NewScreen {instanceName} {FrameBufferNumber}). - * + * * @param command the command that invoked this method */ protected void initialize(ConfigCommand command) { diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigSensor.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigSensor.java index 1c5617b..86cc831 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigSensor.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigSensor.java @@ -70,7 +70,7 @@ class ConfigSensor extends ConfigObject { /** * Handles the command * (NewSensor {instanceName} {inputDeviceName} {indexInInputDevice}) - * + * * @param command the command that invoked this method */ protected void initialize(ConfigCommand command) { @@ -103,7 +103,7 @@ class ConfigSensor extends ConfigObject { * Handles the commands * (SensorAttribute {instanceName} {attributeName} {attributeValue}) and * (SensorProperty {instanceName} {attributeName} {attributeValue}). - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand command) { @@ -141,7 +141,7 @@ class ConfigSensor extends ConfigObject { if (! isName(argv[3])) { syntaxError("Predictor must be a name") ; } - + String predictorName = (String)argv[3] ; if (predictorName.equals("PREDICT_NONE")) { predictor = Sensor.PREDICT_NONE ; @@ -158,7 +158,7 @@ class ConfigSensor extends ConfigObject { if (! isName(argv[3])) { syntaxError("PredictionPolicy must be a name") ; } - + String predictionPolicyName = (String)argv[3] ; if (predictionPolicyName.equals("NO_PREDICTOR")) { predictionPolicy = Sensor.NO_PREDICTOR ; diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigSexpression.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigSexpression.java index 7b1d771..150741a 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigSexpression.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigSexpression.java @@ -120,7 +120,7 @@ class ConfigSexpression { // A close paren finishes the scan. if (tok == ')') break ; - + // Check for too many arguments. if (i >= 20) syntaxError(st, file, "Too many arguments") ; @@ -202,7 +202,7 @@ class ConfigSexpression { if (elements.get(0) instanceof Double) { if (elements.size() == 1) syntaxError(st, file, "Can't have single-element vector") ; - + // Point2D if (elements.size() == 2) { if (!(elements.get(1) instanceof Double)) @@ -358,7 +358,7 @@ class ConfigSexpression { /** * This method gets called from the s-expression parser to evaluate a * built-in command. - * + * * @param elements tokenized list of sexp elements * @return object representing result of evaluation */ @@ -395,10 +395,10 @@ class ConfigSexpression { /** * Processes the built-in command (Translate x y z). - * + * * @param elements ArrayList containing Doubles wrapping x, y, and z * translation components at indices 1, 2, and 3 respectively - * + * * @return matrix that translates by the given x, y, and z components */ private Matrix4d makeTranslate(ArrayList elements) { @@ -424,13 +424,13 @@ class ConfigSexpression { /** * Processes the (Rotate x y z) built-in command. - * + * * @param elements ArrayList containing Doubles wrapping x, y, and z Euler * angles at indices 1, 2, and 3 respectively - * + * * @return matrix that rotates by the given Euler angles around static X, * Y, and Z basis vectors: first about X, then Y, and then Z - * + * * @see Transform3D#setEuler() */ private Matrix4d makeRotate(ArrayList elements) { @@ -464,10 +464,10 @@ class ConfigSexpression { * (Concatenate m1 m2) built-in commands. Although these do exactly the * same thing, using the appropriate command is recommended in order to * explicitly describe the sequence of transforms and their intent. - * + * * @param elements ArrayList containing Matrix4d objects m1 and m2 at * indices 1 and 2 respectively - * + * * @return matrix that concatenates m1 and m2 in that order: if a point is * transformed by the resulting matrix, then in effect the points are * first transformed by m1 and then m2 @@ -499,11 +499,11 @@ class ConfigSexpression { /** * Processes the built-in command (BoundingSphere center radius). * This is used when configuring behaviors. - * + * * @param elements ArrayList containing Point3d at index 1 for the sphere * center and Double at index 2 wrapping the sphere radius, or the String * "infinite" at index 2. - * + * * @return BoundingSphere with the given center and radius */ private BoundingSphere makeBoundingSphere(ArrayList elements) { diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigView.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigView.java index c86c38a..4d45a7b 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigView.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigView.java @@ -66,7 +66,7 @@ class ConfigView extends ConfigObject { * ConfigView. This is set during parsing of the configuration file. */ boolean stereoEnable = false ; - + /** * Indicates whether or not antialiasing is enabled for this ConfigView. * This is set during parsing of the configuration file. @@ -107,7 +107,7 @@ class ConfigView extends ConfigObject { private ConfigPhysicalBody configBody = null ; private ConfigPhysicalEnvironment configEnv = null ; private ConfigViewPlatform configViewPlatform = null ; - + /** * Overrides initialize() to do nothing. */ @@ -117,7 +117,7 @@ class ConfigView extends ConfigObject { /** * Processes properties for this object. Handles commands of the form:

      * (ViewAttribute {instanceName} {attrName} {attrValue}) - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand command) { @@ -132,7 +132,7 @@ class ConfigView extends ConfigObject { // Check that arg[1] and arg[2] are strings if (argc != 4) { syntaxError("Incorrect number of arguments to " + - command.commandName) ; + command.commandName) ; } if (!isName(argv[1])) { @@ -415,7 +415,7 @@ class ConfigView extends ConfigObject { if (!coeCenteringEnableSet) coeCenteringEnable = false ; } - + j3dView.setWindowEyepointPolicy(windowEyepointPolicy) ; j3dView.setWindowMovementPolicy(windowMovementPolicy) ; j3dView.setWindowResizePolicy(windowResizePolicy) ; @@ -431,17 +431,17 @@ class ConfigView extends ConfigObject { if (stereoEnable) { Point3d leftEyeBody = new Point3d() ; Point3d rightEyeBody = new Point3d() ; - + physicalBody.getLeftEyePosition(leftEyeBody) ; physicalBody.getRightEyePosition(rightEyeBody) ; leftEyeCoe.add(leftEyeBody) ; rightEyeCoe.add(rightEyeBody) ; } - + j3dView.setLeftManualEyeInCoexistence(leftEyeCoe) ; j3dView.setRightManualEyeInCoexistence(rightEyeCoe) ; - + j3dView.setBackClipPolicy(backClipPolicy) ; j3dView.setFrontClipPolicy(frontClipPolicy) ; j3dView.setBackClipDistance(backClipDistance) ; diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatform.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatform.java index 9484dfa..faec569 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatform.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatform.java @@ -66,7 +66,7 @@ class ConfigViewPlatform extends ConfigObject { * The corresponding ViewingPlatform instance. */ ViewingPlatform viewingPlatform = null ; - + /** * Indicates the view attach policy specified in the configuration file. * If none is set, it remains -1 even though a default may be in effect. @@ -77,7 +77,7 @@ class ConfigViewPlatform extends ConfigObject { * The associated ConfigViewPlatformBehavior, if any. */ ConfigViewPlatformBehavior configBehavior = null ; - + /** * Overrides initialize() to do nothing. */ @@ -88,7 +88,7 @@ class ConfigViewPlatform extends ConfigObject { * Processes attributes for this object. Handles commands of the form:

      * (ViewPlatformAttribute {instanceName} {attrName} {attrValue})
      * (ViewPlatformProperty {instanceName} {attrName} {attrValue}) - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand command) { @@ -177,7 +177,7 @@ class ConfigViewPlatform extends ConfigObject { /** * Creates a ViewingPlatform from attributes gathered by this object. - * + * * @param transformCount the number of TransformGroups to attach to the * ViewingPlatform * @return the new ViewingPlatform diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatformBehavior.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatformBehavior.java index e81bc3f..226b507 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatformBehavior.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigViewPlatformBehavior.java @@ -68,7 +68,7 @@ class ConfigViewPlatformBehavior extends ConfigObject { /** * Processes properties for this object. Handles commands of the form:

      * (ViewPlatformBehaviorProperty {instanceName} {attrName} {arg} ...) - * + * * @param command the command that invoked this method */ protected void setProperty(ConfigCommand cmd) { @@ -113,7 +113,7 @@ class ConfigViewPlatformBehavior extends ConfigObject { /** * Instantiate a ViewPlatformBehavior of the given class name.

      - * + * * NOTE: All ConfigView and ConfigSensor objects must be processed before * calling this method. * diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfiguredUniverse.java b/src/classes/share/com/sun/j3d/utils/universe/ConfiguredUniverse.java index 15f86b3..f1ceedb 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfiguredUniverse.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfiguredUniverse.java @@ -83,7 +83,7 @@ import javax.media.j3d.*; * SimpleUniverse. If one or more Canvas3D objects are provided, it will use * them instead of creating new ones. All of the constructors provided by * SimpleUniverse are also available here.

      - * + * * The syntax and description of the configuration file may be found * here. Example config files can * be found here. @@ -143,7 +143,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * the given Canvas3D instance. * * @param canvas the canvas to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * * @see SimpleUniverse#SimpleUniverse(Canvas3D) @@ -161,7 +161,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * transforms, and a Viewer object with the given Canvas3D. * * @param canvas the canvas to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * @param transformCount the number of transforms in the * MultiTransformGroup object to be created @@ -219,10 +219,10 @@ public class ConfiguredUniverse extends SimpleUniverse { /** * Creates a Locale, a single ViewingPlatform, and a Viewer object from - * the given array of Canvas3D instances. + * the given array of Canvas3D instances. * * @param canvases the canvases to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * * @see Locale @@ -236,10 +236,10 @@ public class ConfiguredUniverse extends SimpleUniverse { /** * Creates a Locale, a single ViewingPlatform with the specified number of * transforms, and a Viewer object using the given array of Canvas3D - * instances. + * instances. * * @param canvases the canvases to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * @param transformCount the number of transforms in the * MultiTransformGroup object to be created @@ -256,10 +256,10 @@ public class ConfiguredUniverse extends SimpleUniverse { /** * Creates a Locale, a single ViewingPlatform with the specified number of * transforms, and a Viewer object using the given array of Canvas3D - * instances. + * instances. * * @param canvases the canvases to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * @param transformCount the number of transforms in the * MultiTransformGroup object to be created @@ -475,7 +475,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * @param userConfig container holding viewing configuration components; * must not be null * @param localeFactory the factory object used to create the Locale, or - * null + * null * @param origin the origin used to set the origin of the Locale object; * if this object is null, then 0.0 is used * @@ -497,7 +497,7 @@ public class ConfiguredUniverse extends SimpleUniverse { "no views defined in configuration file"); viewer = (Viewer[])c.toArray(new Viewer[1]); - + c = configContainer.getViewingPlatforms(); if (c == null || c.size() == 0) { createDefaultViewingPlatform @@ -522,7 +522,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * @param transformCount the number of transforms in the * MultiTransformGroup object to be created * @param canvases the canvases to associate with the Viewer object; - * passing in null will cause this parameter to be ignored and a canvas + * passing in null will cause this parameter to be ignored and a canvas * to be created by the utility * @param userConfig the URL to the user's configuration file; passing in * null causes the default values to be used. @@ -605,7 +605,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * attaches the platform to the Locale. * * @param transformCount number of TransformGroups to create in the - * ViewingPlatform + * ViewingPlatform */ private void createDefaultViewingPlatform(int transformCount) { ViewingPlatform vp = new ViewingPlatform(transformCount); @@ -617,7 +617,7 @@ public class ConfiguredUniverse extends SimpleUniverse { /** * Sets a view attach policy appropriate for a window eyepoint policy. - * + * * @param v Viewer to which the ViewingPlatform will be attached * @param vp ViewingPlatform to which the Viewer will be attached */ @@ -633,7 +633,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * Returns the Viewer object specified by the given index. * * @param index The index of which Viewer object to return. - * + * * @return The Viewer object specified by the given index. */ public Viewer getViewer(int index) { @@ -641,8 +641,8 @@ public class ConfiguredUniverse extends SimpleUniverse { } /** - * Returns all of the Viewer objects associated with this scene graph. - * + * Returns all of the Viewer objects associated with this scene graph. + * * @return The Viewer objects associated with this scene graph. */ public Viewer[] getViewers() { @@ -716,7 +716,7 @@ public class ConfiguredUniverse extends SimpleUniverse { * the Sensor array maintained by PhysicalEnvironment. The head tracker * Sensor is the only one read by the Java 3D core and must generate reads * with a full 6 degrees of freedom (3D position and 3D orientation).

      - * + * * Other Sensors need not generate reads with a full 6 degrees of freedom, * although their reads must be expressed using Transform3D. Some * joysticks may provide only 2D relative X and Y axis movement; dials, diff --git a/src/classes/share/com/sun/j3d/utils/universe/SimpleUniverse.java b/src/classes/share/com/sun/j3d/utils/universe/SimpleUniverse.java index e0feb0d..567ddfd 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/SimpleUniverse.java +++ b/src/classes/share/com/sun/j3d/utils/universe/SimpleUniverse.java @@ -56,14 +56,14 @@ import javax.media.j3d.*; * This class sets up a minimal user environment to quickly and easily * get a Java 3D program up and running. This utility class creates * all the necessary objects on the "view" side of the scene graph. - * Specifically, this class creates a locale, a single ViewingPlatform, + * Specifically, this class creates a locale, a single ViewingPlatform, * and a Viewer object (both with their default values). * Many basic Java 3D applications * will find that SimpleUniverse provides all necessary functionality * needed by their applications. More sophisticated applications * may find that they need more control in order to get extra functionality * and will not be able to use this class. - * + * * @see Viewer * @see ViewingPlatform */ @@ -208,7 +208,7 @@ public class SimpleUniverse extends VirtualUniverse { Canvas3D canvas, URL userConfig) { this( origin, numTransforms, canvas, userConfig, null ); } - + /** * Creates the "view" side of the scene graph. The passed in parameters * override the default values where appropriate. @@ -237,7 +237,7 @@ public class SimpleUniverse extends VirtualUniverse { ViewingPlatform vwp; createLocale( origin, localeFactory ); - + // Create the ViewingPlatform and Viewer objects, passing // down the appropriate parameters. vwp = new ViewingPlatform(numTransforms); @@ -265,7 +265,7 @@ public class SimpleUniverse extends VirtualUniverse { public SimpleUniverse(ViewingPlatform viewingPlatform, Viewer viewer) { this( viewingPlatform, viewer, null ); } - + /** * Creates the "view" side of the scene graph. The passed in parameters * override the default values where appropriate. @@ -280,7 +280,7 @@ public class SimpleUniverse extends VirtualUniverse { LocaleFactory localeFactory ) { createLocale( null, localeFactory ); viewingPlatform.setUniverse( this ); - + // Assign object references. this.viewer = new Viewer[1]; this.viewer[0] = viewer; @@ -292,17 +292,17 @@ public class SimpleUniverse extends VirtualUniverse { // graph is now "live". locale.addBranchGraph(viewingPlatform); } - - /** + + /** * Constructor for use by Configured Universe */ SimpleUniverse( HiResCoord origin, LocaleFactory localeFactory ) { createLocale( origin, localeFactory ); } - - /** + + /** * Create the Locale using the LocaleFactory and HiRes origin, - * if specified. + * if specified. */ private void createLocale( HiResCoord origin, LocaleFactory localeFactory ) { @@ -332,10 +332,10 @@ public class SimpleUniverse extends VirtualUniverse { } /** - * Returns the Viewer object associated with this scene graph. + * Returns the Viewer object associated with this scene graph. * SimpleUniverse creates a single Viewer object for use in the * scene graph. - * + * * @return The Viewer object associated with this scene graph. */ public Viewer getViewer() { @@ -431,7 +431,7 @@ public class SimpleUniverse extends VirtualUniverse { public void cleanup() { // Get view associated with this SimpleUniverse View view = viewer[0].getView(); - + // Issue 134: cleanup all off-screen canvases for (int i = view.numCanvas3Ds() - 1; i >= 0; i--) { Canvas3D c = view.getCanvas3D(i); diff --git a/src/classes/share/com/sun/j3d/utils/universe/ViewInfo.java b/src/classes/share/com/sun/j3d/utils/universe/ViewInfo.java index 2d41c13..dcaf61e 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ViewInfo.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ViewInfo.java @@ -87,7 +87,7 @@ import javax.vecmath.* ; * capability doesn't need to be set for these applications.

      * * Other Synchronization Issues

      - * + * * Scene graph updates are guaranteed to take effect in the same frame only * if run from the processStimulus() method of a Behavior. Updates from * multiple behaviors are only guaranteed to take effect in the same frame if @@ -98,7 +98,7 @@ import javax.vecmath.* ; * it's set. Updating scene graph elements from anything other than the * Behavior thread, such as an external input thread or a renderer callback * in Canvas3D, will not necessarily be synchronized with rendering.

      - * + * * Direct updates to geometry data have a different frame latency than * updates to scene graph transforms and structure. In the Java 3D 1.3 * architecture, updates to by-reference geometry arrays and texture data have @@ -115,9 +115,9 @@ import javax.vecmath.* ; * computes the changes that need to be made based on current view state. If * the update behavior is awakened by a behavior post from the computing * behavior then the update will be delayed by a single frame.

      - * + * * Implementation Notes

      - * + * * This utility is essentially a rewrite of a few private Java 3D core * classes, but designed for public use and source code availability. The * source code may be helpful in understanding some of the more complex @@ -127,25 +127,25 @@ import javax.vecmath.* ; * the view model as defined by the Java 3D Specification, so it can be * considered an alternative implementation. This class will produce the * same results as the Java 3D core implementation except for:

        - * + * *
      • The frame latency issue for virtual world transforms.
      • - * + * *

      • Active clip node status. If a clip node is active in the scene graph, * it should override the view's back clip plane. This class has no such * information, so this can't be implemented.
      • - * + * *

      • "Infinite" view transforms for background geometry. These are simply * the rotation components of the normal view transforms with adjusted * clip planes. Again, this function depends upon scene graph content * inaccessible to this class.
      • - * + * *

      • Small floating point precision differences resulting from the * alternative computations.
      • - * + * *

      • Bugs in this class and the Java 3D core.
      • - * + * *

      • Tracked head position.

      - * + * * The last item deserves some mention. Java 3D provides no way to directly * query the tracked head position being used by the renderer. The View's * getUserHeadToVworld method always incorporates a virtual world @@ -157,7 +157,7 @@ import javax.vecmath.* ; * and possible workarounds.

      * * Thread Safety

      - * + * * All transforms are lazily evaluated. The updateScreen, * updateCanvas, updateViewPlatform, * updateView, and updateHead methods just set flags @@ -223,7 +223,7 @@ public class ViewInfo { // the Java 3D view model. Since ViewInfo is per-View and we want to // cache screen and platform derived data, we maintain static references // to the screens and platforms here. - // + // // From a design standpoint our ViewInfo objects should probably be in the // scope of an object that encloses these maps so they can be gc'ed // properly. This is cumbersome with the current design constraints, so @@ -257,7 +257,7 @@ public class ViewInfo { private boolean autoUpdate = false ; private int autoUpdateFlags = 0 ; - // Cached View policies. + // Cached View policies. private int viewPolicy = View.SCREEN_VIEW ; private int resizePolicy = View.PHYSICAL_WORLD ; private int movementPolicy = View.PHYSICAL_WORLD ; @@ -310,7 +310,7 @@ public class ViewInfo { * The View must be attached to a ViewPlatform. If the ViewPlatform is * attached to a live scene graph, then ALLOW_POLICY_READ * capability must be set on the ViewPlatform node. - * + * * @param view the View to use * @see #updateView * @see #updateCanvas updateCanvas(Canvas3D) @@ -327,7 +327,7 @@ public class ViewInfo { * attached to a ViewPlatform. If the ViewPlatform is attached to a live * scene graph, then ALLOW_POLICY_READ capability must be set * on the ViewPlatform node. - * + * * @param view the View to use

      * @param autoUpdateFlags a logical OR of any of the * VIEW_AUTO_UPDATE, CANVAS_AUTO_UPDATE, @@ -362,7 +362,7 @@ public class ViewInfo { * Alternatively, the other constructors can be used by calling * ViewInfo.clear when done with ViewInfo, or by simply * retaining the static references until the JVM exits.

      - * + * * @param view the View to use

      * @param autoUpdateFlags a logical OR of any of the * VIEW_AUTO_UPDATE, CANVAS_AUTO_UPDATE, @@ -406,7 +406,7 @@ public class ViewInfo { /** * Gets the current transforms from image plate coordinates to view * platform coordinates and copies them into the given Transform3Ds.

      - * + * * With a monoscopic canvas the image plate transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left image plate transform, and @@ -459,7 +459,7 @@ public class ViewInfo { /** * Gets the current transforms from image plate coordinates to virtual * world coordinates and copies them into the given Transform3Ds.

      - * + * * With a monoscopic canvas the image plate transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left image plate transform, and @@ -555,7 +555,7 @@ public class ViewInfo { // a monoscopic view policy of CYCLOPEAN_EYE_VIEW (which averages the // left and right eye positions) when the eyepoints are expressed in // coexistence coordinates or are derived from the tracked head. - // + // if (ci.updateCoeToPlate) { if (verbose) System.err.println("updating CoeToPlate") ; if (ci.coeToPlate == null) { @@ -621,7 +621,7 @@ public class ViewInfo { * platform is positioned with respect to the virtual world through the * scene graph, so the view platform to coexistence transform defines the * space in which the virtual world and physical world coexist.

      - * + * * This method requires a Canvas3D. A different transform may be returned * for each canvas in the view if any of the following apply:

        * @@ -838,7 +838,7 @@ public class ViewInfo { /** * Gets the transforms from eye coordinates to image plate coordinates and * copies them into the Transform3Ds specified.

        - * + * * When head tracking is used the eye positions are taken from the head * position and set in relation to the image plates with each Screen3D's * trackerBaseToImagePlate transform. Otherwise the window @@ -847,7 +847,7 @@ public class ViewInfo { * determined solely by calibration constants in Screen3D and * PhysicalBody; see the source code for the private method * getEyesHMD for more information.

        - * + * * Eye coordinates are always aligned with image plate coordinates, so * these transforms are always just translations. With a monoscopic * canvas the eye transform is copied to the first argument and the second @@ -902,8 +902,8 @@ public class ViewInfo { // *apparent* width and height as viewed through the HMD optics. They // must be set directly through the Screen3D methods; the default pixel // metrics of 90 pixels/inch used by Java 3D aren't appropriate for HMD - // optics. - // + // optics. + // // Most HMDs have 100% overlap between the left and right displays; in // that case, headTrackerToLeftImagePlate and headTrackerToRightImagePlate // should be identical. The HMD manufacturer's specifications of the @@ -987,7 +987,7 @@ public class ViewInfo { ci.rightManualEyeInPlate.z) ; break ; case View.RELATIVE_TO_SCREEN: - setEyeScreenRelative(ci, + setEyeScreenRelative(ci, ci.leftManualEyeInPlate, ci.rightManualEyeInPlate) ; break ; @@ -1013,7 +1013,7 @@ public class ViewInfo { // Eye position Y is always the canvas center. leftEye.y = rightEye.y = ci.canvasY + (ci.canvasHeight / 2.0) ; - + // Eye positions Z are as given. leftEye.z = leftZ ; rightEye.z = rightZ ; @@ -1055,7 +1055,7 @@ public class ViewInfo { /** * Gets the current transforms from eye coordinates to view platform * coordinates and copies them into the given Transform3Ds.

        - * + * * With a monoscopic canvas the eye transform is copied to the first * argument and the second argument is not used. For a stereo canvas the * first argument receives the left eye transform, and if the second @@ -1070,12 +1070,12 @@ public class ViewInfo { * resize policy or the SCALE_SCREEN_SIZE screen scale * policy, which alter the scale depending upon the width of the canvas or * the width of the screen respectively.

        - * + * * With window eyepoint policies of RELATIVE_TO_FIELD_OF_VIEW, * RELATIVE_TO_SCREEN, or RELATIVE_TO_WINDOW, * then the transforms returned may differ across canvases due to * the following additional conditions:

          - * + * *
        • The window eyepoint policy is RELATIVE_TO_WINDOW or * RELATIVE_TO_SCREEN, in which case the manual eye * position in image plate can be set differently for each @@ -1084,7 +1084,7 @@ public class ViewInfo { *
        • The window eyepoint policy is RELATIVE_TO_FIELD_OF_VIEW * and the view attach policy is NOMINAL_SCREEN, which * decouples the view platform's canvas Z offset from the eyepoint's - * canvas Z offset.
        • + * canvas Z offset.

          * *

        • The eyepoint X and Y coordinates are centered in the canvas with a * window eyepoint policy of RELATIVE_TO_FIELD_OF_VIEW @@ -1100,7 +1100,7 @@ public class ViewInfo { * @param e2vpl the Transform3D to receive the left transform * @param e2vpr the Transform3D to receive the right transform, or null */ - public void getEyeToViewPlatform(Canvas3D c3d, + public void getEyeToViewPlatform(Canvas3D c3d, Transform3D e2vpl, Transform3D e2vpr) { CanvasInfo ci = updateCache(c3d, "getEyeToViewPlatform", false) ; @@ -1121,7 +1121,7 @@ public class ViewInfo { ci.eyeToViewPlatform.mul(ci.plateToViewPlatform, ci.eyeToPlate) ; if (ci.useStereo) { - if (ci.rightEyeToViewPlatform == null) + if (ci.rightEyeToViewPlatform == null) ci.rightEyeToViewPlatform = new Transform3D() ; ci.rightEyeToViewPlatform.mul @@ -1135,7 +1135,7 @@ public class ViewInfo { /** * Gets the current transforms from view platform coordinates to eye * coordinates and copies them into the given Transform3Ds.

          - * + * * With a monoscopic canvas the eye transform is copied to the first * argument and the second argument is not used. For a stereo canvas the * first argument receives the left eye transform, and if the second @@ -1144,14 +1144,14 @@ public class ViewInfo { * This method requires a Canvas3D. The transforms returned may differ * across canvases for all the same reasons discussed in the description * of getEyeToViewPlatform. - * + * * @param c3d the Canvas3D to use * @param vp2el the Transform3D to receive the left transform * @param vp2er the Transform3D to receive the right transform, or null * @see #getEyeToViewPlatform * getEyeToViewPlatform(Canvas3D, Transform3D, Transform3D) */ - public void getViewPlatformToEye(Canvas3D c3d, + public void getViewPlatformToEye(Canvas3D c3d, Transform3D vp2el, Transform3D vp2er) { CanvasInfo ci = updateCache(c3d, "getViewPlatformToEye", false) ; @@ -1183,7 +1183,7 @@ public class ViewInfo { /** * Gets the current transforms from eye coordinates to virtual world * coordinates and copies them into the given Transform3Ds.

          - * + * * With a monoscopic canvas the eye transform is copied to the first * argument and the second argument is not used. For a stereo canvas the * first argument receives the left eye transform, and if the second @@ -1195,7 +1195,7 @@ public class ViewInfo { * * This method requires a Canvas3D. The transforms returned may differ * across canvases for all the same reasons discussed in the description - * of getEyeToViewPlatform. + * of getEyeToViewPlatform. * * @param c3d the Canvas3D to use * @param e2vwl the Transform3D to receive the left transform @@ -1244,7 +1244,7 @@ public class ViewInfo { * plate eye location defines the apex of a viewing frustum; * otherwise, the orientation of the image plate determines the * direction of a parallel projection.

          - * + * * With a monoscopic canvas the projection transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left projection transform, @@ -1257,12 +1257,12 @@ public class ViewInfo { * ALLOW_LOCAL_TO_VWORLD_READ capability set; otherwise, a * scale factor of 1.0 will be used for the scale factor from virtual * world units to view platform units. - * + * * @param c3d the Canvas3D to use * @param e2ccl the Transform3D to receive left transform * @param e2ccr the Transform3D to receive right transform, or null */ - public void getProjection(Canvas3D c3d, + public void getProjection(Canvas3D c3d, Transform3D e2ccl, Transform3D e2ccr) { CanvasInfo ci = updateCache(c3d, "getProjection", true) ; @@ -1308,7 +1308,7 @@ public class ViewInfo { * and copies them into the given Transform3Ds. These transforms take * the clip space volume bounded by the range [-1.0 .. + 1.0] on each * of the X, Y, and Z and project it into eye coordinates.

          - * + * * With a monoscopic canvas the projection transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left projection transform, and @@ -1321,12 +1321,12 @@ public class ViewInfo { * ALLOW_LOCAL_TO_VWORLD_READ capability set; otherwise, a * scale factor of 1.0 will be used for the scale factor from virtual * world units to view platform units. - * + * * @param c3d the Canvas3D to use * @param cc2el the Transform3D to receive left transform * @param cc2er the Transform3D to receive right transform, or null */ - public void getInverseProjection(Canvas3D c3d, + public void getInverseProjection(Canvas3D c3d, Transform3D cc2el, Transform3D cc2er) { CanvasInfo ci = updateCache(c3d, "getInverseProjection", true) ; @@ -1361,7 +1361,7 @@ public class ViewInfo { * transforms take the clip space volume bounded by the range * [-1.0 .. +1.0] on each of the X, Y, and Z axes and project into * the view platform coordinate system.

          - * + * * With a monoscopic canvas the projection transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left projection transform, and @@ -1374,12 +1374,12 @@ public class ViewInfo { * ALLOW_LOCAL_TO_VWORLD_READ capability set; otherwise, a * scale factor of 1.0 will be used for the scale factor from virtual * world units to view platform units. - * + * * @param c3d the Canvas3D to use * @param cc2vpl the Transform3D to receive left transform * @param cc2vpr the Transform3D to receive right transform, or null */ - public void getInverseViewPlatformProjection(Canvas3D c3d, + public void getInverseViewPlatformProjection(Canvas3D c3d, Transform3D cc2vpl, Transform3D cc2vpr) { @@ -1420,7 +1420,7 @@ public class ViewInfo { * transforms take the clip space volume bounded by the range * [-1.0 .. +1.0] on each of the X, Y, and Z axes and project into * the virtual world.

          - * + * * With a monoscopic canvas the projection transform is copied to the * first argument and the second argument is not used. For a stereo * canvas the first argument receives the left projection transform, and @@ -1435,7 +1435,7 @@ public class ViewInfo { * @param cc2vwl the Transform3D to receive left transform * @param cc2vwr the Transform3D to receive right transform, or null */ - public void getInverseVworldProjection(Canvas3D c3d, + public void getInverseVworldProjection(Canvas3D c3d, Transform3D cc2vwl, Transform3D cc2vwr) { @@ -1472,7 +1472,7 @@ public class ViewInfo { // Compute a projection matrix from the given eye position in image plate, // the front and back clip Z positions in image plate, and the current // canvas position in image plate. - // + // private void computeProjection(CanvasInfo ci, Point3d eye, double front, double back, Transform3D p) { @@ -1511,7 +1511,7 @@ public class ViewInfo { // parametric form as P = tV. To find the projection onto the plane // containing the canvas, find t such that P.z = iz; ie, t = iz/V.z. // The projection P is thus [V.x*iz/V.z, V.y*iz/V.z, iz]. - // + // // This projection can expressed as the following matrix equation: // // -iz 0 0 0 V.x @@ -1529,7 +1529,7 @@ public class ViewInfo { // the translation results in (V.x - lx)(2/(hx - lx)) - 1, which after // some algebra can be confirmed to the same as the following // canonical scale/offset form: - // + // // V.x*2/(hx - lx) - (hx + lx)/(hx - lx) // // Similarly for Y: @@ -1540,29 +1540,29 @@ public class ViewInfo { // // 2*V.x*idx - (hx + lx)idx // 2*V.y*idy - (hy + ly)idy - // + // // These scales and offsets are represented by the following matrix: - // + // // 2*idx 0 0 -(hx + lx)*idx // 0 2*idy 0 -(hy + ly)*idy - // 0 0 1 0 - // 0 0 0 1 {matrix 2} + // 0 0 1 0 + // 0 0 0 1 {matrix 2} // // The result after concatenating the projection transform // ({matrix 2} X {matrix 1}): - // + // // -2*iz*idx 0 (hx + lx)*idx 0 // 0 -2*iz*idy (hy + ly)*idy 0 // 0 0 -iz {a} 0 {b} // 0 0 -1 0 {matrix 3} - // + // // The Z scaling is handled by m[10] ("a") and m[11] ("b"), which must // map the range [front..back] to [1..-1] in clipping space. If ze is // the Z coordinate in eye space, and zc is the Z coordinate in // clipping space after division by w, then from {matrix 3}: - // + // // zc = (a*ze + b)/-ze = -(a + b/ze) - // + // // We want this to map to +1 when ze is at the near clip plane, and // to -1 when ze is at the far clip plane: // @@ -1624,7 +1624,7 @@ public class ViewInfo { // // Get front clip plane Z coordinate in image plate space. - // + // private double getFrontClip(CanvasInfo ci, Point3d eye) { if (frontClipPolicy == View.PHYSICAL_EYE || frontClipPolicy == View.VIRTUAL_EYE) { @@ -1637,7 +1637,7 @@ public class ViewInfo { // // Get back clip plane Z coordinate in image plate space. - // + // private double getBackClip(CanvasInfo ci, Point3d eye) { // // Note: Clip node status is unavailable here. If a clip node is @@ -1696,7 +1696,7 @@ public class ViewInfo { * ALLOW_LOCAL_TO_VWORLD_READ capability set; otherwise, a * scale factor of 1.0 will be used for the scale factor from virtual * world units to view platform units. - * + * * @param c3d the Canvas3D to use * @return the physical front clip distance */ @@ -1730,7 +1730,7 @@ public class ViewInfo { * ALLOW_LOCAL_TO_VWORLD_READ capability set; otherwise, a * scale factor of 1.0 will be used for the scale factor from virtual * world units to view platform units. - * + * * @param c3d the Canvas3D to use * @return the physical back clip distance */ @@ -1746,7 +1746,7 @@ public class ViewInfo { ci.frontClipDistance = view.getFrontClipDistance() * getClipScale(ci, frontClipPolicy) ; - + ci.backClipDistance = view.getBackClipDistance() * getClipScale(ci, backClipPolicy) ; @@ -1776,7 +1776,7 @@ public class ViewInfo { /** * Gets the scale factor from physical meters to view platform units.

          - * + * * This method requires a Canvas3D. A different scale may be returned * for each canvas in the view if any of the following apply:

            * @@ -1816,7 +1816,7 @@ public class ViewInfo { /** * Gets the scale factor from physical meters to virtual units.

            - * + * * This method requires a Canvas3D. A different scale may be returned * across canvases for the same reasons as discussed in the description of * getPhysicalToViewPlatformScale.

            @@ -1858,7 +1858,7 @@ public class ViewInfo { * using the setPhysicalScreenWidth method of Screen3D, then * Java 3D will derive the screen width based on a screen resolution of 90 * pixels/inch. - * + * * @param c3d the Canvas3D to use * @return the width of the canvas scaled to physical meters */ @@ -1874,7 +1874,7 @@ public class ViewInfo { * using the setPhysicalScreenHeight method of Screen3D, then * Java 3D will derive the screen height based on a screen resolution of 90 * pixels/inch. - * + * * @param c3d the Canvas3D to use * @return the height of the canvas scaled to physical meters */ @@ -1890,7 +1890,7 @@ public class ViewInfo { * width and height are not explicitly set in Screen3D, then Java 3D will * derive those screen parameters based on a screen resolution of 90 * pixels/inch. - * + * * @param c3d the Canvas3D to use * @param location the output position, in meters, of the lower-left * corner of the canvas relative to the image plate lower-left corner; Z @@ -1939,7 +1939,7 @@ public class ViewInfo { * @see #getViewPlatformToCoexistence * getViewPlatformToCoexistence(Canvas3D, Transform3D) */ - public void getSensorToVworld(Canvas3D c3d, + public void getSensorToVworld(Canvas3D c3d, Sensor sensor, Transform3D s2vw) { CanvasInfo ci = updateCache(c3d, "getSensorToVworld", true) ; @@ -2083,7 +2083,7 @@ public class ViewInfo { * has not been enabled for the View, then this method should be called if * any of the attributes of the View associated with this object have * changed.

            - * + * * These do not include the attributes of the existing Canvas3D or * Screen3D components of the View, but do include the attributes of all * other components such as the PhysicalEnvironment and PhysicalBody, and @@ -2204,7 +2204,7 @@ public class ViewInfo { private void getViewInfo() { if (verbose) System.err.println(" getViewInfo") ; - // Check if an update of the Canvas3D collection is needed. + // Check if an update of the Canvas3D collection is needed. if (this.canvasCount != view.numCanvas3Ds()) { this.canvasCount = view.numCanvas3Ds() ; getCanvases() ; @@ -2261,7 +2261,7 @@ public class ViewInfo { if (this.headToTrackerBase == null) this.headToTrackerBase = new Transform3D() ; } - + body.getLeftEyePosition(this.leftEyeInHead) ; body.getRightEyePosition(this.rightEyeInHead) ; body.getHeadToHeadTracker(this.headToHeadTracker) ; @@ -2308,7 +2308,7 @@ public class ViewInfo { } // Propagate view updates to each canvas. - for (int i = 0 ; i < canvasCount ; i++) + for (int i = 0 ; i < canvasCount ; i++) this.canvasInfo[i].updateViewDependencies() ; this.updateView = false ; @@ -2319,13 +2319,13 @@ public class ViewInfo { } } - // + // // Each view can have multiple canvases, each with an associated screen. // Each canvas is associated with only one view. Each screen can have // multiple canvases that are used across multiple views. We rebuild the // canvas info instead of trying to figure out what canvases have been // added or removed from the view. - // + // private void getCanvases() { if (this.canvasInfo.length < canvasCount) { this.canvasInfo = new CanvasInfo[canvasCount] ; @@ -2383,10 +2383,10 @@ public class ViewInfo { this.updateView = true ; } - // + // // Update the view platform. Each view can be attached to only one, but // each view platform can have many views attached. - // + // private void getViewPlatform() { ViewPlatform vp = view.getViewPlatform() ; if (vp == null) @@ -2474,7 +2474,7 @@ public class ViewInfo { * These are the same conditions under which the Java 3D renderer uses * head tracking. This method can be overridden if there is any need to * decouple the head tracking status of ViewInfo from the renderer. - * + * * @return true if ViewInfo should use head tracking */ protected boolean useHeadTracking() { @@ -2483,7 +2483,7 @@ public class ViewInfo { // // Cache the current tracked head position and derived data. - // + // private void getHeadInfo() { if (verbose) System.err.println(" getHeadInfo") ; @@ -2501,11 +2501,11 @@ public class ViewInfo { this.canvasInfo[i].updateHeadDependencies() ; this.updateHead = false ; - // + // // The head position used by the Java 3D renderer isn't accessible // in the public API. A head tracker generates continuous data, so // getting the same sensor read as the renderer is unlikely. - // + // // Possible workaround: for fixed screens, get the Java 3D // renderer's version of plateToVworld and headToVworld by calling // Canvas3D.getImagePlateToVworld() and View.getUserHeadToVworld(). @@ -2532,7 +2532,7 @@ public class ViewInfo { // means that objects in the virtual world cannot be made to appear in // a fixed position relative to the tracked head position without a // frame lag between them. - // + // // The reason for this is that the tracked head position used by the // Java 3D renderer is updated asynchronously from scene graph // updates. This is done to reduce latency between the user's @@ -2541,7 +2541,7 @@ public class ViewInfo { // update to the scene graph may have a frame latency before it gets // rendered, a change to the user's tracked position is always // reflected in the current frame. - // + // // This problem can't be fixed without eliminating the frame latency // in the Java 3D internal state, although there are possible // workarounds at the expense of increased user position latency. @@ -2584,7 +2584,7 @@ public class ViewInfo { // The ViewInfo methods can be used to compute the view and projection // matrices, which can then be delayed to synchronize with the scene // graph. - // + // // Note that these workarounds could be used to make view-dependent // scene graph updates consistent, but they still can't do anything // about synchronizing the actual physical position of the user with @@ -2609,7 +2609,7 @@ public class ViewInfo { private boolean updateScreen = true ; private Map viewInfoMap = new HashMap() ; - private List viewInfoList = new LinkedList() ; + private List viewInfoList = new LinkedList() ; private Transform3D t3d = new Transform3D() ; private double screenWidth = 0.0 ; @@ -2667,7 +2667,7 @@ public class ViewInfo { getCanvasList(vi).add(ci) ; } - // + // // Get all relevant screen information, find out what changed, and // flag derived data. With normal use it's unlikely that any of the // Screen3D attributes will change after the first time this method is @@ -2824,9 +2824,9 @@ public class ViewInfo { vp.getLocalToVworld(this.viewPlatformToVworld) ; this.vworldToViewPlatform.invert(viewPlatformToVworld) ; - + // Get the scale factor from the virtual world to view platform - // transform. Note that this is always a congruent transform. + // transform. Note that this is always a congruent transform. vworldToViewPlatform.get(m) ; double newScale = Math.sqrt(m[0]*m[0] + m[1]*m[1] + m[2]*m[2]) ; @@ -2855,7 +2855,7 @@ public class ViewInfo { // // A per-canvas cache. - // + // private class CanvasInfo { private Canvas3D c3d = null ; private ScreenInfo si = null ; @@ -2880,7 +2880,7 @@ public class ViewInfo { // coeToPlate is the same for each Canvas3D in a Screen3D unless // coexistence centering is enabled and the window movement policy is // PHYSICAL_WORLD. - // + // private Transform3D coeToPlate = null ; private Transform3D coeToRightPlate = null ; private boolean updateCoeToPlate = true ; @@ -2894,7 +2894,7 @@ public class ViewInfo { // eyepoint policy is RELATIVE_TO_FIELD_OF_VIEW and the view attach // policy is not NOMINAL_SCREEN, which will set the view platform // origin in coexistence based on the width of the canvas. - // + // private Transform3D viewPlatformToCoe = null ; private Transform3D coeToViewPlatform = null ; private boolean updateViewPlatformToCoe = true ; @@ -2949,7 +2949,7 @@ public class ViewInfo { // // The projection transform depends upon eye position in image plate. - // + // private Transform3D projection = null ; private Transform3D rightProjection = null ; private boolean updateProjection = true ; @@ -3033,7 +3033,7 @@ public class ViewInfo { System.err.println(" scale " + windowScale) ; } } - + // For multiple physical screens, AWT returns the canvas location // relative to the origin of the aggregated virtual screen. We // need the location relative to the physical screen origin. @@ -3088,7 +3088,7 @@ public class ViewInfo { rightManualEyeInPlate) ; } } - + updateCanvasDependencies() ; this.updateStereo = false ; this.updateWindowScale = false ; @@ -3268,7 +3268,7 @@ public class ViewInfo { // tracker, window eyepoint policy, field of view, coexistence // centering, or coexistence to image plate may have changed. updateEyeInPlate = true ; - + // If the eye position in image plate has changed, then the // projection transform may need to be updated. The projection // policy and clip plane distances and policies may have changed. diff --git a/src/classes/share/com/sun/j3d/utils/universe/Viewer.java b/src/classes/share/com/sun/j3d/utils/universe/Viewer.java index 8aa1598..6e1d94e 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/Viewer.java +++ b/src/classes/share/com/sun/j3d/utils/universe/Viewer.java @@ -78,19 +78,19 @@ import java.lang.reflect.Constructor; * The default Viewer creates one Canvas3D. If the Viewer object creates * the Canvas3D's, it will also create a JPanel and JFrame for each Canvas3D. * - * Dynamic video resize is a new feature in Java 3D 1.3.1. + * Dynamic video resize is a new feature in Java 3D 1.3.1. * This feature provides a means for doing swap synchronous resizing * of the area that is to be magnified (or passed through) to the * output video resolution. This functionality allows an application * to draw into a smaller viewport in the framebuffer in order to reduce - * the time spent doing pixel fill. The reduced size viewport is then + * the time spent doing pixel fill. The reduced size viewport is then * magnified up to the video output resolution using the SUN_video_resize * extension. This extension is only implemented in XVR-4000 and later * hardware with back end video out resizing capability. * - * If video size compensation is enable, the line widths, point sizes and pixel - * operations will be scaled internally with the resize factor to approximately - * compensate for video resizing. The location of the pixel ( x, y ) in the + * If video size compensation is enable, the line widths, point sizes and pixel + * operations will be scaled internally with the resize factor to approximately + * compensate for video resizing. The location of the pixel ( x, y ) in the * resized framebuffer = ( floor( x * factor + 0.5 ), floor( y * factor + 0.5 ) ) * *

            @@ -112,7 +112,7 @@ public class Viewer { private Window[] j3dWindows = null; private ViewingPlatform viewingPlatform = null; - + static HashMap viewerMap = new HashMap(5); private float dvrFactor = 1.0f; private boolean doDvr = false; @@ -123,9 +123,9 @@ public class Viewer { * Get the Viewer associated with the view object. * * @param view The View object for inquiry. - * @return The Viewer object associated with this View object. + * @return The Viewer object associated with this View object. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 @@ -145,9 +145,9 @@ public class Viewer { * Removes the entry associated with the view object. * * @param view The View object to be removed. - * @return The Viewer object associated with this View object. + * @return The Viewer object associated with this View object. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 @@ -168,14 +168,14 @@ public class Viewer { /** * Removes all Viewer mappings from the Viewer map. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 */ // To support a back door for DVR support. public static void clearViewerMap() { - synchronized (viewerMap) { + synchronized (viewerMap) { viewerMap.clear(); } // System.out.println("clearViewerMap - viewerMap.size() " + viewerMap.size()); @@ -187,20 +187,20 @@ public class Viewer { * Returns a status flag indicating whether or not dynamic video size * is enabled. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 */ // To support a back door for DVR support. public boolean isDvrEnabled() { - return doDvr; + return doDvr; } /** * Turns on or off dynamic video size. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @param dvr enables or disables dynamic video size. @@ -218,7 +218,7 @@ public class Viewer { * Retrieves the dynamic video resize factor of this * viewer. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 @@ -232,7 +232,7 @@ public class Viewer { /** * Set the dynamic video resize factor for this viewer. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @param dvr set the dynamic video resize factor for this viewer. @@ -247,11 +247,11 @@ public class Viewer { } /** - * Turns on or off dynamic video resize compensation. + * Turns on or off dynamic video resize compensation. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. - * + * * @param dvrRCE enables or disables dynamic video resize compensation. * * @since Java 3D 1.3.1 @@ -263,10 +263,10 @@ public class Viewer { } /** - * Returns a status flag indicating whether or not dynamic video resize + * Returns a status flag indicating whether or not dynamic video resize * compensation is enabled. * - * Note: This method is targeted for SUN framebuffer XVR-4000 and later + * Note: This method is targeted for SUN framebuffer XVR-4000 and later * hardware that support video size extension. * * @since Java 3D 1.3.1 @@ -372,10 +372,10 @@ public class Viewer { // Create a View and attach the Canvas3D and the physical // body and environment to the view. view = new View(); - + // Fix to issue 424 view.setUserHeadToVworldEnable(true); - + // Add it to the Viewer's HashMap. synchronized (viewerMap) { Viewer.viewerMap.put(view, this); @@ -448,10 +448,10 @@ public class Viewer { // Create a View and attach the Canvas3D and the physical // body and environment to the view. view = new View(); - + // Fix to issue 424 view.setUserHeadToVworldEnable(true); - + // Add it to the Viewer's HashMap. synchronized (viewerMap) { Viewer.viewerMap.put(view, this); @@ -487,17 +487,17 @@ public class Viewer { physicalEnvironment = cv.physicalEnvironment; // Get available screen devices. - // + // // When running with JDK 1.3.1 or older under the X Window System with // Xinerama enabled, a single screen device is returned which is // actually a virtual screen spanning all the physical screens in the // X display. These can only be configured as a single planar screen // in the configuration file. - // + // // JDK 1.4 and newer returns a screen device for each physical screen, // allowing them to configured as distinct screens with arbitrary // orientations relative to each other. - // + // GraphicsDevice[] devices; GraphicsEnvironment graphicsEnv; @@ -669,7 +669,7 @@ public class Viewer { } // Create the JFrames and JPanels for application-supplied Canvas3D - // objects. + // objects. private void createFramesAndPanels( boolean setVisible ) { j3dJFrames = new JFrame[canvases.length]; j3dJPanels = new JPanel[canvases.length]; @@ -679,7 +679,7 @@ public class Viewer { j3dWindows[i] = j3dJFrames[i] = new JFrame(); j3dJFrames[i].getContentPane().setLayout(new BorderLayout()); j3dJFrames[i].setSize(256, 256); - + // Put the Canvas3D into a JPanel. j3dJPanels[i] = new JPanel(); j3dJPanels[i].setLayout(new BorderLayout()); @@ -742,7 +742,7 @@ public class Viewer { * Get the ViewingPlatform object used by this Viewer. * * @return The ViewingPlatform object used by this - * Viewer object. + * Viewer object. */ public ViewingPlatform getViewingPlatform() { return viewingPlatform; @@ -889,7 +889,7 @@ public class Viewer { * constructed without any Canvas3D objects then the Viewer object will * create a Canva3D object, a JPanel containing the Canvas3D object, and a * JFrame to place the JPanel in.

            - * + * * NOTE: When running under JDK 1.4 or newer, the JFrame always directly * contains the JPanel which contains the Canvas3D. When running under * JDK 1.3.1 and creating a borderless full screen through a configuration diff --git a/src/classes/share/com/sun/j3d/utils/universe/ViewingPlatform.java b/src/classes/share/com/sun/j3d/utils/universe/ViewingPlatform.java index 2499b3e..490af23 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ViewingPlatform.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ViewingPlatform.java @@ -106,13 +106,13 @@ public class ViewingPlatform extends BranchGroup { */ protected BranchGroup behaviors; - /** + /** * The universe to which this viewing platform is attached * * @since Java 3D 1.3 */ protected SimpleUniverse universe; - + /** * Creates a default ViewingPlatform object. This consists of a * MultiTransfromGroup node with one transform and a ViewPlatform @@ -212,7 +212,7 @@ public class ViewingPlatform extends BranchGroup { * with the ViewingPlatform. If the ViewingPlatform is to be the * inside of a car, for instance, than the PlatformGeometry could be * the dashboard of the car. - * + * * @param pg The geometry to be associated with this ViewingPlatform. * Passing in null has the effect of deleting any geometry associated * with this ViewingPlatform. @@ -274,7 +274,7 @@ public class ViewingPlatform extends BranchGroup { * Sets the nominal viewing distance in the ViewPlatform transform based * on the current field of view. If the ViewAttachPolicy is not the * default of View.NOMINAL_HEAD, then this method has no effect.

            - * + * * The ViewPlatform is moved back along Z so that objects at the origin * spanning the normalized X range of -1.0 to +1.0 can be fully viewed * across the width of the window. This is done by setting a translation @@ -282,7 +282,7 @@ public class ViewingPlatform extends BranchGroup { * * If there is no Viewer object associated with this ViewingPlatform * object the default field of view of PI/4.0 is used.

            - * + * * NOTE: Support for multiple Viewer objects is not available. If * multiple viewers are attached to this ViewingPlatform than a * RuntimeException will be thrown. @@ -401,7 +401,7 @@ public class ViewingPlatform extends BranchGroup { void removeViewer(Viewer viewer) { viewerList.remove(viewer); } - + /** * Adds a new ViewPlatformBehavior to the ViewingPlatform */ @@ -458,14 +458,14 @@ public class ViewingPlatform extends BranchGroup { else this.addChild(behaviors); } } - + /** * Returns the number of ViewPlatformBehaviors on the ViewingPlatform */ int getViewPlatformBehaviorCount() { return behaviors.numChildren(); } - + /** * Returns the ViewPlatformBehavior at the specified index */ @@ -485,7 +485,7 @@ public class ViewingPlatform extends BranchGroup { } return getViewPlatformBehavior(0); } - + /** * Returns the Viewers attached to this ViewingPlatform * @@ -496,7 +496,7 @@ public class ViewingPlatform extends BranchGroup { if (viewerList.size() == 0) return null; return (Viewer[])viewerList.keySet().toArray( new Viewer[0] ); } - + /** * Returns the Universe to which this ViewingPlatform is attached * @@ -506,7 +506,7 @@ public class ViewingPlatform extends BranchGroup { public SimpleUniverse getUniverse() { return universe; } - + /** * Sets the Universe to which this ViewingPlatform is attached * -- cgit v1.2.3