Page 1 of 1
OpenGL, overlapping circles
Posted: 22 Sep 2012, 16:54
by LEDZ
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.
Re: OpenGL, overlapping circles
Posted: 22 Sep 2012, 17:28
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.
Re: OpenGL, overlapping circles
Posted: 22 Sep 2012, 17:41
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

Re: OpenGL, overlapping circles
Posted: 22 Sep 2012, 18:34
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)
Re: OpenGL, overlapping circles
Posted: 22 Sep 2012, 19:27
by aegis
The UnitShapes widget uses OpenGL tricks to do seamlessly-merged circles/shapes.