Search code examples
javagraphics3d2d

Appropriate Transformation for 3D-looking 2D drawing (Java)


I'm looking for the appropriate transformation to make a 2D image look like a 3D drawing. If I draw a "road" with parallel lines on a sheet of paper, and then tilt the top of the page away from you, so that the road appears to be disappearing into the distance is what I am looking for.

I'm using Java and would like an appropriate API/library. I don't believe "AffineTransformation" accomplishes this.


Solution

  • You don't want an AffineTransformation, as that will always preserve parallel lines, which isn't what you want here.

    Luckily the Java Advanced Imaging API (javax.media.jai) has exactly what you want, in the shape of the PerspectiveTransform class (click that link for docs).