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

Author Topic: ConvexShape class  (Read 3203 times)

0 Members and 1 Guest are viewing this topic.

Dejan Geci

  • Newbie
  • *
  • Posts: 19
    • View Profile
ConvexShape class
« on: July 23, 2014, 08:12:15 pm »
I was looking around the https://github.com/SFML/SFML.Net/pull/41 and it got me thinking...

ConvexShape class is not named properly (http://www.mathsisfun.com/definitions/convex.html). It should be named PolygonShape, since we can manually define points that create angles > 180°. Right?

Chaore

  • Newbie
  • *
  • Posts: 41
    • View Profile
    • Email
Re: ConvexShape class
« Reply #1 on: July 23, 2014, 08:25:44 pm »
No Convexe is alright.

According to the tutorial:
Quote
Indeed, SFML is unable to draw concave shapes; if you need to draw a concave shape, you'll have to split it into multiple convex polygons (if possible).



For concave shape Thor library has a class to handle this:
http://www.bromeon.ch/libraries/thor/v2.0/doc/classthor_1_1_concave_shape.html
« Last Edit: July 23, 2014, 08:27:35 pm by Chaore »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: ConvexShape class
« Reply #2 on: July 23, 2014, 08:31:12 pm »
It's great to start a public discussion about a class without reading its documentation or tutorials first...

Quote from: the doc
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly.
Laurent Gomila - SFML developer

Dejan Geci

  • Newbie
  • *
  • Posts: 19
    • View Profile
Re: ConvexShape class
« Reply #3 on: July 23, 2014, 11:58:10 pm »
Thanks Chaore, you are right. I guess I'm used to reading the source code as documentation, and I didn't see any constraints in the code.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: ConvexShape class
« Reply #4 on: July 24, 2014, 12:14:17 am »
I guess I'm used to reading the source code as documentation
You must be working a lot with very badly documented software :P
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: ConvexShape class
« Reply #5 on: July 24, 2014, 12:21:38 am »
I didn't see any constraints in the code.

There isn't any constraints imposed by the SFML library, the constraint comes from how OpenGL is able to handle primitive types.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

motherbrain

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: ConvexShape class
« Reply #6 on: July 25, 2014, 07:39:51 pm »
It's great to start a public discussion about a class without reading its documentation or tutorials first...

Quote from: the doc
It is important to keep in mind that a convex shape must always be... convex, otherwise it may not be drawn correctly.

In the tutorial it says:
Quote
Officially, sf::ConvexShape can only create convex shapes. But in fact, its requirements are a little more relaxed. In fact, the only technical constraint that your shape must follow, is that if you draw a line from its center of gravity to any of its point, you mustn't cross an edge. With this relaxed definition, you can for example draw stars.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: ConvexShape class
« Reply #7 on: July 25, 2014, 08:01:33 pm »
It's more an implementation detail. If one day I change the way convex shapes are drawn, this may not be true anymore. I should probably remove this from the tutorial.
Laurent Gomila - SFML developer