Drawing simple 2D primitives with ease?

Is it possible to draw simple 2D figures like line, rectangle or ellipse right to the screen, like in Processing, by doing something as simple as


stroke(255, 0, 0);

line(10, 20, 100, 200);[/java]

? By saying ‘right to the screen’ I mean that it is just enough to give these two instructions and the red line appears… and there is no need to handle it with the rootNode or something like that… just a plain 2D that simply directly alters pixels on the resulting image that is shown on the screen?

Nevermind, thanks! I have found the way. Still adapring to the scene node system.

What is the way ?

Please describe the solution for others who have not “seen the light”

You can make an BufferedImage, paint on its content (Graphics2D) and convert it into texture. Place the texture on the gui node. There are, of course, few improvements for the conversion that need to be done if you want to make such conversion more than once :slight_smile:

Ah, well… sorry, frankly, I do not remember what I meant by that phrase… :slight_smile: That was more than 3 years ago… Actually there is no way to do this in JME directly…

But since that time I:

  • used the ImagePainter JME plugin to draw on the texture as @FrozenShade suggests
  • that was not enough so I integrated Processing into JME and now I can draw JME textures with full power of Processing, even the dynamically updated ones (a continuously running Processing PApplet)
  • used shaders to do a similar thing
  • used the simple meshes like Line and Quad, provided by JME to draw these things as 3D Geometries, also in the wireframe mode.

Do any of these make any sense to you?