I know how to make a billboard with a material and a texture. But how do I put an animated image on that billboard?
It's not an animated gif. It looks like this:


Code: Select all
int main()
{
//...
billboard->setMaterialTexture(0, driver->getTexture("sample_animation_5x5.jpg"));
core::vector2df translate(0.0f);
std::vector<core::vector2df> ts;
for (f32 m=0.0f; m<5.0f; m+=1.0f)
{
for (f32 n=0.0f; n<5.0f; n+=1.0f)
{
//printf("(m,n)=(%f,%f)\n", m, n);
translate = core::vector2df(n, m) * 0.2f;
ts.push_back(translate);
}
}
while (device->run())
if (device->isWindowActive())
{
////////////////////////////////////////////////////////////////////////
static int texindex = 0;
core::vector2df translate = ts[texindex];
core::matrix4 mat;
mat.buildTextureTransform(0.0f, core::vector2df(0.0f), translate, core::vector2df(0.2f));
billboard->getMaterial(0).setTextureMatrix(0, mat);
++texindex;
if (texindex > int(ts.size()-1))
texindex = 0;
////////////////////////////////////////////////////////////////////////
driver->beginScene(true, true, 0);
smgr->drawAll();
driver->endScene();
}
else { device->yield(); }
if (device)
device->drop();
return 0;
}