Advertisement

Matrix Decomposition

Started by September 15, 2014 11:52 AM
12 comments, last by fs1 10 years, 5 months ago

Thanks haegarr. I will try your suggestion !

Regards!

This bring me to another quick question. Let's say I multiply each xyz primitive coordinates by 1/2, should I expect to get a sprite half the size of the original?
Thanks and Regards.

EDIT: I guess this will need a displacement component as well along with halfing the vertices
Advertisement

This bring me to another quick question. Let's say I multiply each xyz primitive coordinates by 1/2, should I expect to get a sprite half the size of the original?
Thanks and Regards.

EDIT: I guess this will need a displacement component as well along with halfing the vertices


Coordinate scaling is always done relative to the coordinate system's origin. In general that means you probably need to translate your sprite to be centered at the origin, scale it there, and then translate it back to where it was. Then it will be at the same spot, just half the original size.

“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”

You can then compute the center of each sprite by summing the N vertex positions and divide by N. Then subtract those center position from each of the N vertex positions, half the resulting vector, and re-add the center. E.g.

for each sprite
   vec2 center(0, 0);
   for each of the N vertices of the sprite do
      center += vertex.pos;
   center /= N;
   for each of the N vertices of the sprite do
      vertex.pos = ( vertex.pos + center ) * 0.5;

haegarr, thanks ! That works perfect !

Thank you all for the help.

This topic is closed to new replies.

Advertisement