Dinamically create a texture from a string

I am trying to create a TextureKey from a string to use with assetManager.loadTexture() and produce a Texture that can be applied on any surface.

I am trying to work with BitmapText, but I cannot find a way to get the texturekey from the texture it generates, any idea?

My goal is to provide debug textures to be replaced with real ones based on string Ids, so as long they exist on assets path they will be loaded, otherwise a string with the missing texture name will be shown (this could be some default on the engine too, to help on speeding up initial developments)

Just found TestBitmapText3D, but seems not be what I am trying to accomplish.

BitmapText isn’t creating a texture. It creates a quad per letter.

If you want to write letters to a texture (seems to be what you want) then the texture key has nothing to do with that. You create an image, write stuff into it, then wrap it into a texture. I think there is some kind of image renderer plugin that lets you write text to a texture.

@pspeed

any more tips on what classes could be related to it?
I think: Image img; img.addData(); seems to be what you said

still trying to find it, the “Text” on google confuses with “texture” and the “String” confuses with the class String, so it is unbelievably hard to match properly “render string text to texture” eheheh :frowning:

I found this
http://www.jmonkeyengine.org/doc/com/jme/scene/Text.html
but that class seems to exist no more?

http://hub.jmonkeyengine.org/javadoc/com/jme3/texture/image/ImageRaster.html
is the entry point, now you only need to know how to paint wich pixel for text to appear.

look at the link above, that class is probably from jme2 as can be seen by the missing 3 in the packagename

I guess I wasn’t specific enough with my mention of a plugin. So I took the five seconds of trouble to open the plug-in list in the SDK (you should learn how to find it because there is stuff in there).

Edit: switched the image out for one that had the entry highlighted conventionally.

@EmpirePhoenix, the ImageRaster way seems interesting to draw lines and many other things, thx! I wonder if a text font could be easily parsed to it tho? I mean, instead of drawing dot by dot of each letter.

@pspeed, oh you mean a netbeans jme3 plugin! I thought I would have to find some jar somewhere hehe. Anyway, after installing the plugin, my code seems not be able to find the ImagePainter?
But I found this:
http://hub.jmonkeyengine.org/forum/topic/image-getpixelsetpixel-imagepainter-editing-jme3-images/
so I could use its paintTextLine() method!

Also, I wonder why this is not included into the jme3 already? I mean, I would prefer to use it from jme3 instead of having to add that java file into my project, so updates to jme3 would bring updates to it also if any and so on.

EDIT: it seems unmaintened, so I am trying to fix it

Because JME can’t throw every random thing that some user might want in. It has to focus on the parts that make sense. (In my opinion, already too much is included but that ship has sailed.)

MORE things should be plugins.

Also, if you are developing against stable JME 3.0.10 I think it should still work fine. What are the errors you are getting?

@pspeed, I updated ImagePainter.java to use ImageRaster! it works great!

so, basically I had to implement ImageRaster usage (as old Image seems to have methods migrated to ImageRaster), was actually very simple…

I think I should contribute it back at @zarch thread, just dont know how. But… as there is a working plugin, my guess is my work was unnecessary? as this file may already be updated and available somewhere?

To any newb around (like me), it is very simple…

Install the plugin ImagePainter on NetBeans JME3 SDK.
On your project: properties -> libraries -> add library
ImagePainter (as all other plugins libraries) will be available there!

no need to update that java manually…
thanks ppl!

EDIT: @pspeed, indeed now I see that plugins will suffice, no need all things go in main jme3 :slight_smile: