简体   繁体   English

使用 Java3D/其他 3D API 创建“激光灯”

[英]Creating 'laserlights' with Java3D/other 3D API

Yesterday I decided to start my new simulator project with Java and Java3D.昨天我决定用 Java 和 Java3D 开始我的新模拟器项目。 Since I already programmed Java before it was a big plus and I could directly start with the simulator.因为我在 Java 之前就已经编写了它是一个很大的优势,所以我可以直接从模拟器开始。 Now I was a bit thinking about how I was going to approach this, and I directly stumbled and the biggest part of my program: the laser in the simulators.现在我有点思考我将如何解决这个问题,我直接绊倒了我程序的最大部分:模拟器中的激光。

I want to create lasers similar to these (of course I won't ever come that close in the beginning, but you get the idea)我想创造与这些相似的激光(当然我一开始不会那么接近,但你明白了)

替代文字
(source: wrzuta.pl ) (来源: wrzuta.pl

The problem is, can anyone give me a rough explanation of how to approach this?问题是,谁能给我一个如何解决这个问题的粗略解释? I walked through the full documentation of Java3D but I couldn't find a feature to create things like these.我浏览了 Java3D 的完整文档,但找不到创建此类内容的功能。 Just some starting point would be nice already.只是一些起点就已经很好了。

(If anyone recommends a different 3D API for this kind of task, which is also for Java, please tell me) (如果有人为此类任务推荐不同的 3D API,也适用于 Java,请告诉我)

Thanks in advance,提前致谢,

William v. Doorn威廉诉多恩案

Let me preface my answer by saying my experience with Java3D is quite limited.让我在回答之前说我对 Java3D 的经验非常有限。 I've played with the examples, but that's about it.我玩过这些例子,但仅此而已。 However, many of the rules apply across 3D environments.但是,许多规则适用于 3D 环境。

If you're talking about a static image: use very narrow cones, add color and transparency, possibly a texture to decrease the alpha component with respect to the distance from the cone's central axis.如果您在谈论静态图像:使用非常窄的锥体,添加颜色和透明度,可能是纹理以减少相对于锥体中心轴距离的 alpha 分量。

If you're talking about an animated scene, that gets a bit harder.如果你在谈论动画场景,那就有点难了。 You need to synthesize the fog.你需要合成雾。 Volumetrics will give you incredible images, but it's computationally expensive, and I don't think Jave3D supports it. Volumetrics 将为您提供令人难以置信的图像,但它的计算成本很高,而且我认为 Jave3D 不支持它。 However, I think you can fake it if you have an object that is parent to all of the laser beams and Java3D will let anchor a texture to the parent and let the children inherit it.但是,我认为如果您有一个对象是所有激光束的父对象,并且 Java3D 会将纹理锚定到父对象并让子对象继承它,那么我认为您可以伪造它。

Update 1 : I would start with a Cone with a very small radius as a single beam.更新 1 :我会从一个半径非常小的锥体作为单个光束开始。

Use alpha textures.使用 alpha 纹理。 Take your polygon, paint the "beam" of the laser as a solid green edge.拿你的多边形,把激光的“光束”画成一个纯绿色的边缘。 Put green cloud texture with alpha channel between the laser-edges.在激光边缘之间放置带有 alpha 通道的绿色云纹理。

Finished.完成的。 :-) :-)

I'm not familiar at all with the Java 3D API, but when I quickly looked through the documentation I stumbled upon the LineArray .我对 Java 3D API 一点也不熟悉,但是当我快速浏览文档时,我偶然发现了LineArray Googling for this class led me to a piece of example code which led me to believe it might be what you are looking for.谷歌搜索这门课让我找到了一段示例代码,这让我相信它可能是你正在寻找的。 Other than that I can highly recommend jMonkeyEngine , which definitely supports GL lines.除此之外,我强烈推荐jMonkeyEngine ,它绝对支持 GL 行。 Hopefully this helps!希望这会有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM