aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorphil <[email protected]>2016-12-05 10:20:08 +1300
committerphil <[email protected]>2016-12-05 10:20:08 +1300
commit6a417a5ee6137ffea809fee0559b8aaa7ba24bbd (patch)
treed426efcac93aa0e8b1f3c2b8c2c4720cdb211698 /src
parentaa746d5209f0aaa17634a1629b6a7d23f6596a94 (diff)
Changed examples to use SimpleShaderAppearance auto shader building
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTestGL2ES2.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java16
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/appearance/Tetrahedron.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java11
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/background/BackgroundTexture.java2
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/background/BackgroundTextureGL2ES2.java2
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/depth_func/RenderFrameGL2ES2.java27
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorldGL2ES2.java2
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2.java4
-rw-r--r--src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2_Texture.java4
13 files changed, 46 insertions, 42 deletions
diff --git a/src/main/java/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTestGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTestGL2ES2.java
index b6b2bbf..859fba5 100644
--- a/src/main/java/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTestGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/alternate_appearance/AlternateAppearanceBoundsTestGL2ES2.java
@@ -143,7 +143,7 @@ public class AlternateAppearanceBoundsTestGL2ES2 extends JApplet implements Acti
BranchGroup objRoot = new BranchGroup();
// Create an alternate appearance
- otherApp = new SimpleShaderAppearance(true, false);
+ otherApp = new SimpleShaderAppearance();
//otherApp = new Appearance();
altMat = new Material();
altMat.setCapability(Material.ALLOW_COMPONENT_WRITE);
@@ -158,7 +158,7 @@ public class AlternateAppearanceBoundsTestGL2ES2 extends JApplet implements Acti
objRoot.addChild(altApp);
// Build foreground geometry
- Appearance app1 = new SimpleShaderAppearance(true, false);
+ Appearance app1 = new SimpleShaderAppearance();
//Appearance app1 = new Appearance();
mat1 = new Material();
mat1.setCapability(Material.ALLOW_COMPONENT_WRITE);
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 d0b0090..464b17f 100644
--- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java
+++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixed.java
@@ -422,8 +422,8 @@ public class AppearanceMixed extends javax.swing.JFrame {
spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// Create a simple shape leaf node and set the appearance
- Shape3D shape = new Tetrahedron();
- shape.setAppearance(app);
+ Shape3D shape = new Tetrahedron(app);
+
// add it to the scene graph.
spinTg.addChild(shape);
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 7230100..90b1eb4 100644
--- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceMixedGL2ES2.java
@@ -34,7 +34,6 @@ import java.awt.GraphicsConfiguration;
import org.jdesktop.j3d.examples.Resources;
import org.jogamp.java3d.Alpha;
import org.jogamp.java3d.AmbientLight;
-import org.jogamp.java3d.Appearance;
import org.jogamp.java3d.BoundingSphere;
import org.jogamp.java3d.BranchGroup;
import org.jogamp.java3d.Canvas3D;
@@ -174,7 +173,7 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
gc = getGraphicsContext3D();
// Create the appearance for the triangle fan
- Appearance app = new SimpleShaderAppearance(true, false);
+ SimpleShaderAppearance app = new SimpleShaderAppearance();
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
Color3f objColor = new Color3f(0.0f, 0.0f, 0.8f);
@@ -222,7 +221,7 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
// into the scene graph.
int row, col;
- Appearance[][] app = new SimpleShaderAppearance [3][3];
+ SimpleShaderAppearance[][] app = new SimpleShaderAppearance [3][3];
for (row = 0; row < 3; row++)
for (col = 0; col < 3; col++)
@@ -243,8 +242,8 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
}
- private Appearance createAppearance(int idx) {
- Appearance app = new SimpleShaderAppearance(true, false);;
+ private SimpleShaderAppearance createAppearance(int idx) {
+ SimpleShaderAppearance app = new SimpleShaderAppearance();
// Globally used colors
Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
@@ -314,7 +313,7 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
// Texture mapped, lit solid
case 4:
- {app = new SimpleShaderAppearance(true, true);;
+ {
// Set up the texture map
TextureLoader tex = new TextureLoader(texImage, this);
app.setTexture(tex.getTexture());
@@ -393,7 +392,7 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
}
- private Group createObject(Appearance app, double scale,
+ private Group createObject(SimpleShaderAppearance app, double scale,
double xpos, double ypos) {
// Create a transform group node to scale and position the object.
@@ -408,8 +407,7 @@ public class AppearanceMixedGL2ES2 extends javax.swing.JFrame {
spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// Create a simple shape leaf node and set the appearance
- Shape3D shape = new Tetrahedron();
- shape.setAppearance(app);
+ Shape3D shape = new Tetrahedron(app);
// add it to the scene graph.
spinTg.addChild(shape);
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 6ec9944..615b276 100644
--- a/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java
+++ b/src/main/java/org/jdesktop/j3d/examples/appearance/AppearanceTest.java
@@ -293,8 +293,8 @@ public class AppearanceTest extends javax.swing.JFrame {
spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
// Create a simple shape leaf node and set the appearance
- Shape3D shape = new Tetrahedron();
- shape.setAppearance(app);
+ Shape3D shape = new Tetrahedron(app);
+
// add it to the scene graph.
spinTg.addChild(shape);
diff --git a/src/main/java/org/jdesktop/j3d/examples/appearance/Tetrahedron.java b/src/main/java/org/jdesktop/j3d/examples/appearance/Tetrahedron.java
index 625e7e4..6af7bc9 100644
--- a/src/main/java/org/jdesktop/j3d/examples/appearance/Tetrahedron.java
+++ b/src/main/java/org/jdesktop/j3d/examples/appearance/Tetrahedron.java
@@ -79,7 +79,7 @@ public class Tetrahedron extends Shape3D {
new TexCoord2f(0.5f, sqrt3 / 2.0f),
};
- public Tetrahedron() {
+ public Tetrahedron(Appearance app) {
int i;
TriangleArray tetra = new TriangleArray(12, TriangleArray.COORDINATES |
@@ -108,6 +108,6 @@ public class Tetrahedron extends Shape3D {
}
}
this.setGeometry(tetra);
- this.setAppearance(new Appearance());
+ this.setAppearance(app);
}
}
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 e392053..9d6c9f4 100644
--- a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundGeometryGL2ES2.java
@@ -81,13 +81,14 @@ public class BackgroundGeometryGL2ES2 extends javax.swing.JFrame {
Background bg = new Background();
bg.setApplicationBounds(bounds);
- BranchGroup backGeoBranch = new BranchGroup();
+ BranchGroup backGeoBranch = new BranchGroup();
+ Appearance backgroundApp = new SimpleShaderAppearance();
Sphere sphereObj = new Sphere(1.0f, Sphere.GENERATE_NORMALS |
Sphere.GENERATE_NORMALS_INWARD |
Sphere.GENERATE_TEXTURE_COORDS |
- Sphere.GENERATE_TEXTURE_COORDS_Y_UP, 45);
- Appearance backgroundApp = new SimpleShaderAppearance(true, false);//sphereObj.getAppearance();
- sphereObj.setAppearance(backgroundApp);
+ Sphere.GENERATE_TEXTURE_COORDS_Y_UP, 45, backgroundApp);
+
+
backGeoBranch.addChild(sphereObj);
bg.setGeometry(backGeoBranch);
objTrans.addChild(bg);
@@ -121,7 +122,7 @@ public class BackgroundGeometryGL2ES2 extends javax.swing.JFrame {
0.3f, 0.2f, 0.1f, 0.3f,
0.3f, 0.2f, 0.1f, 0.2f};
- Appearance a1 = new SimpleShaderAppearance(true, false);
+ Appearance a1 = new SimpleShaderAppearance();
Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
Color3f sColor = new Color3f(0.5f, 0.5f, 1.0f);
diff --git a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTexture.java b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTexture.java
index 8592046..740d990 100644
--- a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTexture.java
+++ b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTexture.java
@@ -102,7 +102,7 @@ public class BackgroundTexture extends javax.swing.JFrame
float scaleZ[] = { 0.3f, 0.2f, 0.1f, 0.1f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f, 0.2f };
- Appearance a1 = new SimpleShaderAppearance(true, false);
+ Appearance a1 = new SimpleShaderAppearance();
Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
Color3f sColor = new Color3f(0.5f, 0.5f, 1.0f);
diff --git a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTextureGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTextureGL2ES2.java
index 9a79385..9326000 100644
--- a/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTextureGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/background/BackgroundTextureGL2ES2.java
@@ -100,7 +100,7 @@ public class BackgroundTextureGL2ES2 extends javax.swing.JFrame
float scaleZ[] = { 0.3f, 0.2f, 0.1f, 0.1f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f, 0.3f, 0.3f, 0.2f, 0.1f, 0.2f };
- Appearance a1 = new SimpleShaderAppearance(true, false);
+ Appearance a1 = new SimpleShaderAppearance();
Color3f eColor = new Color3f(0.0f, 0.0f, 0.0f);
Color3f sColor = new Color3f(0.5f, 0.5f, 1.0f);
diff --git a/src/main/java/org/jdesktop/j3d/examples/depth_func/RenderFrameGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/depth_func/RenderFrameGL2ES2.java
index af8d50e..633b111 100644
--- a/src/main/java/org/jdesktop/j3d/examples/depth_func/RenderFrameGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/depth_func/RenderFrameGL2ES2.java
@@ -46,6 +46,7 @@ import org.jogamp.java3d.ScaleInterpolator;
import org.jogamp.java3d.Transform3D;
import org.jogamp.java3d.TransformGroup;
import org.jogamp.java3d.utils.behaviors.mouse.MouseRotate;
+import org.jogamp.java3d.utils.geometry.Box;
import org.jogamp.java3d.utils.geometry.Sphere;
import org.jogamp.java3d.utils.shader.Cube;
import org.jogamp.java3d.utils.shader.SimpleShaderAppearance;
@@ -124,16 +125,15 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
objectsTGTrans.addChild(objectsTGRot);
lampsBG.addChild(objectsTGTrans);
- //adding a sphere as backgroung so there is something else than flat black, and cut cube removal as an other implication. (seeing through)
- Appearance globalSphereAppearance = new SimpleShaderAppearance(true, false);
+ //adding a sphere as background so there is something else than flat black, and cut cube removal as an other implication. (seeing through)
+ Appearance globalSphereAppearance = new SimpleShaderAppearance();
PolygonAttributes globalSpherePA = new PolygonAttributes();
globalSpherePA.setCullFace(PolygonAttributes.CULL_FRONT);// so that interior of the sphere is visible.
Material globalSphereMaterial = new Material();
globalSphereMaterial.setEmissiveColor(.25f, .3f, .35f);
globalSphereAppearance.setMaterial(globalSphereMaterial);
globalSphereAppearance.setPolygonAttributes(globalSpherePA);
- Sphere globalSphere = new Sphere(6.0f);
- globalSphere.setAppearance(globalSphereAppearance);
+ Sphere globalSphere = new Sphere(6.0f, globalSphereAppearance);
globalSphere.setBounds(bounds);
oGroup.addChild(globalSphere);
@@ -169,7 +169,7 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
rotBoxScaleInt.setSchedulingBounds(bounds);
rotBoxScaleInt.setBounds(bounds);
- Appearance rotBoxApp = new SimpleShaderAppearance(false, false);
+ SimpleShaderAppearance rotBoxApp = new SimpleShaderAppearance();
Material rotBoxMat = new Material();
rotBoxMat.setDiffuseColor(.4f, .4f, .4f);
rotBoxApp.setMaterial(rotBoxMat);
@@ -196,8 +196,9 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
//adding static back face wireframe cube
{
+
+ SimpleShaderAppearance staticWFBoxApp = new SimpleShaderAppearance();
Cube staticWFBoxBack = new Cube();
- Appearance staticWFBoxApp = new SimpleShaderAppearance(false, false);
Material staticWFBoxMat = new Material();
staticWFBoxMat.setDiffuseColor(0.f, 0.f, 0.f);
staticWFBoxMat.setEmissiveColor(0.f, .4f, 0.f);
@@ -217,8 +218,14 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
//adding static front face wireframe cube
{
+
+ Appearance staticWFBoxApp = new SimpleShaderAppearance();
+
+ // TODO: if not geometry not shared then appearance shared what????
+ //Box staticWFBox = new Box(1,1,1, Box.GENERATE_NORMALS | Box.GEOMETRY_NOT_SHARED, staticWFBoxApp);
Cube staticWFBox = new Cube();
- Appearance staticWFBoxApp = new SimpleShaderAppearance(false, false);
+ staticWFBox.setAppearance(staticWFBoxApp);
+
Material staticWFBoxMat = new Material();
staticWFBoxMat.setDiffuseColor(0.f, 0.f, 0.f);
staticWFBoxMat.setEmissiveColor(0.f, 1.f, 0.f);
@@ -226,7 +233,6 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
PolygonAttributes staticWFBoxPA = new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK, 0.0f);
staticWFBoxApp.setPolygonAttributes(staticWFBoxPA);
staticWFBoxApp.setRenderingAttributes(staticWFBoxRA);
- staticWFBox.setAppearance(staticWFBoxApp);
staticWFBox.setBounds(bounds);
staticObjectOG.addChild(staticWFBox);
}
@@ -244,9 +250,9 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
// adding static flat cube
{
- Cube staticBox = new Cube();
+ SimpleShaderAppearance boxApp = new SimpleShaderAppearance();
+ Box staticBox = new Box(1, 1, 1,Box.GENERATE_NORMALS | Box.GEOMETRY_NOT_SHARED, boxApp);
staticBox.setBounds(bounds);
- Appearance boxApp = new SimpleShaderAppearance(false, false);
Material boxMat = new Material();
boxMat.setDiffuseColor(.7f, .7f, .7f);
boxApp.setMaterial(boxMat);
@@ -256,7 +262,6 @@ public class RenderFrameGL2ES2 extends javax.swing.JFrame
staticBoxRA.setDepthTestFunction(RenderingAttributes.LESS);
staticBoxRA.setDepthBufferWriteEnable(false);
boxApp.setRenderingAttributes(staticBoxRA);
- staticBox.setAppearance(boxApp);
staticObjectOG.addChild(staticBox);
}
oGroup.addChild(rotObjectBG);
diff --git a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java
index e06216a..1edf8df 100644
--- a/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java
+++ b/src/main/java/org/jdesktop/j3d/examples/gl2es2pipeline/SphereGLSL.java
@@ -184,8 +184,8 @@ public class SphereGLSL extends javax.swing.JFrame
caL1.setColor(lColor1);
caL2.setColor(lColor2);
- Appearance appL1 = new SimpleShaderAppearance(false, false);
- Appearance appL2 = new SimpleShaderAppearance(false, false);
+ Appearance appL1 = new SimpleShaderAppearance();
+ Appearance appL2 = new SimpleShaderAppearance();
appL1.setColoringAttributes(caL1);
appL2.setColoringAttributes(caL2);
diff --git a/src/main/java/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorldGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorldGL2ES2.java
index 3ed6f76..c5a9e16 100644
--- a/src/main/java/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorldGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/jcanvas3d/JInternalWorldGL2ES2.java
@@ -146,7 +146,7 @@ public class JInternalWorldGL2ES2 extends JInternalFrame {
new Point3f( -2.3f, -0.5f, 0.f));
Shape3D sh = new Shape3D();
- Appearance app = new SimpleShaderAppearance(false,false);
+ Appearance app = new SimpleShaderAppearance();
Material mm = new Material();
mm.setLightingEnable(true);
app.setMaterial(mm);
diff --git a/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2.java b/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2.java
index 0d7f8c0..a76429c 100644
--- a/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2.java
+++ b/src/main/java/org/jdesktop/j3d/examples/sphere_motion/SphereMotionGL2ES2.java
@@ -170,8 +170,8 @@ public class SphereMotionGL2ES2 extends javax.swing.JFrame
ColoringAttributes caL2 = new ColoringAttributes();
caL1.setColor(lColor1);
caL2.setColor(lColor2);
- Appearance appL1 = new SimpleShaderAppearance(false, false);
- Appearance appL2 = new SimpleShaderAppearance(false, false);
+ Appearance appL1 = new SimpleShaderAppearance();
+ Appearance appL2 = new SimpleShaderAppearance();
appL1.setColoringAttributes(caL1);
appL2.setColoringAttributes(caL2);
l1Trans.addChild(new Sphere(0.05f, appL1));
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
index 5f793e0..ab48ece 100644
--- 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
@@ -184,8 +184,8 @@ public class SphereMotionGL2ES2_Texture extends javax.swing.JFrame
ColoringAttributes caL2 = new ColoringAttributes();
caL1.setColor(lColor1);
caL2.setColor(lColor2);
- Appearance appL1 = new SimpleShaderAppearance(false, false);
- Appearance appL2 = new SimpleShaderAppearance(false, false);
+ Appearance appL1 = new SimpleShaderAppearance();
+ Appearance appL2 = new SimpleShaderAppearance();
appL1.setColoringAttributes(caL1);
appL2.setColoringAttributes(caL2);
l1Trans.addChild(new Sphere(0.05f, appL1));