在 Java3D 中创建发光球体
我正在寻找一种使用 Java3D 重现这种雾球发光效果的方法。
http://bzflag.org/screenshots/bzfi0021.jpg http://bzflag.org/screenshots/bzfi0019.jpg http://bzflag.org/screenshots/bzfi0022.jpg
我正在创建一个转换组使用点光源和发射材料球体,但我无法重现雾气。
有想法吗?
谢谢!
============ 解决方案(感谢 Ricket)===========
try
{
TextureLoader myLoader = new TextureLoader( new File("./data/grad.png").toURI().toURL(), this );
ImageComponent2D myImage = myLoader.getImage( );
Raster raster = new Raster( );
raster.setPosition( new Point3f( 0.0f, 0.0f, 0.0f ) );
raster.setType( Raster.RASTER_COLOR );
raster.setSize( 50, 50);
raster.setImage( myImage );
TransparencyAttributes ta = new TransparencyAttributes( TransparencyAttributes.BLENDED, 0.0f );
Appearance app = new Appearance();
app.setTransparencyAttributes( ta );
objScale.addChild( new OrientedShape3D(raster, app, OrientedShape3D.ROTATE_ABOUT_POINT, new Point3f( 0.0f, 0.0f, 0.0f )));
}
catch (MalformedURLException e) { throw new RuntimeException(); }
I'm looking for a way to reproduce this foggy-sphere-glowing effect using Java3D.
http://bzflag.org/screenshots/bzfi0021.jpg
http://bzflag.org/screenshots/bzfi0019.jpg
http://bzflag.org/screenshots/bzfi0022.jpg
I'm creating a transform group with a point light source and an emissive-material-sphere, but I can't reproduce the foggyness.
Ideas?
Thanks!
============ SOLUTION (Thanks to Ricket) ===========
try
{
TextureLoader myLoader = new TextureLoader( new File("./data/grad.png").toURI().toURL(), this );
ImageComponent2D myImage = myLoader.getImage( );
Raster raster = new Raster( );
raster.setPosition( new Point3f( 0.0f, 0.0f, 0.0f ) );
raster.setType( Raster.RASTER_COLOR );
raster.setSize( 50, 50);
raster.setImage( myImage );
TransparencyAttributes ta = new TransparencyAttributes( TransparencyAttributes.BLENDED, 0.0f );
Appearance app = new Appearance();
app.setTransparencyAttributes( ta );
objScale.addChild( new OrientedShape3D(raster, app, OrientedShape3D.ROTATE_ABOUT_POINT, new Point3f( 0.0f, 0.0f, 0.0f )));
}
catch (MalformedURLException e) { throw new RuntimeException(); }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我很确定“球体”实际上是在 3D 空间中绘制的 2D 精灵作为广告牌,然后在其位置也“绘制”了匹配的颜色光。雾度只是图像的 2D 梯度。
这只是我玩过游戏后的最佳猜测,我还没有看过源代码。
I'm pretty sure the "sphere" is actually a 2D sprite drawn in 3D space as a billboard, and then a matching color light also 'drawn' at its position. The fogginess is just a 2D gradient of the image.
This is just my best guess from having played the game though, I haven't looked at the source.
文章 了解 Java 3D API 中的光照解释了如何设置光照参数。如果您无法用一个球体模拟发光效果,您可以尝试将一个更小、更亮的球体放入一个彩色透明球体中。
The Article Understanding Lighting in the Java 3D API explains how to setup the lighting parameters. If you can't simulate the glowing effect with one sphere you could try to put a smaller brigther one into a colored transparent sphere.
您可以尝试查看代码。他们甚至还有一个指南。
You might try looking at the code. They even have a guide.