Hi !

I think there are three important uses for inputdevices :
  - positioning of objects according to the current sensor-read
  - moving of objects according to the current sensor-read
  - reading button values

Just now, the only possibility to implement this, is to implement a
behavior
that polls the sensor on every frame.

A much better implementation would (imho) be something like :

  while(true) {
    pollAndProcessSensorValues(sensor);
    sensor.waitForSensorReadChange();
  }

Probably finding out, if the Transform3D has changed or does not equals
identity is much easier for the InputDevice, than judging from the
transformation.

And implementing this in the sensor class is not very hard :

public class Sensor {
  [...]
  private Object waitChange      = new Object();
  private Object waitNotIdentity = new Object();

  [...]

  public void setNextSensorRead(long time, Transform3D transform, int[]
values, boolean hasChanged, boolean isIdentity) {
    [...]
  }

  public void setNextSensorRead(long time, Transform3D transform, int[]
values) {
    super.setNextSensorRead(...);

    if (isIdentity(transform)
      waitChange.notifyAll();

    if (hasChanged(transform))
      waitNotIdentity.notifyAll();
  }

  public void waitForSensorReadNotIdentity() throws InterruptedException
{
    waitNotIdentity.wait();
  }

  public void waitForSensorChange() throws InterruptedException { ... }

  public void waitForSensorButton() throws InterruptedException { ... }

}

There is missing some synchronization and ExceptionHandling, but I guess
this should work ...
(For devices that are not DEMAND_DRIVEN)

Comments (from Sun ?) !?! Am I mistaken, or could this be some sensible
solution ?
(Or are the notify() methods taking so much time, that this is not
practical ?)

Niklas

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to