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

Author Topic: SFML and Box2D.. Shaping polygons?  (Read 3055 times)

0 Members and 1 Guest are viewing this topic.

Aster

  • Full Member
  • ***
  • Posts: 130
    • View Profile
SFML and Box2D.. Shaping polygons?
« on: September 22, 2012, 10:35:20 am »
Hello everyone, first post on these forums for me..

Anyways, I'm developing a game, and I'll be using Box2D in it. My original master plan was to let users add content with a simple configuration file and textures and whatnot. However, to accomplish this, I'll need to shape the Box2D polygons to the shape of the non-transparent part of each texture.. Has anyone ever done this? I'm not sure it would be the most efficient of all things, but it would be really useful to know if it's possible, and to get some tips..

Thanks in advance!
Aster

P.S: I have absolutely no idea where to post this, so I posted it in the place that seemed like the most vague of the all to me.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: SFML and Box2D.. Shaping polygons?
« Reply #1 on: September 22, 2012, 11:11:27 am »
Quote
P.S: I have absolutely no idea where to post this
You're requesting Help about the Graphics module... wait... oh my god! There's a Help section with a Graphics sub-forum!
>:(
Laurent Gomila - SFML developer

Aster

  • Full Member
  • ***
  • Posts: 130
    • View Profile
Re: SFML and Box2D.. Shaping polygons?
« Reply #2 on: September 22, 2012, 11:16:42 am »
Thanks for moving it! I wasn't too sure that it was really graphics related, thanks for settling that for me. :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: SFML and Box2D.. Shaping polygons?
« Reply #3 on: September 22, 2012, 11:35:57 am »
I guess it's possible and as a preloading generator function it could also workout quite well.
SFML also supports the direct use of polygons though so you might want to let the users define their own polygon. ;)
It's hard to say how hard such a generator function is to implement, but you could try it. IIRC someone once wrote a tool that lets user construct their own polygons. Maybe you can find it by searching through the project forum.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Aster

  • Full Member
  • ***
  • Posts: 130
    • View Profile
Re: SFML and Box2D.. Shaping polygons?
« Reply #4 on: September 22, 2012, 12:14:07 pm »
I guess it's possible and as a preloading generator function it could also workout quite well.

My plan exactly.

SFML also supports the direct use of polygons though so you might want to let the users define their own polygon. ;)

I plan on letting the user do that, but for less advanced users, I also wanted to have the game create polygons itself.

It's hard to say how hard such a generator function is to implement, but you could try it. IIRC someone once wrote a tool that lets user construct their own polygons. Maybe you can find it by searching through the project forum.

I'll look around. Thanks for your help!

Aster

Marcus

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: SFML and Box2D.. Shaping polygons?
« Reply #5 on: September 28, 2012, 04:52:16 pm »
You would have to write an algorithm to find the vertices of the image. I'm sure it has been done before. From there it's pretty easy to translate that into a Box2D polygon.

 

anything