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

Author Topic: Making polygons  (Read 2219 times)

0 Members and 1 Guest are viewing this topic.

sgthale

  • Newbie
  • *
  • Posts: 9
    • View Profile
Making polygons
« on: December 07, 2010, 07:18:45 pm »
I looked at the Tutorial - Graphics - Drawing simple shapes to make filled polygons but i need it to support concave shapes so i can fill use it in my dynamic light engine. If not, how can you split the concave into convex shapes?

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making polygons
« Reply #1 on: December 07, 2010, 07:22:38 pm »
You mean something like this tutorial?

http://www.sfml-dev.org/tutorials/1.6/graphics-shape.php

sgthale

  • Newbie
  • *
  • Posts: 9
    • View Profile
Making polygons
« Reply #2 on: December 07, 2010, 07:24:46 pm »
woops i just updated my post. How can i split a concave to convex so i can use that?

Breakman79

  • Jr. Member
  • **
  • Posts: 58
    • View Profile
Making polygons
« Reply #3 on: December 07, 2010, 07:57:10 pm »
There's nothing built-in to handle that.  You'll have to split your shape up into triangles, rectangles, and other non-concave shapes and combine them together on your own.  

For instance, you can make a star by drawing a triangle on each side of a pentagon.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Making polygons
« Reply #4 on: December 07, 2010, 07:58:31 pm »
You could search for "ear-clipping" or "Delaunay triangulation". Especially if you choose the second algorithm, do not implement it at your own. It takes too long.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: