RE: [Algorithms] Rotating UVs part II
Brought to you by:
vexxed72
From: Awen L. <ali...@ed...> - 2002-09-30 14:31:57
|
Oups: center your UV coords: substract 0.5, and add it again after computation x'=x-.5f y'=y-.5f x''=rotate x' y''=rotate y' x_final=x''+.5f y_final=y''+.5f I personnaly concatenate all computations (why only rotations, do use scale/shear/translate/noisify) via 3x2 matrices) Note: If you 'frame' your texture, using many pictures in a texture (it can be your method) for animation/randomization purposes, be aware that your rotations may show some parts of adjacent frames. -----Message d'origine----- De : gda...@li... [mailto:gda...@li...]De la part de Odin Jensen Envoye : lundi 30 septembre 2002 16:12 A : gda...@li... Objet : [Algorithms] Rotating UVs part II Ok. Now I got the rotation perfekt. Only it gets translated as well. I want it to stay centered and not move about :) Here's my test code float fUV[8] = {0,0,1,0,0,1,1,1}; float fAngle = DEG2RAD(tTime.GetTime()*60.0f); for (int iUV = 0; iUV < 8; iUV+=2) { float fNewU = fUV[iUV + 0]; float fNewV = fUV[iUV + 1]; fUV[iUV + 0] = (fNewU * cos(fAngle) - fNewV * sin(fAngle)); fUV[iUV + 1] = (fNewU * sin(fAngle) + fNewV * cos(fAngle)); } I',m not really sure where I messed up. If I add 0.5f after each UV calculation it gets centered around the top left corner and I just can't figure out how to center it. Thanks Odin ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ GDAlgorithms-list mailing list GDA...@li... https://lists.sourceforge.net/lists/listinfo/gdalgorithms-list Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=6188 |