Textured GUI skin

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

@loonychewy
thanks i didn't know that i always thought irrlicht isn't capable of doing 2d streching...but than i remembered it was rotation which it can't do..lol..my fault.
oh and ITexture provides getOriginalSize () which is the dimension of the loaded image. I had trouble with this too because getSize gives some crazy dimension....

PS: thanks alot by the way :D
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

loonychewy wrote:BlindSide, as ITexture doesn't provide the texture dimension, the only way I'm aware of is to load the texture file as an IImage, and then use IImage::getDimension(). But I'm not so sure what's the ease of use you're trying to achieve. Would you mind elaborating?
:)

Its ok you answered my question, I thought you can somehow get dimensions for "sourceRect" using ITexture but you cannot so its ok...

Woops, looks like it does provide the size 8)

Code: Select all

	//! Returns original size of the texture.
	/** The texture is usually
	scaled, if it was created with an unoptimal size. For example if the size
	of the texture file it was loaded from was not a power of two. This returns
	the size of the texture, it had before it was scaled. Can be useful
	when drawing 2d images on the screen, which should have the exact size
	of the original texture. Use ITexture::getSize() if you want to know 
	the real size it has now stored in the system.
	\return Returns the original size of the texture. */
	virtual const core::dimension2d<s32>& getOriginalSize() = 0;

	//! Returns dimension (=size) of the texture.
	/** \return Returns the size of the texture. */
	virtual const core::dimension2d<s32>& getSize() = 0;
You can therefore use this in the function and eliminate need for user to enter "sourceRect"

(Usage is ITexture blah; dimension2d<s32> blahsize = blah.getSize(); )

Oh snap Sudi bet me to it :P
zenaku
Posts: 212
Joined: Tue Jun 07, 2005 11:23 pm

Post by zenaku »

I have to give credit to Emil Halim and his TAnimatedSpriteSceneNode. Implementing the IGUISkin interface is easy. Coming up with 2D stretched animation code was more difficult, so I borrowed his, with a few small tweaks. :) Since the rendering is done with scene nodes, you can do things like rotation which you cannot do with normal draw2DImage(). The biggest change I made to his original code was to reset the view matrix when drawing the scene node, which is actually a very bad/slow thing to do. The view matrix should be reset only once before the call to guienv->drawAll() instead of inside each scene node render(). doh :) Still, it works :)
-------------------------------------
IrrLua - a Lua binding for Irrlicht
http://irrlua.sourceforge.net/
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Just great! :D

I love you! (You're German right? Wie ist's denn so in Singapur?)

Finally someone did it! Hope it works. I searched something like this for months.
loonychewy
Posts: 22
Joined: Fri Dec 30, 2005 2:00 am
Location: Singapore
Contact:

Post by loonychewy »

Namek Kural wrote: I love you! (You're German right? Wie ist's denn so in Singapur?)
May I ask who is the "you" you are referring to? :D
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

I meant you!

I've got a question: Did you already try CGUITexturedSkin with irrlicht 1.4?

My debugger says, 'irr::gui::CGUITexturedSkin' couldn't be created because of some abstract members. What I don't understand is that the debugger shows a link to IGUISkin.h but the problem seems to occure in IGUITextureSkin.h?

I don't know what to do :(

PS: I thought you spoke German because in the example application, there are some German words. But you took the code from the tutorials right?
loonychewy
Posts: 22
Joined: Fri Dec 30, 2005 2:00 am
Location: Singapore
Contact:

Post by loonychewy »

Unfortunately, I've not been updating it with the Irrlicht 1.4 due to a lack of time ( pLoonyChewy->GenerateExcuses(100) ) There're some API changes to the GUI sub-system in 1.4. If you or anyone else is interested, I can do an update to it :)

You may already know, there're also a couple of equally good, if not better implementations of textured GUI such as http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=22449. Well done guys!

P.S. Ich bin Singapurer, aber ich lerne jetzt Deutsch :)
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

I'm interested, too

I just made a skin for yours :P
Why did you make the checkbox-texture so huge? ^^

I tried the one from your link before and neither implementing it nor running the .exe worked correctly but yours did and I think your solution is better :P
Yours is done much cooler ^^

Maybe someone's interested in my skin: (Just rename it to "guiskin.png")
My Skin
loonychewy
Posts: 22
Joined: Fri Dec 30, 2005 2:00 am
Location: Singapore
Contact:

Post by loonychewy »

I've just updated it to alpha 0.3, to be compatible with Irrlicht 1.4. Get it from my link in the first post.

Namek Kural:
My checkbox is large cos there's a lot of empty space in the texture :P Anyway, you can feel free to alter the xml to match your own texture.
Your texture is nice! Can I suggest some gradient in the textbox region and a shadow at its edges will make it perfect! Or maybe make it icy-blue to differentiate it from the default irrlicht skin?
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Thank you! I'll try it as soon as possible :P

EDIT: Thanks! Works just fine!!

This should become a part of the irrlicht sdk!

Just one question: The buttons areall textured now but the 3D effect of th original irrlicht gui is still there, what can I do?
One way would be to load a gui file which has no 3d effect but there must be another solution.
sp00n
Posts: 114
Joined: Wed Sep 13, 2006 9:39 am

Post by sp00n »

nice work
but in your example only text labels on the controls are transparent, not the own controls. Is it a bug or a feature? (c)
loonychewy
Posts: 22
Joined: Fri Dec 30, 2005 2:00 am
Location: Singapore
Contact:

Post by loonychewy »

Hi sp00n, sorry for the delayed response. Let me just call it unimplemented :-P The alpha channel in the texture is supported, but dynamically varying the gui's transparency is not yet implemented.
Namek Kural
Posts: 81
Joined: Sun Sep 09, 2007 7:01 pm
Location: BW, Germany

Post by Namek Kural »

Hey!

I switched to a MacBook Pro a few days ago and started converting my "big" project to the Mac Platform.

Everything is fine now expect of one thing that unluckily happens to be your code:

void CGUITexturedSkin::setSpriteBank(IGUISpriteBank* bank)

The Error says:

Code: Select all

ld: duplicate symbol irr::gui::CGUITexturedSkin::setSpriteBank(irr::gui::IGUISpriteBank*) in /Users/jonathan/Development/Projects/Star Wars Galaxy 3D/build/Star Wars Galaxy 3D.build/Release/Star Wars Galaxy 3D.build/Objects-normal/i386/CGUITexturedSkin.o and /Users/jonathan/Development/Projects/Star Wars Galaxy 3D/build/Star Wars Galaxy 3D.build/Release/Star Wars Galaxy 3D.build/Objects-normal/i386/main.o
Please, could anyone explain to me what duplicate symbol means? :oops:
loonychewy
Posts: 22
Joined: Fri Dec 30, 2005 2:00 am
Location: Singapore
Contact:

Post by loonychewy »

I've recently made a minor modification to dynamically change the skin texture alpha accordingly when the skin colour changes.

Because the texture already have some transparent regions, and I only want to change the alpha of those non-transparent regions, I can only do it pixel by pixel, testing it for non-zero alpha on the original texture first, before modifying the corresponding pixel on the skin texture. This may not be the most ideal approach. Anyone have any good suggestions?

Also, only the skin's alpha itself is changed, but not those for button images and so on, because those textures are stored within the UIElements themselves. Is there a good way for me to update their alphas as well?

If anyone's interested, the updated source and .exe is in the original post. :D
Post Reply