OpenGL, overlapping circles

OpenGL, overlapping circles

Discuss your problems with the latest release of the engine here. Problems with games, maps or other utilities belong in their respective forums.

Moderator: Moderators

Post Reply
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

OpenGL, overlapping circles

Post by LEDZ »

I'm experimenting with a widget that uses DrawWorld to draw circles.
Does anyone know how the following could be done:
Image

Essentially the overlapped parts are removed.
It would be awesome if someone knows how to do this.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: OpenGL, overlapping circles

Post by zwzsg »

Use the brute way! Calculate which circles intersect, and where, then draw only the segment that are outside the intersecting slice. Since it only involves circles in a 2D plane, the calculation involved are not that complicated.
LEDZ
Posts: 66
Joined: 27 Jun 2011, 13:43

Re: OpenGL, overlapping circles

Post by LEDZ »

Thats all very well, but I am a OpenGL noob.
How do I draw only a part circle. So far I have used gl.DrawGroundCircle
8)
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7049
Joined: 16 Nov 2004, 13:08

Re: OpenGL, overlapping circles

Post by zwzsg »

A bit like that (not tested):

Code: Select all

local function YourVertFunction()
	for angle=0,2*math.pi*3/4,math.pi/32 do
		gl.Vertex(x+r*math.cos(a),y,z+r*math.sin(a))
	end
end

gl.BeginEnd(GL.LINE_LOOP,YourVertFunction)
User avatar
aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

Re: OpenGL, overlapping circles

Post by aegis »

The UnitShapes widget uses OpenGL tricks to do seamlessly-merged circles/shapes.
Post Reply

Return to “Help & Bugs”