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

Author Topic: Filling in deforming 2D mesh  (Read 1589 times)

0 Members and 1 Guest are viewing this topic.

Calum.McManus

  • Newbie
  • *
  • Posts: 2
    • View Profile
Filling in deforming 2D mesh
« on: February 04, 2017, 06:38:16 pm »
I am currently working on a project similar to The floor is Jelly game.

Here is a .gif of the current stage for reference http://imgur.com/a/xdkyq

My issue is that SFML does not support filling in of these shape (concave).

I have tried Thor library for concave shapes but it seems to have more issues with it than worth going much further with. These issues being:
1. If I add a point to a thor::concaveShape with the index of 0, the project errors on build.
2. With issue one this means the first point is always 0,0 so this a clear issue.
3. While the mesh deforms if parts of the mesh overlap the shape vanishes until the mesh stops overlapping then it draws again.
4. My points are made up of spline points. So in that .gif it has around 300 points and it seems to just crash with that many point regardless. (I have tested will less points and this does not happen).

I have tried using thor::TriangulatePolygon but it just errors on build every time, maybe I am using it wrong but the documentation doesn't make too much sense to me.

I am at a loss and it seems I might have to start from scratch with a new library as this is for my course work and I don't have the time to fix problems that seem to be on the library side. :(

Any way I can fill this in with colour or is SFML/Thor just not designed for this? If soo anyone know a good C++ library for this stuff?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Filling in deforming 2D mesh
« Reply #1 on: February 05, 2017, 09:00:31 am »
So did you try and fix the compiler/linker errors? They usually tell you exactly what's wrong and most oft the time it's a user error.

Similarly, crashes can be debugged and analyzed. I haven't used Thor's concave shape that extensively, but I can't imagine it having such "basic" problems. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Filling in deforming 2D mesh
« Reply #2 on: February 05, 2017, 12:32:16 pm »
SFML will be able to draw your filled your shape but, of course, you need to break the shape down in its base triangles first. If you are having trouble with Thor, you may need to break it down into triangles yourself; luckily, there is always some information somewhere available to explain how. See if this helps:
https://www.siggraph.org/education/materials/HyperGraph/scanline/outprims/polygon1.htm

EDIT: Here's some more links :) :
https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf
http://www.cs.princeton.edu/~chazelle/pubs/polygon-triang.pdf
https://github.com/greenm01/poly2tri
« Last Edit: February 05, 2017, 12:40:21 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Calum.McManus

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Filling in deforming 2D mesh
« Reply #3 on: February 07, 2017, 02:15:15 am »
So did you try and fix the compiler/linker errors? They usually tell you exactly what's wrong and most oft the time it's a user error.

Similarly, crashes can be debugged and analyzed. I haven't used Thor's concave shape that extensively, but I can't imagine it having such "basic" problems. ;)

The problem is not link errors, with Thor I can literally just add 4 points to make a square and it crash on build every time. And the disappearing mesh issue is actually with OpenGL and the way triangles interact, it seems thor is not built to deal with deforming meshes as it can't triangulate it every frame. It seems that manual triangulation is my only option, but that on top of the mash spring physics is going to be a push for performance.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10821
    • View Profile
    • development blog
    • Email
Re: Filling in deforming 2D mesh
« Reply #4 on: February 07, 2017, 03:57:11 am »
with Thor I can literally just add 4 points to make a square and it crash on build every time.
It either doesn't build or crashes when running it after building it. For the first case you get compiler or linker errors and for the later you can use a debugger to figure out why.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/