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

∥☆過路亽.° 提交于 2019-12-10 16:38:28

问题


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.


回答1:


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).




回答2:


I can't give you a simple answer, but I can tell you that what you're looking to draw is called two-point perspective. With this information, maybe you will be able to find a library that takes a 3D object and produces a perspective view.

Here's a simple Java applet that I've seen previously that demonstrates 2-point perspective: http://mathforum.org/workshops/sum98/participants/sanders/TryPersp.gsp.html

Hope this helps!




回答3:


Your problem is not trivial, but certainly solvable. You can take any four-sided image and apply a 3D perspective transformation. Just don't expect it to be a one-liner.

I'm at home now (checking SO before going to sleep, of course :D), but I'm almost 100% certain this is the site I used to find the appropriate code in C#:

http://ryoushin.com/cmerighi/en-us/61,2007-10-29/Image_Distortion_Enhancements.aspx

Porting it to java should be fairly straightforward. Let me know if the link doesn't solve your answer and I'll edit my answer tomorrow with more info.



来源:https://stackoverflow.com/questions/4138010/appropriate-transformation-for-3d-looking-2d-drawing-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!