Category Archive: Experiment

Genie effect with as3

Here is a Mac OSX like Genie effect made with AS3.

It’s basically made with Flash 10’s drawTriangles API & Yoshihiro Shindo’s betweenAS3 tween library.

It’s just a initial sketch, but seems there is plenty of possibilities around the new bitmap drawing API.

Particle Storm demo & source

I think I have forgotton to post this experiment to JActionScripters.
Here is a playable demo & source code that I showed on the FITC2009 session. Storm simulation with 10000 particle.

Basically all physic and mouse interaction is calculated with bitmap force map. Precalculating mouse interaction with bitmap is much faster than doing mouse distance with 10000 particles every frame.

You can also see stupid 250000 particle version here.

ARMessageCard (ARSandPainting)

ARMessageCard

In the Spark meeting #09, I presented an ARMessageCard for Geoff. At first, a card on the marker seems to be white, but a message will be rose by particles moves if you tilt the card. It works like a sand painting.

ARMessageCard from Yoshihiro Shindo on Vimeo.

You can try it at here (Please use this marker). Of course, source code was uploaded.

A point of this Flash is calculating gravity from the inclination of the card to move particles.

If you defined variables like:

private var _mat:Matrix3D = new Matrix3D();
private var _rot:Number3D = Number3D.ZERO;
private var _v:Number3D = new Number3D();

*Matrix3D and Number3D are provided by Papervision3D.

You can get gravity by the following code:

_mat.copy(_baseNode.transform);
_mat.invert();
_rot = Matrix3D.matrix2euler(_mat, _rot);
_v.reset(0, 1, 0);
_v.rotateY(_rot.y);
_v.rotateX(_rot.x);
_v.rotateZ(_rot.z);
var gx:Number = -_v.x * 2.0;
var gy:Number = -_v.y * 2.0;

*_baseNode is provided by FLARToolKit.

First, invert the transform matrix calculated by the FLARToolKit to get a transform matrix of gravity about the marker. Next, apply only rotations from the transform matrix to a normalized vector for gravity. Finally, get x value and y value from it. If you move particles based on these values, it will work fine :)

Porting a few Max/MSP Objects

randomgroove

I started to port a few Max/MSP Objects such as “groove~” “waveform~” “buffer~” “dac~” to ActionScript Classes.

It’s not been completed yet but here is the first sample.

Random Groove
(you can cut up synchronized two audio files randomly)

These API is something like below.

dac = new DAC();
buffer = new Buffer(2000);  // buffer length(ms)

groove = new Groove(buffer);
groove.loop = true;

waveform = new Waveform(buffer);
addChild(waveform);
waveform.addEventListener(Event.CHANGE, waveformChangeHandler);

private function waveformChangeHandler(event:Event):void
{
    begin.text = String(int(waveform.range.x));
    end.text = String(int(waveform.range.y));

    groove.range(waveform.range);
    dac.play(groove.data);
}

Optimize iteration for Particle

Few weeks ago, Particle was a trend in Japanese Flash guys. Many works were posted to the Wonderfl with a tag “パーティクル祭 (Particle Matsuri)” (means Particle Festival).

In one of them, there is “100,000 particles” posted by bkzen. I think it’s pretty cool! but I need more speed. :p So I posted a quick optmized one. It brings 33% faster (21fps -> 28fps) in my Mac. ;)

You can see what did I changed by clicking “diff” link in above page. In short, I changed an iteration method from Array to LinkedList. Because array index access and calculating and checking an index (variable i) are pretty slow.

// Slow
while (i > num) {
    p = particles[i];
    // do something
    i++;
}

But accessing an member variable is fast because it's optimized by AVM2. So it causes fast iteration.

// Fast
while ((p = p.next) != null) {
    // do something
}

Please use this optimization if you need fast iteration especially in case you have a large data.

Study – Long Exposure-Like Visual Effect

One of my professions is a professional photographer. Of many techniques,
I love to take long exposure photos and often like to light-paint within them.

2006_HNY_card
This is a real photo taken with a Nikon DSLR, 30secs, drawn with two LED penlights (blue/white) for a new year's card in 2006.
Click here to read more »

Adaptive thresholding experiment

Hello, World!

My name is Tomohiko Koyama aka Saqoosha. I think everyone knows me as a developer of FLARToolKit. I joined JActionScripters.com too, and I hope that Japanese Flashers are exposed to the world more and more. My English is not so good. If you find a mistake, please correct me.

Recently, I researched about Thresholding algorithms. Thresholding algorithms are used to binarize and preprocess the input to find some objects within the image. FLARToolKit uses a thresholding algorithm to detect the marker.

The algorithm currently using in FLARToolKit is Global Thresholding.

Saq-Global-Thresholding

Its implementation is simple and faster, but no flexibility about illumination variation. I looked for a thresholding algorithm to improve this weak point. Then found Adaptive Thresholding.

Click here to read more »