www.jpct.net
jPCT - a 3d engine for Java => Support => Topic started by: AGP on December 27, 2011, 06:50:21 am
-
It's pretty much only in front of the skybox. I'm creating the Overlay as follows.
public void createOverlay(World theWorld, FrameBuffer buffer) {
BufferedImage radarMap = new BufferedImage(targetWidth, targetHeight+5, BufferedImage.TYPE_INT_RGB);
radarMap.getGraphics().drawImage(borders, 0, 5, null);
radarMap.getGraphics().drawImage(logo, targetWidth/2-logo.getWidth(null)/2, 0, null);
Texture radarTexture = new Texture(radarMap);
TextureManager.getInstance().addTexture("SuperRadar", radarTexture);
Overlay over = new Overlay(theWorld, buffer, "SuperRadar");
over.setNewCoordinates(540, 40, 540+targetWidth, 40+targetHeight);
over.setDepth(Config.nearPlane);//THIS WASN'T HERE. I ADDED IT TO TEST WHETHER IT FIXED FOR SOFTWARE (IT DIDN'T)
over.setTransparency(100);
}
-
Strange...do you have a screen shot and maybe a test case?
-
Unless it's related to the scale of my models (I doubt it), a test case would be as simple as creating an Overlay with the code I posted. Here's a screenshot:
(http://www.agpgames.com/SupermanInSoftware.png)
-
Which instance of world did you use the create the Overlay? Not the one of the sky box, i hope!?
-
No, until a couple of days ago I wasn't even aware that the Skybox had its own World.
-
I can't verify this problem. Everything works fine for me except that
over.setDepth(Config.nearPlane);
isn't a good idea because it places the overlay on the clipping plane, which means that it might get clipped or not, depending on some inaccuracies. Better is
over.setDepth(Config.nearPlane+1);
which is default anyway.
Are you applying a sort offset?
-
No. I guess I'll send you my Metropolis with a stripped-down version of the game so you could verify it.
-
Yes, please do that. Something must be different from my test cases... ???
-
Just e-mailed it to you. Sorry that I didn't chop it any more than I did, but it's already at a small fraction of its size. It should be a good enough test case.
-
I had a look at it...what you have in your screen shot there is no Overlay. It's the result of a call to the draw()-method of your Radar-class, which you do right after rendering the sky box. In the software path in your test case, you don't even call the createOverlay()-method. If you do (and omit the call to Radar.draw()), you'll get the overlay at the right position and in front of everything else.
-
Jesus, really? That code is quite a while old, but I tend to trust myself. Maybe I shouldn't. :- ) Anyway, thanks for noticing it.
-
OK, I see why I was calling draw(...): it has to be called in order to draw the position of the enemies on the radar. I just should've called createOverlay(...) outside of the if (hardRender) bit (and shouldn't draw the radar's borders on draw(...) although the borders as drawn by draw(...) do look better than the Overlay in software mode).
So is there a way for me to draw the enemies on the Overlay in such a way as for them to not be hidden by the buildings? Do I have to keep creating a Texture (that seems WAY too slow)?
-
I take it that's a "no." But shouldn't there be?
-
orry...i forgot to answer this... :-\ I suggest to display the enemies as seperate blits. Just like the car example does it for its basic radar.
-
Thanks, I will look into it. But is it impossible to create a Texture.getGraphics()? If so, why? And if not, why not make one?
-
No, that's not possible, because you can't use a graphics context to draw into a texture lying something in the GPU's memory. All you can do is to upload it again. And the fastest way to do this ATM is to use an ITextureEffect, but that's not really fast either.