From 80fd150d309bd13424be73392a4bde2c742a185f Mon Sep 17 00:00:00 2001 From: kcr Date: Wed, 8 Feb 2006 22:48:24 +0000 Subject: Merged changes between 1.4.0-beta3 and 1.4.0-beta4 into dev-1_5 --- src/VirtualInputDevice/ButtonPositionControls.java | 207 ----------- src/VirtualInputDevice/HelloUniverse.html | 15 - src/VirtualInputDevice/HelloUniverse.java | 134 ------- src/VirtualInputDevice/HelloUniverse_plugin.html | 39 -- src/VirtualInputDevice/PositionControls.java | 68 ---- src/VirtualInputDevice/README | 239 ------------ src/VirtualInputDevice/RotationControls.java | 71 ---- src/VirtualInputDevice/SensorBehavior.java | 70 ---- src/VirtualInputDevice/VirtualInputDevice.java | 258 ------------- src/VirtualInputDevice/WheelControls.java | 399 --------------------- src/VirtualInputDevice/build.xml | 69 ---- 11 files changed, 1569 deletions(-) delete mode 100644 src/VirtualInputDevice/ButtonPositionControls.java delete mode 100644 src/VirtualInputDevice/HelloUniverse.html delete mode 100644 src/VirtualInputDevice/HelloUniverse.java delete mode 100644 src/VirtualInputDevice/HelloUniverse_plugin.html delete mode 100644 src/VirtualInputDevice/PositionControls.java delete mode 100644 src/VirtualInputDevice/README delete mode 100644 src/VirtualInputDevice/RotationControls.java delete mode 100644 src/VirtualInputDevice/SensorBehavior.java delete mode 100644 src/VirtualInputDevice/VirtualInputDevice.java delete mode 100644 src/VirtualInputDevice/WheelControls.java delete mode 100644 src/VirtualInputDevice/build.xml (limited to 'src/VirtualInputDevice') diff --git a/src/VirtualInputDevice/ButtonPositionControls.java b/src/VirtualInputDevice/ButtonPositionControls.java deleted file mode 100644 index 73fccbe..0000000 --- a/src/VirtualInputDevice/ButtonPositionControls.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import java.awt.*; -import java.awt.event.*; -import javax.vecmath.*; -import javax.media.j3d.*; - -public class ButtonPositionControls extends Panel implements PositionControls, MouseListener { - private final static int STILL=0; - private final static int MOVING_UP=1; - private final static int MOVING_DOWN=2; - private final static int MOVING_LEFT=3; - private final static int MOVING_RIGHT=4; - private final static int MOVING_FORWARD=5; - private final static int MOVING_BACK=6; - - // initial mode - private int mode = STILL; - - Vector3f position = new Vector3f(); - Vector3f orig_position = new Vector3f(); - - private Button leftB = new Button("Move Left"); - private Button rightB = new Button("Move Right"); - private Button upB = new Button("Move Up"); - private Button downB = new Button("Move Down"); - - private Button forwardB = new Button("Move Forward"); - private Button backwardB = new Button("Move Back"); - - private Button reset = new Button("Reset"); - private InputDevice device; - - private float step_rate = 0.0023f; // movement rate per millisecond - private long time_last_state_change = System.currentTimeMillis(); - - // the constructor arguments are the intitial X, Y, and Z positions - public ButtonPositionControls( float x, float y, float z ) { - - // up, down, right, and left movement buttons - Panel panPanel = new Panel(); - panPanel.setLayout( new BorderLayout() ); - panPanel.add("North", upB); - panPanel.add("East", rightB); - panPanel.add("South", downB); - panPanel.add("West", leftB); - - // forward, backward, and reset buttons - Panel p = new Panel(); - p.setLayout( new GridLayout(0,1,0,0) ); - p.add(forwardB); - p.add(backwardB); - p.add(reset); - - // set the initial position - position.x = x; - position.y = y; - position.z = z; - orig_position.set(position); - - // add a mouse listener to each button - upB.addMouseListener(this); - downB.addMouseListener(this); - leftB.addMouseListener(this); - rightB.addMouseListener(this); - forwardB.addMouseListener(this); - backwardB.addMouseListener(this); - reset.addMouseListener(this); - - this.setLayout( new BorderLayout() ); - add("East", p ); - add("West", panPanel ); - } - - public void setDevice ( InputDevice device) { - this.device = device; - } - - public void getPosition(Vector3f pos ) { - calculateMotion(); - pos.set(position); - } - - public void setPosition(Vector3f pos ) { - position.set(pos); - } - - public void setStepRate( float stepRate ) { - step_rate = stepRate; - } - - private void calculateMotion() { - - long current_time = System.currentTimeMillis(); - long elapsed_time = current_time - time_last_state_change; - - switch(mode) { - case STILL: - break; - case MOVING_LEFT: - position.x = orig_position.x - step_rate*elapsed_time; - break; - case MOVING_RIGHT: - position.x = orig_position.x + step_rate*elapsed_time; - break; - case MOVING_UP: - position.y = orig_position.y + step_rate*elapsed_time; - break; - case MOVING_DOWN: - position.y = orig_position.y - step_rate*elapsed_time; - break; - case MOVING_FORWARD: - position.z = orig_position.z - step_rate*elapsed_time; - break; - case MOVING_BACK: - position.z = orig_position.z + step_rate*elapsed_time; - break; - default: - throw( new RuntimeException("Unknown motion")); - } - } - - public void mouseClicked( MouseEvent e ) { - } - - public void mouseEntered( MouseEvent e ) { - } - - public void mouseExited( MouseEvent e ) { - } - - public void mousePressed( MouseEvent e ) { - if (e.getSource()==leftB && mode != MOVING_LEFT) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_LEFT; - orig_position.set(position); - } else if (e.getSource()==rightB && mode != MOVING_RIGHT) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_RIGHT; - orig_position.set(position); - } else if (e.getSource()==upB && mode != MOVING_UP) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_UP; - orig_position.set(position); - } else if (e.getSource()==downB && mode != MOVING_DOWN) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_DOWN; - orig_position.set(position); - } else if (e.getSource()==forwardB && mode != MOVING_FORWARD) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_FORWARD; - orig_position.set(position); - } else if (e.getSource()==backwardB && mode != MOVING_BACK) { - time_last_state_change = System.currentTimeMillis(); - mode = MOVING_BACK; - orig_position.set(position); - } else if (e.getSource()==reset) { - device.setNominalPositionAndOrientation(); - } - } - - public void mouseReleased( MouseEvent e ) { - mode = STILL; - } -} diff --git a/src/VirtualInputDevice/HelloUniverse.html b/src/VirtualInputDevice/HelloUniverse.html deleted file mode 100644 index cd8d3de..0000000 --- a/src/VirtualInputDevice/HelloUniverse.html +++ /dev/null @@ -1,15 +0,0 @@ - - -Hello, Universe! - - - -
-
-If you were using a Java-capable browser, -you would see Hello Universe! instead of this paragraph. -
-
-
- - diff --git a/src/VirtualInputDevice/HelloUniverse.java b/src/VirtualInputDevice/HelloUniverse.java deleted file mode 100644 index 3632727..0000000 --- a/src/VirtualInputDevice/HelloUniverse.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import com.sun.j3d.utils.applet.MainFrame; -import com.sun.j3d.utils.geometry.ColorCube; -import com.sun.j3d.utils.universe.*; -import javax.media.j3d.*; -import javax.vecmath.*; - -public class HelloUniverse extends Applet { - - private SimpleUniverse u = null; - - public BranchGroup createSceneGraph() { - - BranchGroup objRoot = new BranchGroup(); - TransformGroup objTrans = new TransformGroup(); - objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); - objRoot.addChild(objTrans); - objTrans.addChild(new ColorCube(0.2)); - Transform3D yAxis = new Transform3D(); - Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, - 0, 0, - 4000, 0, 0, - 0, 0, 0); - RotationInterpolator rotator = - new RotationInterpolator(rotationAlpha, objTrans, yAxis, - 0.0f, (float) Math.PI*2.0f); - BoundingSphere bounds = - new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0); - rotator.setSchedulingBounds(bounds); - objTrans.addChild(rotator); - return objRoot; - } - - - public HelloUniverse() { - - } - - public void init() { - // These are the string arguments given to the VirtualInputDevice - // constructor. These are settable parameters. Look in the - // VirtualInputDevice constructor for a complete list. - String[] args = new String[10]; - args[0] = "printvalues"; - args[1] = "true"; - args[2] = "yscreeninitloc"; - args[3] = "50"; - args[4] = null; - - InputDevice device = new VirtualInputDevice( args ); - - // now create the HelloUniverse Canvas - setLayout(new BorderLayout()); - GraphicsConfiguration config = - SimpleUniverse.getPreferredConfiguration(); - - Canvas3D c = new Canvas3D(config); - add("Center", c); - - // Create a simple scene and attach it to the virtual universe - BranchGroup scene = createSceneGraph(); - u = new SimpleUniverse(c); - - // The InputDevice must be initialized before registering it - // with the PhysicalEnvironment object. - device.initialize(); - - // Register the VirtualInputDevice with Java 3D - u.getViewer().getPhysicalEnvironment().addInputDevice( device ); - - TransformGroup viewTrans = - u.getViewingPlatform().getViewPlatformTransform(); - SensorBehavior s = new SensorBehavior( viewTrans, device.getSensor(0) ); - s.setSchedulingBounds( new BoundingSphere - ( new Point3d(0.0,0.0,0.0), Float.MAX_VALUE )); - scene.addChild( s ); - u.addBranchGraph(scene); - } - - public void destroy() { - u.cleanup(); - } - - - public static void main(String[] args) { - new MainFrame(new HelloUniverse(), 350, 350); - } -} diff --git a/src/VirtualInputDevice/HelloUniverse_plugin.html b/src/VirtualInputDevice/HelloUniverse_plugin.html deleted file mode 100644 index d3619d9..0000000 --- a/src/VirtualInputDevice/HelloUniverse_plugin.html +++ /dev/null @@ -1,39 +0,0 @@ - - -Hello, Universe! - - - - - - - - - - -</COMMENT> -<blockquote> -<hr> -If you were using a Java-capable browser, -you would see Hello Universe! instead of this paragraph. -<hr> -</blockquote> - - - - - - - - diff --git a/src/VirtualInputDevice/PositionControls.java b/src/VirtualInputDevice/PositionControls.java deleted file mode 100644 index e5ea536..0000000 --- a/src/VirtualInputDevice/PositionControls.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import java.awt.Component; -import javax.vecmath.Vector3f; - -// Classes that implement this interface must be a -// subclass of java.awt.Component -public interface PositionControls { - - /** - * Get the position - */ - public void getPosition( Vector3f pos); - - /** - * Set the position - */ - public void setPosition( Vector3f pos); - - /** - * Increment added to position each time mouse is pressed - * or if the mouse is held down each time the Sensor is - * read - */ - public void setStepRate( float stepRate ); -} diff --git a/src/VirtualInputDevice/README b/src/VirtualInputDevice/README deleted file mode 100644 index efc4b7b..0000000 --- a/src/VirtualInputDevice/README +++ /dev/null @@ -1,239 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - - Java 3D (TM) Input Device Driver Development Guide - -Topics - - * Write Once, Run Anywhere (TM) - * Overview of the InputDevice and Sensor APIs - * Recipe for an Application Program that Uses Input Devices - * Location for Installation of Device Drivers - * Using a Preexistent Native Driver - * Package Naming Conventions - * Device Driver Constructor - * Driver Scheduling and Blocking Semantics - - -Write Once, Run Anywhere - -Platform independence is the cornerstone of the Java (TM) platform. -This vision now extends to external input devices as well. The -overarching goal of the Java 3D input device architecture is to enable -Java programs that use devices to run in a platform independent -manner. - -We encourage developers to use Java APIs for their drivers. APIs such -as the javax.comm API allow platform independent access to serial and -parallel ports. However, even if a driver is partially written with -native code, the Java 3D InputDevice interface is layered on top of the -driver such that once the native portion of the driver has been -installed into the local JRE, the application code is platform -independent. - -In a future release, the Java 3D team is going to release a registry -mechanism that will reside in the JRE as part of the Java 3D -installation and allow registration of device drivers. The -SimpleUniverse utility will be modified to allow querying of devices by -generic characteristics, and will subsequently look up and instantiate -the appropriate device driver registered with the registry mechanism. -The Java 3D team also expects to release a set of generic mappings for -devices. This will enable applications to count on the same behavior -from different drivers for similar types of devices. There will also -be personalized profiles that enable a user to specify device mappings -for features like dominant hand preference and eye position. - - -Overview of the InputDevice and Sensor APIs - -Java 3D abstracts the concept of a device via the InputDevice -interface. The developer's implementation of the InputDevice interface -is layered on top of the device driver. The device may be a real -device such as a joystick or it may be a virtual device such as a piece -of Java code that does transform calculations. - -A device sends data back to Java 3D by placing values into Sensor -objects which the device code manages and updates. The Sensor class -encapsulates a transform and a timestamp. The transform is specified -in the TrackerBase coordinate system. - -Java 3D schedules calls to the device's pollAndProcessInput routine, -which is a method in the InputDevice interface. This method is -responsible for updating the devices sensor values. The sensors' -values and time stamps are read by a user's behavior code and/or each -frame (by the Java 3D implementation) when head tracking is enabled. -There are several options for scheduling, and they are detailed in the -InputDevice javadoc and in the section below entitled "Driver -Scheduling and Blocking Semantics." - -Please read the javadocs for InputDevice and Sensor for more detailed -information. There is also a sample program in the Java 3D release -called VirtualInputDevice, which implements these concepts in Java code. - - -Recipe for an Application Program that Uses Input Devices - -Please see the Java 3D example program in the examples directory called -VirtualInputDevice for an example of using this code recipe: - 1) Implement the InputDevice interface with a class of your own - 2) Call the device's constructor from your main program - 3) Call initialize() on the device - 4) Call PhysicalEnvironment.addInputDevice(InputDevice) or if you are - using SimpleUniverse, call SimpleUniverse.getViewer(). - getPhysicalEnvironment().addInputDevice(InputDevice) - 5) Assuming you want to modify the viewer's transform with the device: - add a WakeupOnElapsedFrames behavior to your scene graph that wakes - up every frame and in the processStimulus method modify the view - transform with the transform you pull out of Sensor.getRead. - -In a future release, it will be possible to replace steps 2, 3, & 4 with -a single method call to the SimpleUniverse utility. - - -Location for Installation of Device Drivers - -There are two suggested ways to package and distribute drivers. - -If a driver is written entirely in Java and if it is tightly coupled -with a particular application without the expectation of reuse in other -applications, then it should be bundled and distributed with the -application itself. - -If a driver is not associated with any particular application program, -if it contains any native code, or if it is expected to be used by more -than one application program, then it should be installed directly into -the end user's local JRE. It is expected that most drivers for real -devices fall into this category. On the Solaris platform, the Java -portion of the driver should be installed into jre/lib/ext as a -uniquely named jar file and if there is native code it should be -compiled into a shared object and installed into jre/lib/sparc. On the -Win32 platform, the Java portion of the driver should be installed into -jre\lib\ext as a uniquely named jar file and if there is native code it -should be compiled into a standard dynamically linked library (dll) and -installed into jre\bin. - - -Using a Preexistent Native Driver - -It is possible to make a Java 3D driver out of a preexistent native -driver. In order to do this, you need to create an InputDevice -interface that uses JNI to access the associated native driver methods -whenever the corresponding InputDevice interface method is called from -Java 3D. The native portion of the driver must be installed into the -target JRE. - - -Package Naming Conventions - -All device drivers that are installed into the JRE should be part of a -package that follows both standard Java and Java 3D naming -conventions. For instance, an input device driver should be placed -into a package called -com..j3d.drivers.input.. The package should -be jarred up into a jar file that has a unique name. - -Any native .so or .dll files installed into the JRE should be uniquely -named. - - -Device Driver Constructor - -The constructor arguments for a device driver must be an array of -strings. So a driver should have a single public constructor that -takes an array of strings. The idea behind this requirement is that -eventually the Java 3D registry will contain an array of string -arguments to be sent to the device constructor at instantiation time. -The SimpleUniverse API will also make a provision for optional String -arguments to be added to the array of String arguments found in the -registry. - - -Driver Scheduling and Blocking Semantics - -When a device is registered with Java 3D via the -PhysicalEnvironment.addInputDevice(InputDevice) method call, -InputDevice.getProcessingMode() is called on the registered device. -This method should return one of the three processing modes defined in -the InputDevice interface: BLOCKING, NON_BLOCKING, and DEMAND_DRIVEN. - - BLOCKING signifies that the driver for a device is a blocking driver - and that it should be scheduled for regular reads by Java 3D. A - blocking driver is defined as a driver that can cause the thread - accessing the driver (the Java 3D implementation thread calling the - pollAndProcessInput method) to block while the data is being accessed - from the driver. - - NON_BLOCKING signifies that the driver for a device is a non-blocking - driver and that it should be scheduled for regular reads by Java 3D. - A non-blocking driver is defined as a driver that does not cause the - calling thread to block while data is being retrieved from the - driver. If no data is available from the device, pollAndProcessInput - should return without updating the sensor read value. - - DEMAND_DRIVEN signifies that the Java 3D implementation should not - schedule regular reads on the sensors of this device; the Java 3D - implementation will only call pollAndProcessInput when one of the - device's sensors' getRead methods is called. A DEMAND_DRIVEN driver - must always provide the current value of the sensor on demand - whenever pollAndProcessInput is called. This means that DEMAND_DRIVEN - drivers are non-blocking by definition. - -It is important that you correctly classify your driver. If it is a -NON_BLOCKING driver, most Java 3D implementations will choose to add -inertia inside the scheduling thread to avoid starvation of the other -Java 3D threads. If it is a BLOCKING driver, most Java 3D -implementations will choose to spawn a separate scheduling thread for -each BLOCKING device. If your driver is a DEMAND_DRIVEN driver, your -driver must always provide the current value upon request along with -the current time stamp. - -When running drivers with the Solaris operating system using the -Solaris reference 1.2 JRE and green threads, you should be aware that -there is a bug that forces all drivers to be BLOCKING. Thus, you -should be careful to always use native threads on the Solaris reference -1.2 JRE in order to get the expected behavior. This is not an issue -with the Solaris 1.2 Performance JRE release, which is native threads -only. - - diff --git a/src/VirtualInputDevice/RotationControls.java b/src/VirtualInputDevice/RotationControls.java deleted file mode 100644 index b95a51a..0000000 --- a/src/VirtualInputDevice/RotationControls.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import java.awt.Component; - -// Classes that implement this interface must be a subclass -// of java.awt.Component - -public interface RotationControls { - - /** - * Get the angle of Rotation around the X Axis - */ - public abstract float getXAngle(); - - /** - * Get the angle or Rotation around the Y Axis - */ - public abstract float getYAngle(); - - /** - * Get the angle or Rotation around the Z Axis - */ - public abstract float getZAngle(); - - /** - * Reset angles to original angle. - */ - public abstract void reset(); -} diff --git a/src/VirtualInputDevice/SensorBehavior.java b/src/VirtualInputDevice/SensorBehavior.java deleted file mode 100644 index f587a83..0000000 --- a/src/VirtualInputDevice/SensorBehavior.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import javax.media.j3d.*; -import java.util.*; - -public class SensorBehavior extends Behavior { - - private WakeupOnElapsedFrames conditions = new WakeupOnElapsedFrames(0); - private TransformGroup transformGroup; - private Sensor sensor; - private Transform3D transform = new Transform3D(); - - public SensorBehavior( TransformGroup tg, Sensor sensor ) { - transformGroup = tg; - this.sensor = sensor; - } - - public void initialize() { - wakeupOn( conditions ); - } - - public void processStimulus( Enumeration criteria ) { - sensor.getRead( transform ); - transformGroup.setTransform( transform ); - wakeupOn( conditions ); - } - -} diff --git a/src/VirtualInputDevice/VirtualInputDevice.java b/src/VirtualInputDevice/VirtualInputDevice.java deleted file mode 100644 index 934c8f8..0000000 --- a/src/VirtualInputDevice/VirtualInputDevice.java +++ /dev/null @@ -1,258 +0,0 @@ -/* - * $RCSfile$ - * - * Copyright (c) 2006 Sun Microsystems, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * - Redistribution of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * - Redistribution in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * Neither the name of Sun Microsystems, Inc. or the names of - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * This software is provided "AS IS," without a warranty of any - * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND - * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY - * EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL - * NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF - * USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS - * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR - * ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, - * CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND - * REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF THE USE OF OR - * INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGES. - * - * You acknowledge that this software is not designed, licensed or - * intended for use in the design, construction, operation or - * maintenance of any nuclear facility. - * - * $Revision$ - * $Date$ - * $State$ - */ - -import javax.media.j3d.*; -import javax.vecmath.*; -import java.awt.*; -import java.awt.event.*; - -public class VirtualInputDevice implements InputDevice { - - private Vector3f position = new Vector3f(); - private Transform3D newTransform = new Transform3D(); - Sensor sensors[] = new Sensor[1]; - - // The wheel controls control the view platform orientation - private RotationControls rotControls; - - // The button position controls control the view platform position - private PositionControls positionControls; - - private Transform3D rotTransX = new Transform3D(); - private Transform3D rotTransY = new Transform3D(); - private Transform3D rotTransZ = new Transform3D(); - - private Vector3f initPos = new Vector3f(); - - private int processingMode; - private SensorRead sensorRead = new SensorRead(); - - // These are the settable parameters. - private boolean printvalues; - private int xscreeninitloc; - private int yscreeninitloc; - private int xscreensize; - private int yscreensize; - private float xobjinitloc; - private float yobjinitloc; - private float zobjinitloc; - private float xaxisrotinit; - private float yaxisrotinit; - private float zaxisrotinit; - - /* - * Create a device, and use the string arguments in args to construct - * the device with user preferences. - */ - public VirtualInputDevice( String[] args ) { - - // default user-definable values - printvalues = false; - xscreeninitloc = 400; - yscreeninitloc = 0; - xscreensize = 400; - yscreensize = 200; - xobjinitloc = 0.0f; - yobjinitloc = 0.0f; - zobjinitloc = 2.2f; - xaxisrotinit = 0.0f; - yaxisrotinit = 0.0f; - zaxisrotinit = 0.0f; - - - for(int i=0 ; i Math.PI*1.5) - g2.setColor( Color.red ); // Infront of wheel - else { - g2.setColor( Color.black ); // Behind Wheel - g2.setClip( xBackClip ); - } - - g2.setXORMode( getBackground() ); - trans.setToTranslation( xOrig+pipOffset, y ); - g2.setTransform( trans ); - g2.fillPolygon( xPip ); - - // Reset graphics context - trans.setToIdentity(); - g2.setTransform( trans ); - g2.setColor(origColor); - g2.setPaintMode(); - } - - private void drawYPip( Graphics2D g2, float angle ) { - AffineTransform trans = new AffineTransform(); - int x; - int xOrig = margin; - int yOrig = margin+diameter+space; - Color origColor = g2.getColor(); - - if (angle <= Math.PI) { - x = xOrig + diameter - (int)((Math.abs( angle-Math.PI/2 )/(Math.PI/2)) * diameter/2); - } else - x = xOrig + (int)((Math.abs( (angle-Math.PI*1.5) )/(Math.PI/2)) * diameter/2); - - if (angle Math.PI*1.5) - g2.setColor( Color.red ); // Infront on wheel - else { - g2.setColor( Color.black ); // Behind Wheel - g2.setClip( yBackClip ); - } - - g2.setXORMode( getBackground() ); - trans.setToTranslation( x, yOrig+pipOffset ); - g2.setTransform( trans ); - g2.fillPolygon( yPip ); - - // Reset graphics context - trans.setToIdentity(); - g2.setTransform( trans ); - g2.setColor(origColor); - g2.setPaintMode(); - } - - private void drawZPip( Graphics2D g2, float zAngle ) { - AffineTransform trans = new AffineTransform(); - Color origColor = g2.getColor(); - - trans.translate( margin, margin ); - trans.rotate(zAngle, diameter/2, diameter/2 ); - - g2.setXORMode( getBackground() ); - g2.setTransform(trans); - g2.setColor( Color.red ); - g2.fillPolygon( zPip ); - - // Reset graphics context - trans.setToIdentity(); - g2.setTransform( trans ); - g2.setColor( origColor ); - g2.setPaintMode(); - } - - public Dimension getPreferredSize() { - return size; - } - - public void setSize( Dimension d ) { - // Set size to smallest dimension - if (d.width0) - yAngle += angleStep; - - yAngle = constrainAngle(yAngle); - - // Draw the new Pip - drawYPip( (Graphics2D)((Canvas)e.getSource()).getGraphics(), - yAngle ); - oldMousePos = pos; - break; - case SLIDE_X: - // Overwrite the old pip - drawXPip( (Graphics2D)((Canvas)e.getSource()).getGraphics(), - xAngle ); - if (diffY<0) - xAngle -= angleStep; - else if (diffY>0) - xAngle += angleStep; - - xAngle = constrainAngle(xAngle); - - // Draw the new Pip - drawXPip( (Graphics2D)((Canvas)e.getSource()).getGraphics(), - xAngle ); - oldMousePos = pos; - break; - case SLIDE_Z: - drawZPip( (Graphics2D)((Canvas)e.getSource()).getGraphics(), - zAngle ); - - if (diffX<0) - zAngle -= angleStep; - else if (diffX>0) - zAngle += angleStep; - - zAngle = constrainAngle( zAngle ); - drawZPip( (Graphics2D)((Canvas)e.getSource()).getGraphics(), - zAngle ); - oldMousePos = pos; - break; - default: - throw( new RuntimeException("Internal Error")); - } - } - - public void mouseMoved( MouseEvent e ) { - } - - /** - * Constrain angle to be 0 (float)Math.PI*2 ) return angle-(float)Math.PI*2; - if ( angle < 0.0f) return angle+(float)Math.PI*2; - return angle; - } -} diff --git a/src/VirtualInputDevice/build.xml b/src/VirtualInputDevice/build.xml deleted file mode 100644 index 4e57328..0000000 --- a/src/VirtualInputDevice/build.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3