creating 2D drawable textures (3 posts)

Topic tags: 2d images, painting
  • Profile picture of DulcetTone DulcetTone1p said 3 months, 2 weeks ago:

    I need to create accurate scientific graphs that I can apply to Quads and to the faces of cylinders within JME3 (which I understand will be an array of Quads, anyhow).

    My needs will include some form of

    drawLine(X1, y1, x2, y2, width, ColorRGBA)
    fillRect(int x1, int y1, int x2, int y2, ColorRGBA)
    printString(String chars, int x1, int y1, ColorRGBA, etc, etc)

    I’m a bit confused by Image, Texture, and Material and see no clear means within Image (which I gather is the final source of this bitmap) to supply its data except upon construction.

    Should I be using Java2D to create these images, and somehow there and then to hand these into the JME world of Images and Textures? Will I be able to semi-efficiently alter textures in a dynamic manner? Limited whiteboarding may be nice.

    Thanks for any direction to get me started.

    tone

  • Profile picture of normen normen1290p said 3 months, 2 weeks ago:

    I don’t know if it still works 100% but heres a “paintable” texture for jME3: http://jmonkeyengine.org/groups/contribution-depot-jme3/snippets/single/14/

  • Profile picture of tralala tralala24p said 3 months, 1 week ago:

    use material.setTexture(“ColorMap”, texture);
    where texture is constructed from a bufferedimage with these methods.

       /** this method calls dispose on Graphics2D g */
       public static Texture2D createTexture(BufferedImage img, Graphics2D g, Texture.MinFilter min, Texture.MagFilter mag)
       {
          if (g != null) g.dispose();
          AWTLoader loader = new AWTLoader();
          Texture2D tex = new Texture2D(loader.load(img, true));
    
          tex.setMinFilter(min);
          tex.setMagFilter(mag);
          return tex;
       }
    
       /** create a texture from this image without min maps.
        *  this method calls dispose on Graphics2D g
        */
       public static Texture2D createTexture(BufferedImage img, Graphics2D g)
       {
          return createTexture(img, g, Texture.MinFilter.NearestNoMipMaps, Texture.MagFilter.Nearest);
       }