I have created a class which reads a picture readable by Irrlicht of abitrary size and splits it into several parts depending on max objects that should be used. The parts will be placed to a random position within given borders with random colors and are animated to the given destination by changing their position and color step by step.
Here is the original thread where aek came up with his idea which I liked so much and inspired me to create the class:
http://irrlicht.sourceforge.net/phpBB2/ ... sc&start=0
Here comes my post from the original thread:
It is a class which can be parameterized as follows
Code: Select all
//! Splits an image readable by Irrlicht of abitrary size into several parts and animates these parts from a given starting position to a given target destination.
class TesselatedImage
//! Constructor.
/*! @param img - The path to the image.
@param startFr - Vector defining the left(x1)/bottom(y1)/front(z1) position of the cube within the parts are being randomly positioned.
@param startTo - Vector defining the right(x2)/top(y2)/behind(z2) position of the cube with x2 > x1, y2 > y1, z2 > z1.
@param targetPos - The bottom left position of the final compound image.
@param speed - Amount of units per seconds a part is moving to its target position.
@param maxTes - The maximum number of parts that should be used to split the image. If resolutionX * resolutionY < maxTes then a part represents more than one pixel.
@param colChange - How quickly a part can correct its color to reach the final color, defined in 'one unit per RGB' per second.
@param type - What the parts should be made of, default is using a Billboard.
@param dim - The quadratic dimension of the billboard or the radius of the sphere. See parameter type.
@param gap - The gap between parts.
*/
TesselatedImage(stringc img, vector3df startFr, vector3df startTo, vector3df targetPos, float speed=10.0f, int maxTes=5000, float colChange=5.0, Type type=Billboard, float dim=4.0f, float gap=0.05f);
Code: Select all
TesselatedImage *tesImage = new TesselatedImage(<your image>, vector3df(-600,0,500), vector3df(500, 550, 1000), vector3df(-130,50,100), 45, 15000, 10);
tesImage->startAnimation();
and do
Code: Select all
if (tesImage->hasAnimationFinished())
{
tesImage->reset();
tesImage->startAnimation();
}
Note: to get it running you need an instance to the Irrlicht driver (I have used a Singleton here to get it), exchange
Code: Select all
#include "graphicsirr.h"
...
GraphicsIrr *graphics = GraphicsIrr::getInstance();
Code:
Code: Select all
IImage *image = graphics->driver->createImageFromFile(img.c_str());
http://www.mediafire.com/file/j2mzmymyw ... dImage.rar
I have never used a free hosting service until now, tried it, works, hope the link keeps working.
Have fun and thanks again to aek for his brilliant idea.
ciao
Airo