Oh, BTW, calculating collision points in an applet seems to be working fine for me. For reference, here are a couple of methods I am using now that I know work in an applet:
public void mousePressed( MouseEvent e )
{
// Get the mouse's coordinates on the applet window:
int x = e.getX();
int y = e.getY();
// Get the 3D coordinates in Camera space:
SimpleVector position = new SimpleVector( Interact2D.reproject2D3D(
camera, buffer, x, y ) );
// Convert the coordinates to World space:
position.matMul( camera.getBack().invert3x3() );
position.add( camera.getPosition() );
// Determine the direction from the camera position to the click point:
SimpleVector direction = position.calcSub( camera.getPosition() ).normalize();
// Calculate the distance to whatever was clicked on:
float distance = world.calcMinDistance( position, direction, 10000 );
// Check if we clicked on something:
if( distance != Object3D.COLLISION_NONE )
{
// Calculate the exact 3D coordinates for the point that was clicked:
SimpleVector collisionPoint = new SimpleVector( direction );
collisionPoint.scalarMul( distance );
collisionPoint.add( position );
// collisionPoint is the exact 3D coordinate.
clickMap( collisionPoint ); // user clicked on the map
}
}
public void move( long currentTime )
{
// if bullet expired or crashed, do nothing
if( expired || crashed )
return;
// check if bullet should expire
if( currentTime - creationTime >= lifeSpan )
{
expired = true;
return;
}
// calculate how far to move the bullet
float distance = ( currentTime - lastMoveTime ) * distancePerMilli;
// save the current time
lastMoveTime = currentTime;
// check if the bullet should expire
if( lastMoveTime - creationTime >= lifeSpan )
{
expired = true;
return;
}
// check if the movement will result in a collision:
SimpleVector position = object3D.getTransformedCenter();
float targetDistance = world.calcMinDistance( position, direction,
100000 );
// See if the bullet is going to collide with something:
if( (targetDistance != Object3D.COLLISION_NONE)
&& (targetDistance <= distance) )
{
// collision occurred, move bullet to the collision point:
SimpleVector smallTranslation = new SimpleVector( direction );
smallTranslation.scalarMul( targetDistance );
object3D.translate( smallTranslation );
crash();
return;
}
// move bullet the full distance:
SimpleVector translation = new SimpleVector( direction );
translation.scalarMul( distance );
object3D.translate( translation );
}