diff options
author | nobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-07 17:22:49 +0000 |
---|---|---|
committer | nobody <nobody@28c7f869-5b4e-e670-f602-82bfaf57f300> | 2006-03-07 17:22:49 +0000 |
commit | 19e30a5771eb1ec413e562c0d99b6263978dfba0 (patch) | |
tree | 76057ae4a8f7cf38526388d242f37882fe01015e | |
parent | 667e9374a310f09fdb4c91893a93719e81ad8a9f (diff) |
This commit was manufactured by cvs2svn to create branch 'dev-1_5'.
59 files changed, 5885 insertions, 0 deletions
diff --git a/THIRDPARTY-LICENSE-VIEWPOINT.txt b/THIRDPARTY-LICENSE-VIEWPOINT.txt new file mode 100644 index 0000000..a7420da --- /dev/null +++ b/THIRDPARTY-LICENSE-VIEWPOINT.txt @@ -0,0 +1,22 @@ +The following additional provisions apply to third party software +included as part of this product. + + src/resources/geometry/ + beethoven.obj + galleon.obj + p51_mustang.obj + +# Courtesy of: +# +# Viewpoint Animation Engineering +# 870 West Center +# Orem, Utah 84057 +# (801)224-2222 +# 1-800-DATASET +# +# (c) Copyright 1992 Viewpoint Animation Engineering Inc. +# Sun Microsystems has been authorized to freely distribute +# these Datasets. They are provided for unlimited use in +# existing or modified form. The actual Dataset (ie, geometry) +# may not, however, be resold in existing or modified form. +# diff --git a/src/classes/org/jdesktop/j3d/examples/Resources.java b/src/classes/org/jdesktop/j3d/examples/Resources.java new file mode 100644 index 0000000..13012d3 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/Resources.java @@ -0,0 +1,70 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples; + +import java.net.URL; + +/** + * + */ +public class Resources { + + /** + * Do not construct an instance of this class. + */ + private Resources() { + + } + + /** + * Return the URL of the filename under the resources directory + */ + public static URL getResource(String filename) { + URL url = Resources.class.getResource(filename); + return url; + } + + +} diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form new file mode 100644 index 0000000..2440a43 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form @@ -0,0 +1,36 @@ +<?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="AppearanceMixed"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.form b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.form new file mode 100644 index 0000000..43cd90f --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.form @@ -0,0 +1,36 @@ +<?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="AppearanceTest"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form new file mode 100644 index 0000000..9e76404 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form @@ -0,0 +1,37 @@ +<?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="BackgroundGeometry"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="opaque" type="boolean" value="false"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form b/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form new file mode 100644 index 0000000..1483b2c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form @@ -0,0 +1,36 @@ +<?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="ObjLoadCg"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form b/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form new file mode 100644 index 0000000..2be0fec --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form @@ -0,0 +1,36 @@ +<?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="SamplerTestCg"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java new file mode 100644 index 0000000..f34185e --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.java @@ -0,0 +1,251 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.cg_shader; + +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.geometry.Sphere; +import com.sun.j3d.utils.image.TextureLoader; +import com.sun.j3d.utils.shader.StringIO; +import javax.media.j3d.*; +import javax.vecmath.*; +import java.awt.GraphicsConfiguration; +import java.io.IOException; +import java.net.URL; +import javax.swing.JOptionPane; +import org.jdesktop.j3d.examples.Resources; + +public class SamplerTestCg extends javax.swing.JFrame { + + private static String cloudTexName = "resources/images/bg.jpg"; + private static String earthTexName = "resources/images/earth.jpg"; + private static String fragmentProgName = "cg_shader/multitex_fp.cg"; + private URL cloudURL = null; + private URL earthURL = null; + private static final int CLOUD = 0; + private static final int EARTH = 1; + + SimpleUniverse univ = null; + + public BranchGroup createSceneGraph() { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + + // Create texture objects + cloudURL = Resources.getResource(cloudTexName); + Texture cloudTex = new TextureLoader(cloudURL, this).getTexture(); + earthURL = Resources.getResource(earthTexName); + Texture earthTex = new TextureLoader(earthURL, this).getTexture(); + + // Create the shader program + String vertexProgram = null; + String fragmentProgram = null; + try { + fragmentProgram = StringIO.readFully(Resources.getResource(fragmentProgName)); + } + catch (IOException e) { + System.err.println(e); + } + Shader[] shaders = new Shader[1]; + shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG, + Shader.SHADER_TYPE_FRAGMENT, + fragmentProgram); + final String[] shaderAttrNames = { + "cloudFactor" + }; + final Object[] shaderAttrValues = { + new Float(0.6f), + }; + ShaderProgram shaderProgram = new CgShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + // Create the shader attribute set + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + for (int i = 0; i < shaderAttrNames.length; i++) { + ShaderAttribute shaderAttribute = + new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); + shaderAttributeSet.put(shaderAttribute); + } + + // Create shader appearance to hold the shader program and + // shader attributes + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + app.setShaderAttributeSet(shaderAttributeSet); + + // Setup texture coordinate generation + Vector4f plane0S = new Vector4f(3.0f, 1.5f, 0.3f, 0.0f); + Vector4f plane0T = new Vector4f(1.0f, 2.5f, 0.24f, 0.0f); + TexCoordGeneration tcg0 = + new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, + TexCoordGeneration.TEXTURE_COORDINATE_2, plane0S, plane0T); + + // Setup texture coordinate generation + TexCoordGeneration tcg1 = + new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, + TexCoordGeneration.TEXTURE_COORDINATE_2); + + // Put the textures in unit 0,1 + TextureUnitState[] tus = new TextureUnitState[2]; + tus[CLOUD] = new TextureUnitState(); + tus[CLOUD].setTexture(cloudTex); + tus[CLOUD].setTexCoordGeneration(tcg0); + tus[EARTH] = new TextureUnitState(); + tus[EARTH].setTexture(earthTex); + tus[EARTH].setTexCoordGeneration(tcg1); + app.setTextureUnitState(tus); + + // Create a Sphere object using the shader appearance, + // and add it into the scene graph. + Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 30, app); + objTrans.addChild(sph); + + // Create a new Behavior object that will perform the + // desired operation on the specified transform and add + // it into the scene graph. + Transform3D yAxis = new Transform3D(); + Alpha rotationAlpha = new Alpha(-1, 4000); + + RotationInterpolator rotator = + new RotationInterpolator(rotationAlpha, objTrans, yAxis, + 0.0f, (float) Math.PI*2.0f); + BoundingSphere bounds = + new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); + rotator.setSchedulingBounds(bounds); + objRoot.addChild(rotator); + + // Have Java 3D perform optimizations on this scene graph. + //objRoot.compile(); + + return objRoot; + } + + private Canvas3D initScene() { + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + BranchGroup scene = createSceneGraph(); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) { + error.printVerbose(); + JOptionPane.showMessageDialog(SamplerTestCg.this, + error.toString(), + "ShaderError", + JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form SamplerTestCg + */ + public SamplerTestCg() { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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() { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("SamplerTestCg"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new SamplerTestCg().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/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form b/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form new file mode 100644 index 0000000..ef60e53 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form @@ -0,0 +1,36 @@ +<?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="SphereCg"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.form b/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.form new file mode 100644 index 0000000..736b93c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.form @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="fileMenu"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem"> + <Properties> + <Property name="text" type="java.lang.String" value="Exit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="title" type="java.lang.String" value="Vertex Attribute Test"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/> + </Events> + <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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="mainPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="guiPanel"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="vertexCheckBoxPanel"> + <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="vertexFormat"> + <Font PropertyName="font" name="Lucida Sans" size="10" style="0"/> + </TitledBorder> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JSeparator" name="jSeparator1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 4]"/> + </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="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 4]"/> + </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="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JCheckBox" name="vertexAttrsBox"> + <Properties> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="VertexAttrs"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="geometryPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="createButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Create Geometry"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="destroyButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Destroy Geometry"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="destroyButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="2" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java b/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java new file mode 100644 index 0000000..b9d6185 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/VertexAttrTestCg.java @@ -0,0 +1,407 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ +package org.jdesktop.j3d.examples.cg_shader; + +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.shader.StringIO; +import javax.media.j3d.*; +import java.awt.GraphicsConfiguration; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.vecmath.Color3f; +import javax.vecmath.Point3d; +import org.jdesktop.j3d.examples.Resources; + + +public class VertexAttrTestCg extends javax.swing.JFrame { + + SimpleUniverse univ = null; + BranchGroup scene = null; + + public BranchGroup createSceneGraph(boolean hasVertexAttrs) { + + // Bounds for BG and behavior + BoundingSphere bounds = + new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); + + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + objRoot.setCapability(BranchGroup.ALLOW_DETACH); + + // Set up the background + Color3f bgColor = new Color3f(0.1f, 0.1f, 0.1f); + Background bg = new Background(bgColor); + bg.setApplicationBounds(bounds); + objRoot.addChild(bg); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + + // Create a simple Shape3D node; add it to the scene graph. + objTrans.addChild(new MyShape(this, hasVertexAttrs)); + + return objRoot; + } + + private Canvas3D initScene() { + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) { + error.printVerbose(); + JOptionPane.showMessageDialog(VertexAttrTestCg.this, + error.toString(), + "ShaderError", + JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + return c; + } + + /** + * Creates new form VertexAttrTestCg + */ + public VertexAttrTestCg() { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + static class MyShape extends Shape3D { + // Coordinate data + private static final float[] coords = { + 0.0f, 0.0f, 0.0f, + 0.5f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, + }; + + private static final int[] sizes = { 1, 3 }; + private static final float[] weights = { + 0.45f, + 0.15f, + 0.95f, + }; + private static final float[] temps = { + 1.0f, 0.5f, 0.5f, + 0.5f, 1.0f, 0.5f, + 0.5f, 0.5f, 1.0f, + }; + + private static final String[] vaNames = { "weight", "temperature" }; + + J3DBuffer createDirectFloatBuffer(float[] arr) { + ByteOrder order = ByteOrder.nativeOrder(); + + FloatBuffer nioBuf = ByteBuffer.allocateDirect(arr.length * 4).order(order).asFloatBuffer(); + nioBuf.put(arr); + return new J3DBuffer(nioBuf); + } + + + MyShape(JFrame frame, boolean hasVertexAttrs) { + + int vertexFormat = GeometryArray.COORDINATES; + int vertexAttrCount = 0; + int[] vertexAttrSizes = null; + String[] vertexAttrNames = null; + String[] shaderAttrNames = null; + + if (hasVertexAttrs) { + vertexFormat |= GeometryArray.VERTEX_ATTRIBUTES; + vertexAttrCount = vaNames.length; + vertexAttrSizes = sizes; + vertexAttrNames = vaNames; + } + + TriangleArray tri = new TriangleArray(6, vertexFormat, 0, null, vertexAttrCount, vertexAttrSizes); + tri.setValidVertexCount(3); + tri.setCoordinates(0, coords); + + if (hasVertexAttrs) { + tri.setVertexAttrs(0, 0, weights); + tri.setVertexAttrs(1, 0, temps); + + + String vertexProgram = null; + try { + vertexProgram = StringIO.readFully(Resources.getResource("cg_shader/vertexshader_vp.cg")); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Shader[] shaders = new Shader[1]; + shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_CG, + Shader.SHADER_TYPE_VERTEX, + vertexProgram); + ShaderProgram shaderProgram = new CgShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setVertexAttrNames(vertexAttrNames); + + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + + this.setGeometry(tri); + this.setAppearance(app); + + } else { + this.setGeometry(tri); + this.setAppearance(new Appearance()); + } + } + } + + // ---------------------------------------------------------------- + + /** 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; + + mainPanel = new javax.swing.JPanel(); + guiPanel = new javax.swing.JPanel(); + vertexCheckBoxPanel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jSeparator1 = new javax.swing.JSeparator(); + jSeparator2 = new javax.swing.JSeparator(); + jPanel2 = new javax.swing.JPanel(); + vertexAttrsBox = new javax.swing.JCheckBox(); + geometryPanel = new javax.swing.JPanel(); + createButton = new javax.swing.JButton(); + destroyButton = new javax.swing.JButton(); + drawingPanel = new javax.swing.JPanel(); + jMenuBar1 = new javax.swing.JMenuBar(); + fileMenu = new javax.swing.JMenu(); + exitMenuItem = new javax.swing.JMenuItem(); + + setTitle("Vertex Attribute Test"); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + exitForm(evt); + } + }); + + mainPanel.setLayout(new java.awt.BorderLayout()); + + guiPanel.setLayout(new java.awt.GridBagLayout()); + + guiPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + vertexCheckBoxPanel.setLayout(new java.awt.GridBagLayout()); + + vertexCheckBoxPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "vertexFormat", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Sans", 0, 10))); + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel1.add(jSeparator1, gridBagConstraints); + + jSeparator2.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + jPanel1.add(jSeparator2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel1, gridBagConstraints); + + jPanel2.setLayout(new java.awt.GridBagLayout()); + + vertexAttrsBox.setSelected(true); + vertexAttrsBox.setText("VertexAttrs"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + jPanel2.add(vertexAttrsBox, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(vertexCheckBoxPanel, gridBagConstraints); + + geometryPanel.setLayout(new java.awt.GridBagLayout()); + + createButton.setText("Create Geometry"); + createButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + createButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + geometryPanel.add(createButton, gridBagConstraints); + + destroyButton.setText("Destroy Geometry"); + destroyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + destroyButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); + geometryPanel.add(destroyButton, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(geometryPanel, gridBagConstraints); + + mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH); + + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER); + + getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER); + + fileMenu.setText("File"); + exitMenuItem.setText("Exit"); + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exitMenuItemActionPerformed(evt); + } + }); + + fileMenu.add(exitMenuItem); + + jMenuBar1.add(fileMenu); + + setJMenuBar(jMenuBar1); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void destroyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_destroyButtonActionPerformed + if (scene != null) { + univ.getLocale().removeBranchGraph(scene); + scene = null; + } + }//GEN-LAST:event_destroyButtonActionPerformed + + private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createButtonActionPerformed + if (scene == null) { + boolean hasVertexAttrs = vertexAttrsBox.isSelected(); + scene = createSceneGraph(hasVertexAttrs); + univ.addBranchGraph(scene); + } + }//GEN-LAST:event_createButtonActionPerformed + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + /** Exit the Application */ + private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm + System.exit(0); + }//GEN-LAST:event_exitForm + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new VertexAttrTestCg().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton createButton; + private javax.swing.JButton destroyButton; + private javax.swing.JPanel drawingPanel; + private javax.swing.JMenuItem exitMenuItem; + private javax.swing.JMenu fileMenu; + private javax.swing.JPanel geometryPanel; + private javax.swing.JPanel guiPanel; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JSeparator jSeparator2; + private javax.swing.JPanel mainPanel; + private javax.swing.JCheckBox vertexAttrsBox; + private javax.swing.JPanel vertexCheckBoxPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg b/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg new file mode 100644 index 0000000..400a252 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg @@ -0,0 +1,56 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +float4 main(float2 tc0 : TEXCOORD0, + float2 tc1: TEXCOORD1, + uniform float cloudFactor, + uniform sampler2D earthTex : TEXUNIT1, + uniform sampler2D cloudTex : TEXUNIT0): COLOR +{ + float3 color0 = tex2D(cloudTex, tc0).rgb; + float3 color1 = tex2D(earthTex, tc1).rgb; + float3 finalColor = color0*cloudFactor + color1; + + return float4(finalColor, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg b/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg new file mode 100644 index 0000000..0e44251 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg @@ -0,0 +1,77 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + + +// define inputs from application +struct appin +{ + float4 Position : POSITION; + float4 Normal : NORMAL; +}; + +// define outputs from vertex shader +struct vertout +{ + float4 Position : POSITION; + float4 Color0 : COLOR0; +}; + + +vertout main(appin IN, + float3 temperature, + float weight, + uniform float4x4 ModelViewProj) +{ + vertout OUT; + + ModelViewProj = glstate.matrix.mvp; + + // transform vertex position into homogenous clip-space + OUT.Position = mul(ModelViewProj, IN.Position); + + // Compute color from temperature, weight + OUT.Color0 = float4(temperature * weight, 1.0); + + return OUT; +} diff --git a/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form new file mode 100644 index 0000000..5a555b4 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form @@ -0,0 +1,36 @@ +<?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="TickTockCollision"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg new file mode 100644 index 0000000..d291913 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg @@ -0,0 +1,149 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for single fullscreen desktop configuration. + * A view platform behavior is created and configured here as well. + * + ************************************************************************ + */ + +// Create a new screen object and associate it with a logical name and a +// number. This number is used as an index to retrieve the AWT GraphicsDevice +// from the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen center 0) + +// Create a fullscreen window +// +(ScreenAttribute center WindowSize NoBorderFullScreen) + +// Set the available image area for the full screen. +// +(ScreenAttribute center PhysicalScreenWidth 0.360) +(ScreenAttribute center PhysicalScreenHeight 0.288) + +// Set the TrackerBaseToImagePlate transform for this screen. The coexistence +// to tracker base transform is identity by default, so the tracker base origin +// and orientation will also set the origin and orientation of coexistence +// coordinates in the physical world. This is the primary purpose of setting +// this transform when neither head tracking nor multiple screens are being +// used. +// +// The tracker base and center of coexistence are set here to the middle of the +// screen's image plate. Their basis vectors are aligned with the image plate +// basis vectors. The physical eyepoint position will be set relative to +// coexistence coordinates below. +// +(ScreenAttribute center TrackerBaseToImagePlate + (Translate 0.180 0.144 0.000)) + +// Create a view using the defined screen. +// +(NewView view0) +(ViewAttribute view0 Screen center) + +// Set the eyepoint relative to coexistence coordinates. Here it is set 45cm +// toward the user along +Z. Skewed projections can be set by by offsetting +// the eyepoint along X and Y. +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45)) + +// Create a view platform behavior. Here we use OrbitBehavior, although any +// concrete subclass of the abstract ViewPlatformBehavior with a parameterless +// constructor could be used. The logical name to assign to this behavior is +// specified by the 2nd argument to the NewViewPlatformBehavior command, while +// the 3rd argument is the name of the ViewPlatformBehavior subclass. It is +// instantiated through introspection. +// +// Attributes defined by the abstract ViewPlatformBehavior superclass itself +// can be set directly with the ViewPlatformBehaviorAttribute command. The +// details of the subclass implementation are not known to ConfiguredUniverse, +// so any configuration information needed by such a subclass is set by the +// ViewPlatformBehaviorProperty command. The property name specified by that +// command is taken to be a method name of the subclass and invoked through +// introspection. +// +// View platform behaviors often need sensors or canvases as event sources to +// drive the behavior action. An implementation of ViewPlatformBehavior always +// gets the current ViewingPlatform through the setViewingPlatform() method. +// The canvases used by the ViewingPlatform can be retrieved by calling its +// getViewers() method and then calling each Viewer's getCanvas3Ds() +// method. Sensors can be retrived by calling the ViewingPlatform method +// getUniverse(), checking to see if the returned SimpleUniverse is a +// ConfiguredUniverse, and then calling its getNamedSensors() method. +// +(NewViewPlatformBehavior vpb com.sun.j3d.utils.behaviors.vp.OrbitBehavior) + +// Set the scheduling bounds to be a BoundingSphere with its center at +// (0.0 0.0 0.0) and a radius of 100 meters. +// +(ViewPlatformBehaviorAttribute vpb SchedulingBounds + (BoundingSphere (0.0 0.0 0.0) 100.0)) + +// Set properties specific to OrbitBehavior. All arguments following the +// method name are wrapped and passed to the specified method as an array of +// Objects. Strings "true" and "false" get turned into Boolean, and number +// strings get turned into Double. Constructs such as (0.0 1.0 2.0) and +// ((0.0 1.0 2.0 0.5) (3.0 4.0 5.0 1.0) (6.0 7.0 8.0 0.0)) get converted to +// Point3d and Matrix4d respectively. Note that last row of a Matrix4d doesn't +// need to be specified; it is implicitly (0.0 0.0 0.0 1.0). +// +// The REVERSE_ALL flags are usually passed to the OrbitBehavior constructor. +// Since it is being instantiated with its parameterless constructor the +// reverse flags are set here explicitly. +// +(ViewPlatformBehaviorProperty vpb ReverseTranslate true) +(ViewPlatformBehaviorProperty vpb ReverseRotate true) +(ViewPlatformBehaviorProperty vpb ReverseZoom true) + +// Create a new view platform and set the view platform behavior. +// +(NewViewPlatform vp) +(ViewPlatformAttribute vp ViewPlatformBehavior vpb) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg new file mode 100644 index 0000000..3db4070 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg @@ -0,0 +1,113 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for single fullscreen stereo desktop + * configuration with no head tracking. + * + ************************************************************************ + */ + +// Create a new screen object and associate it with a logical name and a +// number. This number is used as an index to retrieve the AWT GraphicsDevice +// from the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen center 0) + +// Create a fullscreen window +// +(ScreenAttribute center WindowSize NoBorderFullScreen) + +// Set the available image area for the full screen. +// +(ScreenAttribute center PhysicalScreenWidth 0.360) +(ScreenAttribute center PhysicalScreenHeight 0.288) + +// Set the TrackerBaseToImagePlate transform for this screen. The coexistence +// to tracker base transform is identity by default, so the tracker base origin +// and orientation will also set the origin and orientation of coexistence +// coordinates in the physical world. This is the primary purpose of setting +// this transform when neither head tracking nor multiple screens are being +// used. +// +// The tracker base and center of coexistence are set here to the middle of the +// screen's image plate. Their basis vectors are aligned with the image plate +// basis vectors. The physical eyepoint position will be set relative to +// coexistence coordinates below. +// +(ScreenAttribute center TrackerBaseToImagePlate + (Translate 0.180 0.144 0.000)) + +// Define the physical body. +// +// The head origin is halfway between the eyes, with X extending to the right, +// Y up, and positive Z extending into the skull. +// +(NewPhysicalBody SiteUser) + +// Set the interpupilary distance. This sets the LeftEyePosition and +// RightEyePosition to offsets of half this distance along both directions of +// the X axis. +// +(PhysicalBodyAttribute SiteUser StereoEyeSeparation 0.066) + +// Create a view using the defined screen and physical body. +// +(NewView view0) +(ViewAttribute view0 Screen center) +(ViewAttribute view0 PhysicalBody SiteUser) + +// Set the eyepoint relative to coexistence coordinates. Here it is set 45cm +// toward the user along +Z. +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45)) + +// Enable stereo viewing. +// +(ViewAttribute view0 StereoEnable true) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr.cfg new file mode 100644 index 0000000..587f481 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-vr.cfg @@ -0,0 +1,212 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a single screen stereo desktop display + * using a head tracker and 6DOF mouse. + * + ************************************************************************ + */ + +// Configure the head tracker. The NewDevice command binds a logical name +// (the 2nd argument) to an InputDevice implementation whose class name is +// specified in the 3rd argument. The InputDevice implementation for a head +// tracker must generate position and orientation data relative to a fixed +// frame of reference in the physical world, the "tracker base" of the Java +// 3D view model. +// +// The InputDevice is instantiated through introspection of the class name. +// Available InputDevice implementations are site-specific, so substitute +// the class name in a NewDevice command below with one that is available at +// the local site. +// +// Note that properties are used to configure an InputDevice instead of +// attributes. The details of an InputDevice implementation are not known to +// ConfiguredUniverse, so the property name is invoked as a method through +// introspection. The example properties below must be replaced with the ones +// needed, if any, by specific InputDevice implementations. +// +// All property arguments following the method name are wrapped and passed to +// the specified method as an array of Objects. Strings "true" and "false" +// get wrapped into Boolean, and number strings get wrapped into Double. +// Construct such as (0.0 1.0 2.0) and ((0.0 1.0 2.0 0.5) (3.0 4.0 5.0 1.0) +// (6.0 7.0 8.0 0.0)) get converted to Point3d and Matrix4d respectively. +// Note that last row of a Matrix4d doesn't need to be specified; it is +// implicitly (0.0 0.0 0.0 1.0). +// +(NewDevice glasses LogitechRedBarron) +(DeviceProperty glasses SerialPort "/dev/ttya") // Unix paths need quoting. +(DeviceProperty glasses ReceiverBaseline 0.1450) +(DeviceProperty glasses ReceiverLeftLeg 0.0875) +(DeviceProperty glasses ReceiverHeight 0.0470) +(DeviceProperty glasses ReceiverTopOffset 0.0000) + +// Configure an InputDevice to use for a 6 degree of freedom mouse if +// required. In some implementations the same InputDevice instance can be +// used both for head tracking and multiple peripheral sensing devices. +// This example assumes an implementation that requires multiple instances, +// one for each sensor, sharing the same physical hardware used for the +// tracker base. In either case all the sensors must generate position and +// orientation relative to the same fixed tracker base frame of reference. +// +(NewDevice wand LogitechRedBarron) +(DeviceProperty wand SerialPort "/dev/ttyb") +(DeviceProperty wand ReceiverBaseline 0.0700) +(DeviceProperty wand ReceiverLeftLeg 0.0625) +(DeviceProperty wand ReceiverHeight 0.0510) +(DeviceProperty wand ReceiverTopOffset 0.0000) + +// Create logical names for the available sensors in the specified input +// devices. The last argument is the sensor's index in the input device. +// +(NewSensor head glasses 0) +(NewSensor mouse6d wand 0) + +// Set the 6DOF mouse sensor hotspot in the local sensor coordinate system. +// The hotspot is simply the "active" point relative to the sensor origin +// which interacts with the virtual world, such as the point used for picking +// or grabbing an object. Its interpretation is up to the sensor behavior. +// +// It is set here to 10 centimeters from the base to allow reaching into the +// screen without bumping the device into the glass, and to prevent the device +// itself from obscuring the pointer echo. +// +(SensorAttribute mouse6d Hotspot (0.0 0.0 -0.10)) + + +// Create a new screen object and associate it with a logical name and a +// number. This number is used as an index to retrieve the AWT GraphicsDevice +// from the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen center 0) + +// Set the actual available image area. This measured as 0.350 meters in +// width and 0.245 meters in height for the monitor in the sample setup when +// running in stereo resolution. +// +(ScreenAttribute center PhysicalScreenWidth 0.350) +(ScreenAttribute center PhysicalScreenHeight 0.245) +(ScreenAttribute center WindowSize NoBorderFullScreen) + +// Set the TrackerBaseToImagePlate transform for this screen. This transforms +// points in tracker base coordinates to image plate coordinates. +// +// For this sample setup the tracker base is leaning at 50 degrees about its +// X-axis over the top edge of the monitor. The middle of the tracker base +// (its origin) is offset by (0.175, 0.345, 0.020) from the lower left +// corner of the screen (origin of the image plate). +// +(ScreenAttribute center TrackerBaseToImagePlate + (RotateTranslate (Rotate 50.000 0.000 0.000) + (Translate 0.175 0.345 0.020))) + + +// Create a physical environment. This contains the available input devices, +// audio devices, and sensors, and defines the coexistence coordinate system. +// +(NewPhysicalEnvironment SampleSite) + +// Register the input devices defined in this file. +// +(PhysicalEnvironmentAttribute SampleSite InputDevice glasses) +(PhysicalEnvironmentAttribute SampleSite InputDevice wand) + +// Register the sensor which will drive head tracking. +// +(PhysicalEnvironmentAttribute SampleSite HeadTracker head) + +// Define coexistence coordinates. +// +// Coexistence coordinates are defined relative to the tracker base to simplify +// calibration measurements, just as the tracker base is used as the common +// reference frame for the TrackerBaseToImagePlate calibration. +// +// Here the coexistence origin is set to the middle of the center screen, using +// the same basis vectors as its image plate. This will put the tracker base +// origin at (0.0 0.220 0.020) relative to the coexistence origin along its +// basis vectors. +// +(PhysicalEnvironmentAttribute SampleSite CoexistenceToTrackerBase + (TranslateRotate (Translate 0.0 -0.220 -0.020) + (Rotate -50.0 0.0 0.0))) + +// Define the physical body. +// +// The head origin is halfway between the eyes, with X extending to the right, +// Y up, and positive Z extending into the skull. +// +(NewPhysicalBody SiteUser) + +// Set the interpupilary distance. This sets the LeftEyePosition and +// RightEyePosition to offsets of half this distance along both directions of +// the X axis. +// +(PhysicalBodyAttribute SiteUser StereoEyeSeparation 0.066) + +// Define the position and orientation of the head relative to the tracker +// mounted on the head. +// +(PhysicalBodyAttribute SiteUser HeadToHeadTracker ((1.0 0.0 0.0 0.000) + (0.0 1.0 0.0 0.020) + (0.0 0.0 1.0 0.018))) + + +// Create a view using the defined screens, PhysicalEnvironment, and +// PhysicalBody. +// +(NewView view0) +(ViewAttribute view0 Screen center) +(ViewAttribute view0 PhysicalEnvironment SampleSite) +(ViewAttribute view0 PhysicalBody SiteUser) + +// Enable stereo viewing. Enable head tracking to get the position of the eyes +// with respect to coexistence. +// +(ViewAttribute view0 StereoEnable true) +(ViewAttribute view0 TrackingEnable True) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg new file mode 100644 index 0000000..eec0e31 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg @@ -0,0 +1,89 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a conventional single screen, windowed + * desktop configuration. + * + ************************************************************************ + */ + +// Create a new screen object and associate it with a logical name and a +// number. This number is used as an index to retrieve the AWT GraphicsDevice +// from the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen center 0) + +// Create a 700x700 pixel window on the screen. +// +(ScreenAttribute center WindowSize (700.0 700.0)) + +// Create a view using the defined screen. +// +(NewView view0) +(ViewAttribute view0 Screen center) + +// ConfiguredUniverse is oriented toward multi-screen viewing environments, so +// it sets the following attributes to those listed. For a conventional window +// on a single screen desktop configuration we need to set them back to their +// normal defaults. +// +// View.windowEyePointPolicy RELATIVE_TO_COEXISTENCE +// View.windowMovementPolicy VIRTUAL_WORLD +// View.windowResizePolicy VIRTUAL_WORLD +// View.coexistenceCenteringEnable false +// ViewPlatform.viewAttachPolicy NOMINAL_SCREEN +// +(ViewAttribute view0 WindowEyepointPolicy RELATIVE_TO_FIELD_OF_VIEW) +(ViewAttribute view0 WindowMovementPolicy PHYSICAL_WORLD) +(ViewAttribute view0 WindowResizePolicy PHYSICAL_WORLD) +(ViewAttribute view0 CoexistenceCenteringEnable true) + +(NewViewPlatform vp) +(ViewPlatformAttribute vp ViewAttachPolicy NOMINAL_HEAD) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg new file mode 100644 index 0000000..41173e3 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg @@ -0,0 +1,98 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a single fullscreen desktop configuration. + * + ************************************************************************ + */ + +// Create a new screen object and associate it with a logical name and a +// number. This number is used as an index to retrieve the AWT GraphicsDevice +// from the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen center 0) + +// Create a fullscreen window +// +(ScreenAttribute center WindowSize NoBorderFullScreen) + +// Set the available image area for the full screen. This is important when an +// explicit ScreenScale view attribute is defined for precise scaling between +// objects in the virtual world and their projections into the physical world. +// The defaults are 0.365 meters for width and 0.292 meters for height. +// +(ScreenAttribute center PhysicalScreenWidth 0.360) +(ScreenAttribute center PhysicalScreenHeight 0.288) + +// Set the TrackerBaseToImagePlate transform for this screen. The coexistence +// to tracker base transform is identity by default, so the tracker base origin +// and orientation will also set the origin and orientation of coexistence +// coordinates in the physical world. This is the primary purpose of setting +// this transform when neither head tracking nor multiple screens are being +// used. +// +// The tracker base and center of coexistence are set here to the middle of the +// screen's image plate. Their basis vectors are aligned with the image plate +// basis vectors. The physical eyepoint position will be set relative to +// coexistence coordinates below. +// +(ScreenAttribute center TrackerBaseToImagePlate + (Translate 0.180 0.144 0.000)) + +// Create a view using the defined screen. +// +(NewView view0) +(ViewAttribute view0 Screen center) + +// Set the eyepoint relative to coexistence coordinates. Here it is set 45cm +// toward the user along +Z. Skewed projections can be created by offsetting +// the eyepoint along X and/or Y. +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45)) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg new file mode 100644 index 0000000..667ea52 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg @@ -0,0 +1,134 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for dual-screen (flat) desktop configuration + * with no head tracking. + * + ************************************************************************ + */ + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen left 0) +(NewScreen right 1) + +// Set the screen dimensions. +// +(ScreenAttribute left PhysicalScreenWidth 0.360) +(ScreenAttribute left PhysicalScreenHeight 0.288) + +(ScreenAttribute right PhysicalScreenWidth 0.360) +(ScreenAttribute right PhysicalScreenHeight 0.288) + +// Specify full screen windows. +// +(ScreenAttribute left WindowSize NoBorderFullScreen) +(ScreenAttribute right WindowSize NoBorderFullScreen) + +// Set the TrackerBaseToImagePlate transforms for these screens. This +// transforms points in tracker base coordinates to each screen's image plate +// coordinates, where the origin of the image plate is defined to be the lower +// left corner of the screen with X increasing to the right, Y increasing to +// the top, and Z increasing away from the screen. +// +// Without head or sensor tracking the tracker base is still needed as a fixed +// frame of reference for describing the orientation and position of each +// screen to the others. The coexistence to tracker base transform is set to +// identity by default, so the tracker base origin and orientation will also +// set the origin and orientation of coexistence coordinates in the physical +// world. +// +// The tracker base and center of coexistence is set here to the middle of the +// edge shared by the two screens. +// +(ScreenAttribute left TrackerBaseToImagePlate + (Translate 0.360 0.144 0.0)) +(ScreenAttribute right TrackerBaseToImagePlate + (Translate 0.000 0.144 0.0)) + +// Sometimes it is desirable to include the bevels in between the monitors in +// the TrackerBaseToImagePlate transforms, so that the abutting bevels obscure +// the view of the virtual world instead of stretching it out between the +// monitors. For a bevel width of 4.5 cm on each monitor, the above commands +// would become the following: +// +// (ScreenAttribute left TrackerBaseToImagePlate +// (Translate 0.405 0.144 0.0)) +// (ScreenAttribute right TrackerBaseToImagePlate +// (Translate -0.045 0.144 0.0)) +// +// Conversely, a similar technique may be used to include overlap between the +// screens. This is useful for projection systems which use edge blending +// to provide seamless integration between screens. + + +// Create a view using the defined screens. +// +(NewView view0) +(ViewAttribute view0 Screen left) +(ViewAttribute view0 Screen right) + +// Set the eyepoint relative to coexistence coordinates. Here it is set 45cm +// toward the user along Z, extending out from the midpoint of the edge shared +// by the two screens. This will create the appropriate skewed projection +// frustums for each image plate. +// +// If a planar display surface is all that is required, the same effect could +// be achieved in a virtual screen enviroment such as Xinerama by simply +// creating a canvas that spans both screens. In some display environments the +// use of a canvas that spans multiple physical screens may cause significant +// performance degradation, however. +// +// See j3d1x2-rot30 for an example of a non-planar configuration that cannot be +// achieved through a single canvas spanning both screens. +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45)) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg new file mode 100644 index 0000000..68f4a6e --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg @@ -0,0 +1,99 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a dual-screen desktop configuration + * with each screen rotated toward the other by 30 degrees about Y from + * planar. The inside angle between them is 120 degrees. + * + ************************************************************************ + */ + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen left 0) +(NewScreen right 1) + +// Set the available image areas for full screens. +// +(ScreenAttribute left PhysicalScreenWidth 0.360) +(ScreenAttribute left PhysicalScreenHeight 0.288) + +(ScreenAttribute right PhysicalScreenWidth 0.360) +(ScreenAttribute right PhysicalScreenHeight 0.288) + +// Specify full screen windows. +// +(ScreenAttribute left WindowSize NoBorderFullScreen) +(ScreenAttribute right WindowSize NoBorderFullScreen) + +// Set the TrackerBaseToImagePlate transforms for these screens. +// +// The tracker base is set here to the middle of the edge shared by the two +// screens. Each screen is rotated 30 degrees toward the other about the +// tracker base +Y axis, so that the tracker base +Z is centered between the +// two screens. +// +(ScreenAttribute left TrackerBaseToImagePlate + (RotateTranslate (Rotate 0.000 -30.000 0.0) + (Translate 0.360 0.144 0.0))) + +(ScreenAttribute right TrackerBaseToImagePlate + (RotateTranslate (Rotate 0.000 30.000 0.0) + (Translate 0.000 0.144 0.0))) + + +// Create a view using the defined screens. +// +(NewView view0) +(ViewAttribute view0 Screen left) +(ViewAttribute view0 Screen right) +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45)) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr.cfg new file mode 100644 index 0000000..029decf --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave-vr.cfg @@ -0,0 +1,222 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a cave environment with head tracking and + * stereo viewing. This cave consists of 3 projectors with 3 screens to the + * left, front, and right of the user, all at 90 degrees to each other. + * + * The projectors in the VirtualPortal sample site are actually turned + * on their sides to get more height. Screen 0 is rotated 90 degrees + * counter-clockwise, while screens 1 and 2 are rotated 90 degrees + * clockwise. + * + ************************************************************************ + */ + +// Configure the head tracker. The NewDevice command binds a logical name +// (the 2nd argument) to an InputDevice implementation whose class name is +// specified in the 3rd argument. The InputDevice implementation for a head +// tracker must generate position and orientation data relative to a fixed +// frame of reference in the physical world, the "tracker base" of the Java +// 3D view model. +// +// The InputDevice is instantiated through introspection of the class name. +// Available InputDevice implementations are site-specific, so substitute +// the class name in a NewDevice command below with one that is available at +// the local site. +// +// Note that properties are used to configure an InputDevice instead of +// attributes. The details of an InputDevice implementation are not known to +// ConfiguredUniverse, so the property name is invoked as a method through +// introspection. The example properties below must be replaced with the ones +// needed, if any, by specific InputDevice implementations. All arguments +// following the method name are wrapped and passed to the specified method as +// an array of Objects. +// +// All property arguments following the method name are wrapped and passed to +// the specified method as an array of Objects. Strings "true" and "false" +// get wrapped into Boolean, and number strings get wrapped into Double. +// Construct such as (0.0 1.0 2.0) and ((0.0 1.0 2.0 0.5) (3.0 4.0 5.0 1.0) +// (6.0 7.0 8.0 0.0)) get converted to Point3d and Matrix4d respectively. +// Note that last row of a Matrix4d doesn't need to be specified; it is +// implicitly (0.0 0.0 0.0 1.0). +// +(NewDevice glasses LogitechRedBarron) +(DeviceProperty glasses SerialPort "/dev/ttya") // Unix paths need quoting. +(DeviceProperty glasses TransmitterBaseline 0.4600) +(DeviceProperty glasses TransmitterLeftLeg 0.4400) +(DeviceProperty glasses TransmitterCalibrationDistance 0.4120) + +// Create a logical name for the head tracker sensor. The last argument is +// the sensor's index in the input device. +// +(NewSensor head glasses 0) + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen left 0) +(NewScreen center 1) +(NewScreen right 2) + + +// Set the available image areas as well as their positition and orientation +// relative to the tracker base. From the orientation of a user standing +// within this VirtualPortal site and facing the center screen, the tracker +// base is along the vertical midline of the screen, 0.248 meters down from +// the top edge, and 1.340 meters in front of it. The tracker base is +// oriented so that its +X axis points to the left, its +Y axis points toward +// the screen, and its +Z axis points toward the floor. +// +(ScreenAttribute left PhysicalScreenWidth 2.480) +(ScreenAttribute left PhysicalScreenHeight 1.705) +(ScreenAttribute left WindowSize NoBorderFullScreen) +(ScreenAttribute left TrackerBaseToImagePlate + (( 0.0 0.0 -1.0 2.230) + ( 0.0 -1.0 0.0 1.340) + (-1.0 0.0 0.0 0.885))) + +(ScreenAttribute center PhysicalScreenWidth 2.485) +(ScreenAttribute center PhysicalScreenHeight 1.745) +(ScreenAttribute center WindowSize NoBorderFullScreen) +(ScreenAttribute center TrackerBaseToImagePlate + (( 0.0 0.0 1.0 0.248) + (-1.0 0.0 0.0 0.885) + ( 0.0 -1.0 0.0 1.340))) + +(ScreenAttribute right PhysicalScreenWidth 2.480) +(ScreenAttribute right PhysicalScreenHeight 1.775) +(ScreenAttribute right WindowSize NoBorderFullScreen) +(ScreenAttribute right TrackerBaseToImagePlate + (( 0.0 0.0 1.0 0.2488) + ( 0.0 -1.0 0.0 1.340) + ( 1.0 0.0 0.0 0.860))) + +// Create a physical environment. This contains the available input devices, +// audio devices, and sensors, and defines the coexistence coordinate system +// for mapping between the virtual and physical worlds. +// +(NewPhysicalEnvironment VirtualPortal) + +// Register the input device defined in this file and the sensor which will +// drive head tracking. +// +(PhysicalEnvironmentAttribute VirtualPortal InputDevice glasses) +(PhysicalEnvironmentAttribute VirtualPortal HeadTracker head) + +// Set the location of the center of coexistence relative to the tracker base. +// Here it set to the center of the center screen. The default view attach +// policy of NOMINAL_SCREEN used by ConfiguredUniverse will place the origin of +// the view platform in coexistence coordinates at the center of coexistence. +// +(PhysicalEnvironmentAttribute VirtualPortal + CoexistenceToTrackerBase + ((-1.0 0.0 0.0 0.000) + ( 0.0 0.0 -1.0 1.340) + ( 0.0 -1.0 0.0 0.994))) + +// The above center of coexistence is appropriate for the sample geometry +// files available in the programs/examples directory. Often a more +// immersive point of view is required for larger virtual worlds. This can be +// achieved by placing the center of coexistence closer to the nominal position +// of the user's head, so that the view platform origin in coexistence +// coordinates will map there as well. +// +// Here we set the location of the center of coexistence 0.5 meters along the +// tracker base +Z axis, 1.737 meters from the floor (about 5 ft 8.4 inches). +// +// (PhysicalEnvironmentAttribute VirtualPortal +// CoexistenceToTrackerBase +// ((-1.0 0.0 0.0 0.0) +// ( 0.0 0.0 -1.0 0.0) +// ( 0.0 -1.0 0.0 0.5))) + + +// Define the physical body. +// +// The head origin is halfway between the eyes, with X extending to the right, +// Y up, and positive Z extending into the skull. +// +(NewPhysicalBody LabRat) +(PhysicalBodyAttribute LabRat StereoEyeSeparation .07) + +// Define the position and orientation of the head relative to the tracker +// mounted on the head. +// +(PhysicalBodyAttribute LabRat HeadToHeadTracker + ((-1.0 0.0 0.0 0.00) + ( 0.0 0.0 -1.0 0.05) + ( 0.0 -1.0 0.0 0.11))) +// Now define the view. +// +(NewView view0) +(ViewAttribute view0 Screen left) +(ViewAttribute view0 Screen center) +(ViewAttribute view0 Screen right) +(ViewAttribute view0 PhysicalBody LabRat) +(ViewAttribute view0 PhysicalEnvironment VirtualPortal) + +// Set the screen scale. This is scale factor from virtual to physical +// coordinates. +// +(ViewAttribute view0 ScreenScalePolicy SCALE_SCREEN_SIZE) + +// Alternative for explict scaling. +// +//(ViewAttribute view0 ScreenScalePolicy SCALE_EXPLICIT) +//(ViewAttribute view0 ScreenScale 5.00) + +// Enable stereo viewing. Enable head tracking to get the position of the eyes +// with respect to coexistence. Boolean values may be specified as either +// true, True, false, or False. +// +(ViewAttribute view0 StereoEnable true) +(ViewAttribute view0 TrackingEnable True) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg new file mode 100644 index 0000000..afc532c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg @@ -0,0 +1,171 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for a cave environment. This cave + * consists of 3 projectors with 3 screens to the left, front, and right + * of the user, all at 90 degrees to each other. + * + * The projectors in the VirtualPortal sample site are actually turned + * on their sides to get more height. Screen 0 is rotated 90 degrees + * counter-clockwise, while screens 1 and 2 are rotated 90 degrees + * clockwise. + * + ************************************************************************ + */ + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen left 0) +(NewScreen center 1) +(NewScreen right 2) + + +// Set the available image areas as well as their positition and orientation +// relative to the tracker base. Although this config file doesn't enable +// head tracking, the tracker base is still needed as a point of reference to +// describe the position and orientation of the screens relative to the +// environment. +// +// From the orientation of a user standing within this VirtualPortal site and +// facing the center screen, the tracker base is along the vertical midline of +// the screen, 0.248 meters down from the top edge, and 1.340 meters in front +// of it. The tracker base is oriented so that its +X axis points to the left, +// its +Y axis points toward the screen, and its +Z axis points toward the +// floor. +// +(ScreenAttribute left PhysicalScreenWidth 2.480) +(ScreenAttribute left PhysicalScreenHeight 1.705) +(ScreenAttribute left WindowSize NoBorderFullScreen) +(ScreenAttribute left TrackerBaseToImagePlate + (( 0.0 0.0 -1.0 2.230) + ( 0.0 -1.0 0.0 1.340) + (-1.0 0.0 0.0 0.885))) + +(ScreenAttribute center PhysicalScreenWidth 2.485) +(ScreenAttribute center PhysicalScreenHeight 1.745) +(ScreenAttribute center WindowSize NoBorderFullScreen) +(ScreenAttribute center TrackerBaseToImagePlate + (( 0.0 0.0 1.0 0.248) + (-1.0 0.0 0.0 0.885) + ( 0.0 -1.0 0.0 1.340))) + +(ScreenAttribute right PhysicalScreenWidth 2.480) +(ScreenAttribute right PhysicalScreenHeight 1.775) +(ScreenAttribute right WindowSize NoBorderFullScreen) +(ScreenAttribute right TrackerBaseToImagePlate + (( 0.0 0.0 1.0 0.2488) + ( 0.0 -1.0 0.0 1.340) + ( 1.0 0.0 0.0 0.860))) + +// Set the location of the center of coexistence relative to the tracker base. +// Here it set to the center of the center screen. This config file will set +// the location of the user's eyes relative to this point. The default view +// attach policy of NOMINAL_SCREEN used by ConfiguredUniverse will place the +// origin of the view platform in coexistence coordinates at the center of +// coexistence. +// +(NewPhysicalEnvironment VirtualPortal) +(PhysicalEnvironmentAttribute VirtualPortal + CoexistenceToTrackerBase + ((-1.0 0.0 0.0 0.000) + ( 0.0 0.0 -1.0 1.340) + ( 0.0 -1.0 0.0 0.994))) + +// The above center of coexistence is appropriate for the sample geometry +// files available in the programs/examples directory. Often a more +// immersive point of view is required for larger virtual worlds. This can be +// achieved by placing the center of coexistence closer to the nominal position +// of the user's head, so that the view platform origin in coexistence +// coordinates will map there as well. +// +// Here we set the location of the center of coexistence 0.5 meters along the +// tracker base +Z axis, 1.737 meters from the floor (about 5 ft 8.4 inches). +// +// (PhysicalEnvironmentAttribute VirtualPortal +// CoexistenceToTrackerBase +// ((-1.0 0.0 0.0 0.0) +// ( 0.0 0.0 -1.0 0.0) +// ( 0.0 -1.0 0.0 0.5))) + + +// Now define the view. +// +(NewView view0) +(ViewAttribute view0 Screen left) +(ViewAttribute view0 Screen center) +(ViewAttribute view0 Screen right) +(ViewAttribute view0 PhysicalEnvironment VirtualPortal) + +// Set the user eye position in the display environment. It is set here to +// 1.340 meters back from the center screen (directly under the tracker), and +// 1.737 meters from the floor (about 5 ft 8.4 inches). +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.494 1.340)) + +// Here is an alternative center eye position to use with the immersive +// coexistence coordinate system defined in comments above. +// +// (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.0)) + +// Set the screen scale. This is scale factor from virtual to physical +// coordinates. +// +(ViewAttribute view0 ScreenScalePolicy SCALE_SCREEN_SIZE) + +// Alternative for explict scaling. +// +// (ViewAttribute view0 ScreenScalePolicy SCALE_EXPLICIT) +// (ViewAttribute view0 ScreenScale 5.00) + +// No stereo viewing for this configuration. +// +(ViewAttribute view0 StereoEnable False) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg new file mode 100644 index 0000000..d221e74 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg @@ -0,0 +1,110 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for 3 screens. Left and right screens are + * rotated 45 degrees from the center screen. + * + ************************************************************************ + */ + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen left 0) +(NewScreen center 1) +(NewScreen right 2) + +// Set the available image areas for full screens. +// +(ScreenAttribute left PhysicalScreenWidth 0.360) +(ScreenAttribute left PhysicalScreenHeight 0.288) + +(ScreenAttribute center PhysicalScreenWidth 0.360) +(ScreenAttribute center PhysicalScreenHeight 0.288) + +(ScreenAttribute right PhysicalScreenWidth 0.360) +(ScreenAttribute right PhysicalScreenHeight 0.288) + +// Specify full screen windows. +// +(ScreenAttribute left WindowSize NoBorderFullScreen) +(ScreenAttribute center WindowSize NoBorderFullScreen) +(ScreenAttribute right WindowSize NoBorderFullScreen) + +// Set the TrackerBaseToImagePlate transforms for these screens. +// +// The tracker base and center of coexistence are set here to the middle of the +// center screen. The basis vectors are aligned with the center screen image +// plate. The left and right screens are rotated 45 degrees toward each other +// about their shared edges with the center screen. +// +(ScreenAttribute center TrackerBaseToImagePlate + (Translate 0.180000 0.144000 0.000000)) + +// cos(45) * 0.360 * 0.5 = 0.127279; 0.360 + 0.127279 = 0.487279 +(ScreenAttribute left TrackerBaseToImagePlate + (RotateTranslate + (Rotate 0.000000 -45.000000 0.000000) + (Translate 0.487279 0.144000 0.127279))) + +// cos(45) * 0.360 * 0.5 = 0.127279 +(ScreenAttribute right TrackerBaseToImagePlate + (RotateTranslate + (Rotate 0.000000 45.000000 0.000000) + (Translate -0.127279 0.144000 0.127279))) + +// Create a view using the defined screens. +// +(NewView view0) +(ViewAttribute view0 Screen left) +(ViewAttribute view0 Screen center) +(ViewAttribute view0 Screen right) +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.5)) diff --git a/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg new file mode 100644 index 0000000..46df9a3 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg @@ -0,0 +1,135 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +/* + ************************************************************************ + * + * Java 3D configuration file for 4 screen projection configuration + * arranged in a 2x2 power wall. + * + ************************************************************************ + */ + +// Create new screen objects and associate them with logical names and numbers. +// These numbers are used as indices to retrieve the AWT GraphicsDevice from +// the array that GraphicsEnvironment.getScreenDevices() returns. +// +// NOTE: The GraphicsDevice order in the array is specific to the local +// site and display system. +// +(NewScreen topleft 0) +(NewScreen topright 1) +(NewScreen bottomleft 3) +(NewScreen bottomright 2) + +// Set the available image areas for full screens. This is important when +// precise scaling between objects in the virtual world and their projections +// into the physical world is desired through use of explicit ScreenScale view +// attributes. The defaults are 0.365 meters for width and 0.292 meters for +// height. +// +(ScreenAttribute topleft PhysicalScreenWidth 0.912) +(ScreenAttribute topleft PhysicalScreenHeight 0.680) + +(ScreenAttribute topright PhysicalScreenWidth 0.912) +(ScreenAttribute topright PhysicalScreenHeight 0.680) + +(ScreenAttribute bottomleft PhysicalScreenWidth 0.912) +(ScreenAttribute bottomleft PhysicalScreenHeight 0.685) + +(ScreenAttribute bottomright PhysicalScreenWidth 0.912) +(ScreenAttribute bottomright PhysicalScreenHeight 0.685) + + +// Specify full screen windows. +// +(ScreenAttribute topleft WindowSize NoBorderFullScreen) +(ScreenAttribute topright WindowSize NoBorderFullScreen) +(ScreenAttribute bottomleft WindowSize NoBorderFullScreen) +(ScreenAttribute bottomright WindowSize NoBorderFullScreen) + +// Set the TrackerBaseToImagePlate transforms for these screens. This +// transforms points in tracker base coordinates to each screen's image plate +// coordinates, where the origin of the image plate is defined to be the lower +// left corner of the screen with X increasing to the right, Y increasing to +// the top, and Z increasing away from the screen. +// +// Without head or sensor tracking the tracker base is still needed as a point +// of reference for describing the orientation and position of each screen to +// the others. The coexistence to tracker base transform is set to identity by +// default, so the tracker base origin and orientation will also set the origin +// and orientation of coexistence coordinates in the physical world. +// +// The tracker base and center of coexistence are set here to the center of the +// 2x2 array with its basis vectors aligned to image plate coordinates. +// +(ScreenAttribute topleft TrackerBaseToImagePlate + (Translate 0.912 0.000 0.0)) +(ScreenAttribute topright TrackerBaseToImagePlate + (Translate 0.000 0.000 0.0)) +(ScreenAttribute bottomleft TrackerBaseToImagePlate + (Translate 0.912 0.685 0.0)) +(ScreenAttribute bottomright TrackerBaseToImagePlate + (Translate 0.000 0.685 0.0)) + +// Create a view using the defined screens. +// +(NewView view0) +(ViewAttribute view0 Screen topleft) +(ViewAttribute view0 Screen topright) +(ViewAttribute view0 Screen bottomleft) +(ViewAttribute view0 Screen bottomright) + +// Set the screen scale. This is scale factor from virtual to physical +// coordinates. The default policy of SCALE_SCREEN_SIZE doesn't work well here +// since in the 2x2 arrangement the individual screens are too small. The +// explicit scale factor below assumes a normalized range of object coordinates +// of [-1.0 .. +1.0]. +// +(ViewAttribute view0 ScreenScalePolicy SCALE_EXPLICIT) +(ViewAttribute view0 ScreenScale 0.912) + +// Set the user eye position in the display environment. +// +(ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 1.0)) diff --git a/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form new file mode 100644 index 0000000..22838dc --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form @@ -0,0 +1,36 @@ +<?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="DistortGlyphTest"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java new file mode 100644 index 0000000..8dbaada --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/dot3/Dot3Demo.java @@ -0,0 +1,551 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.dot3; + +import com.sun.j3d.utils.behaviors.vp.OrbitBehavior; +import com.sun.j3d.utils.geometry.GeometryInfo; +import com.sun.j3d.utils.image.TextureLoader; +import com.sun.j3d.utils.universe.SimpleUniverse; +import com.sun.j3d.utils.universe.ViewingPlatform; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.image.BufferedImage; + +import java.util.Enumeration; + +import javax.media.j3d.AmbientLight; +import javax.media.j3d.Appearance; +import javax.media.j3d.Background; +import javax.media.j3d.Behavior; +import javax.media.j3d.BoundingSphere; +import javax.media.j3d.BranchGroup; +import javax.media.j3d.Canvas3D; +import javax.media.j3d.DirectionalLight; +import javax.media.j3d.GeometryArray; +import javax.media.j3d.ImageComponent2D; +import javax.media.j3d.Material; +import javax.media.j3d.PolygonAttributes; +import javax.media.j3d.Shape3D; +import javax.media.j3d.TexCoordGeneration; +import javax.media.j3d.Texture; +import javax.media.j3d.Texture2D; +import javax.media.j3d.TextureAttributes; +import javax.media.j3d.TextureUnitState; +import javax.media.j3d.WakeupOnElapsedFrames; + +import javax.swing.JFrame; +import javax.swing.JPanel; + +import javax.vecmath.Color3f; +import javax.vecmath.Point3d; +import javax.vecmath.Vector3f; +import org.jdesktop.j3d.examples.Resources; + +/** + * This example program is contributed by Alessandro Borges + */ + +/** + * <pre> + * DOT3 per-pixel lighting demo. + * It uses a Normal map and a Light map, both coded as independent textures. + * Each pixel color is a vector coded, where color range [0,255] is mapped + * as vector in range [-1.0,+1.0]. + * + * A math operation called DOT3 applied to Light vector and Normal vector results + * a scalar value, interpreted as light intensity. This operation is made for each + * pixel on texture. + * Light Intensity = DOT3(light, normal); + * + * This technique allows complex lighting effects, as bumps, on low polygon count + * geometries. + * </pre> + * + */ + +public class Dot3Demo extends JFrame { + // a external control panel for this demo + private TextureControlPanel ctrlPanel = null; + // default bounds used in this application + private BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), + 100.0); + // TextureUnitStates used in this application + TextureUnitState tuLightMap; + TextureUnitState tuDOT3NormalMap; + TextureUnitState tuColor; + + /** Where the TUs are applied **/ + TextureUnitState[] tusArr; + /** appearance will be changed at runtime **/ + Appearance appearance; + /** polygonAttributes will be changed at runtime **/ + PolygonAttributes polygonAttributes; + + // textures used + Texture textureColor; + Texture textureDOT3NormalMap; + Texture2D textureLightMap; + // needs for runtime updates on lightMap + ImageComponent2D imageLightMap; + + // default texture names used + String textureColorName= "resources/images/wood.jpg"; + String textureDOT3NormalMapName = "resources/images/Java3Ddot3.jpg"; + + /** + * Constructor. + */ + public Dot3Demo() { + super("Java3D DOT3 demo"); + try { + init(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + private void init() throws Exception { + this.setSize(new Dimension(400, 400)); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel mainPanel = new JPanel(); + this.getContentPane().add(mainPanel, null); + mainPanel.setLayout(new BorderLayout()); + // get default configuration for 3D + GraphicsConfiguration conf = SimpleUniverse.getPreferredConfiguration(); + Canvas3D canvas = new Canvas3D(conf); + // create simpleUniverse + SimpleUniverse su = new SimpleUniverse(canvas); + // create sceneGraph and add it to universe + BranchGroup sceneGraph = createSceneGraph(); + su.addBranchGraph(sceneGraph); + + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + su.getViewingPlatform().setNominalViewingTransform(); + + // Ensure at least 5 msec per frame (i.e., < 200Hz) + su.getViewer().getView().setMinimumFrameCycleTime(5); + + // add the behaviors to the ViewingPlatform + ViewingPlatform viewingPlatform = su.getViewingPlatform(); + viewingPlatform.setNominalViewingTransform(); + + // add orbit behavior to ViewingPlatform + OrbitBehavior orbit = new OrbitBehavior(canvas, OrbitBehavior.REVERSE_ALL | + OrbitBehavior.STOP_ZOOM); + orbit.setSchedulingBounds(bounds); + viewingPlatform.setViewPlatformBehavior(orbit); + + mainPanel.add(canvas, BorderLayout.CENTER); + this.setVisible(true); + //create a control panel to user interaction + ctrlPanel = new TextureControlPanel(this); + ctrlPanel.setVisible(true); + ctrlPanel.setLocation(410,10); + } + + /** + * loads all needed textures, and creates light map texture + */ + private void loadTextures() { + try { + //java.net.URL urlColor = new java.net.URL("file:" + textureColorName); + //java.net.URL urlDot3 = new java.net.URL("file:" + textureDOT3NormalMapName); + java.net.URL urlColor = Resources.getResource(textureColorName); + java.net.URL urlDot3 = Resources.getResource(textureDOT3NormalMapName); + + // loading textures + textureColor = new TextureLoader(urlColor,this).getTexture(); + textureDOT3NormalMap = new TextureLoader(urlDot3,this) .getTexture(); + + // create Image for textureLightMap + BufferedImage image = new BufferedImage(256,256,BufferedImage.TYPE_INT_RGB); + Graphics2D graphics = image.createGraphics(); + graphics.setPaint(new Color(130,130,250)); + graphics.fillRect(0,0,image.getWidth(),image.getHeight()); + graphics.dispose(); + + imageLightMap = new ImageComponent2D(ImageComponent2D.FORMAT_RGB,image,false,false); + imageLightMap.setCapability(ImageComponent2D.ALLOW_IMAGE_WRITE); + imageLightMap.setCapability(ImageComponent2D.ALLOW_IMAGE_READ); + + //create textureLightMap with above imageLightMap + textureLightMap = new Texture2D(Texture2D.BASE_LEVEL,Texture2D.RGB,256,256); + textureLightMap.setImage(0,imageLightMap); + textureLightMap.setMagFilter(Texture2D.NICEST); + textureLightMap.setMinFilter(Texture2D.NICEST); + + // application with update textureLightMap at runtime, so lets enable some caps + textureLightMap.setCapability(Texture2D.ALLOW_ENABLE_WRITE); + textureLightMap.setCapability(Texture2D.ALLOW_ENABLE_READ); + textureLightMap.setCapability(Texture2D.ALLOW_IMAGE_WRITE); + textureLightMap.setCapability(Texture2D.ALLOW_IMAGE_READ); + + } catch(Exception e) { + System.err.println("Failed to load textures"); + e.printStackTrace(); + } + } + + /** + * setup TextureUnitStates used in this demo. * + * @return + */ + private TextureUnitState[] setupTextureUnitState() { + //texture Attributes for DOT3 normal map + TextureAttributes textAttDot3 = new TextureAttributes(); + + + // lightMap uses TextureAttributes with default REPLACE mode + TextureAttributes textAttLightMap = new TextureAttributes(); + + TextureAttributes texAttColor = new TextureAttributes(); + texAttColor.setTextureMode(TextureAttributes.COMBINE); + + //CombineRgbMode could be also COMBINE_ADD or COMBINE_ADD_SIGNED, with + //different results + texAttColor.setCombineRgbMode(TextureAttributes.COMBINE_MODULATE); + // increase light depth effect + texAttColor.setCombineRgbScale(2); + + textAttDot3.setTextureMode(TextureAttributes.COMBINE); + textAttDot3.setCombineRgbMode(TextureAttributes.COMBINE_DOT3); + textAttDot3.setCombineAlphaMode(TextureAttributes.COMBINE_DOT3); + textAttDot3.setTextureBlendColor(1.f,1.0f,1.0f,0.0f); + // increase light intesity + textAttDot3.setCombineRgbScale(2); + // setup functions + textAttDot3.setCombineRgbFunction(0,TextureAttributes.COMBINE_SRC_COLOR); + textAttDot3.setCombineRgbFunction(1,TextureAttributes.COMBINE_SRC_COLOR); + textAttDot3.setCombineRgbFunction(2,TextureAttributes.COMBINE_SRC_COLOR); + //combine with previous TUS, lightMap + textAttDot3.setCombineRgbSource(0,TextureAttributes.COMBINE_PREVIOUS_TEXTURE_UNIT_STATE); + textAttDot3.setCombineRgbSource(1,TextureAttributes.COMBINE_TEXTURE_COLOR ); + textAttDot3.setCombineRgbSource(2,TextureAttributes.COMBINE_OBJECT_COLOR); + + TexCoordGeneration tcg1=null; + // SphereMap tcg can add nice dynamic effects for curved surfaces, because it + // distributes texture like a light bean over geometry. + // It os not used in this demo, but you can try yourself at home + // with *complex* lightmaps, i.e., spherical light distributions, + // multi light sorces, degradee, waves,etc + /* + tcg1 = new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, + TexCoordGeneration.TEXTURE_COORDINATE_3); + */ + + // create TUS + tuLightMap = new TextureUnitState(textureLightMap,textAttLightMap,tcg1); + tuDOT3NormalMap = new TextureUnitState(textureDOT3NormalMap,textAttDot3,null); + tuColor = new TextureUnitState(textureColor,texAttColor,null); + + // this TUS array is used by geometry at runtime + TextureUnitState[] tus = new TextureUnitState[3]; + tus[0] = tuLightMap; + tus[1] = tuDOT3NormalMap; + tus[2] = tuColor; + // enable texture units for read/write at runtime + for (int i = 0; i < tus.length; i++) { + tus[i].setCapability(TextureUnitState.ALLOW_STATE_WRITE); + tus[i].setCapability(TextureUnitState.ALLOW_STATE_READ); + } + + return tus; + } + + /** + * creates a single Quad geometry with 4 TextureCoordinateMaps, for multitexture use.<br> + * Dimension is scale*(2m , 1m) + * @param scale a scale for this quad + * @return quad geometry for multitexture use + */ + private GeometryArray createGeometry(float scale) { + // vertex coordinates + float[] verts = { 2.0f, -1.0f, 0.0f, + 2.0f, 1.0f, 0.0f, + -2.0f, 1.0f, 0.0f, + -2.0f, -1.0f, 0.0f }; + // 2D texture Coords - each texture unit will use one set of this + float[] texCoords = { 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f}; + // all texture units will use texCoords from unit 0 + int[] texCoordSetMap = {0,0,0,0}; + // normals + Vector3f normal = new Vector3f( 0.0f, 0.0f, 1.0f); + Vector3f[] normals = { normal, normal, normal, normal} ; + // resize quad dimension + for(int i = 0;i<verts.length;i++) { + verts[i] *= scale; + } + // create geometry using GeometryInfo + GeometryInfo gi = new GeometryInfo(GeometryInfo.QUAD_ARRAY); + + gi.setCoordinates(verts); + gi.setNormals(normals); + // preparing for multitexture + // To get up to 4 TUS, it needs 4 sets of 2D texture + gi.setTextureCoordinateParams(4, 2); + gi.setTexCoordSetMap(texCoordSetMap); + + // this demo needs just 3 TUS, but geometry + // is prepared for up to 4 TUS stages + gi.setTextureCoordinates(0,texCoords); + gi.setTextureCoordinates(1,texCoords); + gi.setTextureCoordinates(2,texCoords); + gi.setTextureCoordinates(3,texCoords); + + return gi.getGeometryArray(); + } + + /** + * Creates scenegraphs + * @return a BranchGroup with all needed objects in scene + */ + private BranchGroup createSceneGraph() { + BranchGroup bgRoot = new BranchGroup(); + CheckNewLightMapBehavior checkNewLightMapBehavior = new CheckNewLightMapBehavior(); + + bgRoot.addChild(checkNewLightMapBehavior); + + // a blue background + Background background = new Background(0.4f,0.4f,0.8f); + background.setApplicationBounds(bounds); + bgRoot.addChild(background); + + AmbientLight alit = new AmbientLight(true,new Color3f(0.4f,0.4f,0.4f)); + bgRoot.addChild(alit); + + // Set up some directional lights + // DOT3 doesnot need light, because it is a perpixel lighting technique + //but we add this lights to show + // geometry when using non-DOT3 lighting, as color texture only and + // light map texture mode + Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f); + Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f); + Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f); + Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -1.0f); + + DirectionalLight light1 + = new DirectionalLight(light1Color, light1Direction); + light1.setInfluencingBounds(bounds); + bgRoot.addChild(light1); + + DirectionalLight light2 + = new DirectionalLight(light2Color, light2Direction); + light2.setInfluencingBounds(bounds); + bgRoot.addChild(light2); + + //loading color and DOT3 normal map textures from disk, + //and creating light map at runtime + loadTextures(); + //our single Quad geometry, enabled for multitexture + GeometryArray geo = createGeometry(0.4f); + // a appearance for our geometry + appearance = new Appearance(); + // polygon and texture unit will be updated at runtime + // so we must enabled read/write operations for then + appearance.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_READ); + appearance.setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE); + appearance.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_READ); + appearance.setCapability(Appearance.ALLOW_TEXTURE_UNIT_STATE_WRITE); + + //use a default material. It is necessary when running + //on non per-pixel lighting mod, i.e., using non DOT3 textures + appearance.setMaterial(new Material()); + + polygonAttributes = new PolygonAttributes(); + polygonAttributes.setCapability(PolygonAttributes.ALLOW_MODE_WRITE); + polygonAttributes.setCullFace(PolygonAttributes.CULL_NONE); + + appearance.setPolygonAttributes(polygonAttributes); + + // uses a TUS dot3 enabled + tusArr = setupTextureUnitState(); + appearance.setTextureUnitState(tusArr); + + // joining geometry and appearance in a shape3D + Shape3D shape3D = new Shape3D(geo,appearance); + shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ); + shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE); + + bgRoot.addChild(shape3D); + + bgRoot.compile(); + + return bgRoot; + } + + /** + * Toggles wireframe mode + * @param mode true for wireframe, false for fill polygon + */ + public void setWireframeMode(boolean mode) { + if(mode) + polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_LINE); + else + polygonAttributes.setPolygonMode(PolygonAttributes.POLYGON_FILL); + } + + + /** + * This method togles on/off textures and updates TextureUnitState in correct Order. + * Some video drivers does not accept TextureUnitState arrays with null values among + * non-null values + * @param showLightMap togles LightMap texture + * @param showDot3 togles DOT3 Normal texture + * @param showColor togles Color texture + */ + public void showTextures(boolean showLightMap, boolean showDot3, boolean showColor) { + int bitSet = 0; + bitSet |= showLightMap ? 4 : 0; + bitSet |= showDot3 ? 2 : 0; + bitSet |= showColor ? 1 : 0; + + tusArr[0] = null; + tusArr[1] = null; + tusArr[2] = null; + + switch (bitSet) { + case 7: { //all bit == all tus + tusArr[0] = tuLightMap; + tusArr[1] = tuDOT3NormalMap; + tusArr[2] = tuColor; + } + break; + case 6: { //no Color + tusArr[0] = tuLightMap; + tusArr[1] = tuDOT3NormalMap; + } + break; + case 5: { //no Dot3 + tusArr[0] = tuLightMap; + tusArr[1] = tuColor; + } + break; + case 4: { //lightMap only + tusArr[0] = tuLightMap; + } + break; + case 3: { //no LightMap + tusArr[0] = tuDOT3NormalMap; + tusArr[1] = tuColor; + } + break; + case 2: { //Dot3 Only + tusArr[0] = tuDOT3NormalMap; + } + break; + case 1: { // Color Only + tusArr[0] = tuColor; + } + break; + default: { // case 0, no textures shows at all + } + break; + } + appearance.setTextureUnitState(tusArr); + } + + /** + * updates LightMap texture. + * This method is called from checkNewLightMapBehavior + * @param image new image to be applied + */ + public void updateLighMap(BufferedImage image) { + imageLightMap.setSubImage(image,image.getWidth(),image.getHeight(),0,0,0,0); + } + + private BufferedImage tempImage; + private boolean lockTempImage = false; + + + /** + * main method + * @param args + */ + public static void main(String[] args) { + javax.swing.SwingUtilities.invokeLater(new Runnable() { + public void run() { + new Dot3Demo(); + } + }); + + } + + /** + * A internal class to check if there is a new Light Map to be applied + */ + class CheckNewLightMapBehavior extends Behavior { + WakeupOnElapsedFrames wakeup = new WakeupOnElapsedFrames(0); + + public CheckNewLightMapBehavior() {// auto enable and set schedulling bounds + setEnable(true); + setSchedulingBounds(bounds); + } + + public void initialize() { + wakeupOn(wakeup); + } + + public void processStimulus(Enumeration e) { + // check if there are a new light map ready to use + if (ctrlPanel.hasTextureImageReady()) { + updateLighMap(ctrlPanel.getTextureImage()); + } + //wake up on next frame + wakeupOn(wakeup); + } + } + +} + + diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java b/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java new file mode 100644 index 0000000..6e668be --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java @@ -0,0 +1,241 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.dot3; + +import java.awt.*; +import java.awt.image.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.event.MouseInputListener; + +/** + * A mouse interactive canvas for lightMap image + */ +public class MyCanvas extends JPanel implements MouseInputListener { + BufferedImage lightMask = null; + BufferedImage textureImage = null; + Graphics2D gr = null; + Point location = new Point(); + // default color light map + Color bgColor = new Color(147, 147, 147); + + int x = 0; + int y = 0; + int z = 142; + // texture image size + private static final int textureSize = 256; + boolean mouseOut = true; + //flag about image is ready or not for use + boolean imageReady = false; + // allows mask be dragged with mouse + boolean dragMask = false; + boolean updateLightDir = false; + boolean updateMaskPosition = false; + + /** + * Creates a MyCanvas object with a image lightMask. + * Also creates a default ImageLight map + * @param mask light lightMask used + */ + public MyCanvas(BufferedImage mask) { + super(); + this.lightMask = mask; + // create a light map + setTextureImage(new BufferedImage(textureSize, textureSize, + BufferedImage.TYPE_INT_RGB)); + // Graphics used to update lightmap + gr = getTextureImage().createGraphics(); + + Dimension dimSize = new Dimension(textureSize, textureSize); + // lock size + this.setSize(dimSize); + this.setMaximumSize(dimSize); + this.setMinimumSize(dimSize); + + this.setDoubleBuffered(true); + this.setOpaque(true); + this.addMouseMotionListener(this); + this.addMouseListener(this); + } + + /** + * Handles mouse click event. + * Get mouse coords call repaint for proper imageLight update + * @param ev mouse event + */ + public void mouseClicked(MouseEvent ev) { + x = ev.getX(); + y = this.getHeight() - ev.getY(); + updateLightDir = true; + repaint(); + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseReleased(MouseEvent e) { + } + + /** + * Handles mouse drag event. + * get current mouse position and calls repaint for proper imageLight update + * @param ev + */ + public void mouseDragged(MouseEvent ev) { + if (!mouseOut) { + x = ev.getX(); + y = this.getHeight() - ev.getY(); + + //changes lightDir + if ((ev.getModifiers()& MouseEvent.BUTTON1_MASK) == + MouseEvent.BUTTON1_MASK) { + updateLightDir = true; + updateMaskPosition = false; + } + //updates light mask position + if ((ev.getModifiers() & ev.BUTTON2_MASK) == ev.BUTTON2_MASK || + (ev.getModifiers() & ev.BUTTON3_MASK) == ev.BUTTON3_MASK) { + updateLightDir = false; + updateMaskPosition = true; + } + repaint(); + } + } + + public void mouseMoved(MouseEvent ev) { + // disable updates on lightMap + updateLightDir = false; + updateMaskPosition = false; + } + + public void mouseEntered(MouseEvent e) { + mouseOut = false; + } + + public void mouseExited(MouseEvent e) { + mouseOut = true; + } + + /** + * updates imageLight using current setings + * @param g + */ + public void paintComponent(Graphics g) { + imageReady = false; + Graphics2D g2d = (Graphics2D)g; + + // ligthDir has changed, we must update bgColor li + if(updateLightDir) { + int blue = bgColor.getBlue(); + //clamp values to 255 + y = y>255?255:y; + x = x>255?255:x; + bgColor = new Color(y,x,blue); + } + // paint lightMap + gr.setColor(bgColor); + gr.fillRect(0, 0, textureSize, textureSize); + + // draw mask on mouse position + if (dragMask || updateMaskPosition) { + int maskWH = lightMask.getWidth()/2; + int mx = x - maskWH ; + int my = textureSize - y - maskWH ; // y value is inverted + // clamp mouse position, to avoid drawing outside imageLigh bounds + mx = mx > textureSize ? textureSize : mx; + my = my > textureSize ? textureSize : my; + // draw light mask + gr.drawImage(lightMask, mx, my, this); + } + + g2d.drawImage(getTextureImage(), 0, 0, this); + imageReady = true; + } + + /** + * + * @return true if exists a new texture image available + */ + public boolean hasTextureImageReady() { + return imageReady; + } + + /** + * Returns a texture image.<br> + * You can avoid calling the same image several times + * by checking hasTextureImageReady() first. + * @return latest texture image available + */ + public BufferedImage getTextureImage() { + // sign as texture used for next call; + imageReady = false; + //return image + return textureImage; + } + + + public Image getMask() { + return lightMask; + } + + public void setLightMask(BufferedImage mask) { + this.lightMask = mask; + } + + public Color getBgColor() { + return bgColor; + } + + public void setBgColor(Color bgColor) { + this.bgColor = bgColor; + } + + public void setTextureImage(BufferedImage textureImage) { + this.textureImage = textureImage; + } + + +} + diff --git a/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java b/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java new file mode 100644 index 0000000..72a0027 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/dot3/TextureControlPanel.java @@ -0,0 +1,233 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.dot3; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Rectangle; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; + +import java.net.URL; + +import javax.imageio.ImageIO; + +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JDialog; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSlider; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import org.jdesktop.j3d.examples.Resources; + +/** + * A control panel for Dot3Demo. + * It enables user change LightMap, enables/disables textures units states + * and toggles geometry wireframes on/off + */ +public class TextureControlPanel extends JDialog implements ChangeListener, + ActionListener { + /** renderer for lightMap, with support for mouse interaction **/ + private MyCanvas canvas = null; + /** file name for light mask */ + private String maskFileName = "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 **/ + private Dot3Demo dot3DemoFrame; + + // some checkboxes for user interaction + private JCheckBox cbWireframe = new JCheckBox("Show as Wireframe", false); + private JCheckBox cbDot3 = new JCheckBox("Show Dot3 texture", true); + private JCheckBox cbShowLightMap = new JCheckBox("Show LightMap texture", true); + private JCheckBox cbShowColor = new JCheckBox("Show Color texture", true); + private JCheckBox cbDragLightMask = new JCheckBox("Drag light mask"); + + private JLabel lbSliderZ = new JLabel(); + private JLabel lbMessage = new JLabel(); + + public TextureControlPanel(Dot3Demo owner) { + super(owner); + dot3DemoFrame = owner; + try { + URL url = Resources.getResource(maskFileName); + BufferedImage mask = ImageIO.read(url); + canvas = new MyCanvas(mask); + init(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public TextureControlPanel() { + this(null); + } + + /** + * Creates Graphical User Interface + * @throws Exception + */ + private void init() throws Exception { + Dimension dim = new Dimension(540, 350); + this.setSize(dim); + this.setPreferredSize(dim); + this.setTitle("DOT3Demo Texture Control Panel"); + this.setLayout(new BorderLayout()); + + JPanel panel = new JPanel(); + this.getContentPane().add(panel, BorderLayout.CENTER); + canvas.setSize(new Dimension(256, 256)); + canvas.setBounds(new Rectangle(40, 40, 256, 256)); + + sliderZ.setBounds(new Rectangle(310, 190, 205, 45)); + sliderZ.setPaintTicks(true); + sliderZ.setMajorTickSpacing(63); + + cbWireframe.setBounds(new Rectangle(310, 50, 200, 20)); + cbWireframe.setToolTipText("Toggles Wireframe"); + cbDot3.setBounds(new Rectangle(310, 70, 150, 20)); + cbShowLightMap.setBounds(new Rectangle(310, 90, 200, 20)); + cbShowLightMap.setToolTipText("Toggles DOT3 texture"); + cbShowColor.setBounds(new Rectangle(310, 110, 200, 20)); + cbShowColor.setToolTipText("Toggles Color texture"); + + panel.setLayout(null); + + cbDragLightMask.setBounds(new Rectangle(310, 135, 200, 20)); + lbMessage.setText("<html>Left-click and drag to change Light Direction." + + " Right-click and drag to move spotlight.</html>"); + lbMessage.setBounds(new Rectangle(305, 245, 210, 60)); + + lbSliderZ.setText("Blue Light (Dot3 Z axis)"); + lbSliderZ.setBounds(new Rectangle(310, 170, 210, 15)); + lbSliderZ.setToolTipText("changes light intensity from Z axis"); + + panel.add(cbDragLightMask, null); + panel.add(lbMessage, null); + panel.add(lbSliderZ, null); + panel.add(sliderZ, null); + panel.add(canvas, null); + panel.add(cbShowColor, null); + panel.add(cbShowLightMap, null); + panel.add(cbWireframe, null); + panel.add(cbDot3, null); + + sliderZ.addChangeListener(this); + + cbDot3.addActionListener(this); + cbShowColor.addActionListener(this); + cbShowLightMap.addActionListener(this); + cbWireframe.addActionListener(this); + cbDragLightMask.addActionListener(this); + } + + public void stateChanged(ChangeEvent ev) { + JComponent source = (JComponent)ev.getSource(); + if (sliderZ.equals(source)) { + int xVal = canvas.getBgColor().getRed(); + int yVal = canvas.getBgColor().getGreen(); + int zVal = sliderZ.getValue(); + Color ligtDir = new Color(xVal, yVal, zVal); + updateLightMap(ligtDir) ; + } + } + + private void updateLightMap(Color ligtDir) { + canvas.setBgColor(ligtDir); + canvas.repaint(); + dot3DemoFrame.updateLighMap(canvas.getTextureImage()); + } + + + public void actionPerformed(ActionEvent ev) { + JComponent source = (JComponent)ev.getSource(); + if (cbWireframe.equals(source)) { + dot3DemoFrame.setWireframeMode(cbWireframe.isSelected()); + } else + if (cbDot3.equals(source) + || cbShowColor.equals(source) + || cbShowLightMap.equals(source)) { + dot3DemoFrame.showTextures(cbShowLightMap.isSelected(), + cbDot3.isSelected(), + cbShowColor.isSelected()); + } else if (cbDragLightMask.equals(source)) { + canvas.dragMask = cbDragLightMask.isSelected(); + } + + } + + /** + * Wrapper method call for MyCanvas. hasTextureImageReady() + * @return true if exists a new texture image available + */ + public boolean hasTextureImageReady() { + return canvas.hasTextureImageReady(); + } + + /** + * Wrapper method call for MyCanvas.getTextureImage() + * Returns a texture image.<br> + * Avoid calling the same image several times + * by cheking hasTextureImageReady() first. + * @return latest texture image available + */ + public BufferedImage getTextureImage() { + return canvas.getTextureImage(); + } + + /** + * Wrapper method to MyCanvas.setLightMask(mask) + * @param mask a new light mask + */ + public void setLightMask(BufferedImage mask) { + canvas.setLightMask(mask); + } +} + + diff --git a/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.form b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.form new file mode 100644 index 0000000..0a6a276 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/fps_counter/FPSCounterDemo.form @@ -0,0 +1,36 @@ +<?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="FPSCounterDemo"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/gears/GearBox.form b/src/classes/org/jdesktop/j3d/examples/gears/GearBox.form new file mode 100644 index 0000000..840732c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gears/GearBox.form @@ -0,0 +1,36 @@ +<?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="GearBox"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/gears/GearTest.form b/src/classes/org/jdesktop/j3d/examples/gears/GearTest.form new file mode 100644 index 0000000..0ba2e64 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/gears/GearTest.form @@ -0,0 +1,36 @@ +<?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="GearTest"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.form b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.form new file mode 100644 index 0000000..b6a3e94 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.form @@ -0,0 +1,36 @@ +<?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="EnvironmentMappingGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java new file mode 100644 index 0000000..b5ade60 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/EnvironmentMappingGLSL.java @@ -0,0 +1,238 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.glsl_shader; + +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.geometry.Sphere; +import com.sun.j3d.utils.image.TextureLoader; +import com.sun.j3d.utils.shader.StringIO; +import javax.media.j3d.*; +import javax.vecmath.*; +import java.awt.GraphicsConfiguration; +import java.io.IOException; +import java.net.URL; +import javax.swing.JOptionPane; +import org.jdesktop.j3d.examples.Resources; + +public class EnvironmentMappingGLSL extends javax.swing.JFrame { + + private URL textureURL = null; + private static final int NUM_TEX_UNITS = 1; + private static final int TEX_UNIT = 0; + + SimpleUniverse univ = null; + + public BranchGroup createSceneGraph() { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + + // Create texture object + textureURL = Resources.getResource("resources/images/duke-gears.jpg"); + Texture tex = new TextureLoader(textureURL, this).getTexture(); + // Create the shader program + String vertexProgram = null; + String fragmentProgram = null; + try { + vertexProgram = StringIO.readFully(Resources.getResource("glsl_shader/envmap.vert")); + fragmentProgram = StringIO.readFully(Resources.getResource("glsl_shader/envmap.frag")); + } + catch (IOException e) { + System.err.println(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); + final String[] shaderAttrNames = { + "LightPos", + "BaseColor", + "MixRatio", + "EnvMap", + }; + final Object[] shaderAttrValues = { + new Point3f(1.0f, -1.0f, 2.0f), + new Color3f(0.2f, 0.9f, 0.5f), + new Float(0.4f), + new Integer(TEX_UNIT), + }; + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + // Create the shader attribute set + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + for (int i = 0; i < shaderAttrNames.length; i++) { + ShaderAttribute shaderAttribute = + new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); + shaderAttributeSet.put(shaderAttribute); + } + + // Create shader appearance to hold the shader program and + // shader attributes + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + app.setShaderAttributeSet(shaderAttributeSet); + + // Put the texture in specified texture unit + TextureUnitState[] tus = new TextureUnitState[NUM_TEX_UNITS]; + tus[TEX_UNIT] = new TextureUnitState(); + tus[TEX_UNIT].setTexture(tex); + app.setTextureUnitState(tus); + + // Create a Sphere object using the shader appearance, + // and add it into the scene graph. + Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 20, app); + objTrans.addChild(sph); + + // Create a new Behavior object that will perform the + // desired operation on the specified transform and add + // it into the scene graph. + Transform3D yAxis = new Transform3D(); + Alpha rotationAlpha = new Alpha(-1, 4000); + + RotationInterpolator rotator = + new RotationInterpolator(rotationAlpha, objTrans, yAxis, + 0.0f, (float) Math.PI*2.0f); + BoundingSphere bounds = + new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); + rotator.setSchedulingBounds(bounds); + objRoot.addChild(rotator); + + // Have Java 3D perform optimizations on this scene graph. + //objRoot.compile(); + + return objRoot; + } + + private Canvas3D initScene() { + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + BranchGroup scene = createSceneGraph(); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) { + error.printVerbose(); + JOptionPane.showMessageDialog(EnvironmentMappingGLSL.this, + error.toString(), + "ShaderError", + JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form EnvironmentMappingGLSL + */ + public EnvironmentMappingGLSL() { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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() { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("EnvironmentMappingGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new EnvironmentMappingGLSL().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/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.form b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.form new file mode 100644 index 0000000..343b6d5 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/ObjLoadGLSL.form @@ -0,0 +1,36 @@ +<?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="ObjLoadGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.form b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.form new file mode 100644 index 0000000..6a1a031 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.form @@ -0,0 +1,36 @@ +<?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="SamplerTestGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java new file mode 100644 index 0000000..2195211 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SamplerTestGLSL.java @@ -0,0 +1,255 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +package org.jdesktop.j3d.examples.glsl_shader; + +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.geometry.Sphere; +import com.sun.j3d.utils.image.TextureLoader; +import com.sun.j3d.utils.shader.StringIO; +import javax.media.j3d.*; +import javax.vecmath.*; +import java.awt.GraphicsConfiguration; +import java.io.IOException; +import java.net.URL; +import javax.swing.JOptionPane; +import org.jdesktop.j3d.examples.Resources; + +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 fragmentProgName = "glsl_shader/multitex.frag"; + private URL cloudURL = null; + private URL earthURL = null; + private static final int CLOUD = 0; + private static final int EARTH = 1; + + SimpleUniverse univ = null; + + public BranchGroup createSceneGraph() { + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + + // Create texture objects + cloudURL = Resources.getResource(cloudTexName); + Texture cloudTex = new TextureLoader(cloudURL, this).getTexture(); + earthURL = Resources.getResource(earthTexName); + Texture earthTex = new TextureLoader(earthURL, this).getTexture(); + + // Create the shader program + String vertexProgram = null; + String fragmentProgram = null; + try { + fragmentProgram = StringIO.readFully(Resources.getResource(fragmentProgName)); + } + catch (IOException e) { + System.err.println(e); + } + Shader[] shaders = new Shader[1]; + shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, + Shader.SHADER_TYPE_FRAGMENT, + fragmentProgram); + final String[] shaderAttrNames = { + "cloudFactor", + "cloudTex", + "earthTex", + }; + final Object[] shaderAttrValues = { + new Float(0.6f), + new Integer(0), + new Integer(1), + }; + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + // Create the shader attribute set + ShaderAttributeSet shaderAttributeSet = new ShaderAttributeSet(); + for (int i = 0; i < shaderAttrNames.length; i++) { + ShaderAttribute shaderAttribute = + new ShaderAttributeValue(shaderAttrNames[i], shaderAttrValues[i]); + shaderAttributeSet.put(shaderAttribute); + } + + // Create shader appearance to hold the shader program and + // shader attributes + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + app.setShaderAttributeSet(shaderAttributeSet); + + // Setup texture coordinate generation + Vector4f plane0S = new Vector4f(3.0f, 1.5f, 0.3f, 0.0f); + Vector4f plane0T = new Vector4f(1.0f, 2.5f, 0.24f, 0.0f); + TexCoordGeneration tcg0 = + new TexCoordGeneration(TexCoordGeneration.OBJECT_LINEAR, + TexCoordGeneration.TEXTURE_COORDINATE_2, plane0S, plane0T); + + // Setup texture coordinate generation + TexCoordGeneration tcg1 = + new TexCoordGeneration(TexCoordGeneration.SPHERE_MAP, + TexCoordGeneration.TEXTURE_COORDINATE_2); + + // Put the textures in unit 0,1 + TextureUnitState[] tus = new TextureUnitState[2]; + tus[CLOUD] = new TextureUnitState(); + tus[CLOUD].setTexture(cloudTex); + tus[CLOUD].setTexCoordGeneration(tcg0); + tus[EARTH] = new TextureUnitState(); + tus[EARTH].setTexture(earthTex); + tus[EARTH].setTexCoordGeneration(tcg1); + app.setTextureUnitState(tus); + + // Create a Sphere object using the shader appearance, + // and add it into the scene graph. + Sphere sph = new Sphere(0.4f, Sphere.GENERATE_NORMALS, 30, app); + objTrans.addChild(sph); + + // Create a new Behavior object that will perform the + // desired operation on the specified transform and add + // it into the scene graph. + Transform3D yAxis = new Transform3D(); + Alpha rotationAlpha = new Alpha(-1, 4000); + + RotationInterpolator rotator = + new RotationInterpolator(rotationAlpha, objTrans, yAxis, + 0.0f, (float) Math.PI*2.0f); + BoundingSphere bounds = + new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); + rotator.setSchedulingBounds(bounds); + objRoot.addChild(rotator); + + // Have Java 3D perform optimizations on this scene graph. + //objRoot.compile(); + + return objRoot; + } + + private Canvas3D initScene() { + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + + BranchGroup scene = createSceneGraph(); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) { + error.printVerbose(); + JOptionPane.showMessageDialog(SamplerTestGLSL.this, + error.toString(), + "ShaderError", + JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + univ.addBranchGraph(scene); + + return c; + } + + /** + * Creates new form SamplerTestGLSL + */ + public SamplerTestGLSL() { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + // ---------------------------------------------------------------- + + /** 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() { + drawingPanel = new javax.swing.JPanel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("SamplerTestGLSL"); + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + getContentPane().add(drawingPanel, java.awt.BorderLayout.CENTER); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new SamplerTestGLSL().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/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.form b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.form new file mode 100644 index 0000000..26e9b32 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/SphereGLSL.form @@ -0,0 +1,36 @@ +<?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="SphereGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.form b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.form new file mode 100644 index 0000000..6e31a8f --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.form @@ -0,0 +1,203 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.0" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <NonVisualComponents> + <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> + <SubComponents> + <Menu class="javax.swing.JMenu" name="fileMenu"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + <SubComponents> + <MenuItem class="javax.swing.JMenuItem" name="exitMenuItem"> + <Properties> + <Property name="text" type="java.lang.String" value="Exit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exitMenuItemActionPerformed"/> + </Events> + </MenuItem> + </SubComponents> + </Menu> + </SubComponents> + </Menu> + </NonVisualComponents> + <Properties> + <Property name="title" type="java.lang.String" value="VertexAttrTestGLSL"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </SyntheticProperties> + <Events> + <EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="exitForm"/> + </Events> + <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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="mainPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="guiPanel"> + <Properties> + <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> + <Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo"> + <LineBorder/> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="North"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="vertexCheckBoxPanel"> + <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="vertexFormat"> + <Font PropertyName="font" name="Lucida Sans" size="10" style="0"/> + </TitledBorder> + </Border> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="jPanel1"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JSeparator" name="jSeparator1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 4]"/> + </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="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JSeparator" name="jSeparator2"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[0, 4]"/> + </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="3" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="jPanel2"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="11" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JCheckBox" name="vertexAttrsBox"> + <Properties> + <Property name="selected" type="boolean" value="true"/> + <Property name="text" type="java.lang.String" value="VertexAttrs"/> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="0" gridY="4" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="geometryPanel"> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="2" insetsLeft="2" insetsBottom="2" insetsRight="2" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/> + <SubComponents> + <Component class="javax.swing.JButton" name="createButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Create Geometry"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="createButtonActionPerformed"/> + </Events> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription"> + <GridBagConstraints gridX="-1" gridY="-1" gridWidth="1" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + <Component class="javax.swing.JButton" name="destroyButton"> + <Properties> + <Property name="text" type="java.lang.String" value="Destroy Geometry"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="destroyButtonActionPerformed"/> + </Events> + <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="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="2" insetsRight="0" anchor="10" weightX="0.0" weightY="0.0"/> + </Constraint> + </Constraints> + </Component> + </SubComponents> + </Container> + </SubComponents> + </Container> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[500, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java new file mode 100644 index 0000000..1f73790 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/VertexAttrTestGLSL.java @@ -0,0 +1,408 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ +package org.jdesktop.j3d.examples.glsl_shader; + +import com.sun.j3d.utils.universe.*; +import com.sun.j3d.utils.shader.StringIO; +import javax.media.j3d.*; +import java.awt.GraphicsConfiguration; +import java.io.IOException; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.FloatBuffer; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.vecmath.Color3f; +import javax.vecmath.Point3d; +import org.jdesktop.j3d.examples.Resources; + +public class VertexAttrTestGLSL extends javax.swing.JFrame { + + SimpleUniverse univ = null; + BranchGroup scene = null; + + public BranchGroup createSceneGraph( boolean hasVertexAttrs ) { + + // Bounds for BG and behavior + BoundingSphere bounds = + new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); + + // Create the root of the branch graph + BranchGroup objRoot = new BranchGroup(); + objRoot.setCapability(BranchGroup.ALLOW_DETACH); + + // Set up the background + Color3f bgColor = new Color3f(0.1f, 0.1f, 0.1f); + Background bg = new Background(bgColor); + bg.setApplicationBounds(bounds); + objRoot.addChild(bg); + + // Create the TransformGroup node and initialize it to the + // identity. Enable the TRANSFORM_WRITE capability so that + // our behavior code can modify it at run time. Add it to + // the root of the subgraph. + TransformGroup objTrans = new TransformGroup(); + objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); + objRoot.addChild(objTrans); + + // Create a simple Shape3D node; add it to the scene graph. + objTrans.addChild(new MyShape(this, hasVertexAttrs)); + + return objRoot; + } + + private Canvas3D initScene() { + GraphicsConfiguration config = + SimpleUniverse.getPreferredConfiguration(); + + Canvas3D c = new Canvas3D(config); + univ = new SimpleUniverse(c); + + // Add a ShaderErrorListener + univ.addShaderErrorListener(new ShaderErrorListener() { + public void errorOccurred(ShaderError error) { + error.printVerbose(); + JOptionPane.showMessageDialog(VertexAttrTestGLSL.this, + error.toString(), + "ShaderError", + JOptionPane.ERROR_MESSAGE); + } + }); + + ViewingPlatform viewingPlatform = univ.getViewingPlatform(); + // This will move the ViewPlatform back a bit so the + // objects in the scene can be viewed. + viewingPlatform.setNominalViewingTransform(); + + return c; + } + + /** + * Creates new form VertexAttrTestGLSL + */ + public VertexAttrTestGLSL() { + // Initialize the GUI components + initComponents(); + + // Create the scene and add the Canvas3D to the drawing panel + Canvas3D c = initScene(); + drawingPanel.add(c, java.awt.BorderLayout.CENTER); + } + + static class MyShape extends Shape3D { + private static String vertexProgName = "glsl_shader/vertexshader.vert"; + + // Coordinate data + private static final float[] coords = { + 0.0f, 0.0f, 0.0f, + 0.5f, 0.0f, 0.0f, + 0.0f, 0.5f, 0.0f, + }; + + private static final int[] sizes = { 1, 3 }; + private static final float[] weights = { + 0.45f, + 0.15f, + 0.95f, + }; + private static final float[] temps = { + 1.0f, 0.5f, 0.5f, + 0.5f, 1.0f, 0.5f, + 0.5f, 0.5f, 1.0f, + }; + + private static final String[] vaNames = { "weight", "temperature" }; + + J3DBuffer createDirectFloatBuffer(float[] arr) { + ByteOrder order = ByteOrder.nativeOrder(); + + FloatBuffer nioBuf = ByteBuffer.allocateDirect(arr.length * 4).order(order).asFloatBuffer(); + nioBuf.put(arr); + return new J3DBuffer(nioBuf); + } + + + MyShape(JFrame frame, boolean hasVertexAttrs) { + + int vertexFormat = GeometryArray.COORDINATES; + int vertexAttrCount = 0; + int[] vertexAttrSizes = null; + String[] vertexAttrNames = null; + String[] shaderAttrNames = null; + + if (hasVertexAttrs) { + vertexFormat |= GeometryArray.VERTEX_ATTRIBUTES; + vertexAttrCount = vaNames.length; + vertexAttrSizes = sizes; + vertexAttrNames = vaNames; + } + + TriangleArray tri = new TriangleArray(6, vertexFormat, 0, null, vertexAttrCount, vertexAttrSizes); + tri.setValidVertexCount(3); + tri.setCoordinates(0, coords); + + if (hasVertexAttrs) { + tri.setVertexAttrs(0, 0, weights); + tri.setVertexAttrs(1, 0, temps); + + String vertexProgram = null; + try { + vertexProgram = StringIO.readFully(Resources.getResource(vertexProgName)); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Shader[] shaders = new Shader[1]; + shaders[0] = new SourceCodeShader(Shader.SHADING_LANGUAGE_GLSL, + Shader.SHADER_TYPE_VERTEX, + vertexProgram); + + ShaderProgram shaderProgram = new GLSLShaderProgram(); + shaderProgram.setShaders(shaders); + shaderProgram.setVertexAttrNames(vertexAttrNames); + shaderProgram.setShaderAttrNames(shaderAttrNames); + + ShaderAppearance app = new ShaderAppearance(); + app.setShaderProgram(shaderProgram); + + this.setGeometry(tri); + + this.setAppearance(app); + } else { + this.setGeometry(tri); + this.setAppearance(new Appearance()); + } + } + } + + // ---------------------------------------------------------------- + + /** 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; + + mainPanel = new javax.swing.JPanel(); + guiPanel = new javax.swing.JPanel(); + vertexCheckBoxPanel = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jSeparator1 = new javax.swing.JSeparator(); + jSeparator2 = new javax.swing.JSeparator(); + jPanel2 = new javax.swing.JPanel(); + vertexAttrsBox = new javax.swing.JCheckBox(); + geometryPanel = new javax.swing.JPanel(); + createButton = new javax.swing.JButton(); + destroyButton = new javax.swing.JButton(); + drawingPanel = new javax.swing.JPanel(); + jMenuBar1 = new javax.swing.JMenuBar(); + fileMenu = new javax.swing.JMenu(); + exitMenuItem = new javax.swing.JMenuItem(); + + setTitle("VertexAttrTestGLSL"); + addWindowListener(new java.awt.event.WindowAdapter() { + public void windowClosing(java.awt.event.WindowEvent evt) { + exitForm(evt); + } + }); + + mainPanel.setLayout(new java.awt.BorderLayout()); + + guiPanel.setLayout(new java.awt.GridBagLayout()); + + guiPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + vertexCheckBoxPanel.setLayout(new java.awt.GridBagLayout()); + + vertexCheckBoxPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "vertexFormat", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Sans", 0, 10))); + jPanel1.setLayout(new java.awt.GridBagLayout()); + + jSeparator1.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 1; + jPanel1.add(jSeparator1, gridBagConstraints); + + jSeparator2.setPreferredSize(new java.awt.Dimension(0, 4)); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 3; + jPanel1.add(jSeparator2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel1, gridBagConstraints); + + jPanel2.setLayout(new java.awt.GridBagLayout()); + + vertexAttrsBox.setSelected(true); + vertexAttrsBox.setText("VertexAttrs"); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 4; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + jPanel2.add(vertexAttrsBox, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; + vertexCheckBoxPanel.add(jPanel2, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(vertexCheckBoxPanel, gridBagConstraints); + + geometryPanel.setLayout(new java.awt.GridBagLayout()); + + createButton.setText("Create Geometry"); + createButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + createButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + geometryPanel.add(createButton, gridBagConstraints); + + destroyButton.setText("Destroy Geometry"); + destroyButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + destroyButtonActionPerformed(evt); + } + }); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; + gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0); + geometryPanel.add(destroyButton, gridBagConstraints); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridy = 0; + gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2); + guiPanel.add(geometryPanel, gridBagConstraints); + + mainPanel.add(guiPanel, java.awt.BorderLayout.NORTH); + + drawingPanel.setLayout(new java.awt.BorderLayout()); + + drawingPanel.setPreferredSize(new java.awt.Dimension(500, 500)); + mainPanel.add(drawingPanel, java.awt.BorderLayout.CENTER); + + getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER); + + fileMenu.setText("File"); + exitMenuItem.setText("Exit"); + exitMenuItem.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + exitMenuItemActionPerformed(evt); + } + }); + + fileMenu.add(exitMenuItem); + + jMenuBar1.add(fileMenu); + + setJMenuBar(jMenuBar1); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void destroyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_destroyButtonActionPerformed + if (scene != null) { + univ.getLocale().removeBranchGraph(scene); + scene = null; + } + }//GEN-LAST:event_destroyButtonActionPerformed + + private void createButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_createButtonActionPerformed + if (scene == null) { + boolean hasVertexAttrs = vertexAttrsBox.isSelected(); + scene = createSceneGraph(hasVertexAttrs); + univ.addBranchGraph(scene); + } + }//GEN-LAST:event_createButtonActionPerformed + + private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed + System.exit(0); + }//GEN-LAST:event_exitMenuItemActionPerformed + + /** Exit the Application */ + private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm + System.exit(0); + }//GEN-LAST:event_exitForm + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new VertexAttrTestGLSL().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton createButton; + private javax.swing.JButton destroyButton; + private javax.swing.JPanel drawingPanel; + private javax.swing.JMenuItem exitMenuItem; + private javax.swing.JMenu fileMenu; + private javax.swing.JPanel geometryPanel; + private javax.swing.JPanel guiPanel; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JSeparator jSeparator2; + private javax.swing.JPanel mainPanel; + private javax.swing.JCheckBox vertexAttrsBox; + private javax.swing.JPanel vertexCheckBoxPanel; + // End of variables declaration//GEN-END:variables + +} diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.frag b/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.frag new file mode 100644 index 0000000..3e298f8 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.frag @@ -0,0 +1,61 @@ +// +// Fragment shader for environment mapping with an +// equirectangular 2D texture +// +// Authors: John Kessenich, Randi Rost +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +const vec3 Xunitvec = vec3 (1.0, 0.0, 0.0); +const vec3 Yunitvec = vec3 (0.0, 1.0, 0.0); + +uniform vec3 BaseColor; +uniform float MixRatio; + +uniform sampler2D EnvMap; + +varying vec3 Normal; +varying vec3 EyeDir; +varying float LightIntensity; + +void main (void) +{ + // Compute reflection vector + vec3 reflectDir = reflect(EyeDir, Normal); + + // Compute altitude and azimuth angles + + vec2 index; + + index.y = dot(normalize(reflectDir), Yunitvec); + reflectDir.y = 0.0; + index.x = dot(normalize(reflectDir), Xunitvec) * 0.5; + + // Translate index values into proper range + + if (reflectDir.z >= 0.0) + index = (index + 1.0) * 0.5; + else + { + index.t = (index.t + 1.0) * 0.5; + index.s = (-index.s) * 0.5 + 1.0; + } + + // if reflectDir.z >= 0.0, s will go from 0.25 to 0.75 + // if reflectDir.z < 0.0, s will go from 0.75 to 1.25, and + // that's OK, because we've set the texture to wrap. + + // Do a lookup into the environment map. + + vec3 envColor = vec3 (texture2D(EnvMap, index)); + + // Add lighting to base color and mix + + vec3 base = LightIntensity * BaseColor; + envColor = mix(envColor, base, MixRatio); + + gl_FragColor = vec4 (envColor, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.vert b/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.vert new file mode 100644 index 0000000..d4e8b44 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/envmap.vert @@ -0,0 +1,25 @@ +// +// Vertex shader for environment mapping with an +// equirectangular 2D texture +// +// Authors: John Kessenich, Randi Rost +// +// Copyright (c) 2002-2004 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// + +varying vec3 Normal; +varying vec3 EyeDir; +varying float LightIntensity; + +uniform vec3 LightPos; + +void main(void) +{ + gl_Position = ftransform(); + Normal = normalize(gl_NormalMatrix * gl_Normal); + vec4 pos = gl_ModelViewMatrix * gl_Vertex; + EyeDir = pos.xyz; + LightIntensity = max(dot(normalize(LightPos - EyeDir), Normal), 0.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/multitex.frag b/src/classes/org/jdesktop/j3d/examples/glsl_shader/multitex.frag new file mode 100644 index 0000000..b0426cd --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/multitex.frag @@ -0,0 +1,61 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +uniform float cloudFactor; +uniform sampler2D earthTex; +uniform sampler2D cloudTex; + +uniform sampler2D EnvMap; + +void main (void) +{ + vec2 tc0 = gl_TexCoord[0].xy; + vec2 tc1 = gl_TexCoord[1].xy; + + vec3 color0 = vec3(texture2D(cloudTex, tc0)); + vec3 color1 = vec3(texture2D(earthTex, tc1)); + vec3 finalColor = color0*cloudFactor + color1; + + gl_FragColor = vec4(finalColor, 1.0); +} diff --git a/src/classes/org/jdesktop/j3d/examples/glsl_shader/vertexshader.vert b/src/classes/org/jdesktop/j3d/examples/glsl_shader/vertexshader.vert new file mode 100644 index 0000000..8f331ec --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/glsl_shader/vertexshader.vert @@ -0,0 +1,61 @@ +/* + * $RCSfile$ + * + * Copyright (c) 2006 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$ + */ + +// A simple GLSL vertex program for demo. vertex attributes + +attribute float weight; +attribute vec3 temperature; + +void main() +{ + // Transform the vertex + vec4 outPosition = gl_ModelViewProjectionMatrix * gl_Vertex; + + // Compute color from temperature + vec4 outColor; + outColor = vec4(temperature * weight, 1); + // Assign output parameters + gl_FrontColor = outColor; + gl_Position = outPosition; +} diff --git a/src/classes/org/jdesktop/j3d/examples/lod/LOD.form b/src/classes/org/jdesktop/j3d/examples/lod/LOD.form new file mode 100644 index 0000000..7bba785 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/lod/LOD.form @@ -0,0 +1,36 @@ +<?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="LOD"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.form b/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.form new file mode 100644 index 0000000..631f59a --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/morphing/Morphing.form @@ -0,0 +1,36 @@ +<?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="Morphing"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.form b/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.form new file mode 100644 index 0000000..0c0b7e2 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/morphing/Pyramid2Cube.form @@ -0,0 +1,36 @@ +<?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="Pyramid2Cube"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.form b/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.form new file mode 100644 index 0000000..f8ced41 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/objload/ObjLoad.form @@ -0,0 +1,36 @@ +<?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="ObjLoad"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form new file mode 100644 index 0000000..a82c39c --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/package_info/PackageInfo.form @@ -0,0 +1,45 @@ +<?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="Package Info"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 400]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="myTextArea"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form new file mode 100644 index 0000000..daef961 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/package_info/QueryProperties.form @@ -0,0 +1,44 @@ +<?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="QueryProperties"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[400, 500]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTextArea" name="myTextArea"> + <Properties> + <Property name="columns" type="int" value="20"/> + <Property name="editable" type="boolean" value="false"/> + <Property name="rows" type="int" value="5"/> + </Properties> + </Component> + </SubComponents> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form new file mode 100644 index 0000000..8d60ac0 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/picking/TickTockPicking.form @@ -0,0 +1,36 @@ +<?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="TickTockPicking"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.form b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.form new file mode 100644 index 0000000..3c5f559 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediate.form @@ -0,0 +1,36 @@ +<?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="PureImmediate"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[250, 250]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.form b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.form new file mode 100644 index 0000000..dd881b5 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/pure_immediate/PureImmediateStereo.form @@ -0,0 +1,36 @@ +<?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="PureImmediateStereo"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[512, 256]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.form b/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.form new file mode 100644 index 0000000..036d770 --- /dev/null +++ b/src/classes/org/jdesktop/j3d/examples/sphere_motion/SphereMotion.form @@ -0,0 +1,36 @@ +<?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="SphereMotion"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + </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,44,0,0,1,-112"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + <SubComponents> + <Container class="javax.swing.JPanel" name="drawingPanel"> + <Properties> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[700, 700]"/> + </Property> + </Properties> + <Constraints> + <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> + <BorderConstraints direction="Center"/> + </Constraint> + </Constraints> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> + </Container> + </SubComponents> +</Form> diff --git a/src/resources/images/Java3Ddot3.jpg b/src/resources/images/Java3Ddot3.jpg Binary files differnew file mode 100644 index 0000000..011e574 --- /dev/null +++ b/src/resources/images/Java3Ddot3.jpg diff --git a/src/resources/images/duke-gears.jpg b/src/resources/images/duke-gears.jpg Binary files differnew file mode 100644 index 0000000..6016262 --- /dev/null +++ b/src/resources/images/duke-gears.jpg diff --git a/src/resources/images/mask.png b/src/resources/images/mask.png Binary files differnew file mode 100644 index 0000000..e5a2e35 --- /dev/null +++ b/src/resources/images/mask.png diff --git a/src/resources/images/wood.jpg b/src/resources/images/wood.jpg Binary files differnew file mode 100644 index 0000000..99370c5 --- /dev/null +++ b/src/resources/images/wood.jpg diff --git a/www/project_tools.html b/www/project_tools.html new file mode 100644 index 0000000..bc57931 --- /dev/null +++ b/www/project_tools.html @@ -0,0 +1,12 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> + <meta content="text/html; charset=ISO-8859-1" + http-equiv="content-type"> + <title>Project Tools</title> +</head> +<body> +<div><a href="http://wiki.java.net/bin/view/Javadesktop/Java3D">Wiki</a></div> +<div><a href="https://java3d.dev.java.net/binary-builds.html">Downloads</a></div> +</body> +</html> |