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

Author Topic: transforming on each vertex array  (Read 3291 times)

0 Members and 1 Guest are viewing this topic.

Flaze07

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • Email
transforming on each vertex array
« on: May 01, 2018, 11:45:49 am »
for example :
std::vector< sf::RectangleShape > rect;
//stuffs

int i = 0;
for ( auto& a : rect )
{
        ++i;
        rect.setRotation( 90 + i );
}
 

each of the rect will have different rotations.
I know how to apply transform to vertex array, but if I want the vertex array to have different roations, how do I do that ?

sf::VertexArray vert{ sf::Quads, 8 };
//stufs
sf::Transform t;
t.setRotation( 90 );
win.draw( vert, t ) // unable to set rotation for each 4 vertices
 

Hapax

  • Hero Member
  • *****
  • Posts: 3351
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: transforming on each vertex array
« Reply #1 on: May 01, 2018, 02:48:37 pm »
The setRotation method is a part of an object transform and is generally applied when drawing to all vertices.
However, you can apply custom transforms (or just calculate manually, for example your rotations) to each vertex manually. Of course, you may no longer need the object transform.

One way to rotate a vertex is by using a transform. Start with the indentity transform and apply the transformations you wish to apply and then you can use the transformPoint method.

To rotate a point around another point manually, you will need trigonometric functions. You can google this; it's not too complicated. :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Flaze07

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
    • Email
Re: transforming on each vertex array
« Reply #2 on: May 10, 2018, 02:12:12 pm »
after thinking for several hours, I finally got what you mean, thank you