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

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

### OpenGL, overlapping circles

I'm experimenting with a widget that uses DrawWorld to draw circles.
Does anyone know how the following could be done: Essentially the overlapped parts are removed.
It would be awesome if someone knows how to do this.
0 x

zwzsg
Kernel Panic Co-Developer
Posts: 7017
Joined: 16 Nov 2004, 13:08

### Re: OpenGL, overlapping circles

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.
0 x

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

### Re: OpenGL, overlapping circles

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 0 x

zwzsg
Kernel Panic Co-Developer
Posts: 7017
Joined: 16 Nov 2004, 13:08

### Re: OpenGL, overlapping circles

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)``````
0 x

aegis
Posts: 2456
Joined: 11 Jul 2007, 17:47

### Re: OpenGL, overlapping circles

The UnitShapes widget uses OpenGL tricks to do seamlessly-merged circles/shapes.
0 x