Problems with 2D Image Rotation (Interpolation?) [SOLVED]

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
g0bl1n
Posts: 63
Joined: Thu Feb 21, 2008 8:45 am

Problems with 2D Image Rotation (Interpolation?) [SOLVED]

Post by g0bl1n »

I'm making a simple 2d game that has a grid based building system. I have several "parts" (square, triangle, etc...) And for everything to look pretty the pixels have to line up correctly. For some reason the system I am using to rotate sprites is causing some of the sprites to rotate off of their center, so the pixel no longer line up (so if a square is at rotation 0, rotating it to 90 shouldn't cause a shift in the square's center). I'm using this system by Lonesome Ducky. I've also provided a link to my drawing source in case there is any questions on the drawing system, I've been working on it for a while and I can't seem to fix it, at first I thought my centers were off but I've triple checked everything and it is right.

Drawing Source
Header
CPP

Thanks!
G0bl1n
Last edited by g0bl1n on Sun Jun 26, 2011 6:04 am, edited 1 time in total.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

You're setting the rotation center depending on the origin, which means that the rotation center won't always be at the center of the object. If you set the rotation center to the position + half the dimension, it will rotate around the center of the image.
g0bl1n
Posts: 63
Joined: Thu Feb 21, 2008 8:45 am

Post by g0bl1n »

Hey I figured it out! Turns out my origin was at (5.5,5.5) on my 11x11 image, but I was using a u32 to store the origin, so it was only storing (5,5), switched to f32 and all works fine now! Funny thing is that I didn't even look at that part of the code until you mentioned the origin stuff!

Thanks!
Goblin
Post Reply