Calendar

August 2017
Mo Tu We Th Fr Sa Su
<< >>
123456
78910111213
14151617181920
21222324252627
28293031

Langs

FFK09 was great !

Posted on May 02 2009

I was in Cologne this week at FFK09, and it was a very nice conference ! The weather was not so good the first days, but every other thing was perfect. Being more into wine, I actually didn't know that I could drink that much beer !

As for the presentation, I wished I could at least understand some German, but I was able to follow some of them, since technical words are often in English. Thanks a lot to Marc and Jens for doing some translations for me during my stay ;)

I did two presentations at FFK09. The first one was part of the 10-hots-minutes : five speakers with ten minutes each to show something about their work. Being together with André Michelle and Mario Klingemann I felt like some pressure, so I put together some Physaxe examples but also try to show how you can use particles + a physics engine to build some nice effects such as exploding volcanoes or more fluid-like systems.

But my main one-hour presentation What is SWF ? was about the SWF format, the information it contains and the way you can use this knowledge to improve your code or graphics. You can download the slides of the presentation if you want to have a look.

Everything went very well and I got pretty good feedback so far about it.

PS : I would like to thank in particular Marc Thiele and Sascha Wolter for inviting me at FFK09 and of course organizing the whole thing !

6 comments
  • Matthew (UK)
    May 02, 2009 at 16:01

    Hi Nicolas,

    Thanks for sharing those slides, do you know if an audio recording was made of your talk? If so, do you think it will be made available online?

    thanks
    Matthew

  • May 03, 2009 at 22:05

    Great meeting again Nicolas and good luck with the house! If it's too much of a jungle in the garden, call me and I'll come down with my chainsaw ;-)

    J

  • May 03, 2009 at 22:50

    Thanks Jens, I'm understanding this as a promise then :D
    BTW, thank you for the very nice review of FFK09 on http://flashmagazine.com !

  • May 11, 2009 at 22:04

    Hi Nicolas,

    I really enjoyed your session last week! I was wondering if you could also share the star system example with the four steep how to optimize the code?

    thanks again for the secrets behind the bytecode :)
    Aron

  • May 16, 2009 at 10:32

    Here's the full source-code. You can use FastList instead of Array to improve performances, and after that store the Math class into a local variable or use * invSqrt(d * d * d) instead of dividing by Math.sqrt(d * d * d)

    class Star {
    
        public var x : Float;
        public var y : Float;
        public var vx : Float;
        public var vy : Float;
        public var mass : Float;
        public var color : Int;
    
        public function new() {
        }
    
    }
    
    class Space {
    
        static inline var MAXMASS = 3.0;
        static inline var NSTARS = 1000;
    
        var root : flash.display.MovieClip;
        //var stars : haxe.FastList<Star>;
        var stars : Array<Star>;
        var bitmap : flash.display.BitmapData;
        var tf : flash.text.TextField;
    
        function new(root) {
            this.root = root;
            prepare();
        }
    
        function init() {
            bitmap = new flash.display.BitmapData(root.stage.stageWidth,root.stage.stageHeight,true,0xFF000000);
            root.addChild(new flash.display.Bitmap(bitmap));
            tf = new flash.text.TextField();
            tf.width = tf.height = 1000;
            tf.textColor = 0xFFFFFF;
            tf.selectable = false;
            root.addChild(tf);
            //stars = new haxe.FastList<Star>();
            stars = new Array();
            for( i in 0...NSTARS ) {
                var s = new Star();
                s.x = Math.random() * root.stage.stageWidth;
                s.y = Math.random() * root.stage.stageHeight;
                s.vx = 0.;
                s.vy = 0.;
                s.mass = (0.1 + Math.random()) * MAXMASS / 1.1;
                var r = Math.random();
                var g = Math.random();
                var b = Math.random();
                var t = 255.0 * (s.mass / MAXMASS) / (r + g + b);
                s.color = 0xFF000000 | (Std.int(r * t) << 16) | (Std.int(g * t) << 8) | (Std.int(b * t));
                stars.push(s);
            }
        }
    
        public function prepare() {
            var b = new flash.utils.ByteArray();
            b.length = 1024;
            flash.Memory.select(b);
        }
    
        public inline function invSqrt( x : Float ) : Float {
            var half = 0.5 * x;
            flash.Memory.setFloat(0,x);
            var i = flash.Memory.getI32(0);
            i = 0x5f3759df - (i>>1);
            flash.Memory.setI32(0,i);
            x = flash.Memory.getFloat(0);
            x = x * (1.5 - half*x*x);
            return x;
        }
    
        function update(_) {
            if( bitmap == null ) {
                if( root.stage.stageWidth == 0 )
                    return;
                init();
            }
            mt.Timer.update();
            tf.text = (Std.int(mt.Timer.fps() * 10) / 10)+" FPS";
            var fmt = tf.getTextFormat();
            fmt.size = 32;
            tf.setTextFormat(fmt);
            for( i in 0...2 )
                doUpdate(0.5);
            bitmap.applyFilter(bitmap,bitmap.rect,new flash.geom.Point(0,0),new flash.filters.BlurFilter(2,2,2));
        }
    
        function doUpdate(dt:Float) {
    
            for( i in 0...stars.length ) {
                var s1 = stars[i];
                for( j in i+1...stars.length ) {
                    var s2 = stars[j];
                    var dx = s1.x - s2.x;
                    var dy = s1.y - s2.y;
                    var d = dx * dx + dy * dy;
                    var dmin = s1.mass + s2.mass;
                    dmin *= dmin;
                    if( d < dmin ) {
                        dx *= -1;
                        dy *= -1;
                        d = dmin;
                    }
                    var id = dt / Math.sqrt(d * d * d);
                    s1.vx -= s2.mass * dx * id;
                    s1.vy -= s2.mass * dy * id;
                    s2.vx += s1.mass * dx * id;
                    s2.vy += s1.mass * dy * id;
                }
            }
    
            /*
            var c1 = stars.head;
            while( c1 != null ) {
                var c2 = c1.next;
                var s1 = c1.elt;
                while( c2 != null ) {
                    var s2 = c2.elt;
                    var dx = s1.x - s2.x;
                    var dy = s1.y - s2.y;
                    var d = dx * dx + dy * dy;
                    var dmin = s1.mass + s2.mass;
                    dmin *= dmin;
                    if( d < dmin ) {
                        dx *= -1;
                        dy *= -1;
                        d = dmin;
                    }
                    var id = dt / Math.sqrt(d * d * d);
                    s1.vx -= s2.mass * dx * id;
                    s1.vy -= s2.mass * dy * id;
                    s2.vx += s1.mass * dx * id;
                    s2.vy += s1.mass * dy * id;
                    c2 = c2.next;
                }
                c1 = c1.next;
            }*/
    
            var w = root.stage.stageWidth;
            var h = root.stage.stageHeight;
            var cx = w / 2;
            var cy = h / 2;
            var ZOOM = 1.5;
            var IMASS = 1.0 / MAXMASS;
            bitmap.lock();
            for( s in stars ) {
                s.x += s.vx * dt;
                s.y += s.vy * dt;
                for( x in -1...2 )
                    for( y in -1...2 ) {
                        var ix = Std.int((s.x - cx) * ZOOM + y * s.mass * IMASS + cx);
                        var iy = Std.int((s.y - cy) * ZOOM + x * s.mass * IMASS + cy);
                        var c = bitmap.getPixel32(ix,iy);
                        var r = ((c >> 16) & 0xFF) + ((s.color >> 16) & 0xFF);
                        var g = ((c >> 8) & 0xFF) + ((s.color >> 8) & 0xFF);
                        var b = (c & 0xFF) + (s.color & 0xFF);
                        if( r > 0xFF ) r = 0xFF;
                        if( g > 0xFF ) g = 0xFF;
                        if( b > 0xFF ) b = 0xFF;
                        bitmap.setPixel32(ix,iy,0xFF000000 | (r << 16) | (g << 8) | b);
                    }
            }
            bitmap.unlock();
        }
    
    
    
        static var inst : Space;
    
        static function main() {
            inst = new Space(flash.Lib.current);
            flash.Lib.current.addEventListener(flash.events.Event.ENTER_FRAME,inst.update);
        }
    
    }
  • May 18, 2009 at 23:21

    Perfect Nicolas. Thank you!

Name : Email : Website : Message :