Rotating an image

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Rotating an image

Post by Asterisk Man »

I need to rotate an image while running the program (ITexture actually) to give the user icon of my minimap some sense of direction. Is there any function/s that do this in the engine? I tried looking in the video namespace, but didnt find anything that I think could help me.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

No, there is not and in my experience I dont think there is engine which have such function.

Way your problem is usualy solved (including comercial projects) is animated sprite. You make serie of pictures of the same object in diferent positions ...in your case your position indicator facing diferent angles. Of course not all 360 ...even if that would be posible too. Something betveen 8 - 16 should be enough depending on what you need.

Another way would be to use 3D plain object with texture and transparent background color ...that way you can easily rotate...
tip
Posts: 50
Joined: Fri Feb 13, 2004 8:53 am
Location: grenoble, France
Contact:

Post by tip »

better : put your image as a texture on one (or two) triangles and rotate the objet...
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

tip, 3D plain = two triangles = 6 vertices ... + its always more practical to aply texture on plain (call it square if you want) than on triangle since texture is square too.

..except when speed is most important like in particles.

...he cant use this method if he is doing 2D of course and even if not there is small problem with perspective usualy.
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Post by Asterisk Man »

Im making the minimap in the gui environment, so that rules out the 3D solution, as I've had very little sucess loading meshes thru the gui.

The animated sprite idea really appeals to me though :D , a rather noobish question I have is: how would I select which frame to show(that is, if im using a single sprite file, like a gif or something of that kind)?
tip
Posts: 50
Joined: Fri Feb 13, 2004 8:53 am
Location: grenoble, France
Contact:

Post by tip »

if you're using a gif... you'll need a library to uncompress the gif. as it's a copyrighted format, you may have problems.
PNGlib has some primitive to access the frames in animation.
Or simpler, you can use a big picture with all the frames side by side; and choose the source mapping coordinate changing every frame within the big picture.
Asterisk Man
Posts: 62
Joined: Wed Jun 09, 2004 5:51 am

Post by Asterisk Man »

oooo good idea!

tnx, im brain fried for tonight, can barely think :D
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

You can load them also individualy but to have them in one file as tip sad is probably better way ...also used normaly.

Load those images to array and use index to change picture:
picture[0] -0 dg
picture[1] -90
picture[2] -180
picture[3] -270
Post Reply