round camera view

Blitz3D Forums/Blitz3D Programming/round camera view

mrjh(Posted 2006) [#1]
I want to make a round radar screen at the bottom left of my game. I would like to use a second camera to render to this area. Is there any possible way to get it to render to a circular portion of the screen?


WolRon(Posted 2006) [#2]
I'm not a whiz at this sort of thing, but an idea comes to mind...
1. render your normal screen
2. copy the rectangular portion of the screen where you will be drawing the circular image to another buffer BUT ONLY the outside 'ring' portion (i.e. what would be left if you cut a circle out of a square). That's only 14% of the square that has to be copied.
3. render to the square area with your second camera (remember to use CameraClsMode)
4. copy back to that square the outside ring that you saved earlier.


Rob Farley(Posted 2006) [#3]
Or...

Render to an imagebuffer
Make the outside bits of the circle 255,0,255 (or whatever mask colour)
drawimage the resultant image with a mask of 255,0,255 after the renderworld


Bit of code to demostrate... move the mouse around!



John Pickford(Posted 2006) [#4]
I do this in my game. I render to the backbuffer then copy the image to a texture. Then I display a circular mesh (like a pie) made from triangles with the texture mapped to it.

No need to mess with pixels at all.


Rob Farley(Posted 2006) [#5]
Sounds like a better solution!


John Pickford(Posted 2006) [#6]
You can see a round window in this vid:

http://www.zee-3.com/video/chunks.wmv

It's fast enough for realtime use - my game has up to four of these on screen at once. A nice feature is that the window can be rotated\scaled\alpha'd etc.


big10p(Posted 2006) [#7]
Ah, I was wondering recently how you were doing your circular camera views, John. The masking method discussed above immediately occured to me but it's flawed, since the camera image itself could feasibly contain mask-coloured pixels.

The textured 'pie' mesh seems such an obvious solution, now.


mrjh(Posted 2006) [#8]
Thanks! I thought that this would be much harder, but now it seems so easy!

Thanks a million!


mrjh(Posted 2006) [#9]
One more question,
John, how many triangles do you use for your circular mesh?


John Pickford(Posted 2006) [#10]
I'm only using about 17 at the moment. The mesh has the smallest number of triangles I could get away with but I draw a sprite over the top which gives it a perfectly circular frame.


Avrigus(Posted 2006) [#11]
Hi John,

I've been trying to recreate this effect myself without much luck. Could you post some basic code so we can see how it's implemented?

Cheers!


John Pickford(Posted 2006) [#12]
Which bit are you having problems with? Rendering the texture, creating the pie-mesh or displaying it?


Avrigus(Posted 2006) [#13]
Displaying it is the problem. I created an object in Lightwave (a disc with 16 tri segments), converted it to .b3d and load it into my scene. It displays fine but the texture I output is frozen on the first frame. I guess I might have a problem somewhere in my program loop :-/