diff options
Diffstat (limited to 'src/DepthFuncTest')
-rw-r--r-- | src/DepthFuncTest/DepthFuncTest.form | 159 | ||||
-rw-r--r-- | src/DepthFuncTest/DepthFuncTest.java | 242 | ||||
-rw-r--r-- | src/DepthFuncTest/RenderFrame.form | 25 | ||||
-rw-r--r-- | src/DepthFuncTest/RenderFrame.java | 261 | ||||
-rw-r--r-- | src/DepthFuncTest/build.xml | 69 |
5 files changed, 756 insertions, 0 deletions
diff --git a/src/DepthFuncTest/DepthFuncTest.form b/src/DepthFuncTest/DepthFuncTest.form new file mode 100644 index 0000000..ac15bd3 --- /dev/null +++ b/src/DepthFuncTest/DepthFuncTest.form @@ -0,0 +1,159 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.2" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-82,0,0,1,-109"/> + <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,0,0,0,0,0,0"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generatePosition" type="boolean" value="true"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-106,0,0,1,-117"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="WireFrame Object"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="0" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Depth function"/> + <Property name="toolTipText" type="java.lang.String" value="Mode for normal object"/> + </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleParent" type="javax.accessibility.Accessible" editor="org.netbeans.modules.form.RADVisualComponent$AccessibleParentEditor"> + <ComponentRef name="shadedComboBox"/> + </Property> + </AccessibilityProperties> + </Component> + <Component class="javax.swing.JComboBox" name="normalComboBox"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="8"> + <StringItem index="0" value="ALWAYS"/> + <StringItem index="1" value="NEVER"/> + <StringItem index="2" value="EQUAL"/> + <StringItem index="3" value="NOT_EQUAL"/> + <StringItem index="4" value="LESS"/> + <StringItem index="5" value="LESS_OR_EQUAL"/> + <StringItem index="6" value="GREATER"/> + <StringItem index="7" value="GREATER_OR_EQUAL"/> + </StringArray> + </Property> + <Property name="selectedIndex" type="int" value="6"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[150, 22]"/> + </Property> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="normalComboBoxActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JCheckBox" name="wfCheckBox"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Write Depth Buffer"/> + <Property name="toolTipText" type="java.lang.String" value="Depth will be written for the object, if selected"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="wfCheckBoxActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> + <TitledBorder title="Shaded Object"/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="1" gridWidth="1" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Depth Function"/> + <Property name="toolTipText" type="java.lang.String" value="Mode of shaded object"/> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="shadedComboBox"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="8"> + <StringItem index="0" value="ALWAYS"/> + <StringItem index="1" value="NEVER"/> + <StringItem index="2" value="EQUAL"/> + <StringItem index="3" value="NOT_EQUAL"/> + <StringItem index="4" value="LESS"/> + <StringItem index="5" value="LESS_OR_EQUAL"/> + <StringItem index="6" value="GREATER"/> + <StringItem index="7" value="GREATER_OR_EQUAL"/> + </StringArray> + </Property> + <Property name="selectedIndex" type="int" value="4"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shadedComboBoxActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JCheckBox" name="shadedCheckBox"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="Write Depth Buffer"/> + <Property name="toolTipText" type="java.lang.String" value="Depth will be written for the object, if selected"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="shadedCheckBoxActionPerformed"/> + </Events> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/DepthFuncTest/DepthFuncTest.java b/src/DepthFuncTest/DepthFuncTest.java new file mode 100644 index 0000000..66397e9 --- /dev/null +++ b/src/DepthFuncTest/DepthFuncTest.java @@ -0,0 +1,242 @@ +package DepthFuncTest; +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL + * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF + * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR + * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + * + * $Revision$ + * $Date$ + * $State$ + */ + +import javax.media.j3d.*; + + +/** + *The goal of that example is to show the use of different ZBuffer comparison modes. + */ +public class DepthFuncTest extends javax.swing.JFrame { + + RenderFrame rf; + + /** + * Creates new form DepthFuncTest + */ + public DepthFuncTest() { + initComponents(); + } + + /** 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. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + java.awt.GridBagConstraints gridBagConstraints; + + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + normalComboBox = new javax.swing.JComboBox(); + wfCheckBox = new javax.swing.JCheckBox(); + jPanel2 = new javax.swing.JPanel(); + jLabel3 = new javax.swing.JLabel(); + shadedComboBox = new javax.swing.JComboBox(); + shadedCheckBox = new javax.swing.JCheckBox(); + + getContentPane().setLayout(new java.awt.GridBagLayout()); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + jPanel1.setBorder(new javax.swing.border.TitledBorder("WireFrame Object")); + jLabel1.setFont(new java.awt.Font("Dialog", 0, 12)); + jLabel1.setText("Depth function"); + jLabel1.setToolTipText("Mode for normal object"); + jPanel1.add(jLabel1); + jLabel1.getAccessibleContext().setAccessibleParent(shadedComboBox); + + normalComboBox.setFont(new java.awt.Font("Dialog", 0, 12)); + normalComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ALWAYS", "NEVER", "EQUAL", "NOT_EQUAL", "LESS", "LESS_OR_EQUAL", "GREATER", "GREATER_OR_EQUAL" })); + normalComboBox.setSelectedIndex(6); + normalComboBox.setPreferredSize(new java.awt.Dimension(150, 22)); + normalComboBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + normalComboBoxActionPerformed(evt); + } + }); + + jPanel1.add(normalComboBox); + + wfCheckBox.setFont(new java.awt.Font("Dialog", 0, 12)); + wfCheckBox.setText("Write Depth Buffer"); + wfCheckBox.setToolTipText("Depth will be written for the object, if selected"); + wfCheckBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + wfCheckBoxActionPerformed(evt); + } + }); + + jPanel1.add(wfCheckBox); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + getContentPane().add(jPanel1, gridBagConstraints); + + jPanel2.setBorder(new javax.swing.border.TitledBorder("Shaded Object")); + jLabel3.setFont(new java.awt.Font("Dialog", 0, 12)); + jLabel3.setText("Depth Function"); + jLabel3.setToolTipText("Mode of shaded object"); + jPanel2.add(jLabel3); + + shadedComboBox.setFont(new java.awt.Font("Dialog", 0, 12)); + shadedComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ALWAYS", "NEVER", "EQUAL", "NOT_EQUAL", "LESS", "LESS_OR_EQUAL", "GREATER", "GREATER_OR_EQUAL" })); + shadedComboBox.setSelectedIndex(4); + shadedComboBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + shadedComboBoxActionPerformed(evt); + } + }); + + jPanel2.add(shadedComboBox); + + shadedCheckBox.setFont(new java.awt.Font("Dialog", 0, 12)); + shadedCheckBox.setSelected(true); + shadedCheckBox.setText("Write Depth Buffer"); + shadedCheckBox.setToolTipText("Depth will be written for the object, if selected"); + shadedCheckBox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + shadedCheckBoxActionPerformed(evt); + } + }); + + jPanel2.add(shadedCheckBox); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + getContentPane().add(jPanel2, gridBagConstraints); + + setBounds(0, 0, 403, 174); + } + // </editor-fold>//GEN-END:initComponents + + private void shadedCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shadedCheckBoxActionPerformed + rf.setStaticObjectDBWriteStatus( shadedCheckBox.isSelected() ); + }//GEN-LAST:event_shadedCheckBoxActionPerformed + + private void wfCheckBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_wfCheckBoxActionPerformed + rf.setStaticWFObjectDBWriteStatus( wfCheckBox.isSelected() ); + }//GEN-LAST:event_wfCheckBoxActionPerformed + + private void shadedComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_shadedComboBoxActionPerformed + int func = RenderingAttributes.LESS_OR_EQUAL; + String selectedItem = shadedComboBox.getSelectedItem().toString(); // how to avoid a cast and all that goes with it. (lazyness) + rf.setStaticObjectTestFunc( getID( selectedItem ) ); + }//GEN-LAST:event_shadedComboBoxActionPerformed + + private void normalComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_normalComboBoxActionPerformed + int func = RenderingAttributes.LESS_OR_EQUAL; + String selectedItem = normalComboBox.getSelectedItem().toString(); // how to avoid a cast and all that goes with it. (lazyness) + rf.setStaticWFObjectTestFunc( getID( selectedItem ) ); + }//GEN-LAST:event_normalComboBoxActionPerformed + + int getID( String selectedItem ) + { + int func = RenderingAttributes.LESS_OR_EQUAL; + if ( "LESS_OR_EQUAL".equals(selectedItem) ) + { + func = RenderingAttributes.LESS_OR_EQUAL; + } + else if ( "NEVER".equals(selectedItem) ) + { + func = RenderingAttributes.NEVER; + } + else if ( "ALWAYS".equals(selectedItem) ) + { + func = RenderingAttributes.ALWAYS; + } + else if ( "GREATER".equals(selectedItem) ) + { + func = RenderingAttributes.GREATER; + } + else if ( "GREATER_OR_EQUAL".equals(selectedItem) ) + { + func = RenderingAttributes.GREATER_OR_EQUAL; + } + else if ( "LESS".equals(selectedItem) ) + { + func = RenderingAttributes.LESS; + } + else if ( "EQUAL".equals(selectedItem) ) + { + func = RenderingAttributes.EQUAL; + } + else if ( "NOT_EQUAL".equals(selectedItem) ) + { + func = RenderingAttributes.NOT_EQUAL; + } + return func; + } + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + DepthFuncTest dpt = new DepthFuncTest(); + dpt.rf = new RenderFrame( dpt ); + dpt.setVisible(true); + dpt.rf.setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JComboBox normalComboBox; + private javax.swing.JCheckBox shadedCheckBox; + private javax.swing.JComboBox shadedComboBox; + private javax.swing.JCheckBox wfCheckBox; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/DepthFuncTest/RenderFrame.form b/src/DepthFuncTest/RenderFrame.form new file mode 100644 index 0000000..2edc4bb --- /dev/null +++ b/src/DepthFuncTest/RenderFrame.form @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="J3D frame"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-32,0,0,2,-128"/> + <SyntheticProperty name="formPosition" type="java.awt.Point" value="-84,-19,0,5,115,114,0,14,106,97,118,97,46,97,119,116,46,80,111,105,110,116,-74,-60,-118,114,52,126,-56,38,2,0,2,73,0,1,120,73,0,1,121,120,112,0,0,1,-112,0,0,0,0"/> + <SyntheticProperty name="formSizePolicy" type="int" value="0"/> + <SyntheticProperty name="generatePosition" type="boolean" value="true"/> + <SyntheticProperty name="generateSize" type="boolean" value="true"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-56,0,0,2,120"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> +</Form> diff --git a/src/DepthFuncTest/RenderFrame.java b/src/DepthFuncTest/RenderFrame.java new file mode 100644 index 0000000..ce4e2a0 --- /dev/null +++ b/src/DepthFuncTest/RenderFrame.java @@ -0,0 +1,261 @@ +package DepthFuncTest; +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL + * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF + * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR + * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + * + * $Revision$ + * $Date$ + * $State$ + */ + +import com.sun.j3d.utils.behaviors.mouse.*; +import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; +import java.awt.GraphicsConfiguration; +import javax.media.j3d.*; +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.geometry.*; +import javax.vecmath.*; + + +public class RenderFrame extends javax.swing.JFrame { + + DepthFuncTest dpt; + + SimpleUniverse su; + + RenderingAttributes staticWFBoxRA; + RenderingAttributes staticBoxRA; + + /** Creates new form RenderFrame */ + public RenderFrame( DepthFuncTest _dpt) { + dpt = _dpt; + initComponents(); + initUniverse(); + } + + /** 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. + */ + // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents + private void initComponents() { + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("J3D frame"); + setBounds(400, 0, 640, 480); + } + // </editor-fold>//GEN-END:initComponents + + void initUniverse() { + GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + add("Center", c); + su = new SimpleUniverse(c); + su.addBranchGraph( createScene() ); + c.getView().setMinimumFrameCycleTime( 10 ); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + + BranchGroup createScene() { + BoundingSphere bounds = new BoundingSphere( new Point3d( 0.0, 0.0, 0.0 ), 100.0 ); + + BranchGroup globalBG = new BranchGroup(); + BranchGroup rotObjectBG = new BranchGroup(); + OrderedGroup staticObjectOG = new OrderedGroup(); + 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(); + Transform3D objectsTGTransT3d = new Transform3D(); + objectsTGTransT3d.setTranslation( new Vector3f( 0.0f, 0.0f, -10.0f ) ); + objectsTGTrans.setTransform( objectsTGTransT3d ); + objectsTGRot.addChild( oGroup ); + objectsTGTrans.addChild( objectsTGRot ); + lampsBG.addChild( objectsTGTrans ); + 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 ) ); + 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 ) ); + lampsBG.addChild( backLamp ); + backLamp.setBounds( bounds ); + backLamp.setInfluencingBounds( bounds ); + + //adding shapes. + { + //adding rotating and scaling cube + //doing the rotation + TransformGroup rotBoxTGRot = new TransformGroup(); + rotBoxTGRot.setCapability( rotBoxTGRot.ALLOW_TRANSFORM_WRITE ); + RotationInterpolator rotBoxRotInt = new RotationInterpolator( new Alpha( -1, 20000 ) , rotBoxTGRot ); + rotBoxRotInt.setSchedulingBounds( bounds ); + rotBoxRotInt.setBounds( bounds ); + + //doing the scaling + Transform3D scaleBoxt3d = new Transform3D(); + TransformGroup rotBoxTGScale = new TransformGroup(); + rotBoxTGScale.setCapability( rotBoxTGScale.ALLOW_TRANSFORM_WRITE ); + ScaleInterpolator rotBoxScaleInt = new ScaleInterpolator( new Alpha( -1, Alpha.INCREASING_ENABLE|Alpha.DECREASING_ENABLE, 0, 0, 3000, 1500, 0, 3000, 1500, 0 ) , rotBoxTGScale, new Transform3D(), 0.7f, 1.6f ); + rotBoxScaleInt.setSchedulingBounds( bounds ); + rotBoxScaleInt.setBounds( bounds ); + + Appearance rotBoxApp = new Appearance(); + Material rotBoxMat = new Material(); + rotBoxMat.setDiffuseColor( .4f, .4f, .4f ); + rotBoxApp.setMaterial( rotBoxMat ); + Box rotBox = new Box( 1.1f, 1.1f, 1.1f, rotBoxApp ); + rotBoxTGScale.addChild( rotBox ); + rotBoxTGRot.addChild( rotBoxTGScale ); + TransformGroup rotBoxTG = new TransformGroup(); + rotBoxTG.addChild( rotBoxTGRot ); + rotObjectBG.addChild( rotBoxTG ); + rotObjectBG.addChild( rotBoxScaleInt ); + rotObjectBG.addChild( rotBoxRotInt ); + rotBox.setBounds( bounds ); + rotBox.setAppearance( rotBoxApp ); + } + + //adding static back face wireframe cube + { + Box staticWFBoxBack = new Box( ); + Appearance staticWFBoxApp = new Appearance(); + Material staticWFBoxMat = new Material(); + staticWFBoxMat.setDiffuseColor( 0.f, 0.f, 0.f ); + staticWFBoxMat.setEmissiveColor( 0.f, .4f, 0.f ); + staticWFBoxApp.setMaterial( staticWFBoxMat ); + PolygonAttributes staticWFBoxPABack = new PolygonAttributes( PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_FRONT, 0.0f ); + staticWFBoxApp.setPolygonAttributes( staticWFBoxPABack ); + staticWFBoxRA = new RenderingAttributes(); + staticWFBoxRA.setCapability( staticWFBoxRA.ALLOW_DEPTH_TEST_FUNCTION_WRITE ); + staticWFBoxRA.setCapability( staticWFBoxRA.ALLOW_DEPTH_ENABLE_WRITE ); + staticWFBoxRA.setDepthTestFunction( staticWFBoxRA.GREATER ); + staticWFBoxRA.setDepthBufferWriteEnable( false ); + staticWFBoxApp.setRenderingAttributes( staticWFBoxRA ); + staticWFBoxBack.setAppearance( staticWFBoxApp ); + staticWFBoxBack.setBounds( bounds ); + staticObjectOG.addChild( staticWFBoxBack ); + } + + //adding static front face wireframe cube + { + Box staticWFBox = new Box( ); + Appearance staticWFBoxApp = new Appearance(); + Material staticWFBoxMat = new Material(); + staticWFBoxMat.setDiffuseColor( 0.f, 0.f, 0.f ); + staticWFBoxMat.setEmissiveColor( 0.f, 1.f, 0.f ); + staticWFBoxApp.setMaterial( staticWFBoxMat ); + 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 ); + } + + + {// rotating the static cubes + Transform3D boxt3d = new Transform3D(); + Transform3D tempt3d = new Transform3D(); + boxt3d.rotZ( Math.PI/4.0f ); + tempt3d.rotX( Math.PI/4.0f ); + boxt3d.mul( tempt3d ); + tempt3d.rotY( Math.PI/4.0f ); + boxt3d.mul( tempt3d ); + staticBoxRotTG.setTransform( boxt3d ); + } + + // adding static flat cube + { + Box staticBox = new Box( ); + staticBox.setBounds( bounds ); + Appearance boxApp = new Appearance(); + Material boxMat = new Material(); + boxMat.setDiffuseColor( .7f, .7f, .1f ); + boxApp.setMaterial( boxMat ); + staticBoxRA = new RenderingAttributes(); + staticBoxRA.setCapability( staticBoxRA.ALLOW_DEPTH_TEST_FUNCTION_WRITE ); + staticBoxRA.setCapability( staticBoxRA.ALLOW_DEPTH_ENABLE_WRITE ); + staticBoxRA.setDepthTestFunction( staticBoxRA.LESS ); + staticBoxRA.setDepthBufferWriteEnable( false ); + boxApp.setRenderingAttributes( staticBoxRA ); + staticBox.setAppearance( boxApp ); + staticObjectOG.addChild( staticBox ); + } + + //adding the mouse rotate behavior to the group of cubes. + MouseRotate behavior = new MouseRotate(); + behavior.setTransformGroup( objectsTGRot ); + objectsTGRot.addChild( behavior ); + objectsTGRot.setCapability( objectsTGRot.ALLOW_TRANSFORM_READ ); + objectsTGRot.setCapability( objectsTGRot.ALLOW_TRANSFORM_WRITE ); + behavior.setSchedulingBounds(bounds); + return globalBG; + } + + public void setStaticWFObjectTestFunc( int func ) + { + staticWFBoxRA.setDepthTestFunction( func ); + } + + public void setStaticObjectTestFunc( int func ) + { + staticBoxRA.setDepthTestFunction( func ); + } + + public void setStaticWFObjectDBWriteStatus( boolean status ) + { + staticWFBoxRA.setDepthBufferWriteEnable( status ); + } + + public void setStaticObjectDBWriteStatus( boolean status ) + { + staticBoxRA.setDepthBufferWriteEnable( status ); + } + +} diff --git a/src/DepthFuncTest/build.xml b/src/DepthFuncTest/build.xml new file mode 100644 index 0000000..47e5a36 --- /dev/null +++ b/src/DepthFuncTest/build.xml @@ -0,0 +1,69 @@ +<?xml version="1.0"?> + +<!-- +/* + * $RCSfile$ + * + * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistribution of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistribution in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * Neither the name of Sun Microsystems, Inc. or the names of + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * This software is provided "AS IS," without a warranty of any + * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND + * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY + * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL + * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF + * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS + * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR + * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, + * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND + * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR + * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGES. + * + * You acknowledge that this software is not designed, licensed or + * intended for use in the design, construction, operation or + * maintenance of any nuclear facility. + * + * $Revision$ + * $Date$ + * $State$ + */ + --> + +<project basedir="." default="compile"> + <target name="compile"> + <javac + destdir="." srcdir="." + source="1.4" target="1.4" + debug="true" deprecation="true"> + </javac> + </target> + + <target name="all" depends="compile"> + </target> + + <target description="Clean all build products." name="clean"> + <delete> + <fileset dir="."> + <include name="**/*.class"/> + </fileset> + </delete> + </target> + +</project> |