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 » 22 Sep 2012, 16:54

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

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7013
Joined: 16 Nov 2004, 13:08

Re: OpenGL, overlapping circles

Post by zwzsg » 22 Sep 2012, 17:28

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

Post by LEDZ » 22 Sep 2012, 17:41

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

User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7013
Joined: 16 Nov 2004, 13:08

Re: OpenGL, overlapping circles

Post by zwzsg » 22 Sep 2012, 18:34

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

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

Re: OpenGL, overlapping circles

Post by aegis » 22 Sep 2012, 19:27

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

Post Reply

Return to “Help & Bugs”