Hi all,

Maybe someone can give me a hint. I've observed a strange behavior with
an input device with different calculations of the input values.

one way is like that (multiplying a difference matrix in the behavior):

code in InputDevice implementation:

{
    // itsPositionValues: values read from the 6DOF of freedom device
      final double sinXrot = Math . sin( itsPositionValues[ 3 ] );
      final double sinYrot = Math . sin( itsPositionValues[ 4 ] );
      final double sinZrot = Math . sin( itsPositionValues[ 5 ] );
      final double cosXrot = Math . cos( itsPositionValues[ 3 ] );
      final double cosYrot = Math . cos( itsPositionValues[ 4 ] );

      itsPosition . set( itsPositionValues[ 0 ], itsPositionValues[ 1 ],
itsPositionValues[ 2 ] );
      itsOrientation . set( sinYrot * cosXrot, sinXrot, - cosYrot *
cosXrot );
      itsUpVector . set
         (
            - sinYrot * sinXrot + cosYrot * cosXrot * sinZrot
         ,  cosXrot + sinXrot * sinZrot
         ,  cosYrot * sinXrot - sinYrot * cosXrot * sinZrot
         );
      itsTransform . lookAt( itsZeroPoint, itsOrientation, itsUpVector
);
      itsTransform . setTranslation( itsPosition );
      writeSensor( itsTransform, getButtonValues( ) );
}

code in behavior:
{
      if( itsTG != null ) // itsTG is a TransfromGroup
      {
         itsTG . getTransform( itsTempTransform );
         itsTempTransform . get( itsTransVector );
         itsTempTransform . getRotationScale( itsRotMatrix );
         itsNewTransform . set( itsTransVector );
         itsSensor . getRead( itsTempTransform );
         itsNewTransform . mul( itsTempTransform );
         itsTempTransform . set( itsRotMatrix );
         itsNewTransform . mul( itsTempTransform );
         itsTG . setTransform( itsNewTransform );
      }
      wakeupOn( itsWakeup ); // wake up every frame
}

-----------------------------------------------------------------------------------

the other way is like that (using a difference vector and calculate
absolute matrix)

code in InputDevice implementation

{
      double[ ] positionValues = getPositionValues( );
      final double sinXrot = Math . sin( positionValues[ 3 ] );
      final double sinYrot = Math . sin( positionValues[ 4 ] );
      final double sinZrot = Math . sin( positionValues[ 5 ] );
      final double cosXrot = Math . cos( positionValues[ 3 ] );
      final double cosYrot = Math . cos( positionValues[ 4 ] );

      itsPosition . x += positionValues[ 0 ];
      itsPosition . y += positionValues[ 1 ];
      itsPosition . z += positionValues[ 2 ];

      itsDirection . set( sinYrot * cosXrot, sinXrot, - cosYrot *
cosXrot );
      itsUpVector . set
         (
            - sinYrot * sinXrot + cosYrot * cosXrot * sinZrot
         ,  cosXrot + sinXrot * sinZrot
         ,  cosYrot * sinXrot - sinYrot * cosXrot * sinZrot
         );

      itsTransform . getRotationScale( itsTempMatrix ); // itsTransform
holds the current transformation
      itsTempMatrix . transpose();
      itsTempMatrix . transform( itsDirection );
      itsTempMatrix . transform( itsUpVector );
      itsTransform . lookAt( itsTempPosition, itsDirection, itsUpVector
);
      itsTransform . setTranslation( itsPosition );
      writeSensor( itsTransform, getButtonValues( ) );
}

code in behavior:

{
      if( itsTG != null )
      {
         itsSensor . getRead( itsTransform );
         itsTG . setTransform( itsTransform );
      }
      wakeupOn( itsWakeup );
}

In my opinion both methods should have the same result. But the object
moves faster with the first method than with the second method. I
measured frame rate and InputDevice scheduler rate which are pretty much
the same. So only the stepwidth of the transformation can be different,
but why ?

regards
Paul

===========================================================================
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