Bored programmer series

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
stefbuet
Competition winner
Posts: 495
Joined: Sun Dec 09, 2007 4:13 pm
Location: france

Post by stefbuet »

I really like the sound of the video :o (combined with the images)
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Thank you all for comments!
LosNir wrote:That's awesome!
If I'm right, you load a JPG file, split it into pixels, and each pixel is represents a ball?
Yes, I do it this way. But instead of JPG I used BMP, it's easier to implement loader for this file format.
Virion wrote:anyway did you optimize anything? how was the performance?
I used billboards instead of 3D shperes. There is no dynamic light, so sphere and billboard look indentical, but on billboards whole program run very faster than on spheres.
You will find everything in source.
slavik262 wrote:Also, it looks like the balls are moving along two axes - unless I'm mistaken, they don't all take a straight path to their final destination. Is this true?
Balls are moving along three axes and they are moving in straight path, but it's look that they not moving along straight path. Little illusion :)


Thank you all for your comments, it's very motivating to work :)

Some people mentioned about adding this project to Irrlicht examples.
If you really think that can be used as example of Irrlicht perfomerance, I would be very honored if you add it to examples.

And of course, there is source:
(EDIT)-OBSOLETE -(/EDIT)
and ball.png file:
http://img532.imageshack.us/img532/2424/ballf.png
I have to write once again code with pointers in loop, but for now I don't have so much time.
Feel free to modify my code for your own purposes :)
Last edited by kazymjir on Sat May 15, 2010 11:56 am, edited 3 times in total.
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

http://wklej.org/hash/e6fd95975e2/

Updated code with pointers :)


EDIT: please comment my code, I am new in C++ programming, every tips will be very helpfull for me :)
Airo
Posts: 6
Joined: Thu Jul 23, 2009 5:24 pm
Location: Vienna

Little code snippet

Post by Airo »

Hi!

This is my first post here in the forum, the time has finally come - greetings to all! :)

I have started using Irrlicht for the first time Feb. last year and I like it, thanks to all contributing to it.

Aek, the bored programmer :), has inspired me to implement his idea, I liked it very much when I saw it two days ago and started yesterday with the code snippet which I want to contribute. Maybe someone likes it and can make some use out of it.

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);
It can be used as follows:

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();
then call tesImage->move(<time elapsed in seconds>) to let the parts move to the destination.

and do

Code: Select all

if (tesImage->hasAnimationFinished())
{
    tesImage->reset();
    tesImage->startAnimation();
}
to reset the positions and colors to random values and start again.

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();
with your Irrlicht #include code to be able to make driver calls like

Code: Select all

IImage *image = graphics->driver->createImageFromFile(img.c_str());
Here is the link
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
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Hey Airo, I guess it's better to start your own thread in the CodeSnippets forum instead of hi-jacking this one. Even though your post might be near to what is happening in the OT, you should probably only link to this thread.
Besides that: Welcome to the community, nice contribution.
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Hello Airo !

I am so happy, that my work inspired someone :)

Your code is looking very nice! Everything is arranged, simply in use and very configurable. My code is one big mess and no configurability, everything like be written by 10-years old kid, but your code is showing beauty of code, simplicity and configurability.
Very nice work, I like it :)
Airo
Posts: 6
Joined: Thu Jul 23, 2009 5:24 pm
Location: Vienna

Post by Airo »

Hi,

thanks for your statements. I am happy that you like it.

I will bear in mind to post it in the code snippets forum the next time and link to the thread instead.

Have a nice day. :-)
netpipe
Posts: 669
Joined: Fri Jun 06, 2008 12:50 pm
Location: Edmonton, Alberta, Canada
Contact:

Post by netpipe »

thanks for the code, works well and looks better than magic. i've been having issues with image loading (might be 64 bit bug) but it'll be fixed soon.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

Thanks Tecan :)
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

-Update-
License changed to zlib
http://wklej.org/hash/985d5118917/
kazymjir
Posts: 727
Joined: Sat Feb 20, 2010 4:05 pm
Location: Munich, Bayern

Post by kazymjir »

I moved to new YouTube account, so there is new link to the project video:
http://www.youtube.com/watch?v=VnhRtcIoiX0
Post Reply