[SOLVED] 2 Issues ~ [Quad Rotation] AND [PNG Alpha]

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
JuicyLobster
Posts: 25
Joined: Sat Jun 07, 2008 8:55 pm

[SOLVED] 2 Issues ~ [Quad Rotation] AND [PNG Alpha]

Post by JuicyLobster »

i have been searching through the forums, and as it stands, there still seems to be no true way to rotating 2d drawn images.. I have noticed many many threads from years and years ago on this subject.

I was just wondering where this stands, is someone working on something? Is there a true way to do this where it is seemless and not interfered with the 3D Space? Is there a reason why its not implemented if it was thought of, or going to be?

Rotating 2D drawn images is really important for 2d gui interfaces, especually games. I would of thought an engine with GUI capabilities would of had something like this already.
Last edited by JuicyLobster on Sat Jun 14, 2008 6:53 pm, edited 2 times in total.
--
Juicy, hot, and full of butter!
unclejoe
Posts: 10
Joined: Fri Mar 28, 2008 2:27 pm
Location: Europe

Post by unclejoe »

well, i think there's no way to draw rotated 2d images,
what you can do for certain:

- add a plane to the scene manager,
give it the texture you wish it to have, and rotate it,
but that's probably not what you wish to do because then it won't
be drawn on top of everything.

- you can pre-rotate the image in: photoshop/gimp/paint... and
load the image in all of its directions and make it 'rotate' by
changing the texture of your gui image.

i hope this was helpful for you, but i'm afraid it wasn't, because
you already knew you could do it these ways.
JuicyLobster
Posts: 25
Joined: Sat Jun 07, 2008 8:55 pm

Post by JuicyLobster »

yea its tuff because unless i export an image rotated in photoshop or w/e in 360 images it wont be smooth enough to use for what is needed, can probally get away with 90 images every 4 degrees, but still, just a waste of space, and management.

I wonder if there is a way that the texture data stored can be rotated using a rotating algorithm or something...
--
Juicy, hot, and full of butter!
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

All 2D images eventually resolve to 3D calls, using simple textured quads. Methods to render rotated 2D images tremble on the very verge of existence, awaiting only your tender attentions in order to actualise their nascent potentiality.

Will you step up, brave traveller, and do the deed? If so, turn to page 32. If you will retreat to the stupefying safety of userhoodness, close the book.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
JuicyLobster
Posts: 25
Joined: Sat Jun 07, 2008 8:55 pm

Post by JuicyLobster »

so.. in other words, rotate the quad?

I guess this is what im looking for:
http://irrlicht.sourceforge.net/phpBB2/ ... light=quad

EDIT: ok, so i used that class and changed texture to use video::EMT_TRANSPARENT_ALPHA_CHANNEL; to accommodate my PNG file, however, it wont read the alpha channel right, or something else is making it not read it right, it looks like it does, but to a point where it stops and looks like it just stops, ill post an example of what I mean:

SOLVED: modified code of compas class to:

Code: Select all

	  Mesh.getMaterial().MaterialType =  video::EMT_TRANSPARENT_ALPHA_CHANNEL;
	  Mesh.getMaterial().MaterialTypeParam = 0.02f;

OFF TOPIC
So aside from rotating quads with textures applied to them...

How realistic would rotating texture data be? Would it be possible to rotate the pixels stored in an array for the texture (assuming data stored as a general table like that with another one for alpha data) ?

for example, a simple 5x5 resolution. In this example our image is a l shape, pretend it has various alpha data for each pixel. Now, before we rotate it, it looks like:

[X][X][O][X][X]
[X][X][O][X][X]
[X][X][O][O][X]
[X][X][X][X][X]
[X][X][X][X][X]

After we rotate (Still assuming textures store colour data with alpha data like this for each pixel) It would look like this example below. Now it looks like a normal pixel rotation, but thats my point. Only thing extra is an added alpha field to each pixel...

[O][X][X][X][X]
[X][O][X][O][X]
[X][X][O][X][X]
[X][X][X][X][X]
[X][X][X][X][X]

To some it up, wouldn't it be possible to when after loading a texture, say a png file, that you can rotate its stored values and table of pixel data? or is there more to it?

so in the end, we get something like:

Code: Select all

video::ITexture *tex = driver->getTexture("myImage.png"); 
tex->setRotation(180); //counter clockwise, naturally, by 180 degs 

while(device->run() && driver) 
   { 
      driver->beginScene(true, true, video::SColor(255,0,0,255)); 

      tex->rotate(180); 
      device->draw2DImage(tex......       

      scenemgr->drawAll(); 
      driver->endScene(); 
   }
--
Juicy, hot, and full of butter!
Post Reply