3D 外观的 2D 绘图的适当转换 (Java)

发布于 2024-10-01 14:15:08 字数 165 浏览 3 评论 0原文

我正在寻找适当的转换以使 2D 图像看起来像 3D 绘图。如果我在一张纸上用平行线画一条“路”,然后将纸的顶部向远离你的方向倾斜,使路看起来消失在远处,这就是我正在寻找的东西。

我正在使用 Java,并且想要一个合适的 API/库。我不相信“AffineTransformation”能够实现这一点。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

亢潮 2024-10-08 14:15:08

您不需要 AffineTransformation,因为它将始终保留平行线,这不是您想要的。

幸运的是,Java 高级成像 API (javax.media.jai) 正是您想要的,其形式为 PerspectiveTransform< /code> 类(单击该链接查看文档)。

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

迷爱 2024-10-08 14:15:08

你的问题并不小,但肯定是可以解决的。您可以拍摄任何四面图像并应用 3D 透视变换。只是不要指望它只是一句台词。

我现在在家(当然,在睡觉前检查一下:D),但我几乎 100% 确定这是我用来在 C# 中查找适当代码的网站:

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

将其移植到 java 应该相当简单。如果该链接无法解决您的答案,请告诉我,我明天将使用更多信息编辑我的答案。

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.

时光无声 2024-10-08 14:15:08

我无法给你一个简单的答案,但我可以告诉你,你要画的东西叫做两点透视。有了这些信息,也许您将能够找到一个可以获取 3D 对象并生成透视图的库。

这是我之前见过的一个简单的 Java 小程序,它演示了 2 点透视:
链接< /a>

希望这有帮助!

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:
Link

Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文