Good way to display 2D-Pictures

Hey there!

Just a quick little question:
I’m trying to display a few simple 2D pictures using the Picture class.
But the size of the pictures is 1 by default, do you have to change it
manually every time you load a new picture?

Or is there maybe a better way to display moving and rotating 2D graphics?

Thx in advance!

Use your image as a texture on a quad. Or maybe check sprite meshes and particles if you will be using lots of pictures at the same time …
EDIT: Picture is for GUI elements, you should be able to rotate it in 2D space, if you want it in 3D, you should manually construct a quad and use a texture on it.
EDIT2: Yes you have to change size of the picture manually everytime you load it. It actually only changes the size of underlying geometry.

Well, it’s for a 2D game, so rotating in 3D is nothing I’m looking for.
Using a texture on a squad is pretty straightforward, of course, but I’d
still have to scale the quad manually…

Thanks anyway!

Code from http://hub.jmonkeyengine.org/forum/topic/monkey-blaster-toolforger-edition-p1/ for that:

[java] Texture2D texture = (Texture2D) assetManager.loadTexture(textureKey);
float width = texture.getImage().getWidth();
float height = texture.getImage().getHeight();
// Picture
Picture picture = new Picture(name);
final boolean useAlpha = true;
picture.setTexture(assetManager, texture, useAlpha);
picture.setWidth(width);
picture.setHeight(height);[/java]

It’s a bit roundabout, but it could be easily packaged into a function.

ahh, of course…
I didn’t think of that one :slight_smile:

Well, I sort of walked backwards from Picture.
Picture does not have a getter for the size? Well, okay, somewhere the image gets stuffed in, let’s look at the data objects that pass into Picture, maybe one of these gives me the size - oh yes, Texture2D has it.

It’s an acquired skill that comes with using too many too restricted standard libraries :slight_smile: