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.
rtr_18
Posts: 60 Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer
Post
by rtr_18 » Tue Oct 19, 2010 11:51 am
Hi!
I've an array of textures. I need to animate these textures over an image.
Code: Select all
textureArray.push_back(pManager->getDriver()->getTexture("media/FE/story/scr/ButtonRipple1.png"));
textureArray.push_back(pManager->getDriver()->getTexture("media/FE/story/scr/ButtonRipple2.png"));
textureArray.push_back(pManager->getDriver()->getTexture("media/FE/story/scr/ButtonRipple3.png"));
How to do this?
slavik262
Posts: 753 Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA
Post
by slavik262 » Tue Oct 19, 2010 11:54 am
Change the UV coordinates of the vertices in the mesh every frame. You can also change the UV coordinates in a vertex shader.
rtr_18
Posts: 60 Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer
Post
by rtr_18 » Tue Oct 19, 2010 12:02 pm
I've created a Texture animator like this:
Code: Select all
textureAnimator = pManager->getSceneManager()->createTextureAnimator(textureArray,5000,true);
in side the game loop. But nothing happens. Can you post some piece of code?
slavik262
Posts: 753 Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA
Post
by slavik262 » Tue Oct 19, 2010 12:14 pm
That texture animator just swaps the textures on the given interval. Is that what you're trying to do, or are you trying to move the texture across the mesh?
Bate
Posts: 364 Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany
Post
by Bate » Tue Oct 19, 2010 12:15 pm
If you put that in your gameloop, then you create a new animator each frame!
Here's an example of an animated billboard.
Code: Select all
array<ITexture*> texarr;
for (int i = 1; i < 10; ++i)
{
io::path temp = "explosion";
temp += i;
temp += ".jpg";
texarr.push_back(driver->getTexture(temp));
}
ISceneNodeAnimator* tex = smgr->createTextureAnimator(texarr, 50);
scene::IBillboardSceneNode* bill = smgr->addBillboardSceneNode(0, dimension2df(320, 240), vector3df(0,0,0));
bill->setMaterialTexture(0, texarr[0]);
bill->setMaterialFlag(EMF_LIGHTING, 0);
bill->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
bill->addAnimator(tex);
tex->drop();
Never take advice from someone who likes to give advice, so take my advice and don't take it.
rtr_18
Posts: 60 Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer
Post
by rtr_18 » Tue Oct 19, 2010 12:45 pm
slavik262 wrote:
Is that what you're trying to do, or are you trying to move the texture across the mesh?
I've to make a blinking image over a blue circle image to indicate that it's the current level. Please see the following link in this forum:
http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=40225
Instead of that I'm trying to use a TextureAnimator. Is it possible or not? I've tried what Bate said also. But nothing(none of my images) is visible.
serengeor
Posts: 1712 Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania
Post
by serengeor » Tue Oct 19, 2010 2:12 pm
have you renamed
Code: Select all
for (int i = 1; i < 10; ++i)
{
io::path temp = "explosion"; /// Your texture name
temp += i;
temp += ".jpg"; /// Your texture file extension
texarr.push_back(driver->getTexture(temp));
}
Working on game:
Marrbles (Currently stopped).
rtr_18
Posts: 60 Joined: Thu Jun 10, 2010 8:35 am
Location: Programmer
Post
by rtr_18 » Wed Oct 20, 2010 6:57 am
I've renamed everything to my resource names. Here is my code in side game loop.
Code: Select all
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
billBoard->addAnimator(textureAnimator);
billBoard->setMaterialTexture(0, textureArray[0]);
billBoard->setMaterialFlag(EMF_LIGHTING, 0);
billBoard->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
billBoard->addAnimator(textureAnimator);
textureAnimator->drop();
driver->endScene();
}
}
device->drop();
I've initialised the texture array out side the game loop in main().
Code: Select all
irr::core::array<irr::video::ITexture*> textureArray;
textureArray.push_back(driver->getTexture("ButtonRipple1.png"));
textureArray.push_back(driver->getTexture("ButtonRipple2.png"));
textureArray.push_back(driver->getTexture("ButtonRipple3.png"));
irr::scene::ISceneNodeAnimator* textureAnimator = device->getSceneManager()->createTextureAnimator(textureArray,5000,true);
irr::scene::IBillboardSceneNode* billBoard = device->getSceneManager()->addBillboardSceneNode(0,dimension2df(320,240),vector3df(10,10,0));
context.billBoard = billBoard;
context.textureAnimator = textureAnimator;
Nothing is visible. What to do?
slavik262
Posts: 753 Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA
Post
by slavik262 » Wed Oct 20, 2010 12:08 pm
This code does not go in your game loop. You are adding a new animator every single frame. Just use
Code: Select all
billBoard->addAnimator(textureAnimator);
billBoard->setMaterialTexture(0, textureArray[0]);
billBoard->setMaterialFlag(EMF_LIGHTING, 0);
billBoard->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
outside your game loop.
Bate
Posts: 364 Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany
Post
by Bate » Wed Oct 20, 2010 12:21 pm
rtr_18 wrote:
Code: Select all
while(device->run())
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
billBoard->addAnimator(textureAnimator);
billBoard->setMaterialTexture(0, textureArray[0]);
billBoard->setMaterialFlag(EMF_LIGHTING, 0);
billBoard->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
billBoard->addAnimator(textureAnimator);
textureAnimator->drop();
driver->endScene();
}
}
device->drop();
You should also think about drawing it!
Code: Select all
while(device->run() && driver)
{
driver->beginScene(true, true, SColor(0,200,200,200));
smgr->drawAll();
env->drawAll();
driver->endScene();
}
Never take advice from someone who likes to give advice, so take my advice and don't take it.