Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Wrong behavior while drawing and filling ConvexShape - SFML.Net  (Read 3718 times)

0 Members and 1 Guest are viewing this topic.

editali

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Wrong behavior while drawing and filling ConvexShape - SFML.Net
« 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:

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #1 on: January 05, 2014, 09:34:10 am »
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 to workaround the problem. Thor has been ported to C# as NetEXT, but concave shapes are not implemented yet.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

editali

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #2 on: January 05, 2014, 09:36:52 am »
Thank you nexus for your response, I'm trying VertexArray, if this could not help me I will go for ConcaveShape.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #3 on: January 05, 2014, 10:10:17 am »
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.
« Last Edit: January 05, 2014, 10:16:24 am by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

editali

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #4 on: January 05, 2014, 10:58:46 am »
isn't is possible just to fill VertextArray?

krzat

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #5 on: January 05, 2014, 11:46:25 am »
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.
Well, he can put these quads into VertexArray, can't he?
SFML.Utils - useful extensions for SFML.Net

editali

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Wrong behavior while drawing and filling ConvexShape - SFML.Net
« Reply #6 on: January 05, 2014, 12:56:49 pm »
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!