ROTOZOOMANIM irregularities

Previous topic - Next topic

Moru

I'm having troubles (again) with ROTOZOOMANIM. When I rotate in 90 degree angles the rotated image looks like it got stuck somewhere between 89 and 90 degrees, run this example code and see for your self. Use left and right to rotate left and right by one degree.

Code (glbasic) Select

// --------------------------------- //
// Project: test_rotate
// Start: Saturday, January 31, 2009
// IDE Version: 6.147

LIMITFPS 15
DRAWLINE 0,15, 50,15, RGB(255,255,255)
GRABSPRITE 1, 0,0, 32,32
SAVESPRITE "test.bmp", 1
LOADANIM "test.bmp", 2, 32,32

phi = -90

WHILE TRUE
SMOOTHSHADING FALSE
IF KEY(203) THEN INC phi, 1
IF KEY(205) THEN DEC phi, 1
PRINT "Anim:", 50, 40
ROTOZOOMANIM 2, 0, 50,50, phi, 1
PRINT "Sprite:", 120, 40
ROTOZOOMSPRITE 1, 120,50, phi, 1
DEBUG phi + "\n"
SHOWSCREEN
WEND

MrTAToad

#1
Yes, does seem to be a slightly odd problem there.

Schranz0r

angle are from 0 to 359 ! ;)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

You can set angle to whatever you like, it mods them down automagicly. If you run the example you will notice that the sprite beside works just fine while the anim don't work.

(And it's 0 to 359.9999999... :-)

Schranz0r

Yeah thats right, but -90 isnt -90 ...
Buts realy a bug in rotoanim
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

-90 is just an example because it's showing better then. -90.5 or -91 or -89 isn't doing the trick either. 90, 180 and 270 degrees get a little less distortion but still not looking good. If you press left/right in the test you can slowly go between the different angles as much as you like and see the result.

Kitty Hello

Great... not :/

I can confirm this glitch, however, it's not occurring in my debug environment.
I think it's a sin/cos inaccuracy. If it's really a problem, I'll have to make a switch statement and a fmod before the call to get the 90° rotations right. Do you want that?

Kitty Hello

Fixed in next update!

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Moru

#9
I just updated and some of the angles are fixed, 0, 90, 270 works but not 180 and 360. Note that they do work with rozozoomsprite but not rotozoomanim. Also if you compare them side by side you will notice that the rotozoomsprite updates about 3 times as often as rotozoomanim wich would mean only every third angle is actually different? I'm only using whole numbers as angles.

In higher resolutions the updates looks fine, just not the 180 degree angle.

Moru

Tried some more, here is a testprogram that paints four frames that is 16x16 pixels, saves to disk and loads it in as an animation. Then paints the #1 index from that animation in four places, the first two is done with SMOOTHSHADING TRUE and the second two is done with SMOOTHSHADING FALSE. See the example code below:

The two boxes that is drawn to the left is done with DRAWANIM, the right boxes are done with ROTOZOOMANIM. The later ones are broken on the sides.

Code (glbasic) Select
VIEWPORT 0,0, 16,16
DRAWLINE 0,0, 15,0, RGB(0,255,255)
DRAWLINE 15,0, 15,15, RGB(0,255,255)
DRAWLINE 15,15, 0,15, RGB(0,255,255)
DRAWLINE 0,15, 0,0, RGB(0,255,255)
VIEWPORT 16,0, 16,16
DRAWLINE 0,0, 15,0, RGB(255,0,255)
DRAWLINE 15,0, 15,15, RGB(255,0,255)
DRAWLINE 15,15, 0,15, RGB(255,0,255)
DRAWLINE 0,15, 0,0, RGB(255,0,255)
VIEWPORT 0,16, 16,16
DRAWLINE 0,0, 15,0, RGB(255,255,0)
DRAWLINE 15,0, 15,15, RGB(255,255,0)
DRAWLINE 15,15, 0,15, RGB(255,255,0)
DRAWLINE 0,15, 0,0, RGB(255,255,0)
VIEWPORT 16,16, 16,16
DRAWLINE 0,0, 15,0, RGB(0,255,0)
DRAWLINE 15,0, 15,15, RGB(0,255,0)
DRAWLINE 15,15, 0,15, RGB(0,255,0)
DRAWLINE 0,15, 0,0, RGB(0,255,0)
VIEWPORT 0,0,0,0

GRABSPRITE 1, 0,0, 32,32
SAVESPRITE "test.bmp", 1
DRAWRECT 0,0,100,100, RGB(0,0,0)
LOADANIM "test.bmp", 2, 16,16
DRAWANIM 2, 1, 10,10
ROTOZOOMANIM 2, 1, 30,10, 0, 1

SMOOTHSHADING FALSE
DRAWANIM 2, 1, 10,30
ROTOZOOMANIM 2, 1, 30,30, 0, 1
SHOWSCREEN
KEYWAIT
END

Kitty Hello

Excellent example. Fixed for good in next update. Thank you very much.