how to animate texture coordinate?

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
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

how to animate texture coordinate?

Post by comicsteam »

i know how to use texture animator to change texture for a model
however, this time i need to make a whirlpool
it is better to alter its UV coordinates instead of switching among textures
is it possible to animate texture coordinates of a model?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, of course. Since your tc transformations are probably possible with a texture matrix it's most efficient to use it as the animated object. Simply set the new matrix values instead of the next texture in your animator.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I don't know if you've thought about it yet, but it might be a good idea to write your own scene node animator that does the texture matrix manipulation for you.

Travis
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

Post by comicsteam »

hybrid wrote:Yes, of course. Since your tc transformations are probably possible with a texture matrix it's most efficient to use it as the animated object. Simply set the new matrix values instead of the next texture in your animator.
thanks for your suggestion
i have tried to use the texture matrix
here's my code:

Code: Select all

_sceneNode->getMaterial(1).getTextureMatrix(0).setTextureTranslate(time*0.0,time*0.0001);
the texture coordinates altered, but the result seems strange.
Image
it seems jittered and has some kind of "glossy" effect
what's wrong with this line of code?

another question, what is the difference between setTextureTranslate and setTextureTranslateTransposed?
zillion42
Posts: 324
Joined: Wed Aug 29, 2007 12:32 am
Location: Hamburg, Germany

Post by zillion42 »

a shader can also do that quite easy in fact... the realisticWaterScene node for example moves the bump linear, but I guess if you move 2 or 3 good layers blended (one layer with sudden changes for bubbles and one smooth foam and somehow out.color multipield or added... try) it would look quite nice for a whirlpool
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

time*0.0 seems more than odd...
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

Post by comicsteam »

zillion42 wrote:a shader can also do that quite easy in fact... the realisticWaterScene node for example moves the bump linear, but I guess if you move 2 or 3 good layers blended (one layer with sudden changes for bubbles and one smooth foam and somehow out.color multipield or added... try) it would look quite nice for a whirlpool
i will try. thanks for your suggestion :)
hybrid wrote:time*0.0 seems more than odd...
just because i don't want to change the x value.
same as 0 :)
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

Just a thought.. what's "time"? Is it some huge number converted from u32, causing the texture matrix to have a massive Y translation?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
comicsteam
Posts: 51
Joined: Thu Sep 11, 2008 2:24 pm
Location: Hong Kong
Contact:

Post by comicsteam »

bitplane wrote:Just a thought.. what's "time"? Is it some huge number converted from u32, causing the texture matrix to have a massive Y translation?
thanks for your help~! you pointed out the problem :shock:
"time" is the system time.
it seems too big for the matrix
i fixed it and now it works. :D
Post Reply