Source rectangle of texture

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
giulioz
Posts: 8
Joined: Mon Jun 24, 2013 2:21 pm

Source rectangle of texture

Post by giulioz »

Hello.
I want to animate a BillboardSceneNode using a spritesheet, so I need to set texture's source rectangle.
How I can do this?

Thanks!
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: Source rectangle of texture

Post by greenya »

Generally i know two ways: 1) modify texture coords of the mesh; 2) modify texture matrix of the material.
First case is not possible for billboards, because IBillboardSceneNode doesn't expose the mesh. Second way is possible, because it inherited from ISceneNode, which has getMaterial(). So you can try to do next:

Code: Select all

billboardnode->getMaterial(0).getTextureMatrix(0).setTranslation(0.5f, 0.5f, 0 /* i believe this arg not used */);
giulioz
Posts: 8
Joined: Mon Jun 24, 2013 2:21 pm

Re: Source rectangle of texture

Post by giulioz »

It Works :)
Thank you very much!
Post Reply