aboutsummaryrefslogtreecommitdiffstats
path: root/src/DepthFuncTest/RenderFrame.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/DepthFuncTest/RenderFrame.java')
-rw-r--r--src/DepthFuncTest/RenderFrame.java55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/DepthFuncTest/RenderFrame.java b/src/DepthFuncTest/RenderFrame.java
index ce4e2a0..b56e332 100644
--- a/src/DepthFuncTest/RenderFrame.java
+++ b/src/DepthFuncTest/RenderFrame.java
@@ -1,4 +1,3 @@
-package DepthFuncTest;
/*
* $RCSfile$
*
@@ -60,6 +59,8 @@ public class RenderFrame extends javax.swing.JFrame {
RenderingAttributes staticWFBoxRA;
RenderingAttributes staticBoxRA;
+
+ RenderingAttributes rotatingBoxRA;
/** Creates new form RenderFrame */
public RenderFrame( DepthFuncTest _dpt) {
@@ -74,7 +75,8 @@ public class RenderFrame extends javax.swing.JFrame {
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
- private void initComponents() {
+ private void initComponents()
+ {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("J3D frame");
@@ -104,8 +106,6 @@ public class RenderFrame extends javax.swing.JFrame {
BranchGroup lampsBG = new BranchGroup();
OrderedGroup oGroup = new OrderedGroup();
TransformGroup staticBoxRotTG = new TransformGroup();
- oGroup.addChild( rotObjectBG );
- oGroup.addChild( staticBoxRotTG );
staticBoxRotTG.addChild( staticObjectOG );
TransformGroup objectsTGRot = new TransformGroup();
TransformGroup objectsTGTrans = new TransformGroup();
@@ -115,14 +115,28 @@ public class RenderFrame extends javax.swing.JFrame {
objectsTGRot.addChild( oGroup );
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 Appearance();
+ PolygonAttributes globalSpherePA = new PolygonAttributes();
+ globalSpherePA.setCullFace( globalSpherePA.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 );
+ globalSphere.setBounds( bounds );
+ oGroup.addChild( globalSphere );
+
globalBG.addChild( lampsBG );
// adding lamps.
- PointLight frontLamp = new PointLight( new Color3f( 1.0f, 1.0f, 1.0f ), new Point3f( 5, 5, 5 ), new Point3f( 1f, .0f, 0.f ) );
+ PointLight frontLamp = new PointLight( new Color3f( 1.0f, 1.0f, 1.0f ), new Point3f( 20, 20, 20 ), new Point3f( 0.0f, .0f, 0.f ) );
lampsBG.addChild( frontLamp );
frontLamp.setBounds( bounds );
frontLamp.setInfluencingBounds( bounds );
- PointLight backLamp = new PointLight( new Color3f( 1.0f, .0f, .0f ), new Point3f( -5, -5, -5 ), new Point3f( 1f, .0f, 0.f ) );
+ PointLight backLamp = new PointLight( new Color3f( 1.0f, .0f, .0f ), new Point3f( -20, -20, -20 ), new Point3f( 0.0f, .0f, 0.f ) );
lampsBG.addChild( backLamp );
backLamp.setBounds( bounds );
backLamp.setInfluencingBounds( bounds );
@@ -158,7 +172,15 @@ public class RenderFrame extends javax.swing.JFrame {
rotObjectBG.addChild( rotBoxScaleInt );
rotObjectBG.addChild( rotBoxRotInt );
rotBox.setBounds( bounds );
- rotBox.setAppearance( rotBoxApp );
+
+ rotatingBoxRA = new RenderingAttributes();
+ rotatingBoxRA.setRasterOpEnable( true );
+ rotatingBoxRA.setCapability( staticBoxRA.ALLOW_RASTER_OP_WRITE );
+// rotatingBoxRA.setRasterOp( rotatingBoxRA.ROP_XOR );
+ rotBoxApp.setRenderingAttributes( rotatingBoxRA );
+
+
+ rotBox.setAppearance( rotBoxApp );
}
//adding static back face wireframe cube
@@ -216,7 +238,7 @@ public class RenderFrame extends javax.swing.JFrame {
staticBox.setBounds( bounds );
Appearance boxApp = new Appearance();
Material boxMat = new Material();
- boxMat.setDiffuseColor( .7f, .7f, .1f );
+ boxMat.setDiffuseColor( .7f, .7f, .7f );
boxApp.setMaterial( boxMat );
staticBoxRA = new RenderingAttributes();
staticBoxRA.setCapability( staticBoxRA.ALLOW_DEPTH_TEST_FUNCTION_WRITE );
@@ -227,6 +249,8 @@ public class RenderFrame extends javax.swing.JFrame {
staticBox.setAppearance( boxApp );
staticObjectOG.addChild( staticBox );
}
+ oGroup.addChild( rotObjectBG );
+ oGroup.addChild( staticBoxRotTG );
//adding the mouse rotate behavior to the group of cubes.
MouseRotate behavior = new MouseRotate();
@@ -240,22 +264,27 @@ public class RenderFrame extends javax.swing.JFrame {
public void setStaticWFObjectTestFunc( int func )
{
- staticWFBoxRA.setDepthTestFunction( func );
+ staticWFBoxRA.setDepthTestFunction( func );
}
public void setStaticObjectTestFunc( int func )
{
- staticBoxRA.setDepthTestFunction( func );
+ staticBoxRA.setDepthTestFunction( func );
}
public void setStaticWFObjectDBWriteStatus( boolean status )
{
- staticWFBoxRA.setDepthBufferWriteEnable( status );
+ staticWFBoxRA.setDepthBufferWriteEnable( status );
}
public void setStaticObjectDBWriteStatus( boolean status )
{
- staticBoxRA.setDepthBufferWriteEnable( status );
- }
+ staticBoxRA.setDepthBufferWriteEnable( status );
+ }
+ public void setRotatingObjectROPMode( int mode )
+ {
+ rotatingBoxRA.setRasterOp( mode );
+ }
+
}