Hi,
I was wondering how one would go about implementing the inverse of the JMEDesktop.convert() method? I want to convert from Swing to JME screen coordinates. I've figured out how to do the inverse of the part for getRenderQueueMode() == Renderer.QUEUE_ORTHO, but the else logic is a much more complex:
/**
* Convert mouse coordinates from jME screen to MyJMEDesktop coordinates (Swing).
* @param x jME x coordinate
* @param y jME y coordinate
* @param store resulting JDesktop coordinates
*/
public void convert( int x, int y, Vector2f store ) {
if ( getRenderQueueMode() == Renderer.QUEUE_ORTHO ) {
//TODO: occlusion by other quads (JMEFrames)
x = (int) ( x - getWorldTranslation().x + desktopWidth / 2 );
y = (int) ( desktopHeight / 2 - ( y - getWorldTranslation().y ) );
}
else {
store.set( x, y );
DisplaySystem.getDisplaySystem().getWorldCoordinates( store, 0, pickRay.origin );
DisplaySystem.getDisplaySystem().getWorldCoordinates( store, 0.3f, pickRay.direction ).subtractLocal( pickRay.origin ).normalizeLocal();
applyWorld( bottomLeft.set( -width * 0.5f, -height * 0.5f, 0 ) );
applyWorld( topLeft.set( -width * 0.5f, height * 0.5f, 0 ) );
applyWorld( topRight.set( width * 0.5f, height * 0.5f, 0 ) );
applyWorld( bottomRight.set( width * 0.5f, -height * 0.5f, 0 ) );
if ( pickRay.intersectWherePlanarQuad( topLeft, topRight, bottomLeft, tuv ) ) {
x = (int) ( ( tuv.y - 0.5f ) * width ) + desktopWidth / 2;
y = (int) ( ( tuv.z - 0.5f ) * height ) + desktopHeight / 2;
}
Does anyone have any examples or rough outlines on how to do something like this?
Thanks!