From 0ac05617e4442602e9468f4e1c7370085126bab5 Mon Sep 17 00:00:00 2001 From: phil Date: Sun, 6 Nov 2016 21:55:10 +1300 Subject: resource loading now includes the main/ prefix and incidentally SphereMotionGL2ES3_Texture renamed SphereMotionGL2ES2_Texture --- .../j3d/examples/appearance/AppearanceMixed.java | 8 +- .../examples/appearance/AppearanceMixedGL2ES2.java | 8 +- .../j3d/examples/appearance/AppearanceTest.java | 8 +- .../examples/background/BackgroundGeometry.java | 4 +- .../background/BackgroundGeometryGL2ES2.java | 4 +- .../configured_universe/ConfigObjLoad.java | 4 +- .../examples/distort_glyph/DistortGlyphTest.java | 2 +- .../distort_glyph/DistortGlyphTestGL2ES2.java | 2 +- .../org/jdesktop/j3d/examples/dot3/Dot3Demo.java | 4 +- .../j3d/examples/dot3/TextureControlPanel.java | 2 +- .../ImageComponentByReferenceTest.java | 8 +- .../geometry_by_ref/InterleavedNIOBuffer.java | 16 +- .../examples/geometry_by_ref/InterleavedTest.java | 16 +- .../gl2es2pipeline/EnvironmentMappingGLSL.java | 2 +- .../j3d/examples/gl2es2pipeline/ObjLoadGLSL.java | 4 +- .../examples/gl2es2pipeline/SamplerTestGLSL.java | 4 +- .../glsl_shader/EnvironmentMappingGLSL.java | 2 +- .../j3d/examples/glsl_shader/ObjLoadGLSL.java | 4 +- .../j3d/examples/glsl_shader/SamplerTestGLSL.java | 4 +- .../jdesktop/j3d/examples/morphing/Morphing.java | 4 +- .../org/jdesktop/j3d/examples/objload/ObjLoad.java | 4 +- .../examples/oriented_shape3d/OrientedPtTest.java | 16 +- .../examples/oriented_shape3d/OrientedTest.java | 16 +- .../jdesktop/j3d/examples/overlay2d/Overlay2D.java | 2 +- .../j3d/examples/picking/TickTockPicking.java | 4 +- .../j3d/examples/print_canvas3d/PrintCanvas3D.java | 4 +- .../j3d/examples/sound/BackgroundSoundTest.java | 4 +- .../j3d/examples/sound/PointSoundTest.java | 4 +- .../j3d/examples/sound/ReverberateSound.java | 4 +- .../jdesktop/j3d/examples/sound/SimpleSounds.java | 12 +- .../sphere_motion/SphereMotionGL2ES2_Texture.java | 376 +++++++++++++++++++++ .../sphere_motion/SphereMotionGL2ES3_Texture.java | 376 --------------------- .../j3d/examples/stencil/StencilOutline.java | 4 +- .../j3d/examples/texture/MultiTextureTest.java | 16 +- .../j3d/examples/texture/TextureImage.java | 2 +- .../j3d/examples/texture/TextureImageNPOT.java | 2 +- .../texture_by_ref/TextureByReference.java | 20 +- 37 files changed, 488 insertions(+), 488 deletions(-) create mode 100644 src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2_Texture.java delete mode 100644 src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES3_Texture.java (limited to 'src') diff --git a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java index 943d387..d0b0090 100644 --- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java +++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java @@ -482,18 +482,18 @@ public class AppearanceMixed extends javax.swing.JFrame { if (bgImage == null) { // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); + bgImage = Resources.getResource("main/resources/images/bg.jpg"); if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/stone.jpg"); + texImage = Resources.getResource("main/resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java index e3ec631..74d583e 100644 --- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java +++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java @@ -462,18 +462,18 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame { if (bgImage == null) { // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); + bgImage = Resources.getResource("main/resources/images/bg.jpg"); if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/stone.jpg"); + texImage = Resources.getResource("main/resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java index 0f0315a..6ec9944 100644 --- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java @@ -352,18 +352,18 @@ public class AppearanceTest extends javax.swing.JFrame { if (bgImage == null) { // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); + bgImage = Resources.getResource("main/resources/images/bg.jpg"); if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } if (texImage == null) { // the path to the image for an applet - texImage = Resources.getResource("resources/images/stone.jpg"); + texImage = Resources.getResource("main/resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometry.java b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometry.java index 18d2f5f..cbeda74 100644 --- a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometry.java +++ b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometry.java @@ -217,9 +217,9 @@ public class BackgroundGeometry extends javax.swing.JFrame { if (bgImage == null) { // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); + bgImage = Resources.getResource("main/resources/images/bg.jpg"); if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java index 709dd78..e760b66 100644 --- a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java +++ b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java @@ -198,9 +198,9 @@ public class BackgroundGeometryGL2ES2 extends javax.swing.JFrame { if (bgImage == null) { // the path to the image for an applet - bgImage = Resources.getResource("resources/images/bg.jpg"); + bgImage = Resources.getResource("main/resources/images/bg.jpg"); if (bgImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java b/src/main/java/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java index 9afa414..30e46c2 100644 --- a/src/main/java/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java +++ b/src/main/java/org/jdesktop/j3d/examples/configured_universe/ConfigObjLoad.java @@ -195,9 +195,9 @@ public class ConfigObjLoad { public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); + filename = Resources.getResource("main/resources/geometry/galleon.obj"); if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); + System.err.println("main/resources/geometry/galleon.obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java b/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java index cf88439..a31f365 100644 --- a/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.java @@ -135,7 +135,7 @@ public class DistortGlyphTest extends javax.swing.JFrame { Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); - Texture txtr = new TextureLoader(Resources.getResource("resources/images/gold.jpg"),this).getTexture(); + Texture txtr = new TextureLoader(Resources.getResource("main/resources/images/gold.jpg"),this).getTexture(); app.setTexture(txtr); TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP,TexCoordGeneration.TEXTURE_COORDINATE_2); app.setTexCoordGeneration(tcg); diff --git a/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTestGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTestGL2ES2.java index c92725a..e8df196 100644 --- a/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTestGL2ES2.java +++ b/src/main/java/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTestGL2ES2.java @@ -125,7 +125,7 @@ public class DistortGlyphTestGL2ES2 extends javax.swing.JFrame Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f); Color3f black = new Color3f(0.0f, 0.0f, 0.0f); app.setMaterial(new Material(objColor, black, objColor, black, 80.0f)); - Texture txtr = new TextureLoader(Resources.getResource("resources/images/gold.jpg"), this).getTexture(); + Texture txtr = new TextureLoader(Resources.getResource("main/resources/images/gold.jpg"), this).getTexture(); app.setTexture(txtr); // done in shader see makeShaderAppearance() below //TexCoordGeneration tcg = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, TexCoordGeneration.TEXTURE_COORDINATE_2); diff --git a/src/main/java/org/jdesktop/j3d/examples/dot3/Dot3Demo.java b/src/main/java/org/jdesktop/j3d/examples/dot3/Dot3Demo.java index 8e5ec84..abd2ff4 100644 --- a/src/main/java/org/jdesktop/j3d/examples/dot3/Dot3Demo.java +++ b/src/main/java/org/jdesktop/j3d/examples/dot3/Dot3Demo.java @@ -132,8 +132,8 @@ public class Dot3Demo extends JFrame { ImageComponent2D imageLightMap; // default texture names used - String textureColorName= "resources/images/wood.jpg"; - String textureDOT3NormalMapName = "resources/images/Java3Ddot3.jpg"; + String textureColorName= "main/resources/images/wood.jpg"; + String textureDOT3NormalMapName = "main/resources/images/Java3Ddot3.jpg"; /** * Constructor. diff --git a/src/main/java/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java b/src/main/java/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java index 0aef5f0..d705c37 100644 --- a/src/main/java/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java +++ b/src/main/java/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java @@ -75,7 +75,7 @@ public class TextureControlPanel extends JDialog implements ChangeListener, /** renderer for lightMap, with support for mouse interaction **/ private MyCanvas canvas = null; /** file name for light mask */ - private String maskFileName = "resources/images/mask.png"; + private String maskFileName = "main/resources/images/mask.png"; /** a slider to change Z light direction, i.e, blue channel */ private JSlider sliderZ = new JSlider(JSlider.HORIZONTAL, 1, 255, 142); /** target demo instance to be controled **/ diff --git a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java index 6829952..375ff68 100644 --- a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/ImageComponentByReferenceTest.java @@ -266,9 +266,9 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList public void init() {System.setProperty("sun.awt.noerasebackground", "true"); - texImage = Resources.getResource("resources/images/one.jpg"); + texImage = Resources.getResource("main/resources/images/one.jpg"); if (texImage == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } @@ -296,9 +296,9 @@ public class ImageComponentByReferenceTest extends JApplet implements ActionList public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL url = null; // the path to the image file for an application - url = Resources.getResource("resources/images/one.jpg"); + url = Resources.getResource("main/resources/images/one.jpg"); if (url == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java index 2d642f2..02548dd 100644 --- a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java +++ b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedNIOBuffer.java @@ -371,15 +371,15 @@ public class InterleavedNIOBuffer extends JApplet implements ActionListener { public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // create textures - texImage1 = Resources.getResource("resources/images/bg.jpg"); + texImage1 = Resources.getResource("main/resources/images/bg.jpg"); if (texImage1 == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } - texImage2 = Resources.getResource("resources/images/one.jpg"); + texImage2 = Resources.getResource("main/resources/images/one.jpg"); if (texImage2 == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } @@ -453,15 +453,15 @@ public class InterleavedNIOBuffer extends JApplet implements ActionListener { java.net.URL texURL1 = null; java.net.URL texURL2 = null; // the path to the image for an application - texURL1 = Resources.getResource("resources/images/bg.jpg"); + texURL1 = Resources.getResource("main/resources/images/bg.jpg"); if (texURL1 == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } - texURL2 = Resources.getResource("resources/images/one.jpg"); + texURL2 = Resources.getResource("main/resources/images/one.jpg"); if (texURL2 == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java index 0fd0217..c88fd33 100644 --- a/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/geometry_by_ref/InterleavedTest.java @@ -347,15 +347,15 @@ public class InterleavedTest extends JApplet implements ActionListener { public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // create textures - texImage1 = Resources.getResource("resources/images/bg.jpg"); + texImage1 = Resources.getResource("main/resources/images/bg.jpg"); if (texImage1 == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } - texImage2 = Resources.getResource("resources/images/one.jpg"); + texImage2 = Resources.getResource("main/resources/images/one.jpg"); if (texImage2 == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } @@ -429,15 +429,15 @@ public class InterleavedTest extends JApplet implements ActionListener { java.net.URL texURL1 = null; java.net.URL texURL2 = null; // the path to the image for an application - texURL1 = Resources.getResource("resources/images/bg.jpg"); + texURL1 = Resources.getResource("main/resources/images/bg.jpg"); if (texURL1 == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } - texURL2 = Resources.getResource("resources/images/one.jpg"); + texURL2 = Resources.getResource("main/resources/images/one.jpg"); if (texURL2 == null) { - System.err.println("resources/images/one.jpg not found"); + System.err.println("main/resources/images/one.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java index 6080c2e..053bc53 100644 --- a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/EnvironmentMappingGLSL.java @@ -81,7 +81,7 @@ public class EnvironmentMappingGLSL extends javax.swing.JFrame objRoot.addChild(objTrans); // Create texture object - textureURL = Resources.getResource("resources/images/duke-gears.jpg"); + textureURL = Resources.getResource("main/resources/images/duke-gears.jpg"); Texture tex = new TextureLoader(textureURL, this).getTexture(); // Create the shader program String vertexProgram = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java index 69f6734..8e6ad1e 100644 --- a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/ObjLoadGLSL.java @@ -358,10 +358,10 @@ public class ObjLoadGLSL extends javax.swing.JFrame if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); + filename = Resources.getResource("main/resources/geometry/galleon.obj"); if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); + System.err.println("main/resources/geometry/galleon.obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java index 741441c..34d99c5 100644 --- a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SamplerTestGLSL.java @@ -59,8 +59,8 @@ import org.jogamp.vecmath.Point3d; public class SamplerTestGLSL extends javax.swing.JFrame { - private static String cloudTexName = "resources/images/bg.jpg"; - private static String earthTexName = "resources/images/earth.jpg"; + private static String cloudTexName = "main/resources/images/bg.jpg"; + private static String earthTexName = "main/resources/images/earth.jpg"; private URL cloudURL = null; private URL earthURL = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java index ff5e9cd..037dda6 100644 --- a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java @@ -100,7 +100,7 @@ public class EnvironmentMappingGLSL extends javax.swing.JFrame { objRoot.addChild(objTrans); // Create texture object - textureURL = Resources.getResource("resources/images/duke-gears.jpg"); + textureURL = Resources.getResource("main/resources/images/duke-gears.jpg"); Texture tex = new TextureLoader(textureURL, this).getTexture(); // Create the shader program String vertexProgram = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java index 2feb50a..f9b784f 100644 --- a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.java @@ -345,9 +345,9 @@ public class ObjLoadGLSL extends javax.swing.JFrame { } if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); + filename = Resources.getResource("main/resources/geometry/galleon.obj"); if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); + System.err.println("main/resources/geometry/galleon.obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java index d2c3265..063060a 100644 --- a/src/main/java/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java +++ b/src/main/java/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java @@ -81,8 +81,8 @@ import org.jogamp.vecmath.Vector4f; public class SamplerTestGLSL extends javax.swing.JFrame { - private static String cloudTexName = "resources/images/bg.jpg"; - private static String earthTexName = "resources/images/earth.jpg"; + private static String cloudTexName = "main/resources/images/bg.jpg"; + private static String earthTexName = "main/resources/images/earth.jpg"; private static String fragmentProgName = "glsl_shader/multitex.frag"; private URL cloudURL = null; private URL earthURL = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/morphing/Morphing.java b/src/main/java/org/jdesktop/j3d/examples/morphing/Morphing.java index 4604f66..705ebc6 100644 --- a/src/main/java/org/jdesktop/j3d/examples/morphing/Morphing.java +++ b/src/main/java/org/jdesktop/j3d/examples/morphing/Morphing.java @@ -245,9 +245,9 @@ public class Morphing extends javax.swing.JFrame { objFiles = new java.net.URL[3]; for(int i=0; i<3; i++) { - objFiles[i] = Resources.getResource("resources/geometry/hand" + (i+1) + ".obj"); + objFiles[i] = Resources.getResource("main/resources/geometry/hand" + (i+1) + ".obj"); if (objFiles[i] == null) { - System.err.println("resources/geometry/hand" + (i+1) + ".obj not found"); + System.err.println("main/resources/geometry/hand" + (i+1) + ".obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/objload/ObjLoad.java b/src/main/java/org/jdesktop/j3d/examples/objload/ObjLoad.java index 9936e97..3c63619 100644 --- a/src/main/java/org/jdesktop/j3d/examples/objload/ObjLoad.java +++ b/src/main/java/org/jdesktop/j3d/examples/objload/ObjLoad.java @@ -266,9 +266,9 @@ public class ObjLoad extends javax.swing.JFrame { } if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); + filename = Resources.getResource("main/resources/geometry/galleon.obj"); if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); + System.err.println("main/resources/geometry/galleon.obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java b/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java index 2810378..e4c112b 100644 --- a/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedPtTest.java @@ -244,15 +244,15 @@ public class OrientedPtTest extends Applet { public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // the paths to the image files for an applet - earthImage = Resources.getResource("resources/images/earth.jpg"); + earthImage = Resources.getResource("main/resources/images/earth.jpg"); if (earthImage == null) { - System.err.println("resources/images/earth.jpg not found"); + System.err.println("main/resources/images/earth.jpg not found"); System.exit(1); } - stoneImage = Resources.getResource("resources/images/stone.jpg"); + stoneImage = Resources.getResource("main/resources/images/stone.jpg"); if (stoneImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } @@ -292,15 +292,15 @@ public class OrientedPtTest extends Applet { public static void main(String[] args) {System.setProperty("sun.awt.noerasebackground", "true"); java.net.URL earthURL = null; java.net.URL stoneURL = null; - earthURL = Resources.getResource("resources/images/earth.jpg"); + earthURL = Resources.getResource("main/resources/images/earth.jpg"); if (earthURL == null) { - System.err.println("resources/images/earth.jpg not found"); + System.err.println("main/resources/images/earth.jpg not found"); System.exit(1); } - stoneURL = Resources.getResource("resources/images/stone.jpg"); + stoneURL = Resources.getResource("main/resources/images/stone.jpg"); if (stoneURL == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java b/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java index 0f062e1..57ecfcc 100644 --- a/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/oriented_shape3d/OrientedTest.java @@ -237,15 +237,15 @@ public class OrientedTest extends Applet { public void init() {System.setProperty("sun.awt.noerasebackground", "true"); // the paths to the image files for an applet - earthImage = Resources.getResource("resources/images/earth.jpg"); + earthImage = Resources.getResource("main/resources/images/earth.jpg"); if (earthImage == null) { - System.err.println("resources/images/earth.jpg not found"); + System.err.println("main/resources/images/earth.jpg not found"); System.exit(1); } - stoneImage = Resources.getResource("resources/images/stone.jpg"); + stoneImage = Resources.getResource("main/resources/images/stone.jpg"); if (stoneImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } @@ -312,15 +312,15 @@ public class OrientedTest extends Applet { java.net.URL earthURL = null; java.net.URL stoneURL = null; - earthURL = Resources.getResource("resources/images/earth.jpg"); + earthURL = Resources.getResource("main/resources/images/earth.jpg"); if (earthURL == null) { - System.err.println("resources/images/earth.jpg not found"); + System.err.println("main/resources/images/earth.jpg not found"); System.exit(1); } - stoneURL = Resources.getResource("resources/images/stone.jpg"); + stoneURL = Resources.getResource("main/resources/images/stone.jpg"); if (stoneURL == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/overlay2d/Overlay2D.java b/src/main/java/org/jdesktop/j3d/examples/overlay2d/Overlay2D.java index adf4d8f..b8665dd 100644 --- a/src/main/java/org/jdesktop/j3d/examples/overlay2d/Overlay2D.java +++ b/src/main/java/org/jdesktop/j3d/examples/overlay2d/Overlay2D.java @@ -87,7 +87,7 @@ public class Overlay2D extends javax.swing.JFrame ap.setPolygonAttributes(pa); // Add a transformed texture to the cube, for interest sake - URL earthURL = Resources.getResource("resources/images/earth.jpg"); + URL earthURL = Resources.getResource("main/resources/images/earth.jpg"); Texture earthTex = new TextureLoader(earthURL, this).getTexture(); ap.setTexture(earthTex); diff --git a/src/main/java/org/jdesktop/j3d/examples/picking/TickTockPicking.java b/src/main/java/org/jdesktop/j3d/examples/picking/TickTockPicking.java index b9d76f9..2cca1fd 100644 --- a/src/main/java/org/jdesktop/j3d/examples/picking/TickTockPicking.java +++ b/src/main/java/org/jdesktop/j3d/examples/picking/TickTockPicking.java @@ -432,9 +432,9 @@ public class TickTockPicking extends javax.swing.JFrame { public TickTockPicking() { // the path to the image for an applet - texImage = Resources.getResource("resources/images/stone.jpg"); + texImage = Resources.getResource("main/resources/images/stone.jpg"); if (texImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } // Initialize the GUI components diff --git a/src/main/java/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java b/src/main/java/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java index 23b881f..cdd5558 100644 --- a/src/main/java/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java +++ b/src/main/java/org/jdesktop/j3d/examples/print_canvas3d/PrintCanvas3D.java @@ -248,9 +248,9 @@ public class PrintCanvas3D extends javax.swing.JFrame { public PrintCanvas3D(String args[]) { if (args.length == 0) { - filename = Resources.getResource("resources/geometry/beethoven.obj"); + filename = Resources.getResource("main/resources/geometry/beethoven.obj"); if (filename == null) { - System.err.println("resources/geometry/beethoven.obj not found"); + System.err.println("main/resources/geometry/beethoven.obj not found"); System.exit(1); } } else { diff --git a/src/main/java/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java b/src/main/java/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java index b2011d0..230a249 100644 --- a/src/main/java/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/sound/BackgroundSoundTest.java @@ -235,9 +235,9 @@ public class BackgroundSoundTest extends javax.swing.JFrame { // Initialize the GUI components initComponents(); - url = Resources.getResource("resources/audio/magic_bells.wav"); + url = Resources.getResource("main/resources/audio/magic_bells.wav"); if (url == null) { - System.err.println("resources/audio/magic_bells.wav not found"); + System.err.println("main/resources/audio/magic_bells.wav not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/sound/PointSoundTest.java b/src/main/java/org/jdesktop/j3d/examples/sound/PointSoundTest.java index a39bc87..c5af22b 100644 --- a/src/main/java/org/jdesktop/j3d/examples/sound/PointSoundTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/sound/PointSoundTest.java @@ -263,9 +263,9 @@ public class PointSoundTest extends javax.swing.JFrame { // Initialize the GUI components initComponents(); - url = Resources.getResource("resources/audio/magic_bells.wav"); + url = Resources.getResource("main/resources/audio/magic_bells.wav"); if (url == null) { - System.err.println("resources/audio/magic_bells.wav not found"); + System.err.println("main/resources/audio/magic_bells.wav not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/sound/ReverberateSound.java b/src/main/java/org/jdesktop/j3d/examples/sound/ReverberateSound.java index 9cf7ad0..ef3f9d1 100644 --- a/src/main/java/org/jdesktop/j3d/examples/sound/ReverberateSound.java +++ b/src/main/java/org/jdesktop/j3d/examples/sound/ReverberateSound.java @@ -155,9 +155,9 @@ public class ReverberateSound extends Applet { } public void init() {System.setProperty("sun.awt.noerasebackground", "true"); - url = Resources.getResource("resources/audio/hello_universe.au"); + url = Resources.getResource("main/resources/audio/hello_universe.au"); if (url == null) { - System.err.println("resources/audio/hello_universe.au not found"); + System.err.println("main/resources/audio/hello_universe.au not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/sound/SimpleSounds.java b/src/main/java/org/jdesktop/j3d/examples/sound/SimpleSounds.java index c5df424..7821cdc 100644 --- a/src/main/java/org/jdesktop/j3d/examples/sound/SimpleSounds.java +++ b/src/main/java/org/jdesktop/j3d/examples/sound/SimpleSounds.java @@ -210,21 +210,21 @@ public class SimpleSounds extends Applet { Canvas3D c = new Canvas3D(config); add("Center", c); - url[0] = Resources.getResource("resources/audio/techno_machine.au"); + url[0] = Resources.getResource("main/resources/audio/techno_machine.au"); if (url == null) { - System.err.println("resources/audio/techno_machine.au not found"); + System.err.println("main/resources/audio/techno_machine.au not found"); System.exit(1); } - url[1] = Resources.getResource("resources/audio/hello_universe.au"); + url[1] = Resources.getResource("main/resources/audio/hello_universe.au"); if (url == null) { - System.err.println("resources/audio/hello_universe.au not found"); + System.err.println("main/resources/audio/hello_universe.au not found"); System.exit(1); } - url[2] = Resources.getResource("resources/audio/roar.au"); + url[2] = Resources.getResource("main/resources/audio/roar.au"); if (url == null) { - System.err.println("resources/audio/roar.au not found"); + System.err.println("main/resources/audio/roar.au not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2_Texture.java b/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2_Texture.java new file mode 100644 index 0000000..088e22a --- /dev/null +++ b/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2_Texture.java @@ -0,0 +1,376 @@ +/* + * Copyright (c) 2016 JogAmp Community. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Sun designates this + * particular file as subject to the "Classpath" exception as provided + * by Sun in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ +package org.jdesktop.j3d.examples.sphere_motion; + +import java.awt.GraphicsConfiguration; +import java.io.File; +import java.io.IOException; + +import org.jdesktop.j3d.examples.Resources; +import org.jdesktop.j3d.examples.gl2es2pipeline.SimpleShaderAppearance; +import org.jogamp.java3d.Alpha; +import org.jogamp.java3d.AmbientLight; +import org.jogamp.java3d.Appearance; +import org.jogamp.java3d.Background; +import org.jogamp.java3d.BoundingSphere; +import org.jogamp.java3d.BranchGroup; +import org.jogamp.java3d.Canvas3D; +import org.jogamp.java3d.ColoringAttributes; +import org.jogamp.java3d.DirectionalLight; +import org.jogamp.java3d.GLSLShaderProgram; +import org.jogamp.java3d.Light; +import org.jogamp.java3d.Material; +import org.jogamp.java3d.PointLight; +import org.jogamp.java3d.PositionInterpolator; +import org.jogamp.java3d.RotationInterpolator; +import org.jogamp.java3d.Shader; +import org.jogamp.java3d.ShaderAppearance; +import org.jogamp.java3d.ShaderAttributeSet; +import org.jogamp.java3d.ShaderAttributeValue; +import org.jogamp.java3d.ShaderProgram; +import org.jogamp.java3d.SourceCodeShader; +import org.jogamp.java3d.SpotLight; +import org.jogamp.java3d.Texture; +import org.jogamp.java3d.Transform3D; +import org.jogamp.java3d.TransformGroup; +import org.jogamp.java3d.utils.geometry.Sphere; +import org.jogamp.java3d.utils.image.TextureLoader; +import org.jogamp.java3d.utils.shader.StringIO; +import org.jogamp.java3d.utils.universe.SimpleUniverse; +import org.jogamp.vecmath.Color3f; +import org.jogamp.vecmath.Point3d; +import org.jogamp.vecmath.Point3f; +import org.jogamp.vecmath.Vector3d; +import org.jogamp.vecmath.Vector3f; + +public class SphereMotionGL2ES2_Texture extends javax.swing.JFrame +{ + + private SimpleUniverse univ = null; + private BranchGroup scene = null; + + // Constants for type of light to use + private static final int DIRECTIONAL_LIGHT = 0; + private static final int POINT_LIGHT = 1; + private static final int SPOT_LIGHT = 2; + + // Flag indicates type of lights: directional, point, or spot + // lights. This flag is set based on command line argument + private static int lightType = POINT_LIGHT; + + public BranchGroup createSceneGraph() + { + Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); + Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); + Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); + Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); + Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); + Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); + Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); + + Transform3D t; + + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create a Transformgroup to scale all objects so they + // appear in the scene. + TransformGroup objScale = new TransformGroup(); + Transform3D t3d = new Transform3D(); + t3d.setScale(0.4); + objScale.setTransform(t3d); + objRoot.addChild(objScale); + + // Create a bounds for the background and lights + BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + + // Set up the background + Background bg = new Background(bgColor); + bg.setApplicationBounds(bounds); + objScale.addChild(bg); + + // Create a Sphere object, generate one copy of the sphere, + // and add it into the scene graph. + ShaderAppearance a = new ShaderAppearance(); + Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); + m.setLightingEnable(true); + String vertexProgram = null; + String fragmentProgram = null; + try + { + vertexProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/main/java/org/jdesktop/j3d/examples/sphere_motion/phong_gl2es2_texture.vert")); + fragmentProgram = StringIO.readFully( + new File(System.getProperty("user.dir") + "/src/main/java/org/jdesktop/j3d/examples/sphere_motion/phong_gl2es2_texture.frag")); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + Shader[] shaders = new Shader[2]; + shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, Shader.SHADER_TYPE_VERTEX, vertexProgram); + shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, Shader.SHADER_TYPE_FRAGMENT, fragmentProgram); + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(new String[] { "BaseMap" }); + + a.setShaderProgram(shaderProgram); + + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + shaderAttributeSet.put(new ShaderAttributeValue("BaseMap", new Integer(0))); + a.setShaderAttributeSet(shaderAttributeSet); + + + a.setMaterial(m); + Texture txtr = new TextureLoader(Resources.getResource("main/resources/images/earth.jpg"), this).getTexture(); + a.setTexture(txtr); + Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, 200, a); + objScale.addChild(sph); + + // Create the transform group node for the each light and initialize + // it to the identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at runtime. Add them to the root + // of the subgraph. + TransformGroup l1RotTrans = new TransformGroup(); + l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objScale.addChild(l1RotTrans); + + TransformGroup l2RotTrans = new TransformGroup(); + l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objScale.addChild(l2RotTrans); + + // Create transformations for the positional lights + t = new Transform3D(); + Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0); + t.set(lPos1); + TransformGroup l1Trans = new TransformGroup(t); + l1RotTrans.addChild(l1Trans); + + t = new Transform3D(); + Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0); + t.set(lPos2); + TransformGroup l2Trans = new TransformGroup(t); + l2RotTrans.addChild(l2Trans); + + // Create Geometry for point lights + ColoringAttributes caL1 = new ColoringAttributes(); + ColoringAttributes caL2 = new ColoringAttributes(); + caL1.setColor(lColor1); + caL2.setColor(lColor2); + Appearance appL1 = new SimpleShaderAppearance(false, false); + Appearance appL2 = new SimpleShaderAppearance(false, false); + appL1.setColoringAttributes(caL1); + appL2.setColoringAttributes(caL2); + l1Trans.addChild(new Sphere(0.05f, appL1)); + l2Trans.addChild(new Sphere(0.05f, appL2)); + + // Create lights + AmbientLight aLgt = new AmbientLight(alColor); + + Light lgt1 = null; + Light lgt2 = null; + + Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f); + Point3f atten = new Point3f(1.0f, 0.0f, 0.0f); + Vector3f lDirect1 = new Vector3f(lPos1); + Vector3f lDirect2 = new Vector3f(lPos2); + lDirect1.negate(); + lDirect2.negate(); + + switch (lightType) + { + case DIRECTIONAL_LIGHT: + lgt1 = new DirectionalLight(lColor1, lDirect1); + lgt2 = new DirectionalLight(lColor2, lDirect2); + break; + case POINT_LIGHT: + lgt1 = new PointLight(lColor1, lPoint, atten); + lgt2 = new PointLight(lColor2, lPoint, atten); + break; + case SPOT_LIGHT: + lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1, 25.0f * (float) Math.PI / 180.0f, 10.0f); + lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2, 25.0f * (float) Math.PI / 180.0f, 10.0f); + break; + } + + // Set the influencing bounds + aLgt.setInfluencingBounds(bounds); + lgt1.setInfluencingBounds(bounds); + lgt2.setInfluencingBounds(bounds); + + // Add the lights into the scene graph + objScale.addChild(aLgt); + l1Trans.addChild(lgt1); + l2Trans.addChild(lgt2); + + // Create a new Behavior object that will perform the desired + // operation on the specified transform object and add it into the + // scene graph. + Transform3D yAxis = new Transform3D(); + Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); + RotationInterpolator rotator1 = new RotationInterpolator(rotor1Alpha, l1RotTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); + rotator1.setSchedulingBounds(bounds); + l1RotTrans.addChild(rotator1); + + // Create a new Behavior object that will perform the desired + // operation on the specified transform object and add it into the + // scene graph. + Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 1000, 0, 0, 0, 0, 0); + RotationInterpolator rotator2 = new RotationInterpolator(rotor2Alpha, l2RotTrans, yAxis, 0.0f, 0.0f); + bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); + rotator2.setSchedulingBounds(bounds); + l2RotTrans.addChild(rotator2); + + // Create a position interpolator and attach it to the view + // platform + TransformGroup vpTrans = univ.getViewingPlatform().getViewPlatformTransform(); + Transform3D axisOfTranslation = new Transform3D(); + Alpha transAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 5000, 0, 0, 5000, 0, 0); + axisOfTranslation.rotY(-Math.PI / 2.0); + PositionInterpolator translator = new PositionInterpolator(transAlpha, vpTrans, axisOfTranslation, 2.0f, 3.5f); + translator.setSchedulingBounds(bounds); + objScale.addChild(translator); + + // Let Java 3D perform optimizations on this scene graph. + objRoot.compile(); + + return objRoot; + } + + private Canvas3D createUniverse() + { + // Get the preferred graphics configuration for the default screen + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + // Create a Canvas3D using the preferred configuration + Canvas3D c = new Canvas3D(config); + + // Create simple universe with view branch + univ = new SimpleUniverse(c); + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + univ.getViewingPlatform().setNominalViewingTransform(); + + // Ensure at least 5 msec per frame (i.e., < 200Hz) + univ.getViewer().getView().setMinimumFrameCycleTime(5); + + return c; + } + + /** + * Creates new form SphereMotion + */ + public SphereMotionGL2ES2_Texture(final String[] args) + { + + // Parse the Input Arguments + String usage = "Usage: java SphereMotion [-point | -spot | -dir]"; + for (int i = 0; i < args.length; i++) + { + if (args[i].startsWith("-")) + { + if (args[i].equals("-point")) + { + System.out.println("Using point lights"); + lightType = POINT_LIGHT; + } + else if (args[i].equals("-spot")) + { + System.out.println("Using spot lights"); + lightType = SPOT_LIGHT; + } + else if (args[i].equals("-dir")) + { + System.out.println("Using directional lights"); + lightType = DIRECTIONAL_LIGHT; + } + else + { + System.out.println(usage); + System.exit(0); + } + } + else + { + System.out.println(usage); + System.exit(0); + } + } + + // Initialize the GUI components + initComponents(); + + // Create Canvas3D and SimpleUniverse; add canvas to drawing panel + Canvas3D c = createUniverse(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + + // Create the content branch and add it to the universe + scene = createSceneGraph(); + univ.addBranchGraph(scene); + } + + // ---------------------------------------------------------------- + + /** This method is called from within the constructor to + * initialize the form. + * WARNING: Do NOT modify this code. The content of this method is + * always regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() + { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("SphereMotionGL2ES2_Texture"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// //GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(final String args[]) + { + System.setProperty("sun.awt.noerasebackground", "true"); + System.setProperty("j3d.rend", "jogl2es2"); + System.setProperty("j3d.displaylist", "false"); + java.awt.EventQueue.invokeLater(new Runnable() { + @Override + public void run() + { + SphereMotionGL2ES2_Texture sphereMotion = new SphereMotionGL2ES2_Texture(args); + sphereMotion.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JPanel drawingPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES3_Texture.java b/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES3_Texture.java deleted file mode 100644 index f2d1a63..0000000 --- a/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES3_Texture.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2016 JogAmp Community. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Sun designates this - * particular file as subject to the "Classpath" exception as provided - * by Sun in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ -package org.jdesktop.j3d.examples.sphere_motion; - -import java.awt.GraphicsConfiguration; -import java.io.File; -import java.io.IOException; - -import org.jdesktop.j3d.examples.Resources; -import org.jdesktop.j3d.examples.gl2es2pipeline.SimpleShaderAppearance; -import org.jogamp.java3d.Alpha; -import org.jogamp.java3d.AmbientLight; -import org.jogamp.java3d.Appearance; -import org.jogamp.java3d.Background; -import org.jogamp.java3d.BoundingSphere; -import org.jogamp.java3d.BranchGroup; -import org.jogamp.java3d.Canvas3D; -import org.jogamp.java3d.ColoringAttributes; -import org.jogamp.java3d.DirectionalLight; -import org.jogamp.java3d.GLSLShaderProgram; -import org.jogamp.java3d.Light; -import org.jogamp.java3d.Material; -import org.jogamp.java3d.PointLight; -import org.jogamp.java3d.PositionInterpolator; -import org.jogamp.java3d.RotationInterpolator; -import org.jogamp.java3d.Shader; -import org.jogamp.java3d.ShaderAppearance; -import org.jogamp.java3d.ShaderAttributeSet; -import org.jogamp.java3d.ShaderAttributeValue; -import org.jogamp.java3d.ShaderProgram; -import org.jogamp.java3d.SourceCodeShader; -import org.jogamp.java3d.SpotLight; -import org.jogamp.java3d.Texture; -import org.jogamp.java3d.Transform3D; -import org.jogamp.java3d.TransformGroup; -import org.jogamp.java3d.utils.geometry.Sphere; -import org.jogamp.java3d.utils.image.TextureLoader; -import org.jogamp.java3d.utils.shader.StringIO; -import org.jogamp.java3d.utils.universe.SimpleUniverse; -import org.jogamp.vecmath.Color3f; -import org.jogamp.vecmath.Point3d; -import org.jogamp.vecmath.Point3f; -import org.jogamp.vecmath.Vector3d; -import org.jogamp.vecmath.Vector3f; - -public class SphereMotionGL2ES3_Texture extends javax.swing.JFrame -{ - - private SimpleUniverse univ = null; - private BranchGroup scene = null; - - // Constants for type of light to use - private static final int DIRECTIONAL_LIGHT = 0; - private static final int POINT_LIGHT = 1; - private static final int SPOT_LIGHT = 2; - - // Flag indicates type of lights: directional, point, or spot - // lights. This flag is set based on command line argument - private static int lightType = POINT_LIGHT; - - public BranchGroup createSceneGraph() - { - Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f); - Color3f sColor = new Color3f(1.0f, 1.0f, 1.0f); - Color3f objColor = new Color3f(0.6f, 0.6f, 0.6f); - Color3f lColor1 = new Color3f(1.0f, 0.0f, 0.0f); - Color3f lColor2 = new Color3f(0.0f, 1.0f, 0.0f); - Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f); - Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f); - - Transform3D t; - - // Create the root of the branch graph - BranchGroup objRoot = new BranchGroup(); - - // Create a Transformgroup to scale all objects so they - // appear in the scene. - TransformGroup objScale = new TransformGroup(); - Transform3D t3d = new Transform3D(); - t3d.setScale(0.4); - objScale.setTransform(t3d); - objRoot.addChild(objScale); - - // Create a bounds for the background and lights - BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); - - // Set up the background - Background bg = new Background(bgColor); - bg.setApplicationBounds(bounds); - objScale.addChild(bg); - - // Create a Sphere object, generate one copy of the sphere, - // and add it into the scene graph. - ShaderAppearance a = new ShaderAppearance(); - Material m = new Material(objColor, eColor, objColor, sColor, 100.0f); - m.setLightingEnable(true); - String vertexProgram = null; - String fragmentProgram = null; - try - { - vertexProgram = StringIO.readFully( - new File(System.getProperty("user.dir") + "/src/main/java/org/jdesktop/j3d/examples/sphere_motion/phong_gl2es2_texture.vert")); - fragmentProgram = StringIO.readFully( - new File(System.getProperty("user.dir") + "/src/main/java/org/jdesktop/j3d/examples/sphere_motion/phong_gl2es2_texture.frag")); - } - catch (IOException e) - { - throw new RuntimeException(e); - } - Shader[] shaders = new Shader[2]; - shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, Shader.SHADER_TYPE_VERTEX, vertexProgram); - shaders[1] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, Shader.SHADER_TYPE_FRAGMENT, fragmentProgram); - ShaderProgram shaderProgram = new GLSLShaderProgram(); - shaderProgram.setShaders(shaders); - shaderProgram.setShaderAttrNames(new String[] { "BaseMap" }); - - a.setShaderProgram(shaderProgram); - - ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); - shaderAttributeSet.put(new ShaderAttributeValue("BaseMap", new Integer(0))); - a.setShaderAttributeSet(shaderAttributeSet); - - - a.setMaterial(m); - Texture txtr = new TextureLoader(Resources.getResource("resources/images/earth.jpg"), this).getTexture(); - a.setTexture(txtr); - Sphere sph = new Sphere(1.0f, Sphere.GENERATE_NORMALS | Sphere.GENERATE_TEXTURE_COORDS, 200, a); - objScale.addChild(sph); - - // Create the transform group node for the each light and initialize - // it to the identity. Enable the TRANSFORM_WRITE capability so that - // our behavior code can modify it at runtime. Add them to the root - // of the subgraph. - TransformGroup l1RotTrans = new TransformGroup(); - l1RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - objScale.addChild(l1RotTrans); - - TransformGroup l2RotTrans = new TransformGroup(); - l2RotTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - objScale.addChild(l2RotTrans); - - // Create transformations for the positional lights - t = new Transform3D(); - Vector3d lPos1 = new Vector3d(0.0, 0.0, 2.0); - t.set(lPos1); - TransformGroup l1Trans = new TransformGroup(t); - l1RotTrans.addChild(l1Trans); - - t = new Transform3D(); - Vector3d lPos2 = new Vector3d(0.5, 0.8, 2.0); - t.set(lPos2); - TransformGroup l2Trans = new TransformGroup(t); - l2RotTrans.addChild(l2Trans); - - // Create Geometry for point lights - ColoringAttributes caL1 = new ColoringAttributes(); - ColoringAttributes caL2 = new ColoringAttributes(); - caL1.setColor(lColor1); - caL2.setColor(lColor2); - Appearance appL1 = new SimpleShaderAppearance(false, false); - Appearance appL2 = new SimpleShaderAppearance(false, false); - appL1.setColoringAttributes(caL1); - appL2.setColoringAttributes(caL2); - l1Trans.addChild(new Sphere(0.05f, appL1)); - l2Trans.addChild(new Sphere(0.05f, appL2)); - - // Create lights - AmbientLight aLgt = new AmbientLight(alColor); - - Light lgt1 = null; - Light lgt2 = null; - - Point3f lPoint = new Point3f(0.0f, 0.0f, 0.0f); - Point3f atten = new Point3f(1.0f, 0.0f, 0.0f); - Vector3f lDirect1 = new Vector3f(lPos1); - Vector3f lDirect2 = new Vector3f(lPos2); - lDirect1.negate(); - lDirect2.negate(); - - switch (lightType) - { - case DIRECTIONAL_LIGHT: - lgt1 = new DirectionalLight(lColor1, lDirect1); - lgt2 = new DirectionalLight(lColor2, lDirect2); - break; - case POINT_LIGHT: - lgt1 = new PointLight(lColor1, lPoint, atten); - lgt2 = new PointLight(lColor2, lPoint, atten); - break; - case SPOT_LIGHT: - lgt1 = new SpotLight(lColor1, lPoint, atten, lDirect1, 25.0f * (float) Math.PI / 180.0f, 10.0f); - lgt2 = new SpotLight(lColor2, lPoint, atten, lDirect2, 25.0f * (float) Math.PI / 180.0f, 10.0f); - break; - } - - // Set the influencing bounds - aLgt.setInfluencingBounds(bounds); - lgt1.setInfluencingBounds(bounds); - lgt2.setInfluencingBounds(bounds); - - // Add the lights into the scene graph - objScale.addChild(aLgt); - l1Trans.addChild(lgt1); - l2Trans.addChild(lgt2); - - // Create a new Behavior object that will perform the desired - // operation on the specified transform object and add it into the - // scene graph. - Transform3D yAxis = new Transform3D(); - Alpha rotor1Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0); - RotationInterpolator rotator1 = new RotationInterpolator(rotor1Alpha, l1RotTrans, yAxis, 0.0f, (float) Math.PI * 2.0f); - rotator1.setSchedulingBounds(bounds); - l1RotTrans.addChild(rotator1); - - // Create a new Behavior object that will perform the desired - // operation on the specified transform object and add it into the - // scene graph. - Alpha rotor2Alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 1000, 0, 0, 0, 0, 0); - RotationInterpolator rotator2 = new RotationInterpolator(rotor2Alpha, l2RotTrans, yAxis, 0.0f, 0.0f); - bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); - rotator2.setSchedulingBounds(bounds); - l2RotTrans.addChild(rotator2); - - // Create a position interpolator and attach it to the view - // platform - TransformGroup vpTrans = univ.getViewingPlatform().getViewPlatformTransform(); - Transform3D axisOfTranslation = new Transform3D(); - Alpha transAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 5000, 0, 0, 5000, 0, 0); - axisOfTranslation.rotY(-Math.PI / 2.0); - PositionInterpolator translator = new PositionInterpolator(transAlpha, vpTrans, axisOfTranslation, 2.0f, 3.5f); - translator.setSchedulingBounds(bounds); - objScale.addChild(translator); - - // Let Java 3D perform optimizations on this scene graph. - objRoot.compile(); - - return objRoot; - } - - private Canvas3D createUniverse() - { - // Get the preferred graphics configuration for the default screen - GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); - - // Create a Canvas3D using the preferred configuration - Canvas3D c = new Canvas3D(config); - - // Create simple universe with view branch - univ = new SimpleUniverse(c); - - // This will move the ViewPlatform back a bit so the - // objects in the scene can be viewed. - univ.getViewingPlatform().setNominalViewingTransform(); - - // Ensure at least 5 msec per frame (i.e., < 200Hz) - univ.getViewer().getView().setMinimumFrameCycleTime(5); - - return c; - } - - /** - * Creates new form SphereMotion - */ - public SphereMotionGL2ES3_Texture(final String[] args) - { - - // Parse the Input Arguments - String usage = "Usage: java SphereMotion [-point | -spot | -dir]"; - for (int i = 0; i < args.length; i++) - { - if (args[i].startsWith("-")) - { - if (args[i].equals("-point")) - { - System.out.println("Using point lights"); - lightType = POINT_LIGHT; - } - else if (args[i].equals("-spot")) - { - System.out.println("Using spot lights"); - lightType = SPOT_LIGHT; - } - else if (args[i].equals("-dir")) - { - System.out.println("Using directional lights"); - lightType = DIRECTIONAL_LIGHT; - } - else - { - System.out.println(usage); - System.exit(0); - } - } - else - { - System.out.println(usage); - System.exit(0); - } - } - - // Initialize the GUI components - initComponents(); - - // Create Canvas3D and SimpleUniverse; add canvas to drawing panel - Canvas3D c = createUniverse(); - drawingPanel.add(c, java.awt.BorderLayout.CENTER); - - // Create the content branch and add it to the universe - scene = createSceneGraph(); - univ.addBranchGraph(scene); - } - - // ---------------------------------------------------------------- - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() - { - drawingPanel = new javax.swing.JPanel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle("SphereMotionGL2ES2_Texture"); - drawingPanel.setLayout(new java.awt.BorderLayout()); - - drawingPanel.setPreferredSize(new java.awt.Dimension(700, 700)); - getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); - - pack(); - }// //GEN-END:initComponents - - /** - * @param args the command line arguments - */ - public static void main(final String args[]) - { - System.setProperty("sun.awt.noerasebackground", "true"); - System.setProperty("j3d.rend", "jogl2es2"); - System.setProperty("j3d.displaylist", "false"); - java.awt.EventQueue.invokeLater(new Runnable() { - @Override - public void run() - { - SphereMotionGL2ES3_Texture sphereMotion = new SphereMotionGL2ES3_Texture(args); - sphereMotion.setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JPanel drawingPanel; - // End of variables declaration//GEN-END:variables - -} diff --git a/src/main/java/org/jdesktop/j3d/examples/stencil/StencilOutline.java b/src/main/java/org/jdesktop/j3d/examples/stencil/StencilOutline.java index f93de4f..03c6331 100644 --- a/src/main/java/org/jdesktop/j3d/examples/stencil/StencilOutline.java +++ b/src/main/java/org/jdesktop/j3d/examples/stencil/StencilOutline.java @@ -453,10 +453,10 @@ public class StencilOutline extends javax.swing.JFrame if (filename == null) { - filename = Resources.getResource("resources/geometry/galleon.obj"); + filename = Resources.getResource("main/resources/geometry/galleon.obj"); if (filename == null) { - System.err.println("resources/geometry/galleon.obj not found"); + System.err.println("main/resources/geometry/galleon.obj not found"); System.exit(1); } } diff --git a/src/main/java/org/jdesktop/j3d/examples/texture/MultiTextureTest.java b/src/main/java/org/jdesktop/j3d/examples/texture/MultiTextureTest.java index 49f9406..543787c 100644 --- a/src/main/java/org/jdesktop/j3d/examples/texture/MultiTextureTest.java +++ b/src/main/java/org/jdesktop/j3d/examples/texture/MultiTextureTest.java @@ -230,17 +230,17 @@ public class MultiTextureTest extends Applet implements ItemListener{ public void init() {System.setProperty("sun.awt.noerasebackground", "true"); if (stoneImage == null) { // the path to the image for an applet - stoneImage = Resources.getResource("resources/images/stone.jpg"); + stoneImage = Resources.getResource("main/resources/images/stone.jpg"); if (stoneImage == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } if (skyImage == null) { // the path to the image for an applet - skyImage = Resources.getResource("resources/images/bg.jpg"); + skyImage = Resources.getResource("main/resources/images/bg.jpg"); if (skyImage == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } } @@ -326,15 +326,15 @@ public class MultiTextureTest extends Applet implements ItemListener{ java.net.URL skyURL = null; // the path to the image for an application - stoneURL = Resources.getResource("resources/images/stone.jpg"); + stoneURL = Resources.getResource("main/resources/images/stone.jpg"); if (stoneURL == null) { - System.err.println("resources/images/stone.jpg not found"); + System.err.println("main/resources/images/stone.jpg not found"); System.exit(1); } - skyURL = Resources.getResource("resources/images/bg.jpg"); + skyURL = Resources.getResource("main/resources/images/bg.jpg"); if (skyURL == null) { - System.err.println("resources/images/bg.jpg not found"); + System.err.println("main/resources/images/bg.jpg not found"); System.exit(1); } diff --git a/src/main/java/org/jdesktop/j3d/examples/texture/TextureImage.java b/src/main/java/org/jdesktop/j3d/examples/texture/TextureImage.java index 59f8aa5..e91ecf5 100644 --- a/src/main/java/org/jdesktop/j3d/examples/texture/TextureImage.java +++ b/src/main/java/org/jdesktop/j3d/examples/texture/TextureImage.java @@ -67,7 +67,7 @@ import org.jogamp.vecmath.Point3d; public class TextureImage extends Applet { - private static final String defaultFileName = "resources/images/stone.jpg"; + private static final String defaultFileName = "main/resources/images/stone.jpg"; private java.net.URL texImage = null; private SimpleUniverse u = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java b/src/main/java/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java index f55493c..067f121 100644 --- a/src/main/java/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java +++ b/src/main/java/org/jdesktop/j3d/examples/texture/TextureImageNPOT.java @@ -71,7 +71,7 @@ import org.jogamp.vecmath.Point3d; public class TextureImageNPOT extends Applet { - private static final String defaultFileName = "resources/images/Java3d.jpg"; + private static final String defaultFileName = "main/resources/images/Java3d.jpg"; private java.net.URL texImage = null; private SimpleUniverse u = null; diff --git a/src/main/java/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java b/src/main/java/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java index b30b9a2..8c08d38 100644 --- a/src/main/java/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java +++ b/src/main/java/org/jdesktop/j3d/examples/texture_by_ref/TextureByReference.java @@ -122,16 +122,16 @@ implements ItemListener, ActionListener, ChangeListener { // image files used for the Texture animation for the applet, // or if no parameters are passed in for the application public static final String[] defaultFiles = { - "resources/images/animation1.gif", - "resources/images/animation2.gif", - "resources/images/animation3.gif", - "resources/images/animation4.gif", - "resources/images/animation5.gif", - "resources/images/animation6.gif", - "resources/images/animation7.gif", - "resources/images/animation8.gif", - "resources/images/animation9.gif", - "resources/images/animation10.gif"}; + "main/resources/images/animation1.gif", + "main/resources/images/animation2.gif", + "main/resources/images/animation3.gif", + "main/resources/images/animation4.gif", + "main/resources/images/animation5.gif", + "main/resources/images/animation6.gif", + "main/resources/images/animation7.gif", + "main/resources/images/animation8.gif", + "main/resources/images/animation9.gif", + "main/resources/images/animation10.gif"}; private java.net.URL[] urls = null; -- cgit v1.2.3