SFML community forums
Bindings - other languages => DotNet => Topic started by: editali on January 05, 2014, 08:43:31 am
-
Hi, I don't know did I miss some property to set or it is a bug, this is the problem:
My program is supposed to visualize a signal, so I need to draw a graph and fill inside of this graph, so I create a convex and set n+2 points to specify graph's border (n points for graph line and 2 point to make convex a closed shape((width, height) and (0, height)), it draws graph but has some malfunctions in 2 parts: 1- when draws outline it has some distortion 2- it fills convex like 3d, but I want to fill just inside of graph
I put graph's image:
-
As implied by the name, the class is for convex shapes. Your graph is concave.
If you worked with C++, you could use thor::ConcaveShape (http://www.bromeon.ch/libraries/thor/v2.0/doc/classthor_1_1_concave_shape.html) to workaround the problem. Thor has been ported to C# as NetEXT (http://en.sfml-dev.org/forums/index.php?topic=12819.0), but concave shapes are not implemented yet.
-
Thank you nexus for your response, I'm trying VertexArray, if this could not help me I will go for ConcaveShape.
-
VertexArray won't work either, OpenGL requires convex polygons. In fact, ConvexShape is just built on top of VertexArray.
Thus, you have to split your concave polygon into convex ones (which is done automatically in Thor). An alternative is to model the signal's area as the composition of small quadrilaterals, similar to the Riemann integral (https://en.wikipedia.org/wiki/Riemann_integral).
-
isn't is possible just to fill VertextArray?
-
VertexArray won't work either,
...
An alternative is to model the signal's area as the composition of small quadrilaterals, similar to the Riemann integral (https://en.wikipedia.org/wiki/Riemann_integral).
Well, he can put these quads into VertexArray, can't he?
-
Finally I successfully tested this:
Vertex[n] to highlight graph's edge which is PrimitiveType.LinesStrip
and
Vertex[n*2+1] to fill graph, this one is PrimitiveType.TrianglesStrip
The point is this Vertex[] is faster than Convex more than 2 times!