Creating 'laserlights' with Java3D/other 3D API
Yesterday I decided to start my new simulator project with Java and Java3D. Since I already programmed Java before it was a big plus and I could directly start with the simulator. 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 simula开发者_开发问答tors.
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)
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. 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)
Thanks in advance,
William v. Doorn
Let me preface my answer by saying my experience with Java3D is quite limited. I've played with the examples, but that's about it. However, many of the rules apply across 3D environments.
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.
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. 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.
Update 1: I would start with a Cone with a very small radius as a single beam.
Use alpha textures. 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.
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. 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. Hopefully this helps!
精彩评论