j3d.org Code

org.j3d.device.input.spaceball
Class InputDeviceBase

java.lang.Object
  extended byorg.j3d.device.input.spaceball.InputDeviceBase
All Implemented Interfaces:
javax.media.j3d.InputDevice

public abstract class InputDeviceBase
extends java.lang.Object
implements javax.media.j3d.InputDevice

Base class for input devices with one sensor. Inherited classes shall provide the raw difference values (old absolute value - new absolute value) to setDeltaDeviceInput(int[], int[]) for transformation calculation in the processStimulus method. Input values will be scaled. A difference transformation will be put into the sensor object.

The initialize method of inherited classes must call the setSensor(javax.media.j3d.Sensor) method to set a Sensor object to be used for storing the calculated transformation.

Before using this class an appropriate Behavior (obtained with the getBehavior() method) must be added to the scene graph.

Version:
15. Jun. 2001 Copyright (c) Dipl. Ing. Paul Szawlowski
Author:
Dipl. Ing. Paul Szawlowski - University of Vienna, Dept. of Medical Computer Sciences

Field Summary
protected  InputDeviceBehavior itsBehavior
           
 
Fields inherited from interface javax.media.j3d.InputDevice
BLOCKING, DEMAND_DRIVEN, NON_BLOCKING
 
Constructor Summary
InputDeviceBase(int processingMode)
          Constructs an InputDeviceBase object.
InputDeviceBase(int processingMode, javax.media.j3d.Sensor sensor)
          Constructs an InputDeviceBase object.
 
Method Summary
 void close()
          call this method when overriding
 InputDeviceBehavior getBehavior()
          Utility method to get the assigned Behavior for the input device.
 int getProcessingMode()
           
 javax.media.j3d.Sensor getSensor(int sensorIndex)
          use only after initialisation
 int getSensorCount()
           
 boolean initialize()
          Inherited classes shall override this method and call this method, if their initialization was OK.
 void processStreamInput()
           
protected  void setDeltaDeviceInput(int[] input, int[] buttonValues)
          Calculates the transformation and puts the result into the sensor.
 void setInputValueProcessingOrder(int[] inputOrder)
          Define the processing order of the input values.
 void setNominalPositionAndOrientation()
           
 void setProcessingMode(int mode)
          not implemented
 void setScale(double[] scale)
           
 void setScale(int index, double scale)
          Set individual scale.
protected  void setSensor(javax.media.j3d.Sensor sensor)
          call this method during initialisation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.media.j3d.InputDevice
pollAndProcessInput
 

Field Detail

itsBehavior

protected InputDeviceBehavior itsBehavior
Constructor Detail

InputDeviceBase

public InputDeviceBase(int processingMode)
Constructs an InputDeviceBase object. Sets the default scale ( = 1.0 ) for all input values.

Parameters:
processingMode - use constants

InputDeviceBase

public InputDeviceBase(int processingMode,
                       javax.media.j3d.Sensor sensor)
Constructs an InputDeviceBase object. Sets the default scale ( = 1.0 ) for all input values.

Parameters:
processingMode - use constants
Method Detail

initialize

public boolean initialize()
Inherited classes shall override this method and call this method, if their initialization was OK.

Specified by:
initialize in interface javax.media.j3d.InputDevice
Returns:
false if sensor object was not set from inherited classes
See Also:
setSensor(javax.media.j3d.Sensor)

setNominalPositionAndOrientation

public void setNominalPositionAndOrientation()
Specified by:
setNominalPositionAndOrientation in interface javax.media.j3d.InputDevice

processStreamInput

public void processStreamInput()
Specified by:
processStreamInput in interface javax.media.j3d.InputDevice

close

public void close()
call this method when overriding

Specified by:
close in interface javax.media.j3d.InputDevice

getProcessingMode

public int getProcessingMode()
Specified by:
getProcessingMode in interface javax.media.j3d.InputDevice

setProcessingMode

public void setProcessingMode(int mode)
not implemented

Specified by:
setProcessingMode in interface javax.media.j3d.InputDevice

getSensorCount

public int getSensorCount()
Specified by:
getSensorCount in interface javax.media.j3d.InputDevice

getSensor

public javax.media.j3d.Sensor getSensor(int sensorIndex)
use only after initialisation

Specified by:
getSensor in interface javax.media.j3d.InputDevice

setScale

public void setScale(double[] scale)
Parameters:
scale - value to be multiplied with the input values of the device driver. Size of array = 6.

setScale

public void setScale(int index,
                     double scale)
Set individual scale.

Parameters:
index - 0 <= index < 6
scale - value to be multiplied with the received corrsponding value of the device driver.

getBehavior

public InputDeviceBehavior getBehavior()
Utility method to get the assigned Behavior for the input device. The Behavior will read the transformations of the inputs device's sensor and apply them to the specified TransformGroup.

The Behavior is not added to the scene graph. This must be done by the user.


setInputValueProcessingOrder

public void setInputValueProcessingOrder(int[] inputOrder)
Define the processing order of the input values. E. g. the array { 0, 2, 1, 3, 4, 5 } will reorder the input values in this way: { inputValue[ 0 ], inputValue[ 2 ], inputValue[ 1 ], inputValue[ 3 ], inputValue[ 4 ], inputValue[ 5 ] }

Parameters:
inputOrder - The size of the array and the indizes must match with the number of input values.
See Also:
setDeltaDeviceInput(int[], int[])

setDeltaDeviceInput

protected void setDeltaDeviceInput(int[] input,
                                   int[] buttonValues)
Calculates the transformation and puts the result into the sensor. Scales the input values. Uses the first 3 input values to translate along the x-axis, y-axis and z-axis respectively and uses the second 3 input values to rotate about the y-axis, x-axis and z-axis respectively ( clockwise ). The 4th and 5th input values (rotation about y- and x-axis) are used as polar angles to define a direction vector for the rotations. The reference vector for the direction is (0,0,1).

Parameters:
input - new difference input values for transformation calculation. Size of array = 6.
buttonValues - set to null if input device has no buttons
See Also:
TransformationUtils#getRotationTranslationTransform3D

setSensor

protected void setSensor(javax.media.j3d.Sensor sensor)
call this method during initialisation

Parameters:
sensor - sensor to be used

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org