Circular Magnification - Sniper Scope

I'm hoping to make a sniper-esque game. The background is far away and when the mouse (scope) is over a certain area, then that area is enlarged. A subimage method call would work well for that... But heres the catch, a sniper scope is ROUND not square. How can I capture the subimage and then filter out the parts of the image that are not in the circular scope?

Thanks for any help or ideas.

[407 byte] By [ArikArikArika] at [2007-11-26 16:10:09]
# 1

I can tell you how'd i go about doing it with jogl

I assume with is a first person game. When not in scope mode, have the camera where the sniper's head would be.

When in-scope...translate the camera toward the line of sight in accordance with your zoom. Draw all the objects like normal, then draw the scope outline over it...basically a square as big as the screen, but with a snipe scope circle cut out in the middle.

I've noticed thats how Battlefield 2 does it ;)

Anyways, hope that helps.

David

David_Mirandaa at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 2
As far as the scope outline, you could probably use a texture. You would just have to blend it in a way that the inside of the scope appears transparent.
David_Mirandaa at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 3
The "in jogl" mention of the previous poster is very telling: you're expecting us to tell you how to adapt your render routine without telling us what you're currently doing. Are you using a GL library? 2D sprites? Java3D? What kind of buffer are you writing to?
YAT_Archivista at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 4
well actually...Its a 2D game...And im just going to use the java.awt stuff.I will have some Graphics2D lib stuff as well.Does that tell you what u need to know?
ArikArikArika at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 5
And are you drawing onto a BufferedImage? If so, getting hold of the underlying raster allows some pretty fast optimised circle drawing.
YAT_Archivista at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 6
Yes im drawing to a bufferedImage as a backbuffer...But how can I actually capture a rectangular portion, then CUT OUT a circle to use?
ArikArikArika at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 7
Draw the rectangular area. Then draw the inverse of the circle in black. Alternatively, if you want the area outside the circle to be the unzoomed image, you'll probably want two buffers. Draw zoomed and unzoomed to different ones, then copy circular area.
YAT_Archivista at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 8
The concept makes sense... ill try that/think about first.Would it be good to copy the rectangle to a virtual full-size buffer and then display a circle with the virtual buffer as a texture?
ArikArikArika at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 9
I thought you said you were using Java2D? When did that get texture support?
YAT_Archivista at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 10
im using AWT and Java2D.Is that a bad idea?
ArikArikArika at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...
# 11
No, it's fine. It just doesn't jive with reply #8.
YAT_Archivista at 2007-7-8 22:32:30 > top of Java-index,Other Topics,Java Game Development...