├── Downloads
├── Java3D 1.5.2
│ ├── Java3D 1.5.2.zip
│ ├── j3dcore-ogl.dll
│ ├── j3dcore.jar
│ ├── j3dutils.jar
│ └── vecmath.jar
└── Java3D 1.6.1
│ ├── Java3D 1.6.1.zip
│ ├── j3dcore.jar
│ ├── j3dutils.jar
│ ├── jogamp-fat.jar
│ └── vecmath.jar
├── Extra
└── Performance Guide for Java3D.pdf
├── Getting Started
├── Chapter 0.pdf
├── Chapter 1.pdf
├── Chapter 2.pdf
├── Chapter 3.pdf
├── Chapter 4.pdf
├── Chapter 5.pdf
├── Chapter 6.pdf
└── Chapter 7.pdf
├── Java3D Demo Source Code
├── COPYRIGHT.txt
├── LICENSE.txt
├── README-FIRST.txt
├── README-build.html
├── build.xml
├── manifest.mf
├── nbproject
│ └── project.xml
└── src
│ └── classes
│ └── org
│ └── jdesktop
│ └── j3d
│ └── examples
│ ├── alternate_appearance
│ ├── AlternateAppearanceBoundsTest.java
│ ├── AlternateAppearanceScopeTest.java
│ └── SphereGroup.java
│ ├── appearance
│ ├── AppearanceMixed.form
│ ├── AppearanceMixed.java
│ ├── AppearanceTest.form
│ ├── AppearanceTest.java
│ └── Tetrahedron.java
│ ├── applet3d
│ ├── Applet3D.form
│ ├── Applet3D.html
│ └── Applet3D.java
│ ├── background
│ ├── BackgroundGeometry.form
│ └── BackgroundGeometry.java
│ ├── cg_shader
│ ├── ObjLoadCg.form
│ ├── ObjLoadCg.java
│ ├── SamplerTestCg.form
│ ├── SamplerTestCg.java
│ ├── SphereCg.form
│ ├── SphereCg.java
│ ├── VertexAttrTestCg.form
│ ├── VertexAttrTestCg.java
│ ├── multitex_fp.cg
│ ├── simple_fp.cg
│ ├── simple_vp.cg
│ └── vertexshader_vp.cg
│ ├── collision
│ ├── Box.java
│ ├── CollisionDetector.java
│ ├── TickTockCollision.form
│ └── TickTockCollision.java
│ ├── configured_universe
│ ├── ConfigObjLoad.java
│ ├── README.txt
│ ├── j3d1x1-behavior.cfg
│ ├── j3d1x1-stereo.cfg
│ ├── j3d1x1-vr.cfg
│ ├── j3d1x1-window.cfg
│ ├── j3d1x1.cfg
│ ├── j3d1x2-flat.cfg
│ ├── j3d1x2-rot30.cfg
│ ├── j3d1x3-cave-vr.cfg
│ ├── j3d1x3-cave.cfg
│ ├── j3d1x3-rot45.cfg
│ └── j3d2x2-flat.cfg
│ ├── depth_func
│ ├── DepthFuncTest.form
│ ├── DepthFuncTest.java
│ ├── RenderFrame.form
│ └── RenderFrame.java
│ ├── distort_glyph
│ ├── DistortBehavior.java
│ ├── DistortGlyphTest.form
│ └── DistortGlyphTest.java
│ ├── dot3
│ ├── Dot3Demo.java
│ ├── MyCanvas.java
│ └── TextureControlPanel.java
│ ├── four_by_four
│ ├── BigCube.java
│ ├── Board.java
│ ├── Canvas2D.java
│ ├── Cube.java
│ ├── Cylinder.java
│ ├── FourByFour.html
│ ├── FourByFour.java
│ ├── ID.java
│ ├── PickDragBehavior.java
│ ├── Poles.java
│ ├── Positions.java
│ ├── README.txt
│ ├── instructions.txt
│ └── scores.txt
│ ├── fps_counter
│ ├── FPSCounter.java
│ ├── FPSCounterDemo.form
│ └── FPSCounterDemo.java
│ ├── gears
│ ├── Gear.java
│ ├── GearBox.form
│ ├── GearBox.java
│ ├── GearTest.form
│ ├── GearTest.java
│ ├── Shaft.java
│ ├── SpurGear.java
│ └── SpurGearThinBody.java
│ ├── geometry_by_ref
│ ├── GeometryByReferenceNIOBuffer.java
│ ├── GeometryByReferenceTest.java
│ ├── ImageComponentByReferenceTest.java
│ ├── InterleavedNIOBuffer.java
│ ├── InterleavedTest.java
│ └── TiledImage.java
│ ├── geometry_compression
│ ├── ObjectFileCompressor.java
│ ├── README.txt
│ ├── cgview.java
│ └── obj2cg.java
│ └── glsl_shader
│ ├── EnvironmentMappingGLSL.form
│ ├── EnvironmentMappingGLSL.java
│ ├── aabrick.frag
│ ├── aabrick.vert
│ ├── dimple.frag
│ └── dimple.vert
└── README.md
/Downloads/Java3D 1.5.2/Java3D 1.5.2.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.5.2/Java3D 1.5.2.zip
--------------------------------------------------------------------------------
/Downloads/Java3D 1.5.2/j3dcore-ogl.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.5.2/j3dcore-ogl.dll
--------------------------------------------------------------------------------
/Downloads/Java3D 1.5.2/j3dcore.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.5.2/j3dcore.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.5.2/j3dutils.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.5.2/j3dutils.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.5.2/vecmath.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.5.2/vecmath.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.6.1/Java3D 1.6.1.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.6.1/Java3D 1.6.1.zip
--------------------------------------------------------------------------------
/Downloads/Java3D 1.6.1/j3dcore.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.6.1/j3dcore.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.6.1/j3dutils.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.6.1/j3dutils.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.6.1/jogamp-fat.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.6.1/jogamp-fat.jar
--------------------------------------------------------------------------------
/Downloads/Java3D 1.6.1/vecmath.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Downloads/Java3D 1.6.1/vecmath.jar
--------------------------------------------------------------------------------
/Extra/Performance Guide for Java3D.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Extra/Performance Guide for Java3D.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 0.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 0.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 1.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 1.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 2.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 2.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 3.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 3.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 4.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 4.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 5.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 5.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 6.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 6.pdf
--------------------------------------------------------------------------------
/Getting Started/Chapter 7.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Getting Started/Chapter 7.pdf
--------------------------------------------------------------------------------
/Java3D Demo Source Code/COPYRIGHT.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Java-3D/Java3D/062d74bd006a65b38a2c3c1548c7d35a5c9cf35f/Java3D Demo Source Code/COPYRIGHT.txt
--------------------------------------------------------------------------------
/Java3D Demo Source Code/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
2 |
3 | Redistribution and use in source and binary forms, with or without
4 | modification, are permitted provided that the following conditions
5 | are met:
6 |
7 | - Redistribution of source code must retain the above copyright
8 | notice, this list of conditions and the following disclaimer.
9 |
10 | - Redistribution in binary form must reproduce the above copyright
11 | notice, this list of conditions and the following disclaimer in
12 | the documentation and/or other materials provided with the
13 | distribution.
14 |
15 | Neither the name of Sun Microsystems, Inc. or the names of
16 | contributors may be used to endorse or promote products derived
17 | from this software without specific prior written permission.
18 |
19 | This software is provided "AS IS," without a warranty of any
20 | kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
21 | WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
23 | EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
24 | NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
25 | USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
26 | DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
27 | ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
28 | CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
29 | REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
30 | INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
31 | POSSIBILITY OF SUCH DAMAGES.
32 |
33 | You acknowledge that this software is not designed, licensed or
34 | intended for use in the design, construction, operation or
35 | maintenance of any nuclear facility.
36 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/README-FIRST.txt:
--------------------------------------------------------------------------------
1 | The source code for the j3d-examples project is copyrighted code
2 | that is licensed to individuals or companies who download or otherwise
3 | access the code.
4 |
5 | The copyright notice for this project is in COPYRIGHT.txt
6 |
7 | The source code license information for this project is in LICENSE.txt
8 |
9 | Instructions for building this project are in README-build.html
10 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/README-build.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
49 |
51 | README-build: build instructions for the j3d-examples project
52 |
53 |
54 |
Building
55 | the 3D Example Programs
56 |
To
57 | build the 3D example programs, you must first checkout the j3d-examples
59 | CVS
60 | repository on java.net. For example, run
61 | the cvs checkout command as follows:
62 |
Any operating environment that supports the Java Platform and the
72 | Java 3DTM API should
73 | work. We have built j3d-examples on the following operating environments:
74 |
75 |
76 |
Solaris: Sparc (Ultra60 or better) running Solaris 9
77 |
Linux: i386/i586 running SuSE 9 or RedHat 9.0
78 |
Windows: Windows/XP (Windows
79 | 2000 should work, but is untested)
80 |
Before you start building, please check that your PATH must
94 | include the
95 | following directories:
96 |
97 |
<ant-root-dir>/bin
98 |
<jdk-root_dir>/bin
99 |
100 |
NOTE that Java 3D must be installed into the JDK that you have
101 | in
102 | your path OR you must put the
103 | Java 3D and vecmath jar files (j3dcore.jar, j3dutils.jar and
104 | vecmath.jar) in your CLASSPATH and the directory containing the
105 | Java 3D libraries in your LD_LIBRARY_PATH (Solaris or Linus) or
106 | PATH (Windows).
107 |
108 |
To build all examples:
109 |
110 | cd <cvs-root-dir>/j3d-examples
111 | ant
112 |
113 |
114 |
115 |
This will build all example programs and bundle them into a single
116 | jar
117 | file, j3d-examples.jar, placed in the dist
118 | directory.
119 |
120 |
Running j3d-examples
121 |
To run an example program, you must ensure that your CLASSPATH
122 | contains dist/j3d-examples.jar in its list. For example,
123 | to run the
124 | HelloUniverse program:
125 |
You may also point your Java-enabled web browser at some Java 3D
135 | applet
136 | examples, such as the src/classes/org/jdesktop/j3d/examples/FourByFour.html
137 | page, and run the Java 3D applet example programs
138 | from within your browser. Java 3D must be installed into the JDK
139 | in order to run Java 3D programs from within a browser.
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Implementation-Title: Java 3D Example Programs
3 | Implementation-Version: 1.5.2
4 | Implementation-Vendor: Sun Microsystems, Inc.
5 | Main-Class: org.jdesktop.j3d.examples.hello_universe.HelloUniverse
6 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.ant.freeform
4 |
5 |
6 |
7 | j3d-examples-1.5.2
8 |
9 |
10 |
11 |
12 | java
13 | src/classes
14 |
15 |
16 |
17 |
18 | jar
19 |
20 |
21 | clean
22 |
23 |
24 | run.HelloUniverse
25 |
26 |
27 | clean
28 | jar
29 |
30 |
31 |
32 | jar
33 | dist/j3d-examples.jar
34 | jar
35 |
36 |
37 |
38 |
39 |
40 | src/classes
41 |
42 |
43 | build.xml
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | ../j3d-core
55 | ../vecmath
56 |
57 |
58 |
59 |
60 | src/classes
61 | ../j3d-core/build/default/debug/lib/ext/j3dcore.jar:../j3d-core/build/default/debug/lib/ext/j3dutils.jar:../vecmath/build/debug/lib/ext/vecmath.jar
62 | dist/j3d-examples.jar
63 | 1.5
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/alternate_appearance/SphereGroup.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: SphereGroup.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:31 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.alternate_appearance;
46 |
47 | import javax.media.j3d.*;
48 | import javax.vecmath.*;
49 | import com.sun.j3d.utils.geometry.*;
50 |
51 | public class SphereGroup
52 | extends Group
53 | {
54 | Shape3D[] shapes;
55 | int numShapes = 0;
56 | // Constructors
57 | public SphereGroup( )
58 | {
59 | // radius x,y spacing x,y count appearance
60 | this( 0.25f, 0.75f, 0.75f, 5, 5, null, false );
61 | }
62 |
63 | public SphereGroup( Appearance app )
64 | {
65 | // radius x,y spacing x,y count appearance
66 | this( 0.25f, 0.75f, 0.75f, 5, 5, app, false );
67 | }
68 |
69 | public SphereGroup( float radius, float xSpacing, float ySpacing,
70 | int xCount, int yCount, boolean overrideflag )
71 | {
72 | this( radius, xSpacing, ySpacing, xCount, yCount, null, overrideflag );
73 | }
74 |
75 | public SphereGroup( float radius, float xSpacing, float ySpacing,
76 | int xCount, int yCount, Appearance app, boolean overrideflag )
77 | {
78 | if ( app == null )
79 | {
80 | app = new Appearance( );
81 | Material material = new Material( );
82 | material.setDiffuseColor( new Color3f( 0.8f, 0.8f, 0.8f ) );
83 | material.setSpecularColor( new Color3f( 0.0f, 0.0f, 0.0f ) );
84 | material.setShininess( 0.0f );
85 | app.setMaterial( material );
86 | }
87 |
88 | double xStart = -xSpacing * (double)(xCount-1) / 2.0;
89 | double yStart = -ySpacing * (double)(yCount-1) / 2.0;
90 |
91 | Sphere sphere = null;
92 | TransformGroup trans = null;
93 | Transform3D t3d = new Transform3D( );
94 | Vector3d vec = new Vector3d( );
95 | double x, y = yStart, z = 0.0;
96 | shapes = new Shape3D[xCount * yCount];
97 | for ( int i = 0; i < yCount; i++ )
98 | {
99 | x = xStart;
100 | for ( int j = 0; j < xCount; j++ ) {
101 | vec.set( x, y, z );
102 | t3d.setTranslation( vec );
103 | trans = new TransformGroup( t3d );
104 | addChild( trans );
105 |
106 | sphere = new Sphere(
107 | radius, // sphere radius
108 | Primitive.GENERATE_NORMALS, // generate normals
109 | 16, // 16 divisions radially
110 | app ); // it's appearance
111 | trans.addChild( sphere );
112 | x += xSpacing;
113 | shapes[numShapes] = sphere.getShape();
114 | if (overrideflag)
115 | shapes[numShapes].setCapability(Shape3D.ALLOW_APPEARANCE_OVERRIDE_WRITE);
116 | numShapes++;
117 | }
118 | y += ySpacing;
119 | }
120 | }
121 | Shape3D[] getShapes() {
122 | return shapes;
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceMixed.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/appearance/AppearanceTest.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/appearance/Tetrahedron.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Tetrahedron.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:31 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.appearance;
46 |
47 | import javax.media.j3d.*;
48 | import javax.vecmath.*;
49 |
50 | public class Tetrahedron extends Shape3D {
51 | private static final float sqrt3 = (float) Math.sqrt(3.0);
52 | private static final float sqrt3_3 = sqrt3 / 3.0f;
53 | private static final float sqrt24_3 = (float) Math.sqrt(24.0) / 3.0f;
54 |
55 | private static final float ycenter = 0.5f * sqrt24_3;
56 | private static final float zcenter = -sqrt3_3;
57 |
58 | private static final Point3f p1 = new Point3f(-1.0f, -ycenter, -zcenter);
59 | private static final Point3f p2 = new Point3f(1.0f, -ycenter, -zcenter);
60 | private static final Point3f p3 =
61 | new Point3f(0.0f, -ycenter, -sqrt3 - zcenter);
62 | private static final Point3f p4 =
63 | new Point3f(0.0f, sqrt24_3 - ycenter, 0.0f);
64 |
65 | private static final Point3f[] verts = {
66 | p1, p2, p4, // front face
67 | p1, p4, p3, // left, back face
68 | p2, p3, p4, // right, back face
69 | p1, p3, p2, // bottom face
70 | };
71 |
72 | private TexCoord2f texCoord[] = {
73 | new TexCoord2f(0.0f, 0.0f),
74 | new TexCoord2f(1.0f, 0.0f),
75 | new TexCoord2f(0.5f, sqrt3 / 2.0f),
76 | };
77 |
78 | public Tetrahedron() {
79 | int i;
80 |
81 | TriangleArray tetra = new TriangleArray(12, TriangleArray.COORDINATES |
82 | TriangleArray.NORMALS | TriangleArray.TEXTURE_COORDINATE_2);
83 |
84 | tetra.setCoordinates(0, verts);
85 | for (i = 0; i < 12; i++) {
86 | tetra.setTextureCoordinate(0, i, texCoord[i%3]);
87 | }
88 |
89 | int face;
90 | Vector3f normal = new Vector3f();
91 | Vector3f v1 = new Vector3f();
92 | Vector3f v2 = new Vector3f();
93 | Point3f [] pts = new Point3f[3];
94 | for (i = 0; i < 3; i++) pts[i] = new Point3f();
95 |
96 | for (face = 0; face < 4; face++) {
97 | tetra.getCoordinates(face*3, pts);
98 | v1.sub(pts[1], pts[0]);
99 | v2.sub(pts[2], pts[0]);
100 | normal.cross(v1, v2);
101 | normal.normalize();
102 | for (i = 0; i < 3; i++) {
103 | tetra.setNormal((face * 3 + i), normal);
104 | }
105 | }
106 | this.setGeometry(tetra);
107 | this.setAppearance(new Appearance());
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
70 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/applet3d/Applet3D.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Simple 3D Applet
5 |
6 |
7 |
24 |
Simple Java 3D Applet
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/background/BackgroundGeometry.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
38 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/ObjLoadCg.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/SamplerTestCg.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/SphereCg.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/multitex_fp.cg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: multitex_fp.cg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 | float4 main(float2 tc0 : TEXCOORD0,
46 | float2 tc1: TEXCOORD1,
47 | uniform float cloudFactor,
48 | uniform sampler2D earthTex : TEXUNIT1,
49 | uniform sampler2D cloudTex : TEXUNIT0): COLOR
50 | {
51 | float3 color0 = tex2D(cloudTex, tc0).rgb;
52 | float3 color1 = tex2D(earthTex, tc1).rgb;
53 | float3 finalColor = color0*cloudFactor + color1;
54 |
55 | return float4(finalColor, 1.0);
56 | }
57 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_fp.cg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: simple_fp.cg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 | // Simple fragment program to attenuate the input fragment color as a
46 | // function of the distance of the fragment position from the center
47 | // of the window
48 |
49 | // define inputs from vertex shader to fragment shader
50 | struct vertin
51 | {
52 | float4 HPosition : POSITION;
53 | float4 FragPos : TEXCOORD0;
54 | float4 Color0 : COLOR0;
55 | };
56 |
57 | float4 main(vertin IN) : COLOR
58 | {
59 | // Compute distance from center in range [0.0, 1.0]
60 | float2 dist = min(abs(IN.FragPos.xy), 1.0f);
61 | float2 invDist = 1.0f - dist;
62 |
63 | // Compute attenuation
64 | float atten = invDist.x * invDist.y;
65 | float4 outcolor = float4(IN.Color0 * atten);
66 |
67 | return outcolor;
68 | }
69 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/simple_vp.cg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: simple_vp.cg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 | /*********************************************************************NVMH3****
46 | Path: NVSDK\Common\media\programs
47 | File: simple.cg
48 |
49 | Copyright NVIDIA Corporation 2002
50 | TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
51 | *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
52 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
53 | AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
54 | BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
55 | WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
56 | BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
57 | ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
58 | BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
59 |
60 |
61 | Comments:
62 |
63 | ******************************************************************************/
64 |
65 | // Simple vertex shader, derived from NVIDIA's simple.cg sample
66 | // shader, that modulates the lit color with a noise pattern based on
67 | // vertex position.
68 |
69 | // define inputs from application
70 | struct appin
71 | {
72 | float4 Position : POSITION;
73 | float4 Normal : NORMAL;
74 | };
75 |
76 | // define outputs from vertex shader
77 | struct vertout
78 | {
79 | float4 HPosition : POSITION;
80 | float4 FragPos : TEXCOORD0;
81 | float4 Color0 : COLOR0;
82 | };
83 |
84 | vertout main(appin IN,
85 | uniform float4x4 ModelViewProj,
86 | uniform float4x4 ModelViewIT,
87 | uniform float4 LightVec,
88 | uniform float4 LightColor,
89 | uniform float4 DiffuseMaterial,
90 | uniform float4 SpecularMaterial)
91 | {
92 | vertout OUT;
93 |
94 | // Assume that the profile is PROFILE_ARBVP1...
95 | // #ifdef PROFILE_ARBVP1
96 | ModelViewProj = glstate.matrix.mvp;
97 | ModelViewIT = glstate.matrix.invtrans.modelview[0];
98 | LightVec = glstate.light[0].position;
99 | LightColor = glstate.light[0].diffuse;
100 | DiffuseMaterial = glstate.material.front.diffuse;
101 | SpecularMaterial = glstate.material.front.specular;
102 | // #endif
103 |
104 | // transform vertex position into homogenous clip-space
105 | OUT.HPosition = mul(ModelViewProj, IN.Position);
106 |
107 | // Output the post-perspective-divide position as FragPos
108 | float invW = 1.0f / OUT.HPosition.w;
109 | OUT.FragPos = OUT.HPosition * invW;
110 |
111 | // transform normal from model-space to view-space
112 | float3 normalVec = normalize(mul(ModelViewIT, IN.Normal).xyz);
113 |
114 | // store normalized light vector
115 | float3 lightVec = normalize(LightVec.xyz);
116 |
117 | // calculate half angle vector
118 | float3 eyeVec = float3(0.0, 0.0, 1.0);
119 | float3 halfVec = normalize(lightVec + eyeVec);
120 |
121 | // calculate diffuse component
122 | float diffuse = dot(normalVec, lightVec);
123 |
124 | // calculate specular component
125 | float specular = dot(normalVec, halfVec);
126 |
127 | // The lit() function is a handy function in the standard library that
128 | // can be used to accelerate your lighting calculations.
129 | //
130 | // This function return a vector containing these values:
131 | // result.x = 1.0;
132 | // result.y = max(diffuse, 0);
133 | // result.z = if (result.y > 0.0) then pow(specular, 32) else 0.0
134 | // result.w = 1.0;
135 |
136 | // Use the lit function to compute lighting vector from diffuse and
137 | // specular values
138 | float4 lighting = lit(diffuse, specular, 32);
139 |
140 | // combine diffuse and specular contributions
141 | float3 color0 = (lighting.y * DiffuseMaterial.xyz * LightColor.xyz) +
142 | (lighting.z * SpecularMaterial.xyz);
143 |
144 | // Generate a pseudo-random noise pattern
145 | // float3 xyz = clamp((normalVec.xyz + 1.0) * 0.5, 0.0, 1.0);
146 | float3 xyz = clamp((OUT.HPosition.xyz + 1.0) * 0.5, 0.0, 1.0);
147 |
148 | xyz = frac(xyz * 262144.0);
149 | float randSeed = frac(3.0 * xyz.x + 5.0 * xyz.y + 7.0 * xyz.z);
150 |
151 | float3 altColor;
152 |
153 | randSeed = frac(37.0 * randSeed);
154 | altColor.x = randSeed * 0.5 + 0.5;
155 | randSeed = frac(37.0 * randSeed);
156 | altColor.y = randSeed * 0.5 + 0.5;
157 | randSeed = frac(37.0 * randSeed);
158 | altColor.z = randSeed * 0.5 + 0.5;
159 | randSeed = frac(37.0 * randSeed);
160 | float altAlpha = randSeed * 0.5;
161 |
162 | // Apply noise and output final vertex color
163 | OUT.Color0.rgb = lerp(color0, altColor, altAlpha);
164 | OUT.Color0.a = 1.0;
165 |
166 | return OUT;
167 | }
168 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/cg_shader/vertexshader_vp.cg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: vertexshader_vp.cg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 |
46 | // define inputs from application
47 | struct appin
48 | {
49 | float4 Position : POSITION;
50 | float4 Normal : NORMAL;
51 | };
52 |
53 | // define outputs from vertex shader
54 | struct vertout
55 | {
56 | float4 Position : POSITION;
57 | float4 Color0 : COLOR0;
58 | };
59 |
60 |
61 | vertout main(appin IN,
62 | float3 temperature,
63 | float weight,
64 | uniform float4x4 ModelViewProj)
65 | {
66 | vertout OUT;
67 |
68 | ModelViewProj = glstate.matrix.mvp;
69 |
70 | // transform vertex position into homogenous clip-space
71 | OUT.Position = mul(ModelViewProj, IN.Position);
72 |
73 | // Compute color from temperature, weight
74 | OUT.Color0 = float4(temperature * weight, 1.0);
75 |
76 | return OUT;
77 | }
78 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/collision/Box.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Box.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.collision;
46 |
47 | import javax.media.j3d.*;
48 | import javax.vecmath.*;
49 |
50 | public class Box extends Shape3D {
51 |
52 | public Box(double xsize, double ysize, double zsize) {
53 | super();
54 | double xmin = -xsize/2.0;
55 | double xmax = xsize/2.0;
56 | double ymin = -ysize/2.0;
57 | double ymax = ysize/2.0;
58 | double zmin = -zsize/2.0;
59 | double zmax = zsize/2.0;
60 |
61 | QuadArray box = new QuadArray(24, QuadArray.COORDINATES);
62 |
63 | Point3d verts[] = new Point3d[24];
64 |
65 | // front face
66 | verts[0] = new Point3d(xmax, ymin, zmax);
67 | verts[1] = new Point3d(xmax, ymax, zmax);
68 | verts[2] = new Point3d(xmin, ymax, zmax);
69 | verts[3] = new Point3d(xmin, ymin, zmax);
70 | // back face
71 | verts[4] = new Point3d(xmin, ymin, zmin);
72 | verts[5] = new Point3d(xmin, ymax, zmin);
73 | verts[6] = new Point3d(xmax, ymax, zmin);
74 | verts[7] = new Point3d(xmax, ymin, zmin);
75 | // right face
76 | verts[8] = new Point3d(xmax, ymin, zmin);
77 | verts[9] = new Point3d(xmax, ymax, zmin);
78 | verts[10] = new Point3d(xmax, ymax, zmax);
79 | verts[11] = new Point3d(xmax, ymin, zmax);
80 | // left face
81 | verts[12] = new Point3d(xmin, ymin, zmax);
82 | verts[13] = new Point3d(xmin, ymax, zmax);
83 | verts[14] = new Point3d(xmin, ymax, zmin);
84 | verts[15] = new Point3d(xmin, ymin, zmin);
85 | // top face
86 | verts[16] = new Point3d(xmax, ymax, zmax);
87 | verts[17] = new Point3d(xmax, ymax, zmin);
88 | verts[18] = new Point3d(xmin, ymax, zmin);
89 | verts[19] = new Point3d(xmin, ymax, zmax);
90 | // bottom face
91 | verts[20] = new Point3d(xmin, ymin, zmax);
92 | verts[21] = new Point3d(xmin, ymin, zmin);
93 | verts[22] = new Point3d(xmax, ymin, zmin);
94 | verts[23] = new Point3d(xmax, ymin, zmax);
95 |
96 | box.setCoordinates(0, verts);
97 | setGeometry(box);
98 | setAppearance(new Appearance());
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/collision/CollisionDetector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: CollisionDetector.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:33 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.collision;
46 |
47 | import java.util.Enumeration;
48 | import javax.media.j3d.*;
49 | import javax.vecmath.*;
50 |
51 | public class CollisionDetector extends Behavior {
52 | private static final Color3f highlightColor =
53 | new Color3f(0.0f, 1.0f, 0.0f);
54 | private static final ColoringAttributes highlight =
55 | new ColoringAttributes(highlightColor,
56 | ColoringAttributes.SHADE_GOURAUD);
57 |
58 | private boolean inCollision = false;
59 | private Shape3D shape;
60 | private ColoringAttributes shapeColoring;
61 | private Appearance shapeAppearance;
62 |
63 | private WakeupOnCollisionEntry wEnter;
64 | private WakeupOnCollisionExit wExit;
65 |
66 |
67 | public CollisionDetector(Shape3D s) {
68 | shape = s;
69 | shapeAppearance = shape.getAppearance();
70 | shapeColoring = shapeAppearance.getColoringAttributes();
71 | inCollision = false;
72 | }
73 |
74 | public void initialize() {
75 | wEnter = new WakeupOnCollisionEntry(shape);
76 | wExit = new WakeupOnCollisionExit(shape);
77 | wakeupOn(wEnter);
78 | }
79 |
80 | public void processStimulus(Enumeration criteria) {
81 | inCollision = !inCollision;
82 |
83 | if (inCollision) {
84 | shapeAppearance.setColoringAttributes(highlight);
85 | wakeupOn(wExit);
86 | }
87 | else {
88 | shapeAppearance.setColoringAttributes(shapeColoring);
89 | wakeupOn(wEnter);
90 | }
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/collision/TickTockCollision.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/README.txt:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: README.txt,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.3 $
41 | * $Date: 2007/02/09 17:21:34 $
42 | * $State: Exp $
43 | */
44 |
45 | This directory contains a simple example application that demonstrates the
46 | ConfiguredUniverse utility class available in the com.sun.j3d.utils.universe
47 | package. J3DFly, available separately, is a fully featured application that
48 | also uses ConfiguredUniverse.
49 |
50 | ConfiguredUniverse is an extension of SimpleUniverse that can set up an
51 | interactive viewing environment based upon the contents of a site-specific
52 | configuration file. This is useful when an application needs to run without
53 | change across a broad range of viewing configurations and locally available
54 | input and audio devices. InputDevice implementations can be instantiated by
55 | ConfiguredUniverse and their Sensors can be retrieved by applications along
56 | with the names bound to them in the configuration file.
57 |
58 | Supported viewing configurations include windows on conventional desktops,
59 | stereo-enabled views, fullscreen immersive displays on single or multiple
60 | screens, and virtual reality installations such as cave and head-mounted
61 | displays incorporating 6-degree-of-freedom sensor devices.
62 |
63 | The ConfigObjLoad application is a modified version of the ObjLoad example
64 | program which uses the ConfiguredUniverse utility instead of SimpleUniverse.
65 | It also differs in the following other respects:
66 |
67 | It is an application and cannot be run in a browser. ConfiguredUniverse
68 | creates a JFrame, JPanel, and Canvas3D itself for each screen and is
69 | oriented towards multiple fullscreen viewing environments, although
70 | conventional windowed displays are also supported. The components
71 | created are easily accessable so applications can still incorporate them
72 | into their own user interfaces.
73 |
74 | The configuration file to load is specified by the j3d.configURL
75 | property. If one is not specified, it will load the file j3d1x1-window.cfg
76 | in this directory.
77 |
78 | Alternative custom view platform behaviors other than OrbitBehavior can
79 | be used by specifying the behavior in the configuration file.
80 |
81 | It can retrieve a 6DOF Sensor specified in the configuration file and
82 | use it to demonstrate the Mouse6DPointerBehavior class.
83 |
84 | Typing a "q" or the Escape key will terminate the example program. This
85 | is useful for fullscreen configurations.
86 |
87 | To load a specific configuration file, set the j3d.configURL property on the
88 | command line:
89 |
90 | java -Dj3d.configURL= ConfigObjLoad
91 |
92 | For example, to load j3d1x2-rot30.cfg in the current directory, run
93 |
94 | java -Dj3d.configURL=file:j3d1x2-rot30.cfg ConfigObjLoad
95 |
96 | This directory includes the following sample configuration files. Normally
97 | a configuration file is site-specific but many of these can used as-is.
98 | Others may need customization for screen sizes, available input devices, and
99 | PhysicalBody parameters.
100 |
101 | j3d1x1.cfg: single fullscreen desktop configuration.
102 |
103 | j3d1x1-behavior.cfg: single fullscreen desktop configuration with a
104 | configurable view platform behavior.
105 |
106 | j3d1x1-stereo.cfg: single fullscreen desktop configuration with stereo
107 | viewing.
108 |
109 | j3d1x1-vr.cfg: single fullscreen desktop configuration with stereo viewing,
110 | head tracker, and 6DOF mouse.
111 |
112 | j3d1x1-window.cfg: single screen windowed desktop configuration.
113 |
114 | j3d1x2-flat.cfg: dual-screen flat desktop configuration.
115 |
116 | j3d1x2-rot30.cfg: dual-screen desktop configuration with each screen rotated
117 | toward the other by 30 degrees about Y.
118 |
119 | j3d1x3-cave.cfg: 3-projector configuration with screens to the left, front,
120 | and right of the user.
121 |
122 | j3d1x3-cave-vr.cfg: 3-projector configuration with screens to the left,
123 | front, and right of the user. Includes head tracking and stereo
124 | viewing.
125 |
126 | j3d1x3-rot45.cfg: 3-screen desktop configuration with left and right screens
127 | angled by 45 degrees from the center screen.
128 |
129 | j3d2x2-flat.cfg: 4-screen projector configuration arranged in a 2x2 power
130 | wall.
131 |
132 | Note: JDK 1.4 or newer is required when configuring multiple screens if the
133 | X11 Xinerama extension is being used to create a single virtual screen.
134 | This is due to a limitation of the getScreenDevices() method in the JDK 1.3
135 | version of GraphicsConfiguration which returns only a single GraphicsDevice
136 | from a virtual screen. ConfiguredUniverse will report this condition as an
137 | error in specifying more screens than are available.
138 |
139 | Also: Graphics performance may be degraded in some environments when using a
140 | virtual screen device. See the description of the j3d.disableXinerama
141 | property for possible performance improvements when using Xinerama.
142 |
143 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-behavior.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x1-behavior.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:34 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for single fullscreen desktop configuration.
49 | * A view platform behavior is created and configured here as well.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create a new screen object and associate it with a logical name and a
55 | // number. This number is used as an index to retrieve the AWT GraphicsDevice
56 | // from the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen center 0)
62 |
63 | // Create a fullscreen window
64 | //
65 | (ScreenAttribute center WindowSize NoBorderFullScreen)
66 |
67 | // Set the available image area for the full screen.
68 | //
69 | (ScreenAttribute center PhysicalScreenWidth 0.360)
70 | (ScreenAttribute center PhysicalScreenHeight 0.288)
71 |
72 | // Set the TrackerBaseToImagePlate transform for this screen. The coexistence
73 | // to tracker base transform is identity by default, so the tracker base origin
74 | // and orientation will also set the origin and orientation of coexistence
75 | // coordinates in the physical world. This is the primary purpose of setting
76 | // this transform when neither head tracking nor multiple screens are being
77 | // used.
78 | //
79 | // The tracker base and center of coexistence are set here to the middle of the
80 | // screen's image plate. Their basis vectors are aligned with the image plate
81 | // basis vectors. The physical eyepoint position will be set relative to
82 | // coexistence coordinates below.
83 | //
84 | (ScreenAttribute center TrackerBaseToImagePlate
85 | (Translate 0.180 0.144 0.000))
86 |
87 | // Create a view using the defined screen.
88 | //
89 | (NewView view0)
90 | (ViewAttribute view0 Screen center)
91 |
92 | // Set the eyepoint relative to coexistence coordinates. Here it is set 45cm
93 | // toward the user along +Z. Skewed projections can be set by by offsetting
94 | // the eyepoint along X and Y.
95 | //
96 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45))
97 |
98 | // Create a view platform behavior. Here we use OrbitBehavior, although any
99 | // concrete subclass of the abstract ViewPlatformBehavior with a parameterless
100 | // constructor could be used. The logical name to assign to this behavior is
101 | // specified by the 2nd argument to the NewViewPlatformBehavior command, while
102 | // the 3rd argument is the name of the ViewPlatformBehavior subclass. It is
103 | // instantiated through introspection.
104 | //
105 | // Attributes defined by the abstract ViewPlatformBehavior superclass itself
106 | // can be set directly with the ViewPlatformBehaviorAttribute command. The
107 | // details of the subclass implementation are not known to ConfiguredUniverse,
108 | // so any configuration information needed by such a subclass is set by the
109 | // ViewPlatformBehaviorProperty command. The property name specified by that
110 | // command is taken to be a method name of the subclass and invoked through
111 | // introspection.
112 | //
113 | // View platform behaviors often need sensors or canvases as event sources to
114 | // drive the behavior action. An implementation of ViewPlatformBehavior always
115 | // gets the current ViewingPlatform through the setViewingPlatform() method.
116 | // The canvases used by the ViewingPlatform can be retrieved by calling its
117 | // getViewers() method and then calling each Viewer's getCanvas3Ds()
118 | // method. Sensors can be retrived by calling the ViewingPlatform method
119 | // getUniverse(), checking to see if the returned SimpleUniverse is a
120 | // ConfiguredUniverse, and then calling its getNamedSensors() method.
121 | //
122 | (NewViewPlatformBehavior vpb com.sun.j3d.utils.behaviors.vp.OrbitBehavior)
123 |
124 | // Set the scheduling bounds to be a BoundingSphere with its center at
125 | // (0.0 0.0 0.0) and a radius of 100 meters.
126 | //
127 | (ViewPlatformBehaviorAttribute vpb SchedulingBounds
128 | (BoundingSphere (0.0 0.0 0.0) 100.0))
129 |
130 | // Set properties specific to OrbitBehavior. All arguments following the
131 | // method name are wrapped and passed to the specified method as an array of
132 | // Objects. Strings "true" and "false" get turned into Boolean, and number
133 | // strings get turned into Double. Constructs such as (0.0 1.0 2.0) and
134 | // ((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
135 | // Point3d and Matrix4d respectively. Note that last row of a Matrix4d doesn't
136 | // need to be specified; it is implicitly (0.0 0.0 0.0 1.0).
137 | //
138 | // The REVERSE_ALL flags are usually passed to the OrbitBehavior constructor.
139 | // Since it is being instantiated with its parameterless constructor the
140 | // reverse flags are set here explicitly.
141 | //
142 | (ViewPlatformBehaviorProperty vpb ReverseTranslate true)
143 | (ViewPlatformBehaviorProperty vpb ReverseRotate true)
144 | (ViewPlatformBehaviorProperty vpb ReverseZoom true)
145 |
146 | // Create a new view platform and set the view platform behavior.
147 | //
148 | (NewViewPlatform vp)
149 | (ViewPlatformAttribute vp ViewPlatformBehavior vpb)
150 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-stereo.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x1-stereo.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:34 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for single fullscreen stereo desktop
49 | * configuration with no head tracking.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create a new screen object and associate it with a logical name and a
55 | // number. This number is used as an index to retrieve the AWT GraphicsDevice
56 | // from the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen center 0)
62 |
63 | // Create a fullscreen window
64 | //
65 | (ScreenAttribute center WindowSize NoBorderFullScreen)
66 |
67 | // Set the available image area for the full screen.
68 | //
69 | (ScreenAttribute center PhysicalScreenWidth 0.360)
70 | (ScreenAttribute center PhysicalScreenHeight 0.288)
71 |
72 | // Set the TrackerBaseToImagePlate transform for this screen. The coexistence
73 | // to tracker base transform is identity by default, so the tracker base origin
74 | // and orientation will also set the origin and orientation of coexistence
75 | // coordinates in the physical world. This is the primary purpose of setting
76 | // this transform when neither head tracking nor multiple screens are being
77 | // used.
78 | //
79 | // The tracker base and center of coexistence are set here to the middle of the
80 | // screen's image plate. Their basis vectors are aligned with the image plate
81 | // basis vectors. The physical eyepoint position will be set relative to
82 | // coexistence coordinates below.
83 | //
84 | (ScreenAttribute center TrackerBaseToImagePlate
85 | (Translate 0.180 0.144 0.000))
86 |
87 | // Define the physical body.
88 | //
89 | // The head origin is halfway between the eyes, with X extending to the right,
90 | // Y up, and positive Z extending into the skull.
91 | //
92 | (NewPhysicalBody SiteUser)
93 |
94 | // Set the interpupilary distance. This sets the LeftEyePosition and
95 | // RightEyePosition to offsets of half this distance along both directions of
96 | // the X axis.
97 | //
98 | (PhysicalBodyAttribute SiteUser StereoEyeSeparation 0.066)
99 |
100 | // Create a view using the defined screen and physical body.
101 | //
102 | (NewView view0)
103 | (ViewAttribute view0 Screen center)
104 | (ViewAttribute view0 PhysicalBody SiteUser)
105 |
106 | // Set the eyepoint relative to coexistence coordinates. Here it is set 45cm
107 | // toward the user along +Z.
108 | //
109 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45))
110 |
111 | // Enable stereo viewing.
112 | //
113 | (ViewAttribute view0 StereoEnable true)
114 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1-window.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x1-window.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:34 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for a conventional single screen, windowed
49 | * desktop configuration.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create a new screen object and associate it with a logical name and a
55 | // number. This number is used as an index to retrieve the AWT GraphicsDevice
56 | // from the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen center 0)
62 |
63 | // Create a 700x700 pixel window on the screen.
64 | //
65 | (ScreenAttribute center WindowSize (700.0 700.0))
66 |
67 | // Create a view using the defined screen.
68 | //
69 | (NewView view0)
70 | (ViewAttribute view0 Screen center)
71 |
72 | // ConfiguredUniverse is oriented toward multi-screen viewing environments, so
73 | // it sets the following attributes to those listed. For a conventional window
74 | // on a single screen desktop configuration we need to set them back to their
75 | // normal defaults.
76 | //
77 | // View.windowEyePointPolicy RELATIVE_TO_COEXISTENCE
78 | // View.windowMovementPolicy VIRTUAL_WORLD
79 | // View.windowResizePolicy VIRTUAL_WORLD
80 | // View.coexistenceCenteringEnable false
81 | // ViewPlatform.viewAttachPolicy NOMINAL_SCREEN
82 | //
83 | (ViewAttribute view0 WindowEyepointPolicy RELATIVE_TO_FIELD_OF_VIEW)
84 | (ViewAttribute view0 WindowMovementPolicy PHYSICAL_WORLD)
85 | (ViewAttribute view0 WindowResizePolicy PHYSICAL_WORLD)
86 | (ViewAttribute view0 CoexistenceCenteringEnable true)
87 |
88 | (NewViewPlatform vp)
89 | (ViewPlatformAttribute vp ViewAttachPolicy NOMINAL_HEAD)
90 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x1.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x1.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:34 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for a single fullscreen desktop configuration.
49 | *
50 | ************************************************************************
51 | */
52 |
53 | // Create a new screen object and associate it with a logical name and a
54 | // number. This number is used as an index to retrieve the AWT GraphicsDevice
55 | // from the array that GraphicsEnvironment.getScreenDevices() returns.
56 | //
57 | // NOTE: The GraphicsDevice order in the array is specific to the local
58 | // site and display system.
59 | //
60 | (NewScreen center 0)
61 |
62 | // Create a fullscreen window
63 | //
64 | (ScreenAttribute center WindowSize NoBorderFullScreen)
65 |
66 | // Set the available image area for the full screen. This is important when an
67 | // explicit ScreenScale view attribute is defined for precise scaling between
68 | // objects in the virtual world and their projections into the physical world.
69 | // The defaults are 0.365 meters for width and 0.292 meters for height.
70 | //
71 | (ScreenAttribute center PhysicalScreenWidth 0.360)
72 | (ScreenAttribute center PhysicalScreenHeight 0.288)
73 |
74 | // Set the TrackerBaseToImagePlate transform for this screen. The coexistence
75 | // to tracker base transform is identity by default, so the tracker base origin
76 | // and orientation will also set the origin and orientation of coexistence
77 | // coordinates in the physical world. This is the primary purpose of setting
78 | // this transform when neither head tracking nor multiple screens are being
79 | // used.
80 | //
81 | // The tracker base and center of coexistence are set here to the middle of the
82 | // screen's image plate. Their basis vectors are aligned with the image plate
83 | // basis vectors. The physical eyepoint position will be set relative to
84 | // coexistence coordinates below.
85 | //
86 | (ScreenAttribute center TrackerBaseToImagePlate
87 | (Translate 0.180 0.144 0.000))
88 |
89 | // Create a view using the defined screen.
90 | //
91 | (NewView view0)
92 | (ViewAttribute view0 Screen center)
93 |
94 | // Set the eyepoint relative to coexistence coordinates. Here it is set 45cm
95 | // toward the user along +Z. Skewed projections can be created by offsetting
96 | // the eyepoint along X and/or Y.
97 | //
98 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45))
99 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-flat.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x2-flat.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:35 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for dual-screen (flat) desktop configuration
49 | * with no head tracking.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create new screen objects and associate them with logical names and numbers.
55 | // These numbers are used as indices to retrieve the AWT GraphicsDevice from
56 | // the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen left 0)
62 | (NewScreen right 1)
63 |
64 | // Set the screen dimensions.
65 | //
66 | (ScreenAttribute left PhysicalScreenWidth 0.360)
67 | (ScreenAttribute left PhysicalScreenHeight 0.288)
68 |
69 | (ScreenAttribute right PhysicalScreenWidth 0.360)
70 | (ScreenAttribute right PhysicalScreenHeight 0.288)
71 |
72 | // Specify full screen windows.
73 | //
74 | (ScreenAttribute left WindowSize NoBorderFullScreen)
75 | (ScreenAttribute right WindowSize NoBorderFullScreen)
76 |
77 | // Set the TrackerBaseToImagePlate transforms for these screens. This
78 | // transforms points in tracker base coordinates to each screen's image plate
79 | // coordinates, where the origin of the image plate is defined to be the lower
80 | // left corner of the screen with X increasing to the right, Y increasing to
81 | // the top, and Z increasing away from the screen.
82 | //
83 | // Without head or sensor tracking the tracker base is still needed as a fixed
84 | // frame of reference for describing the orientation and position of each
85 | // screen to the others. The coexistence to tracker base transform is set to
86 | // identity by default, so the tracker base origin and orientation will also
87 | // set the origin and orientation of coexistence coordinates in the physical
88 | // world.
89 | //
90 | // The tracker base and center of coexistence is set here to the middle of the
91 | // edge shared by the two screens.
92 | //
93 | (ScreenAttribute left TrackerBaseToImagePlate
94 | (Translate 0.360 0.144 0.0))
95 | (ScreenAttribute right TrackerBaseToImagePlate
96 | (Translate 0.000 0.144 0.0))
97 |
98 | // Sometimes it is desirable to include the bevels in between the monitors in
99 | // the TrackerBaseToImagePlate transforms, so that the abutting bevels obscure
100 | // the view of the virtual world instead of stretching it out between the
101 | // monitors. For a bevel width of 4.5 cm on each monitor, the above commands
102 | // would become the following:
103 | //
104 | // (ScreenAttribute left TrackerBaseToImagePlate
105 | // (Translate 0.405 0.144 0.0))
106 | // (ScreenAttribute right TrackerBaseToImagePlate
107 | // (Translate -0.045 0.144 0.0))
108 | //
109 | // Conversely, a similar technique may be used to include overlap between the
110 | // screens. This is useful for projection systems which use edge blending
111 | // to provide seamless integration between screens.
112 |
113 |
114 | // Create a view using the defined screens.
115 | //
116 | (NewView view0)
117 | (ViewAttribute view0 Screen left)
118 | (ViewAttribute view0 Screen right)
119 |
120 | // Set the eyepoint relative to coexistence coordinates. Here it is set 45cm
121 | // toward the user along Z, extending out from the midpoint of the edge shared
122 | // by the two screens. This will create the appropriate skewed projection
123 | // frustums for each image plate.
124 | //
125 | // If a planar display surface is all that is required, the same effect could
126 | // be achieved in a virtual screen enviroment such as Xinerama by simply
127 | // creating a canvas that spans both screens. In some display environments the
128 | // use of a canvas that spans multiple physical screens may cause significant
129 | // performance degradation, however.
130 | //
131 | // See j3d1x2-rot30 for an example of a non-planar configuration that cannot be
132 | // achieved through a single canvas spanning both screens.
133 | //
134 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45))
135 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x2-rot30.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x2-rot30.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:35 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for a dual-screen desktop configuration
49 | * with each screen rotated toward the other by 30 degrees about Y from
50 | * planar. The inside angle between them is 120 degrees.
51 | *
52 | ************************************************************************
53 | */
54 |
55 | // Create new screen objects and associate them with logical names and numbers.
56 | // These numbers are used as indices to retrieve the AWT GraphicsDevice from
57 | // the array that GraphicsEnvironment.getScreenDevices() returns.
58 | //
59 | // NOTE: The GraphicsDevice order in the array is specific to the local
60 | // site and display system.
61 | //
62 | (NewScreen left 0)
63 | (NewScreen right 1)
64 |
65 | // Set the available image areas for full screens.
66 | //
67 | (ScreenAttribute left PhysicalScreenWidth 0.360)
68 | (ScreenAttribute left PhysicalScreenHeight 0.288)
69 |
70 | (ScreenAttribute right PhysicalScreenWidth 0.360)
71 | (ScreenAttribute right PhysicalScreenHeight 0.288)
72 |
73 | // Specify full screen windows.
74 | //
75 | (ScreenAttribute left WindowSize NoBorderFullScreen)
76 | (ScreenAttribute right WindowSize NoBorderFullScreen)
77 |
78 | // Set the TrackerBaseToImagePlate transforms for these screens.
79 | //
80 | // The tracker base is set here to the middle of the edge shared by the two
81 | // screens. Each screen is rotated 30 degrees toward the other about the
82 | // tracker base +Y axis, so that the tracker base +Z is centered between the
83 | // two screens.
84 | //
85 | (ScreenAttribute left TrackerBaseToImagePlate
86 | (RotateTranslate (Rotate 0.000 -30.000 0.0)
87 | (Translate 0.360 0.144 0.0)))
88 |
89 | (ScreenAttribute right TrackerBaseToImagePlate
90 | (RotateTranslate (Rotate 0.000 30.000 0.0)
91 | (Translate 0.000 0.144 0.0)))
92 |
93 |
94 | // Create a view using the defined screens.
95 | //
96 | (NewView view0)
97 | (ViewAttribute view0 Screen left)
98 | (ViewAttribute view0 Screen right)
99 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.45))
100 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-cave.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x3-cave.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:35 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for a cave environment. This cave
49 | * consists of 3 projectors with 3 screens to the left, front, and right
50 | * of the user, all at 90 degrees to each other.
51 | *
52 | * The projectors in the VirtualPortal sample site are actually turned
53 | * on their sides to get more height. Screen 0 is rotated 90 degrees
54 | * counter-clockwise, while screens 1 and 2 are rotated 90 degrees
55 | * clockwise.
56 | *
57 | ************************************************************************
58 | */
59 |
60 | // Create new screen objects and associate them with logical names and numbers.
61 | // These numbers are used as indices to retrieve the AWT GraphicsDevice from
62 | // the array that GraphicsEnvironment.getScreenDevices() returns.
63 | //
64 | // NOTE: The GraphicsDevice order in the array is specific to the local
65 | // site and display system.
66 | //
67 | (NewScreen left 0)
68 | (NewScreen center 1)
69 | (NewScreen right 2)
70 |
71 |
72 | // Set the available image areas as well as their positition and orientation
73 | // relative to the tracker base. Although this config file doesn't enable
74 | // head tracking, the tracker base is still needed as a point of reference to
75 | // describe the position and orientation of the screens relative to the
76 | // environment.
77 | //
78 | // From the orientation of a user standing within this VirtualPortal site and
79 | // facing the center screen, the tracker base is along the vertical midline of
80 | // the screen, 0.248 meters down from the top edge, and 1.340 meters in front
81 | // of it. The tracker base is oriented so that its +X axis points to the left,
82 | // its +Y axis points toward the screen, and its +Z axis points toward the
83 | // floor.
84 | //
85 | (ScreenAttribute left PhysicalScreenWidth 2.480)
86 | (ScreenAttribute left PhysicalScreenHeight 1.705)
87 | (ScreenAttribute left WindowSize NoBorderFullScreen)
88 | (ScreenAttribute left TrackerBaseToImagePlate
89 | (( 0.0 0.0 -1.0 2.230)
90 | ( 0.0 -1.0 0.0 1.340)
91 | (-1.0 0.0 0.0 0.885)))
92 |
93 | (ScreenAttribute center PhysicalScreenWidth 2.485)
94 | (ScreenAttribute center PhysicalScreenHeight 1.745)
95 | (ScreenAttribute center WindowSize NoBorderFullScreen)
96 | (ScreenAttribute center TrackerBaseToImagePlate
97 | (( 0.0 0.0 1.0 0.248)
98 | (-1.0 0.0 0.0 0.885)
99 | ( 0.0 -1.0 0.0 1.340)))
100 |
101 | (ScreenAttribute right PhysicalScreenWidth 2.480)
102 | (ScreenAttribute right PhysicalScreenHeight 1.775)
103 | (ScreenAttribute right WindowSize NoBorderFullScreen)
104 | (ScreenAttribute right TrackerBaseToImagePlate
105 | (( 0.0 0.0 1.0 0.2488)
106 | ( 0.0 -1.0 0.0 1.340)
107 | ( 1.0 0.0 0.0 0.860)))
108 |
109 | // Set the location of the center of coexistence relative to the tracker base.
110 | // Here it set to the center of the center screen. This config file will set
111 | // the location of the user's eyes relative to this point. The default view
112 | // attach policy of NOMINAL_SCREEN used by ConfiguredUniverse will place the
113 | // origin of the view platform in coexistence coordinates at the center of
114 | // coexistence.
115 | //
116 | (NewPhysicalEnvironment VirtualPortal)
117 | (PhysicalEnvironmentAttribute VirtualPortal
118 | CoexistenceToTrackerBase
119 | ((-1.0 0.0 0.0 0.000)
120 | ( 0.0 0.0 -1.0 1.340)
121 | ( 0.0 -1.0 0.0 0.994)))
122 |
123 | // The above center of coexistence is appropriate for the sample geometry
124 | // files available in the programs/examples directory. Often a more
125 | // immersive point of view is required for larger virtual worlds. This can be
126 | // achieved by placing the center of coexistence closer to the nominal position
127 | // of the user's head, so that the view platform origin in coexistence
128 | // coordinates will map there as well.
129 | //
130 | // Here we set the location of the center of coexistence 0.5 meters along the
131 | // tracker base +Z axis, 1.737 meters from the floor (about 5 ft 8.4 inches).
132 | //
133 | // (PhysicalEnvironmentAttribute VirtualPortal
134 | // CoexistenceToTrackerBase
135 | // ((-1.0 0.0 0.0 0.0)
136 | // ( 0.0 0.0 -1.0 0.0)
137 | // ( 0.0 -1.0 0.0 0.5)))
138 |
139 |
140 | // Now define the view.
141 | //
142 | (NewView view0)
143 | (ViewAttribute view0 Screen left)
144 | (ViewAttribute view0 Screen center)
145 | (ViewAttribute view0 Screen right)
146 | (ViewAttribute view0 PhysicalEnvironment VirtualPortal)
147 |
148 | // Set the user eye position in the display environment. It is set here to
149 | // 1.340 meters back from the center screen (directly under the tracker), and
150 | // 1.737 meters from the floor (about 5 ft 8.4 inches).
151 | //
152 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.494 1.340))
153 |
154 | // Here is an alternative center eye position to use with the immersive
155 | // coexistence coordinate system defined in comments above.
156 | //
157 | // (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.0))
158 |
159 | // Set the screen scale. This is scale factor from virtual to physical
160 | // coordinates.
161 | //
162 | (ViewAttribute view0 ScreenScalePolicy SCALE_SCREEN_SIZE)
163 |
164 | // Alternative for explict scaling.
165 | //
166 | // (ViewAttribute view0 ScreenScalePolicy SCALE_EXPLICIT)
167 | // (ViewAttribute view0 ScreenScale 5.00)
168 |
169 | // No stereo viewing for this configuration.
170 | //
171 | (ViewAttribute view0 StereoEnable False)
172 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d1x3-rot45.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d1x3-rot45.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:35 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for 3 screens. Left and right screens are
49 | * rotated 45 degrees from the center screen.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create new screen objects and associate them with logical names and numbers.
55 | // These numbers are used as indices to retrieve the AWT GraphicsDevice from
56 | // the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen left 0)
62 | (NewScreen center 1)
63 | (NewScreen right 2)
64 |
65 | // Set the available image areas for full screens.
66 | //
67 | (ScreenAttribute left PhysicalScreenWidth 0.360)
68 | (ScreenAttribute left PhysicalScreenHeight 0.288)
69 |
70 | (ScreenAttribute center PhysicalScreenWidth 0.360)
71 | (ScreenAttribute center PhysicalScreenHeight 0.288)
72 |
73 | (ScreenAttribute right PhysicalScreenWidth 0.360)
74 | (ScreenAttribute right PhysicalScreenHeight 0.288)
75 |
76 | // Specify full screen windows.
77 | //
78 | (ScreenAttribute left WindowSize NoBorderFullScreen)
79 | (ScreenAttribute center WindowSize NoBorderFullScreen)
80 | (ScreenAttribute right WindowSize NoBorderFullScreen)
81 |
82 | // Set the TrackerBaseToImagePlate transforms for these screens.
83 | //
84 | // The tracker base and center of coexistence are set here to the middle of the
85 | // center screen. The basis vectors are aligned with the center screen image
86 | // plate. The left and right screens are rotated 45 degrees toward each other
87 | // about their shared edges with the center screen.
88 | //
89 | (ScreenAttribute center TrackerBaseToImagePlate
90 | (Translate 0.180000 0.144000 0.000000))
91 |
92 | // cos(45) * 0.360 * 0.5 = 0.127279; 0.360 + 0.127279 = 0.487279
93 | (ScreenAttribute left TrackerBaseToImagePlate
94 | (RotateTranslate
95 | (Rotate 0.000000 -45.000000 0.000000)
96 | (Translate 0.487279 0.144000 0.127279)))
97 |
98 | // cos(45) * 0.360 * 0.5 = 0.127279
99 | (ScreenAttribute right TrackerBaseToImagePlate
100 | (RotateTranslate
101 | (Rotate 0.000000 45.000000 0.000000)
102 | (Translate -0.127279 0.144000 0.127279)))
103 |
104 | // Create a view using the defined screens.
105 | //
106 | (NewView view0)
107 | (ViewAttribute view0 Screen left)
108 | (ViewAttribute view0 Screen center)
109 | (ViewAttribute view0 Screen right)
110 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 0.5))
111 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/configured_universe/j3d2x2-flat.cfg:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: j3d2x2-flat.cfg,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:35 $
42 | * $State: Exp $
43 | */
44 |
45 | /*
46 | ************************************************************************
47 | *
48 | * Java 3D configuration file for 4 screen projection configuration
49 | * arranged in a 2x2 power wall.
50 | *
51 | ************************************************************************
52 | */
53 |
54 | // Create new screen objects and associate them with logical names and numbers.
55 | // These numbers are used as indices to retrieve the AWT GraphicsDevice from
56 | // the array that GraphicsEnvironment.getScreenDevices() returns.
57 | //
58 | // NOTE: The GraphicsDevice order in the array is specific to the local
59 | // site and display system.
60 | //
61 | (NewScreen topleft 0)
62 | (NewScreen topright 1)
63 | (NewScreen bottomleft 3)
64 | (NewScreen bottomright 2)
65 |
66 | // Set the available image areas for full screens. This is important when
67 | // precise scaling between objects in the virtual world and their projections
68 | // into the physical world is desired through use of explicit ScreenScale view
69 | // attributes. The defaults are 0.365 meters for width and 0.292 meters for
70 | // height.
71 | //
72 | (ScreenAttribute topleft PhysicalScreenWidth 0.912)
73 | (ScreenAttribute topleft PhysicalScreenHeight 0.680)
74 |
75 | (ScreenAttribute topright PhysicalScreenWidth 0.912)
76 | (ScreenAttribute topright PhysicalScreenHeight 0.680)
77 |
78 | (ScreenAttribute bottomleft PhysicalScreenWidth 0.912)
79 | (ScreenAttribute bottomleft PhysicalScreenHeight 0.685)
80 |
81 | (ScreenAttribute bottomright PhysicalScreenWidth 0.912)
82 | (ScreenAttribute bottomright PhysicalScreenHeight 0.685)
83 |
84 |
85 | // Specify full screen windows.
86 | //
87 | (ScreenAttribute topleft WindowSize NoBorderFullScreen)
88 | (ScreenAttribute topright WindowSize NoBorderFullScreen)
89 | (ScreenAttribute bottomleft WindowSize NoBorderFullScreen)
90 | (ScreenAttribute bottomright WindowSize NoBorderFullScreen)
91 |
92 | // Set the TrackerBaseToImagePlate transforms for these screens. This
93 | // transforms points in tracker base coordinates to each screen's image plate
94 | // coordinates, where the origin of the image plate is defined to be the lower
95 | // left corner of the screen with X increasing to the right, Y increasing to
96 | // the top, and Z increasing away from the screen.
97 | //
98 | // Without head or sensor tracking the tracker base is still needed as a point
99 | // of reference for describing the orientation and position of each screen to
100 | // the others. The coexistence to tracker base transform is set to identity by
101 | // default, so the tracker base origin and orientation will also set the origin
102 | // and orientation of coexistence coordinates in the physical world.
103 | //
104 | // The tracker base and center of coexistence are set here to the center of the
105 | // 2x2 array with its basis vectors aligned to image plate coordinates.
106 | //
107 | (ScreenAttribute topleft TrackerBaseToImagePlate
108 | (Translate 0.912 0.000 0.0))
109 | (ScreenAttribute topright TrackerBaseToImagePlate
110 | (Translate 0.000 0.000 0.0))
111 | (ScreenAttribute bottomleft TrackerBaseToImagePlate
112 | (Translate 0.912 0.685 0.0))
113 | (ScreenAttribute bottomright TrackerBaseToImagePlate
114 | (Translate 0.000 0.685 0.0))
115 |
116 | // Create a view using the defined screens.
117 | //
118 | (NewView view0)
119 | (ViewAttribute view0 Screen topleft)
120 | (ViewAttribute view0 Screen topright)
121 | (ViewAttribute view0 Screen bottomleft)
122 | (ViewAttribute view0 Screen bottomright)
123 |
124 | // Set the screen scale. This is scale factor from virtual to physical
125 | // coordinates. The default policy of SCALE_SCREEN_SIZE doesn't work well here
126 | // since in the 2x2 arrangement the individual screens are too small. The
127 | // explicit scale factor below assumes a normalized range of object coordinates
128 | // of [-1.0 .. +1.0].
129 | //
130 | (ViewAttribute view0 ScreenScalePolicy SCALE_EXPLICIT)
131 | (ViewAttribute view0 ScreenScale 0.912)
132 |
133 | // Set the user eye position in the display environment.
134 | //
135 | (ViewAttribute view0 CenterEyeInCoexistence (0.0 0.0 1.0))
136 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/depth_func/RenderFrame.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
26 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortBehavior.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: DistortBehavior.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:36 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.distort_glyph;
46 |
47 | import java.util.Enumeration;
48 |
49 | import javax.media.j3d.Appearance;
50 | import javax.media.j3d.Behavior;
51 | import javax.media.j3d.GeometryArray;
52 | import javax.media.j3d.Shape3D;
53 | import javax.media.j3d.Transform3D;
54 | import javax.media.j3d.WakeupCondition;
55 | import javax.media.j3d.WakeupCriterion;
56 | import javax.media.j3d.WakeupOnElapsedFrames;
57 | import javax.media.j3d.WakeupOnElapsedTime;
58 |
59 | import javax.vecmath.Vector3f;
60 |
61 | public class DistortBehavior extends Behavior {
62 | // the wake up condition for the behavior
63 | protected WakeupCondition m_InitialWakeupCondition = null;
64 | protected WakeupCondition m_FrameWakeupCondition = null;
65 |
66 | // the GeometryArray for the Shape3D that we are modifying
67 | protected Shape3D m_Shape3D = null;
68 | protected GeometryArray m_GeometryArray = null;
69 |
70 | protected float[] m_CoordinateArray = null;
71 | protected float[] m_OriginalCoordinateArray = null;
72 | protected Appearance m_Appearance = null;
73 |
74 | protected int m_nElapsedTime = 0;
75 | protected int m_nNumFrames = 0;
76 | protected int m_nFrameNumber = 0;
77 |
78 | private int frame = 0;
79 | protected Vector3f m_Vector = null;
80 |
81 | public DistortBehavior(Shape3D shape3D, int nElapsedTime, int nNumFrames) {
82 | // allocate a temporary vector
83 | m_Vector = new Vector3f();
84 |
85 | m_FrameWakeupCondition = new WakeupOnElapsedFrames(0);
86 |
87 | restart(shape3D, nElapsedTime, nNumFrames);
88 | }
89 |
90 | public WakeupCondition restart(Shape3D shape3D, int nElapsedTime, int nNumFrames) {
91 | m_Shape3D = shape3D;
92 | m_nElapsedTime = nElapsedTime;
93 | m_nNumFrames = nNumFrames;
94 | m_nFrameNumber = 0;
95 |
96 | // create the WakeupCriterion for the behavior
97 | m_InitialWakeupCondition = new WakeupOnElapsedTime(m_nElapsedTime);
98 |
99 | // save the GeometryArray that we are modifying
100 | m_GeometryArray = (GeometryArray) m_Shape3D.getGeometry();
101 |
102 | if (m_Shape3D.isLive() == false && m_Shape3D.isCompiled() == false) {
103 | // set the capability bits that the behavior requires
104 | m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
105 | m_Shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
106 |
107 | m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POINT_ATTRIBUTES_WRITE);
108 | m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_POLYGON_ATTRIBUTES_WRITE);
109 | m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TRANSPARENCY_ATTRIBUTES_WRITE);
110 | m_Shape3D.getAppearance().setCapability(Appearance.ALLOW_TEXTURE_WRITE);
111 |
112 | m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_READ);
113 | m_GeometryArray.setCapability(GeometryArray.ALLOW_COORDINATE_WRITE);
114 | m_GeometryArray.setCapability(GeometryArray.ALLOW_COUNT_READ);
115 | }
116 |
117 | // make a copy of the object's original appearance
118 | m_Appearance = new Appearance();
119 | m_Appearance = (Appearance) m_Shape3D.getAppearance().cloneNodeComponent(true);
120 |
121 | // allocate an array for the model coordinates
122 | m_CoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];
123 |
124 | // make a copy of the models original coordinates
125 | m_OriginalCoordinateArray = new float[3 * m_GeometryArray.getVertexCount()];
126 | m_GeometryArray.getCoordinates(0, m_OriginalCoordinateArray);
127 |
128 | // start (or restart) the behavior
129 | setEnable(true);
130 |
131 | return m_InitialWakeupCondition;
132 | }
133 |
134 | public void initialize() {
135 | // apply the initial WakeupCriterion
136 | wakeupOn(m_InitialWakeupCondition);
137 | }
138 |
139 | public void processStimulus(Enumeration criteria) {
140 | while (criteria.hasMoreElements()) {
141 | WakeupCriterion wakeUp = (WakeupCriterion) criteria.nextElement();
142 |
143 | if (wakeUp instanceof WakeupOnElapsedTime) {
144 | } else {
145 | // we are mid explosion, modify the GeometryArray
146 | m_nFrameNumber++;
147 | frame++;
148 | m_GeometryArray.getCoordinates(0, m_CoordinateArray);
149 |
150 | Transform3D t3 = new Transform3D();
151 | for (int n = 0; n < m_CoordinateArray.length; n += 3) {
152 | m_Vector.x = m_OriginalCoordinateArray[n];
153 | m_Vector.y = m_OriginalCoordinateArray[n + 1];
154 | m_Vector.z = m_OriginalCoordinateArray[n + 2];
155 |
156 | float spx = (float) (Math.sin(frame *3f / 500));
157 | float spy = (float) (Math.cos(frame *5f / 500));
158 | Vector3f v = new Vector3f(spx, spy, 0);
159 |
160 | float px = (m_Vector.x - v.x);
161 | float py = (m_Vector.y - v.y);
162 | float pz = (m_Vector.z - v.z);
163 | float d = (float) Math.sqrt(px * px + py * py + pz * pz);
164 |
165 |
166 | m_Vector.add(new Vector3f(-.25f, -.25f, -.25f));
167 | //m_Vector.scale(d);
168 |
169 | t3.rotZ(d);
170 | t3.rotX(d*2);
171 | t3.rotY(d);
172 | t3.transform(m_Vector);
173 |
174 | m_CoordinateArray[n] = m_Vector.x;
175 | m_CoordinateArray[n + 1] = m_Vector.y;
176 | m_CoordinateArray[n + 2] = m_Vector.z;
177 |
178 | }
179 |
180 | // assign the new coordinates
181 | m_GeometryArray.setCoordinates(0, m_CoordinateArray);
182 | }
183 | }
184 |
185 | if (m_nFrameNumber < m_nNumFrames) {
186 | // assign the next WakeUpCondition, so we are notified again
187 | wakeupOn(m_FrameWakeupCondition);
188 | } else {
189 | // restart
190 | m_nFrameNumber = 0;
191 | wakeupOn(m_FrameWakeupCondition);
192 | }
193 | }
194 | }
195 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/distort_glyph/DistortGlyphTest.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/dot3/MyCanvas.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: MyCanvas.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:36 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.dot3;
46 |
47 | import java.awt.*;
48 | import java.awt.image.*;
49 | import java.awt.event.*;
50 | import javax.swing.*;
51 | import javax.swing.event.MouseInputListener;
52 |
53 | /**
54 | * A mouse interactive canvas for lightMap image
55 | */
56 | public class MyCanvas extends JPanel implements MouseInputListener {
57 | BufferedImage lightMask = null;
58 | BufferedImage textureImage = null;
59 | Graphics2D gr = null;
60 | Point location = new Point();
61 | // default color light map
62 | Color bgColor = new Color(147, 147, 147);
63 |
64 | int x = 0;
65 | int y = 0;
66 | int z = 142;
67 | // texture image size
68 | private static final int textureSize = 256;
69 | boolean mouseOut = true;
70 | //flag about image is ready or not for use
71 | boolean imageReady = false;
72 | // allows mask be dragged with mouse
73 | boolean dragMask = false;
74 | boolean updateLightDir = false;
75 | boolean updateMaskPosition = false;
76 |
77 | /**
78 | * Creates a MyCanvas object with a image lightMask.
79 | * Also creates a default ImageLight map
80 | * @param mask light lightMask used
81 | */
82 | public MyCanvas(BufferedImage mask) {
83 | super();
84 | this.lightMask = mask;
85 | // create a light map
86 | setTextureImage(new BufferedImage(textureSize, textureSize,
87 | BufferedImage.TYPE_INT_RGB));
88 | // Graphics used to update lightmap
89 | gr = getTextureImage().createGraphics();
90 |
91 | Dimension dimSize = new Dimension(textureSize, textureSize);
92 | // lock size
93 | this.setSize(dimSize);
94 | this.setMaximumSize(dimSize);
95 | this.setMinimumSize(dimSize);
96 |
97 | this.setDoubleBuffered(true);
98 | this.setOpaque(true);
99 | this.addMouseMotionListener(this);
100 | this.addMouseListener(this);
101 | }
102 |
103 | /**
104 | * Handles mouse click event.
105 | * Get mouse coords call repaint for proper imageLight update
106 | * @param ev mouse event
107 | */
108 | public void mouseClicked(MouseEvent ev) {
109 | x = ev.getX();
110 | y = this.getHeight() - ev.getY();
111 | updateLightDir = true;
112 | repaint();
113 | }
114 |
115 | public void mousePressed(MouseEvent e) {
116 | }
117 |
118 | public void mouseReleased(MouseEvent e) {
119 | }
120 |
121 | /**
122 | * Handles mouse drag event.
123 | * get current mouse position and calls repaint for proper imageLight update
124 | * @param ev
125 | */
126 | public void mouseDragged(MouseEvent ev) {
127 | if (!mouseOut) {
128 | x = ev.getX();
129 | y = this.getHeight() - ev.getY();
130 |
131 | //changes lightDir
132 | if ((ev.getModifiers()& MouseEvent.BUTTON1_MASK) ==
133 | MouseEvent.BUTTON1_MASK) {
134 | updateLightDir = true;
135 | updateMaskPosition = false;
136 | }
137 | //updates light mask position
138 | if ((ev.getModifiers() & ev.BUTTON2_MASK) == ev.BUTTON2_MASK ||
139 | (ev.getModifiers() & ev.BUTTON3_MASK) == ev.BUTTON3_MASK) {
140 | updateLightDir = false;
141 | updateMaskPosition = true;
142 | }
143 | repaint();
144 | }
145 | }
146 |
147 | public void mouseMoved(MouseEvent ev) {
148 | // disable updates on lightMap
149 | updateLightDir = false;
150 | updateMaskPosition = false;
151 | }
152 |
153 | public void mouseEntered(MouseEvent e) {
154 | mouseOut = false;
155 | }
156 |
157 | public void mouseExited(MouseEvent e) {
158 | mouseOut = true;
159 | }
160 |
161 | /**
162 | * updates imageLight using current setings
163 | * @param g
164 | */
165 | public void paintComponent(Graphics g) {
166 | imageReady = false;
167 | Graphics2D g2d = (Graphics2D)g;
168 |
169 | // ligthDir has changed, we must update bgColor li
170 | if(updateLightDir) {
171 | int blue = bgColor.getBlue();
172 | //clamp values to 255
173 | y = y>255?255:y;
174 | x = x>255?255:x;
175 | bgColor = new Color(y,x,blue);
176 | }
177 | // paint lightMap
178 | gr.setColor(bgColor);
179 | gr.fillRect(0, 0, textureSize, textureSize);
180 |
181 | // draw mask on mouse position
182 | if (dragMask || updateMaskPosition) {
183 | int maskWH = lightMask.getWidth()/2;
184 | int mx = x - maskWH ;
185 | int my = textureSize - y - maskWH ; // y value is inverted
186 | // clamp mouse position, to avoid drawing outside imageLigh bounds
187 | mx = mx > textureSize ? textureSize : mx;
188 | my = my > textureSize ? textureSize : my;
189 | // draw light mask
190 | gr.drawImage(lightMask, mx, my, this);
191 | }
192 |
193 | g2d.drawImage(getTextureImage(), 0, 0, this);
194 | imageReady = true;
195 | }
196 |
197 | /**
198 | *
199 | * @return true if exists a new texture image available
200 | */
201 | public boolean hasTextureImageReady() {
202 | return imageReady;
203 | }
204 |
205 | /**
206 | * Returns a texture image.
207 | * You can avoid calling the same image several times
208 | * by checking hasTextureImageReady() first.
209 | * @return latest texture image available
210 | */
211 | public BufferedImage getTextureImage() {
212 | // sign as texture used for next call;
213 | imageReady = false;
214 | //return image
215 | return textureImage;
216 | }
217 |
218 |
219 | public Image getMask() {
220 | return lightMask;
221 | }
222 |
223 | public void setLightMask(BufferedImage mask) {
224 | this.lightMask = mask;
225 | }
226 |
227 | public Color getBgColor() {
228 | return bgColor;
229 | }
230 |
231 | public void setBgColor(Color bgColor) {
232 | this.bgColor = bgColor;
233 | }
234 |
235 | public void setTextureImage(BufferedImage textureImage) {
236 | this.textureImage = textureImage;
237 | }
238 |
239 |
240 | }
241 |
242 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/BigCube.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: BigCube.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | import java.applet.Applet;
48 | import java.awt.event.*;
49 | import javax.media.j3d.*;
50 | import javax.vecmath.*;
51 |
52 | /**
53 | * Class BigCube
54 | *
55 | * Description: Creates the "big" cube used to mark the computer's
56 | * position.
57 | *
58 | * Version: 1.0
59 | */
60 | public class BigCube extends Object {
61 |
62 | private Shape3D shape3D;
63 |
64 | private static final float[] verts = {
65 | // Front Face
66 | 5.0f, -5.0f, 5.0f, 5.0f, 5.0f, 5.0f,
67 | -5.0f, 5.0f, 5.0f, -5.0f, -5.0f, 5.0f,
68 | // Back Face
69 | -5.0f, -5.0f, -5.0f, -5.0f, 5.0f, -5.0f,
70 | 5.0f, 5.0f, -5.0f, 5.0f, -5.0f, -5.0f,
71 | // Right Face
72 | 5.0f, -5.0f, -5.0f, 5.0f, 5.0f, -5.0f,
73 | 5.0f, 5.0f, 5.0f, 5.0f, -5.0f, 5.0f,
74 | // Left Face
75 | -5.0f, -5.0f, 5.0f, -5.0f, 5.0f, 5.0f,
76 | -5.0f, 5.0f, -5.0f, -5.0f, -5.0f, -5.0f,
77 | // Top Face
78 | 5.0f, 5.0f, 5.0f, 5.0f, 5.0f, -5.0f,
79 | -5.0f, 5.0f, -5.0f, -5.0f, 5.0f, 5.0f,
80 | // Bottom Face
81 | -5.0f, -5.0f, 5.0f, -5.0f, -5.0f, -5.0f,
82 | 5.0f, -5.0f, -5.0f, 5.0f, -5.0f, 5.0f,
83 | };
84 |
85 | private static final float[] normals = {
86 | // Front Face
87 | 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
88 | 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
89 | // Back Face
90 | 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f,
91 | 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f,
92 | // Right Face
93 | 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
94 | 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
95 | // Left Face
96 | -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
97 | -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
98 | // Top Face
99 | 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
100 | 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
101 | // Bottom Face
102 | 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
103 | 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
104 | };
105 |
106 | public BigCube(Appearance appearance) {
107 |
108 | QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES |
109 | QuadArray.NORMALS );
110 | quadArray.setCoordinates(0, verts);
111 | quadArray.setNormals(0, normals);
112 |
113 | shape3D = new Shape3D(quadArray, appearance);
114 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
115 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
116 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
117 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
118 | }
119 |
120 | public BigCube(Appearance appearance, float size) {
121 |
122 | QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES |
123 | QuadArray.NORMALS );
124 |
125 | for (int i=0; i<72; i++) verts[i] *= size;
126 |
127 | quadArray.setCoordinates(0, verts);
128 | quadArray.setNormals(0, normals);
129 |
130 | shape3D = new Shape3D(quadArray, appearance);
131 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
132 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
133 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
134 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
135 | }
136 |
137 | public Shape3D getChild() {
138 | return shape3D;
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/Canvas2D.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Canvas2D.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | import java.awt.*;
48 | import java.awt.event.*;
49 | import java.awt.image.*;
50 |
51 | /**
52 | * Class: Canvas2D
53 | *
54 | * Description: Used to respond to mouse events in the 2D window.
55 | *
56 | * Version: 1.0
57 | *
58 | */
59 | class Canvas2D extends Canvas implements MouseListener {
60 |
61 | Image backbuffer; // Backbuffer image
62 | Graphics gc; // Graphics context of backbuffer
63 | Board board; // Game board
64 |
65 | Canvas2D(Board board) {
66 | this.board = board;
67 | }
68 |
69 | public void setBuffer(Image backbuffer) {
70 | this.backbuffer = backbuffer;
71 | gc = backbuffer.getGraphics();
72 | }
73 |
74 | public void update(Graphics g) {
75 | paint(g);
76 | }
77 |
78 | public void paint(Graphics g) {
79 | if (board != null) {
80 | board.render2D(gc);
81 | g.drawImage(backbuffer, 0, 0, this);
82 | }
83 | }
84 |
85 | public void mousePressed(MouseEvent e) {
86 | board.checkSelection2D(e.getX(), e.getY(), 1);
87 | repaint();
88 | }
89 |
90 | public void mouseClicked(MouseEvent e) {}
91 | public void mouseReleased(MouseEvent e) {}
92 | public void mouseEntered(MouseEvent e) {}
93 | public void mouseExited(MouseEvent e) {}
94 | }
95 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/Cube.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Cube.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | import java.applet.Applet;
48 | import java.awt.event.*;
49 | import javax.media.j3d.*;
50 | import javax.vecmath.*;
51 |
52 | public class Cube extends Object {
53 |
54 | private Shape3D shape3D;
55 |
56 | private static final float[] verts = {
57 | // Front Face
58 | 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
59 | -1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f,
60 | // Back Face
61 | -1.0f, -1.0f, -1.0f, -1.0f, 1.0f, -1.0f,
62 | 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, -1.0f,
63 | // Right Face
64 | 1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f,
65 | 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f,
66 | // Left Face
67 | -1.0f, -1.0f, 1.0f, -1.0f, 1.0f, 1.0f,
68 | -1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f,
69 | // Top Face
70 | 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f,
71 | -1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 1.0f,
72 | // Bottom Face
73 | -1.0f, -1.0f, 1.0f, -1.0f, -1.0f, -1.0f,
74 | 1.0f, -1.0f, -1.0f, 1.0f, -1.0f, 1.0f,
75 | };
76 |
77 | private static final float[] normals = {
78 | // Front Face
79 | 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
80 | 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
81 | // Back Face
82 | 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f,
83 | 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, -1.0f,
84 | // Right Face
85 | 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
86 | 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
87 | // Left Face
88 | -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
89 | -1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f,
90 | // Top Face
91 | 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
92 | 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f,
93 | // Bottom Face
94 | 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
95 | 0.0f, -1.0f, 0.0f, 0.0f, -1.0f, 0.0f,
96 | };
97 |
98 | public Cube(Appearance appearance) {
99 |
100 | QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES |
101 | QuadArray.NORMALS |
102 | QuadArray.TEXTURE_COORDINATE_2);
103 | quadArray.setCoordinates(0, verts);
104 | quadArray.setNormals(0, normals);
105 |
106 | shape3D = new Shape3D(quadArray, appearance);
107 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
108 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
109 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
110 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
111 | }
112 |
113 | public Cube(Appearance appearance, float size) {
114 |
115 | QuadArray quadArray = new QuadArray(24, QuadArray.COORDINATES |
116 | QuadArray.NORMALS);
117 | for (int i=0; i<72; i++)
118 | verts[i] *= size;
119 |
120 | quadArray.setCoordinates(0, verts);
121 | quadArray.setNormals(0, normals);
122 |
123 | shape3D = new Shape3D(quadArray, appearance);
124 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_READ);
125 | shape3D.setCapability(Shape3D.ALLOW_GEOMETRY_WRITE);
126 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_READ);
127 | shape3D.setCapability(Shape3D.ALLOW_APPEARANCE_WRITE);
128 | }
129 |
130 | public Shape3D getChild() {
131 | return shape3D;
132 | }
133 | }
134 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/Cylinder.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Cylinder.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | import javax.media.j3d.*;
48 | import javax.vecmath.*;
49 |
50 | public class Cylinder {
51 |
52 | float verts[];
53 | float normals[];
54 | QuadArray quad = null;
55 | float div = 3.0f;
56 | Shape3D shape;
57 |
58 | public Cylinder(float x, float z, float radius, float length, int quality, Appearance a) {
59 |
60 | if (quality < 3) quality = 3;
61 |
62 | div = (float) quality;
63 |
64 | verts = new float[quality*12];
65 | normals = new float[quality*12];
66 |
67 | double inc = 2.0*Math.PI/(double)div;
68 | for (int i=0; i< quality; i++){
69 | float z1 = radius * (float)Math.sin((double)i*inc) + z;
70 | float x1 = radius * (float)Math.cos((double)i*inc) + x;
71 | float z2 = radius * (float)Math.sin((double)(i+1)*inc) + z;
72 | float x2 = radius * (float)Math.cos((double)(i+1)*inc) + x;
73 |
74 | verts[12*i] = x1;
75 | verts[12*i+1] = -length/2.f;
76 | verts[12*i+2] = z1;
77 | verts[12*i+3] = x1;
78 | verts[12*i+4] = length/2.f;
79 | verts[12*i+5] = z1;
80 | verts[12*i+6] = x2;
81 | verts[12*i+7] = length/2.f;
82 | verts[12*i+8] = z2;
83 | verts[12*i+9] = x2;
84 | verts[12*i+10] = -length/2.f;
85 | verts[12*i+11] = z2;
86 |
87 | float nz1 = (float)Math.sin((double)i*inc);
88 | float nx1 = (float)Math.cos((double)i*inc);
89 | float nz2 = (float)Math.sin((double)(i+1)*inc);
90 | float nx2 = (float)Math.cos((double)(i+1)*inc);
91 |
92 | normals[12*i] = nx1;
93 | normals[12*i+1] = 0.0f;
94 | normals[12*i+2] = nz1;
95 | normals[12*i+3] = nx1;
96 | normals[12*i+4] = 0.0f;
97 | normals[12*i+5] = nz1;
98 | normals[12*i+6] = nx2;
99 | normals[12*i+7] = 0.0f;
100 | normals[12*i+8] = nz2;
101 | normals[12*i+9] = nx2;
102 | normals[12*i+10] = 0.0f;
103 | normals[12*i+11] = nz2;
104 | }
105 |
106 | quad = new QuadArray(quality*4, QuadArray.COORDINATES |
107 | QuadArray.NORMALS );
108 | quad.setCoordinates(0, verts);
109 | quad.setNormals(0, normals);
110 | shape = new Shape3D(quad, a);
111 | }
112 |
113 | Shape3D getShape(){
114 | return shape;
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/FourByFour.html:
--------------------------------------------------------------------------------
1 |
2 |
3 | Drag the mouse in the window
4 |
5 |
6 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/ID.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: ID.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | class ID {
48 | int id;
49 |
50 | public ID(int id) {
51 | this.id = id;
52 | }
53 |
54 | public int get() {
55 | return id;
56 | }
57 |
58 | public void set(int id) {
59 | this.id = id;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/four_by_four/PickDragBehavior.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: PickDragBehavior.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:37 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.four_by_four;
46 |
47 | import java.awt.*;
48 | import java.awt.event.*;
49 | import java.util.*;
50 | import javax.media.j3d.*;
51 | import javax.vecmath.*;
52 | import com.sun.j3d.utils.geometry.Sphere;
53 |
54 | /**
55 | * Class: PickDragBehavior
56 | *
57 | * Description: Used to respond to mouse pick and drag events
58 | * in the 3D window.
59 | *
60 | * Version: 1.0
61 | *
62 | */
63 | public class PickDragBehavior extends Behavior {
64 |
65 | WakeupCriterion[] mouseEvents;
66 | WakeupOr mouseCriterion;
67 | int x, y;
68 | int x_last, y_last;
69 | double x_angle, y_angle;
70 | double x_factor, y_factor;
71 | Transform3D modelTrans;
72 | Transform3D transformX;
73 | Transform3D transformY;
74 | TransformGroup transformGroup;
75 | BranchGroup branchGroup;
76 | Canvas2D canvas2D;
77 | Canvas3D canvas3D;
78 | Positions positions;
79 | PickRay pickRay = new PickRay();
80 | SceneGraphPath sceneGraphPath[];
81 | Appearance highlight;
82 | boolean parallel;
83 |
84 | PickDragBehavior(Canvas2D canvas2D, Canvas3D canvas3D, Positions positions,
85 | BranchGroup branchGroup, TransformGroup transformGroup) {
86 |
87 | this.canvas2D = canvas2D;
88 | this.canvas3D = canvas3D;
89 | this.positions = positions;
90 | this.branchGroup = branchGroup;
91 | this.transformGroup = transformGroup;
92 |
93 | modelTrans = new Transform3D();
94 | transformX = new Transform3D();
95 | transformY = new Transform3D();
96 |
97 | Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
98 | Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
99 | Color3f green = new Color3f(0.0f, 1.0f, 0.0f);
100 |
101 | highlight = new Appearance();
102 | highlight.setMaterial(new Material(green, black, green, white, 80.f));
103 |
104 | parallel = true;
105 | }
106 |
107 | public void initialize() {
108 | x = 0;
109 | y = 0;
110 | x_last = 0;
111 | y_last = 0;
112 | x_angle = 0;
113 | y_angle = 0;
114 | x_factor = .02;
115 | y_factor = .02;
116 |
117 | mouseEvents = new WakeupCriterion[2];
118 | mouseEvents[0] = new WakeupOnAWTEvent(MouseEvent.MOUSE_DRAGGED);
119 | mouseEvents[1] = new WakeupOnAWTEvent(MouseEvent.MOUSE_PRESSED);
120 | mouseCriterion = new WakeupOr(mouseEvents);
121 | wakeupOn (mouseCriterion);
122 | }
123 |
124 | public void processStimulus (Enumeration criteria) {
125 | WakeupCriterion wakeup;
126 | AWTEvent[] event;
127 | int id;
128 | int dx, dy;
129 |
130 | while (criteria.hasMoreElements()) {
131 | wakeup = (WakeupCriterion) criteria.nextElement();
132 | if (wakeup instanceof WakeupOnAWTEvent) {
133 | event = ((WakeupOnAWTEvent)wakeup).getAWTEvent();
134 | for (int i=0; i
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/gears/GearBox.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/gears/GearTest.form:
--------------------------------------------------------------------------------
1 |
2 |
3 |
37 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/gears/Shaft.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: Shaft.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.2 $
41 | * $Date: 2007/02/09 17:21:38 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.gears;
46 |
47 | import java.lang.Math.*;
48 | import javax.media.j3d.*;
49 | import javax.vecmath.*;
50 |
51 | public class Shaft extends javax.media.j3d.TransformGroup {
52 |
53 | /**
54 | * Construct a Shaft;
55 | * @return a new shaft that with the specified radius centered about
56 | * the origin an laying in the XY plane and of a specified length
57 | * extending in the Z dimension
58 | * @param radius radius of shaft
59 | * @param length shaft length shaft extends from -length/2 to length/2 in
60 | * the Z dimension
61 | * @param segmentCount number of segments for the shaft face
62 | * @param look the Appearance to associate with this shaft
63 | */
64 | public Shaft(float radius, float length, int segmentCount,
65 | Appearance look) {
66 | // The direction of the ray from the shaft's center
67 | float xDirection, yDirection;
68 | float xShaft, yShaft;
69 |
70 | // The z coordinates for the shaft's faces (never change)
71 | float frontZ = -0.5f * length;
72 | float rearZ = 0.5f * length;
73 |
74 | int shaftFaceVertexCount; // #(vertices) per shaft face
75 | int shaftFaceTotalVertexCount; // total #(vertices) in all teeth
76 | int shaftFaceStripCount[] = new int[1]; // per shaft vertex count
77 | int shaftVertexCount; // #(vertices) for shaft
78 | int shaftStripCount[] = new int[1]; // #(vertices) in strip/strip
79 |
80 | // Front and rear facing normals for the shaft's faces
81 | Vector3f frontNormal = new Vector3f(0.0f, 0.0f, -1.0f);
82 | Vector3f rearNormal = new Vector3f(0.0f, 0.0f, 1.0f);
83 | // Outward facing normal
84 | Vector3f outNormal = new Vector3f(1.0f, 0.0f, 0.0f);
85 |
86 | // Temporary variables for storing coordinates and vectors
87 | Point3f coordinate = new Point3f(0.0f, 0.0f, 0.0f);
88 | Shape3D newShape;
89 |
90 | // The angle subtended by a single segment
91 | double segmentAngle = 2.0 * Math.PI/segmentCount;
92 | double tempAngle;
93 |
94 | // Allow this object to spin. etc.
95 | this.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
96 |
97 | /* for the forward facing fan:
98 | * ___3___
99 | * - | -
100 | * / | \
101 | * 4/\ | /\2
102 | * / \ | / \
103 | * / \ | / \
104 | * : \ | / :
105 | * |--------------- *----------------|
106 | * 5 0 1
107 | *
108 | * for backward facing fan exchange 1 with 5; 2 with 4, etc.
109 | */
110 |
111 | // Construct the shaft's front and rear face
112 | shaftFaceVertexCount = segmentCount + 2;
113 | shaftFaceStripCount[0] = shaftFaceVertexCount;
114 |
115 | TriangleFanArray frontShaftFace
116 | = new TriangleFanArray(shaftFaceVertexCount,
117 | GeometryArray.COORDINATES
118 | | GeometryArray.NORMALS,
119 | shaftFaceStripCount);
120 |
121 | TriangleFanArray rearShaftFace
122 | = new TriangleFanArray(shaftFaceVertexCount,
123 | GeometryArray.COORDINATES
124 | | GeometryArray.NORMALS,
125 | shaftFaceStripCount);
126 |
127 | coordinate.set(0.0f, 0.0f, frontZ);
128 | frontShaftFace.setCoordinate(0, coordinate);
129 | frontShaftFace.setNormal(0, frontNormal);
130 |
131 | coordinate.set(0.0f, 0.0f, rearZ);
132 | rearShaftFace.setCoordinate(0, coordinate);
133 | rearShaftFace.setNormal(0, rearNormal);
134 |
135 | for(int index = 1; index < segmentCount+2; index++) {
136 |
137 | tempAngle = segmentAngle * -(double)index;
138 | coordinate.set(radius * (float)Math.cos(tempAngle),
139 | radius * (float)Math.sin(tempAngle),
140 | frontZ);
141 | frontShaftFace.setCoordinate(index, coordinate);
142 | frontShaftFace.setNormal(index, frontNormal);
143 |
144 | tempAngle = -tempAngle;
145 | coordinate.set(radius * (float)Math.cos(tempAngle),
146 | radius * (float)Math.sin(tempAngle),
147 | rearZ);
148 | rearShaftFace.setCoordinate(index, coordinate);
149 | rearShaftFace.setNormal(index, rearNormal);
150 | }
151 | newShape = new Shape3D(frontShaftFace, look);
152 | this.addChild(newShape);
153 | newShape = new Shape3D(rearShaftFace, look);
154 | this.addChild(newShape);
155 |
156 | // Construct shaft's outer skin (the cylinder body)
157 | shaftVertexCount = 2 * segmentCount + 2;
158 | shaftStripCount[0] = shaftVertexCount;
159 |
160 | TriangleStripArray shaft
161 | = new TriangleStripArray(shaftVertexCount,
162 | GeometryArray.COORDINATES
163 | | GeometryArray.NORMALS,
164 | shaftStripCount);
165 |
166 | outNormal.set(1.0f, 0.0f, 0.0f);
167 |
168 | coordinate.set(radius, 0.0f, rearZ);
169 | shaft.setCoordinate(0, coordinate);
170 | shaft.setNormal(0, outNormal);
171 |
172 | coordinate.set(radius, 0.0f, frontZ);
173 | shaft.setCoordinate(1, coordinate);
174 | shaft.setNormal(1, outNormal);
175 |
176 | for(int count = 0; count < segmentCount; count++) {
177 | int index = 2 + count * 2;
178 |
179 | tempAngle = segmentAngle * (double)(count + 1);
180 | xDirection = (float)Math.cos(tempAngle);
181 | yDirection = (float)Math.sin(tempAngle);
182 | xShaft = radius * xDirection;
183 | yShaft = radius * yDirection;
184 | outNormal.set(xDirection, yDirection, 0.0f);
185 |
186 | coordinate.set(xShaft, yShaft, rearZ);
187 | shaft.setCoordinate(index, coordinate);
188 | shaft.setNormal(index, outNormal);
189 |
190 | coordinate.set(xShaft, yShaft, frontZ);
191 | shaft.setCoordinate(index + 1, coordinate);
192 | shaft.setNormal(index + 1, outNormal);
193 | }
194 | newShape = new Shape3D(shaft, look);
195 | this.addChild(newShape);
196 | }
197 | }
198 |
199 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/geometry_compression/README.txt:
--------------------------------------------------------------------------------
1 | This directory contains example code for using compressed geometry in
2 | Java 3D through the com.sun.j3d.utils.geometry.compression package.
3 |
4 | Applications:
5 |
6 | obj2cg -- takes the names of .obj files to compress followed by the name
7 | of a .cg compressed geometry resource file. If the .cg file
8 | doesn't exist, then an attempt is made to create it; otherwise,
9 | new compressed geometry objects are appended to the end.
10 |
11 | The .obj files are compressed and stored into the .cg file in
12 | the order in which they appear in the command line, and can be
13 | accessed through indices [0 .. fileCount-1]
14 |
15 | cgview -- takes the name of a .cg file and the index of the object to
16 | display, which can range from [0 .. objectCount-1]. The object
17 | may rotated, scaled, and translated in response to mouse drags.
18 |
19 |
20 | Utility classes:
21 |
22 | ObjectFileCompressor.java --
23 | Extends ObjectFile with compression methods.
24 |
--------------------------------------------------------------------------------
/Java3D Demo Source Code/src/classes/org/jdesktop/j3d/examples/geometry_compression/cgview.java:
--------------------------------------------------------------------------------
1 | /*
2 | * $RCSfile: cgview.java,v $
3 | *
4 | * Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
5 | *
6 | * Redistribution and use in source and binary forms, with or without
7 | * modification, are permitted provided that the following conditions
8 | * are met:
9 | *
10 | * - Redistribution of source code must retain the above copyright
11 | * notice, this list of conditions and the following disclaimer.
12 | *
13 | * - Redistribution in binary form must reproduce the above copyright
14 | * notice, this list of conditions and the following disclaimer in
15 | * the documentation and/or other materials provided with the
16 | * distribution.
17 | *
18 | * Neither the name of Sun Microsystems, Inc. or the names of
19 | * contributors may be used to endorse or promote products derived
20 | * from this software without specific prior written permission.
21 | *
22 | * This software is provided "AS IS," without a warranty of any
23 | * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 | * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 | * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL
27 | * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF
28 | * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
29 | * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR
30 | * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL,
31 | * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND
32 | * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR
33 | * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE
34 | * POSSIBILITY OF SUCH DAMAGES.
35 | *
36 | * You acknowledge that this software is not designed, licensed or
37 | * intended for use in the design, construction, operation or
38 | * maintenance of any nuclear facility.
39 | *
40 | * $Revision: 1.3 $
41 | * $Date: 2007/02/09 17:21:40 $
42 | * $State: Exp $
43 | */
44 |
45 | package org.jdesktop.j3d.examples.geometry_compression;
46 |
47 | import com.sun.j3d.utils.applet.MainFrame;
48 | import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
49 | import com.sun.j3d.utils.geometry.compression.*;
50 | import com.sun.j3d.utils.universe.*;
51 | import java.applet.Applet;
52 | import java.awt.BorderLayout;
53 | import java.io.IOException;
54 | import javax.media.j3d.*;
55 | import javax.vecmath.*;
56 |
57 | public class cgview extends Applet {
58 |
59 | private SimpleUniverse u = null;
60 |
61 | public BranchGroup createSceneGraph(CompressedGeometryData cg) {
62 | // Create the root of the branch graph
63 | BranchGroup objRoot = new BranchGroup() ;
64 |
65 | // Create a Transformgroup to scale all objects so they
66 | // appear in the scene.
67 | TransformGroup objScale = new TransformGroup() ;
68 | Transform3D t3d = new Transform3D() ;
69 | t3d.setScale(0.7) ;
70 | objScale.setTransform(t3d) ;
71 | objRoot.addChild(objScale) ;
72 |
73 | // Create the transform group node and initialize it to the
74 | // identity. Enable the TRANSFORM_WRITE capability so that
75 | // our behavior code can modify it at runtime. Add it to the
76 | // root of the subgraph.
77 | TransformGroup objTrans = new TransformGroup() ;
78 | objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE) ;
79 | objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ) ;
80 | objScale.addChild(objTrans) ;
81 |
82 | // Add compressed geometry to the scene graph.
83 | CompressedGeometryData.Header hdr = new CompressedGeometryData.Header() ;
84 | cg.getCompressedGeometryHeader(hdr) ;
85 |
86 | Shape3D[] shapes = cg.decompress();
87 | if (shapes != null) {
88 | for (int i = 0; i < shapes.length; i++) {
89 | objTrans.addChild(shapes[i]);
90 | }
91 | }
92 |
93 | // Create mouse behavior scheduling bounds.
94 | BoundingSphere bounds =
95 | new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0) ;
96 |
97 | // Set up the background
98 | Color3f bgColor = new Color3f(0.05f, 0.05f, 0.5f);
99 | Background bgNode = new Background(bgColor) ;
100 | bgNode.setApplicationBounds(bounds) ;
101 | objRoot.addChild(bgNode) ;
102 |
103 | // Set up the ambient light
104 | Color3f ambientColor = new Color3f(0.1f, 0.1f, 0.1f) ;
105 | AmbientLight ambientLightNode = new AmbientLight(ambientColor) ;
106 | ambientLightNode.setInfluencingBounds(bounds) ;
107 | objRoot.addChild(ambientLightNode) ;
108 |
109 | // Set up the directional lights
110 | Color3f light1Color = new Color3f(1.0f, 1.0f, 0.9f) ;
111 | Vector3f light1Direction = new Vector3f(1.0f, 1.0f, 1.0f) ;
112 | Color3f light2Color = new Color3f(1.0f, 1.0f, 0.9f) ;
113 | Vector3f light2Direction = new Vector3f(-1.0f, -1.0f, -0.9f) ;
114 |
115 | DirectionalLight light1
116 | = new DirectionalLight(light1Color, light1Direction) ;
117 | light1.setInfluencingBounds(bounds) ;
118 | objRoot.addChild(light1) ;
119 |
120 | DirectionalLight light2
121 | = new DirectionalLight(light2Color, light2Direction) ;
122 | light2.setInfluencingBounds(bounds) ;
123 | objRoot.addChild(light2) ;
124 |
125 | return objRoot ;
126 | }
127 |
128 | private void usage() {
129 | System.out.println("Usage: cgview <.cg file>