How would you write some strings to a quad procedurally? I make my Strings into a BitmapText, but how would you get this onto the quad? I thought maybe convert it to an image, then convert that to a texture somehow, but I’m not sure how. Texture class is abstract… Seems strange to me.
I tried:
[java]
BitmapText espText = new BitmapText(guiFont, false);
espText.setText(espanol);
Spatials have asset keys because Spatials can be loaded from assets. (The fact that this is broken for BitmapText not withstanding).
Asset does not equal texture. So, yes, you are confused. You can’t just take one value out of something and force-jam it into another. No more so than if you tried to open a text file in MS paint. (which is almost an exact analogy in this case)
To your original problem, you should look into the ImagePainter plugin. I think it allows text to be rendered. Also, you could do it with Java2D on a BufferedImage and then convert it but ImagePainter will be a much more direct way.
I can’t use the image that imagepainter has painted onto though to create a texture because the texture class is abstract
So I can’t make an object to it then use texture.setImage() like in the javadoc. Or do I have to load a texture in then use that object & modify it… Seems like a bad way to do it thought to me.
ImagePainter will automatically create an Image for you if you want. You can then wrap it into a texture easily enough. There is even an example of doing just that in the ImagePainter test app thing.
Yes the javadocs are useful, but to me they don’t always fully explain how to use the lib. Maybe I missed the javadoc chapter of ‘java for dummies’, but I always found an example worked better. anyways, I get an outofmemory on this line
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at com.zero_separation.plugins.imagepainter.ImagePainter.paintTextArea(ImagePainter.java:1358)
@javagame said:
Yes the javadocs are useful, but to me they don't always fully explain how to use the lib.
Well, one thing that you can count on is that it is completely impossible to ever instantiate an abstract class. So when you find one (like Texture) then you must know that there is some concrete subclass somewhere. JME cannot be magically creating raw Texture objects so it must be creating a subclass.
Javadocs are very good about showing this information.
@javagame said:
Yes the javadocs are useful, but to me they don't always fully explain how to use the lib. Maybe I missed the javadoc chapter of 'java for dummies', but I always found an example worked better. anyways, I get an outofmemory on this line
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,6,main]
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2734)
at java.util.ArrayList.ensureCapacity(ArrayList.java:167)
at java.util.ArrayList.add(ArrayList.java:351)
at com.zero_separation.plugins.imagepainter.ImagePainter.paintTextArea(ImagePainter.java:1358)
That’s odd, I’ll try and remember to take a look at it this evening. If I don’t feel free to poke me over the weekend
Do you always get the same error in the same place?
How large is your text?
The relevant line of code is just adding an int into a list of Integers - with one int per line of text. Perhaps something in the text is confusing it so the search never finishes somehow?
java.lang.NoSuchMethodError: com.jme3.texture.image.ImageRaster.getWidth()I
at com.zero_separation.plugins.imagepainter.ImagePainter.paintSubImage(ImagePainter.java:832)
at com.zero_separation.plugins.imagepainter.ImagePainter.paintTextLine(ImagePainter.java:1295)
I think there must be some inconsistency between the source provided with the plugin and the actual compiled code
EDIT: what I mean by that is the line the stack trace is referring to says
if (xLimit > imageRaster.getWidth()) {
@pspeed said:
Technically that's what he's doing. I think I almost know what you mean but I fail to see how it is easier than just drawing the text to an image.
Hehe… One works in minutes… the other requires a thread of the course of a week?
@t0neg0d said:
Hehe... One works in minutes... the other requires a thread of the course of a week?
Rendering a scene to a texture is proposed as an alternative to a simple image write because the poster is running an old version of JME and so it is incompatible with the simpler way? Seriously? You think that way is actually going to be easier for the OP to figure out?
@pspeed said:
Rendering a scene to a texture is proposed as an alternative to a simple image write because the poster is running an old version of JME and so it is incompatible with the simpler way? Seriously? You think that way is actually going to be easier for the OP to figure out?
Priceless.
Why would they need to figure it out? There is a working example in test. Unless they don’t know how to use CTRL+C/CTRL+V, it sounds like this would be the more straight-forward approach.
@t0neg0d said:
Why would they need to figure it out? There is a working example in test. Unless they don't know how to use CTRL+C/CTRL+V, it sounds like this would be the more straight-forward approach.
Heheh… “Hi, sorry the four lines of code from this working example is failing for you because you don’t have the latest JME… maybe you could try cutting and pasting 20 lines of less efficient code from a completely different working example and debug that instead. It’s ‘simpler’.” lol
OP, please just upgrade your JME and try again. If you are missing ImageRaster.getWidth() then you must be running and old JME. Ignore the extra noise… they way you are going is the simplest way. You just need to get your environment sorted out.