简体   繁体   English

如何使用java3D API在纹理上编写文本?

[英]How to write text on a texture using java3D API?

I'm wondering how I can write some text on a given texture (during execution) ? 我想知道如何在给定纹理上写一些文本(在执行期间)?

I'm using the java3d API. 我正在使用java3d API。

Thanks ! 谢谢 !

I believe you can fetch your texture's ImageComponent from the getImage or getImages methods, cast them to ImageComponent2D (if you can), then call the getImage method on them to get access to the BufferedImage object which finally gives you access to a Graphics object for text drawing. 我相信你可以从getImage或getImages方法获取纹理的ImageComponent,将它们转换为ImageComponent2D(如果可以的话),然后调用它们的getImage方法来访问BufferedImage对象,最终使你可以访问Graphics对象的文本画画。

You will probably have to do this for every MIP level, or regenerate the lower levels from the highest level every time you change it. 您可能必须为每个MIP级别执行此操作,或者每次更改时从最高级别重新生成较低级别。

Alternatively, if you're not going to be updating the texture very frequently, you should be able to just create and apply a new texture from an Image every time you need to using the TextureLoader. 或者,如果您不打算非常频繁地更新纹理,那么每次需要使用TextureLoader时,您应该能够从Image创建并应用新纹理。

I think you should be able to figure it out using this guide (start on page 18 where they're 'drawing' on the cube). 我认为你应该能够使用本指南来解决这个问题(从第18页开始,他们在立方体上“绘图”)。

The Joy of Java 3D Java 3D的喜悦

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

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