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

Author Topic: [SOLVED] How do i transform a sprite with 4 coordinates (aka Vector2)s ?  (Read 589 times)

0 Members and 1 Guest are viewing this topic.

marbelynrye

  • Newbie
  • *
  • Posts: 5
    • View Profile
Given 4 points (or "Vector2"s) how do i transform a sprite to look like the images attached?
« Last Edit: May 13, 2024, 01:03:56 pm by marbelynrye »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #1 on: May 13, 2024, 08:30:49 am »
Do you want to cut out this kind of shape from a texture?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

marbelynrye

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #2 on: May 13, 2024, 09:03:07 am »
No, just transforming a image/sprite  (or "distorting" it to look like that)
« Last Edit: May 13, 2024, 09:07:25 am by marbelynrye »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #3 on: May 13, 2024, 09:21:03 am »
You could just use a vertex array, set the texture position and vertex position.

But this will lead to a potentially unwanted distortion, since the vertex array is made up of two triangles, that are shaped independently.

You may instead want to use Hapax's Elastic Sprite: https://github.com/Hapaxia/SelbaWard/wiki/Elastic-Sprite
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

marbelynrye

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #4 on: May 13, 2024, 09:29:12 am »
oh this is exactly what i needed, thank you sir

marbelynrye

  • Newbie
  • *
  • Posts: 5
    • View Profile
having a hard time getting it compile, i'm probably an idiot but I don't think i'm doing anything wrong.
it's giving me linker errors
sw::ElasticSprite sprite(cattex);
sprite.setVertexOffset(2, { 150.f, -30.f });
 
1>main.obj : error LNK2019: unresolved external symbol "public: __cdecl selbaward::ElasticSprite::ElasticSprite(class sf::Texture const &)" (??0ElasticSprite@selbaward@@QEAA@AEBVTexture@sf@@@Z) referenced in function main
1>main.obj : error LNK2019: unresolved external symbol "public: void __cdecl selbaward::ElasticSprite::setVertexOffset(unsigned int,class sf::Vector2<float>)" (?setVertexOffset@ElasticSprite@selbaward@@QEAAXIV?$Vector2@M@sf@@@Z) referenced in function main
both .hpp files are present

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10936
    • View Profile
    • development blog
    • Email
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #6 on: May 13, 2024, 12:49:19 pm »
If you use SelbaWard as a library, make sure you're linking it.
If you just want to include the specific files, make sure you've add the *.cpp files to your project.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

marbelynrye

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: How do i transform a sprite with 4 coordinates (aka Vector2)s ?
« Reply #7 on: May 13, 2024, 01:03:34 pm »
ah i forgot about the linker properties

 

anything