fun with rotation

Edit: do over! Goggle has failed me again. :frowning:

Say I have a square 2d quad with some coords like, (100,100), (116,100), (116,116), (100,116).

To simplify my question, let me put it like this. I want to rotate it in place. I don’t want it to move, just rotate from the center around to the right or left. Is this possible?

I can’t find any examples that don’t set the coords to like (-8,-8), (8,-8), (8,8), (-8,8) or mess with the camera. Looking at glrotatef documention didn’t help much either.

The simple answer is, you can’t easily, you should have rotated it back when it was at the origin. Which is what you will now go and attempt to do.

Cas :slight_smile:

Looks like my rotation dreams within the limits of the SPGL are toast. :slight_smile: Looking at Alien Flux now I can at understand why everything is the way it is. Oh well, I think what I’m going to do now is just do all the rendering myself explicitly and worry about building something to speed it up later. Getting really tired of not getting anywhere. :wink:

Though I can’t say I didn’t learn anything this week.

edit: spelling, i blame the headache that feels like my eyeballs are trying to liberate themselves from my skull

Yes it’s possible, and it’s very easy !

Just use gl.pushMatrix() before your transormation and gl.popMatrix() after it :

translate_your_quad
gl.pushMatrix();
rotate_your_quad
gl.popMatrix();

It should work…

I could make it work in the middle of all that vertex array code, ya.

I think I’ll be traveling different roads for a time though.

edit: you get an A+ for effort though :stuck_out_tongue:

I can rotate sprites without effort in the SPGL - you just have to remember to rotate them before you translate them, as Ch*man suggests. However, you don’t want to do it like he says, because the performance (for sprites) will be utterly utterly abysmal and you’ll only manage to draw a couple of hundred before it starts to judder.

Cas :slight_smile:

Then theres something I don’t understand. (an experience not wholly unfamiliar to me) How/when can you rotate using the SpriteEngine? Back when I brought this up last time you said something about just having different animations for it. Not what I’m looking for, but you seem to be hinting at what I want now.

If you had a dollar for everytime I asked a question, I know. Indulge me one more time please. :stuck_out_tongue:

All my sprites are going to be top-down little buggers and need to face the direction they are looking in. This should be changing almost every single frame for most of the sprites, unless I design a boring combat system. :wink:

edit: added a LSL3 reference :wink:

Ah, now the version of the sprite engine you’ve got in SPGL currently hasn’t got the rotation code in it :slight_smile: I took it out because I didn’t need it as we pre-render all our sprites in rotated positions. Just let’s say you’d need to perform the rotation before translation occurs in the writeSpriteToBuffer method in SpriteRenderer. In fact if you look back in some of the old cvs versions it’ll still be in there.

Cas :slight_smile:

/me falls backward

edit: evil.

edit2: yep, it’s in there i believe, under version 1.6

god I hope that crap just pastes :slight_smile:

Ok, I just sat down and worked rotation back in. It didn’t exactly just paste but it went in fairly gracefully since you really didn’t change that much.

Yay. :slight_smile: