如何在Java小程序中做3D?
我想在 java 小程序中渲染一个非常简单的 3D 场景。我可以自己完成所有数学计算并将其渲染为位图,但我确信我不是历史上第一个必须在屏幕上绘制几个立方体的人,我想知道这通常是如何完成的。
我读过的每个地方都说Java3D或LWJGL,但据我了解,这些依赖于平台相关的代码,并且需要与Java分开安装,使得它们都不适合图形。
那么这通常是如何完成的呢?
I'd like to render a very simple 3D scene in a java applet. I could do all the math myself and render that to a bitmap, but as I'm sure I'm not the first person in history to have to draw a few cubes to the screen, I was wondering how this is usually done.
Every place I've read has said either Java3D or LWJGL, but as I understand it these rely on platform-dependent code and need to be installed separately from Java, making them both unsuitable for graphics.
So how is this usually done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
此旧页面列出了没有硬件依赖性的 3D Java 小程序的演示/应用程序/库。不幸的是,很少有开源的,其他的甚至无法下载。
我个人建议您尝试 Ken 的 Java 1.1 3D 渲染器Perlin,它提供源代码并免费用于学术目的。
编辑:jGL 是另一个没有硬件依赖性的 Java 3D 库。它模仿 OpenGL 1.* API。它根据 GNU 宽松通用公共许可证 (LGPL) 获得许可。
This old page lists the demos/apps/libraries of 3D Java applets with no hardware dependencies. Unfortunately very few are open-source, others are not even downloadable.
Personally I recommend you to experiment with Java 1.1 3D renderer by Ken Perlin, which has source code available and free to use for academic purposes.
EDIT: jGL is another Java 3D library with no hardware dependencies. It mimics OpenGL 1.* API. It is licensed under GNU Lesser General Public License (LGPL).
在插件 2 JRE (1.6.0_10+) 中,您可以将 JWS 扩展用于嵌入式小程序。这很重要,因为 JWS 可以更轻松地确保正确的二进制文件位于运行时类路径上。 AFAIU JOGL 和 Java 3D 都为其 API 提供 JWS 扩展。
如果您选择这样做,请让小程序添加可拖动参数,以便最终用户可以选择是否需要一个(大部分无用的)浏览器窗口围绕 3D 动画。
In a plug-in 2 JRE (1.6.0_10+), you can use JWS extensions for embedded applets. This is important because JWS makes it much easier to ensure the correct binaries are on the run-time class path. AFAIU JOGL and Java 3D both offer JWS extensions for their APIs.
Should you choose to go that way, please make the applet has the draggable parameter added, so the end user might choose if they want a (mostly useless) browser window wrapped around a 3D animation.
当我需要在小程序中进行一些 3D 渲染时,我遇到了类似的问题。我的解决方案是简单地用 Java 从头开始实现一个 3D 渲染库。人们担心它的性能会很差,但在 I5 处理器上,事实证明情况并非如此。额外的优点是我能够按照我一直希望完成图形的方式编写库。然而,真正的优点是,无论客户端上是否需要安装某些图形库,并且不考虑任何显卡依赖性,它都会运行。
我很乐意将这段代码的子集分享给任何想要查看它的人。
I ran into similar problems when I needed to do some 3d rendering in an applet. My solution was to simply implement from scratch a 3d rendering library in Java. The fear was that it would be a poor performer but on an I5 processor, this proved to not be the case. The added advantage is that I was able to write the library in the way I always wanted graphics to be done. The real advantage,, though, is that it will run regardless of any need to have some graphics library installed on the client and without regard to any graphics card dependencies.
I will gladly share a subset of this code to anyone who wants to look at it.
你能用JOGL吗?
http://download.java.net/media/jogl/demos /www/applettest-jnlp.html
Could you use JOGL?
http://download.java.net/media/jogl/demos/www/applettest-jnlp.html
我不是 Java 人,但 2/3 年前,当我在大学时,我遇到了同样的问题:)
我尝试过 jogl...对于像我这样的 Java 菜鸟来说,我发现使用它来配置和编写一些东西太复杂了。
我使用了 Java3d,它的工作就像一个魅力,当时我遇到的唯一问题是 Java3d 并不适用于所有显卡。但幸运的是,它可以在我大学的计算机上运行:)
I'm not a Java guy, but 2/3 years ago when I was at univeristy I had the same problem :)
I've tried jogl... and for noob in Java like myself I found it too complicated to configure and write something using it.
I used Java3d and it worked like a charm, the only problem I had back then, was that Java3d did not worked with all graphic cards. But fortunatelly it worked with computers at my univeristy :)