Filling problem with a TriangleFan

Started by
5 comments, last by nmi 14 years, 9 months ago
Hi everyone ! here is a picture of my problem: In red i drew the shape i want to fill (a star). I used a trianglefan primitive (the start point is the one on the left of course) and as you can see, there is an "overlapping" problem. I'm sure some of you are familiar with this problem, I was wondering if there's a simplier solution than subdividing my shape... if not, do you know a good reference about these kind of algorithm ? Thank you ! [Edited by - vinpowfull on July 23, 2009 11:43:18 AM]
Advertisement
Quote:Original post by vinpowfull
I'm sure some of you are familiar with this problem, I was wondering if there's a simplier solution than subdividing my shape... if not, do you know a good reference about these kind of algorithm ?
Why not just insert a new point at the centre of the shape and use that as the fan origin?

This is the way triangle fans work, there's no other way around it (in b4 someone with a pixel shader clipping solution [smile]).
Adding the first point at center of the fig will work with a star, but not with this one :


Actualy, i just want to fill any given shape, and display it's border. For the border it's ok, i just have to use a LineStrip primitive...
For the filling, maybe there are other way than using TriangleFan... a shader you say ? (oh another cool thing to learn ^^)
here are some shapes to fill, each shape having it's own color :


BTW, i think there is a bug with the ScrollViewer, look at the scroll bars. This bug disappear when i use a simple bitmap as ImageSource instead of the D3DImage...
edit: the arrows of the scroll bars are functional, and the content actualy scroll but the matter is their size.
In order to fill arbitrary concave polygons with standard D3D/OpenGL polygon-drawing facilities, you'll need to do a convex decomposition of each polygon. Here's one way.
Quote:Original post by Sneftel
In order to fill arbitrary concave polygons with standard D3D/OpenGL polygon-drawing facilities, you'll need to do a convex decomposition of each polygon. Here's one way.


Thank you for the link ;) I'll try to implement one of these.
Is somebody know a way to fill with a shader ?
Check out this maybe:
http://glprogramming.com/red/chapter14.html#name13

This topic is closed to new replies.

Advertisement