Minimap not updating? Using Ortho test

Hello,



I, quite frankly, copied this code from the Ortho test:



[java]minimapPic = new Picture(“minimap”);

minimapPic.setPosition(0, 0);

minimapPic.setWidth( 50 );

minimapPic.setHeight( 50 );

minimapPic.setImage(assetManager, “minimap.png”, false);



guiNode.attachChild(minimapPic);[/java]



How do i update the image? I tried various things but it won’t render anything else other than the original “minimap.png”



Also, while i’m here, how do you go about removing the mipmappping on the texture? I really want a simple pixelated effect for the minimap. There used to be a way to toggle it off before.



Thanks!

@momoko_fan: Yup, that’s exactly it. How do i get the image, though? minimapPic in the code above is a Picture. There’s no getImage() or similar. There’s no setUpdateNeede() neither. There is also no way to set an image other than setImage(AssetManager, String, boolean) in Picture…

Have a look at the TestRenderToMemory.java or TextRenderToTexture (whichever works better) test in, i think it’s, /texture.

It’s a slow method though, if you have many objects. My solution was to have a still image as background (like you do now), and only draw moving objects on the off screen buffer.

If you change the data in the image itself, you may have to call image.setUpdateNeeded()

@momoko_fan



i don’t get it …



Can you elaborate please?

I can’t reproduce your issue.

I modified TestOrtho like so:

[java]

public class TestOrtho extends SimpleApplication {



private Picture p;

private float time = 0;



public static void main(String[] args){

TestOrtho app = new TestOrtho();

app.start();

}



public void simpleInitApp() {

p = new Picture(“Picture”);

p.move(0, 0, -1); // make it appear behind stats view

p.setPosition(0, 0);

p.setWidth(settings.getWidth());

p.setHeight(settings.getHeight());

p.setImage(assetManager, “Interface/Logo/Monkey.png”, false);





// attach geometry to orthoNode

guiNode.attachChild§;

}



@Override

public void simpleUpdate(float tpf){

time += tpf;

if (time > 5){

p.setImage(assetManager, “Interface/Logo/Monkey.jpg”, false);

}

}

}

[/java]

After 5 seconds, the image on the picture is swapped to another.

As you can see, it works fine.

Frankly i don’t see how this proves anything. You are clearly using the same image in the update whereas my problem was explicitly that, i too, am using the same image (filename) but my image, being a minimap, is constantly updated by the game.



[EDIT] ok just saw that you switched to two different files. Well, it’s still not the same thing… Your exampled worked when i tried it in my code.



When it updates, it does not change the image on-screen, it stays at whatever is loaded at init, but when i open the image in an editor, it clearly shows that it was modified.



By the way, my code is exactly the same as your setup, besides the fact that “minimap.png” is overriden each time the player changes position, like so:

[java]

public void writeMinimap(Player player){

BufferedImage minimapImage = new BufferedImage(config.wVIEW_DIST, config.wVIEW_DIST, BufferedImage.TYPE_3BYTE_BGR);

Graphics2D g = minimapImage.createGraphics();



for(int i = 0; i < 16; i++){

for(int j = 0; j < 16; j++){

int rgb = nodeImage[4].getRGB(j, i);

if ( j == px && i == py){

//player dot on minimap

rgb = new Color(255, 0, 0).getRGB();

}

minimapImage.setRGB(j, i, rgb);

}

}

try{ImageIO.write(minimapImage, “png”, new File(“assets\minimap.png”));}catch (IOException e){e.printStackTrace();}

g.dispose();

}

[/java]



dont mind the different filenames in these examples, they are 100% correct in my code…

jME3 loads your image and keeps it in memory, it doesn’t check if you change it afterwards. If you want to reload it, you have to remove it from the cache

You can just modify the image directly after you load it (Texture.getImage(), don’t forget to setRefreshNeeded) instead of updating the file each time