Rotation about the origin

Started by
4 comments, last by Bob Janova 16 years ago
I have a 2D texture that is centered at an arbitrary point in space, and its normal vector is pointed toward the origin. I want to rotate the texture so that it's now centered at a different point, but still with the normal pointing toward the origin. For example I have a texture that is centered at (0,1,0) and I want to rotate its center about the axis to (0,0,1). What rotation functions (glRotatef) should I use to do this?
Advertisement
At any point p, a normal pointing towards the origin is simply -p. So you don't need to rotate anything, just assign the negative of the centre point as the normal.
I do want to rotate the texture, because its generated on the fly based on its location. If the texture is on the left side of the origin from the viewers perspective, then it will generate a different texture. I then want to rotate the texture so the viewer can see the whole texture.
if i'm getting you right then what you want to do is kind of like when in a paint program you do a rotation of x degrees. I would just take the x and y points and have a z var set to zero, and then just pass those three to whichever gl function does a roll rotation (ie affects x and y only)... then just discard the z because it was only there to fill the function and had no other useful purpose anyway and should still be zero... really it could be any value and maybe doesn't even need initializing (but im sure the compiler will spew warnings).

then again maybe i'm reading it wrong and what you want is to just shift the x position so your texture does like a rolling background (like a person running on a treadmill with some silly graphic rolling behind them so it "looks" like they are running through some scenery).

i'm confused. maybe you need to explain yourself a bit better? what's the texture painted onto? is it a cylinder in which case you can simply rotate the cylinder and forget about the texture? is it a billboard that always faces the camera?
Are you talking about a billboard? Like the enemies in Doom, where they are a flat image that is always facing towards the camera?

My method for billboards is to draw the image centred around point P, e.g. the quad they are drawn on is from -1,-1 to 1,1. Then, I reverse the direction vector of the camera (multiply it by -1), normalise it, and use that as the normal of the billboard.
Don't thank me, thank the moon's gravitation pull! Post in My Journal and help me to not procrastinate!
Quote:I do want to rotate the texture, because its generated on the fly based on its location.

Ah, okay. So what you are actually asking is 'how do I get the coordinates to base the texture on, given a centre point', I think. The normal for facing the camera will always be -p.

How is your texture generated? Is the point (or the point sent through the projection/modelview matrix to get a screen coordinate) not already sufficient to generate the texture?

This topic is closed to new replies.

Advertisement