Archive for the ‘DYNAMIC’ Category

Thursday, February 5th, 2009

Recently two compact tweening engines have been released. Grant Skinner’s GTweeny and laborat’s ByteTween. This adds to the two that focus on micro-tween kit sizes in TweenLite and TweensyZero

Basically these engines look to be micro and provide pretty nice features while being so small. Micro tweening engines like GTweeny (3k), ByteTween (1.7k), TweenLite (2.7k), TweensyZero (2.9k) and Tweener (9k) have varying levels of support of features (Tweener being the most loaded with color and filter support without other kits just init, also TweenLite with a nice configurator to include only what you need).  Micro kits have benefits when used for banners, animated assets (where you have many assets and the per asset savings is worthwhile) and other places you just want really small output.

Light Transition ByteTween

(1.7k)

This kit has a c# version as well as a small as3 bytetween version.

The ByteTween static class eats only 1.7K of compiled clip! With this size it supports:

  • Creation of tweens of any numeric property (not color/uint properties).
  • Pause,Unpause,Cancel operations based on the tween target and property.
  • Overlap system that cancel tweens of same property in order to avoid erroneous behavior
  • Alpha tween with negative alpha support (negative alpha sets the MovieClip visibility to false)
  • ’scale’ tween of both ’scaleX’ and ’scaleY’ properties.
  • OnComplete callback with any number of parameters
  • Easy interface for creating new tweens!

Download light_transition_CS_0.5a.zip.zip (c# version)

Download thelab_ByteTween.zip

TweenLite

(2.7k) base

  • SPEED – I’m not aware of any popular tweening engine with a similar feature set that’s as fast as TweenLite. See the speed comparisons yourself.
  • Feature set – In addition to tweening ANY numeric property of ANY object, TweenLite can tween filters, hex colors, volume, tint, saturation, contrast, frames, and even do bezier tweening, plus LOTS more. TweenMax extends TweenLite and adds even more capabilities like pause/resume, rounding, event listeners, timeScale, and more. Overwrite management is an important consideration for a tweening engine as well which is another area where the GreenSock tweening platform shines. You have options for AUTO overwriting or you can manually define how each tween will handle overlapping tweens of the same object.
  • Expandability – With its new plugin architecture, you can activate as many (or as few) features as your project requires. Or write your own plugin if you need a feature that’s unavailable. Minimize bloat, and maximize performance.
  • Management featuresTweenGroup makes it surprisingly simple to create complex sequences and groups of TweenLite/Max tweens that you can pause(), resume(), restart(), or reverse(). You can even tween a TweenGroup’s “progress” property to fastforward or rewind the entire group/sequence.
  • Ease of use – Designers and Developers alike rave about how intuitive the GreenSock tweening platform is.
  • Updates – Frequent updates and feature additions make the GreenSock tweening platform reliable and robust.
  • AS2 and AS3 – Most other engines are only developed for AS2 or AS3 but not both.

Download TweenLite

TweensyZero

(2.9k) base

Here are some simple steps to help you get started with creating your first animations with TweensyZero. TweensyZero is a light weight version of Tweensy most core features found in Tweensy are available to TweensyZero. Documentation for TweensyZero can be found under the folder ‘documentation/zero’ or online

Download TweensyZero

gTweeny

(3k)

gTweeny is gTween‘s lightweight younger sibling. It strips a lot of the secondary features of GTween (proxy, timing modes, etc) in favour of smaller file size. It is currently under 3kb…

Download gTweeny

Here is a list of all open AS3 “Micro” Tweening engines < 5k

Here is a list of all open AS3 Tweening engines and base kits

The decision on which to use can be affected be features you want, how it feels (many use the same object syntax so it is dynamic), what performance do they have (all are orders of magnitude faster than the built in tween (flash) or transitions (mx/flex)), which size is ok, author/community support needed (some are more active than others adding features or simplifying and tweaking performance methodically), and many other factors.  There are definitely plenty to choose from.

Speed Tests for many Tween Engines

For more on each features see their sites or these previous lists on tweening engines:

Tuesday, July 29th, 2008

I rarely mention stuff I have worked on here but I got a chance to use APE and AS3 on the online Plinko game at the site for the Price is Right videogame for the famed pink Plinko Board.  Who doesn’t love Plinko?

I did the programming on this back when I still worked at emarketing/prizelogic.

I will be featuring a small iteration to APE with draggable particles and how I did it.  In the end I didn’t use the draggable particles but they are fun (i ended up changing my collision/border particles after testing).  I ended up controlling the drop location by swapping out a wheel particle after they dropped it.  So that it got the famous Plinko disc bounce and roll.

Why did I use APE? Well it is the least complex physics engine.  I started off with Box2dFlashAS3 and will post that one maybe as well but ended up going with APE mainly for integration it was easier that it was a less intensive codebase.  Box2DFlashAS3 can scare non C++ coders with it’s style let alone AS2 coders moving to AS3.

It is slower with all the other animation going on in the site but you can also play on my server here just the Plinko part.

Can you get 10,000?

Saturday, June 21st, 2008

[youtube]http://www.youtube.com/watch?v=YEM-XAeY4K0[/youtube]

3D models from basic video… This can be huge in all sorts of ways.  For exponential growth you need to go virtual.

  • This is a technology called VideoTrace from Australia
  • The Siggraph paper describing VideoTrace is available here (pdf 6MB)
  • Larger videos available here, with a more compressed version here.
Thursday, April 17th, 2008

Box2dFlashAS3 has been updated to version 2.0 complete with ragdolls and Theo Jansen walkers ala APE fame.

Sunday, April 6th, 2008

Nicolas Cannasse, a virtual machine genius (maker of MTASC compiler, Neko and haXe (haXe compiles to target flash 6-9 but really only flash 9 is used anymore unless you are making banners)) released the Physaxe 2D Physics kit for haXe today.

It is heavily based on Glaze (demos) and Box2D which the Motor2, Glaze and Box2DFlashAS3 physics kits are all based on. Box2D is a great C++ 2D physics engine, it is simple which lended itself to being ported to AS3 quite easily. It is also a testament to AS3 that C++ kits are being ported into the language, not once, but many times. Also C ports like Chipmunk and other signs point to == AS3 is of fun.

Physaxe is quite amazing you must see the demos (very similar to Glade demos), it will get the inspirational wheels turning in your idea machines.

2D Physics in Flash and AS3 are extremely hot and can be used for many, many things from game development to promotions to simulations to user interface or visualizations and even modeling natural systems. It is nice to have a port of Box2D and similar to glade capabilities with Chipmunk like Glade has.

A game and physics engine for Flash including:

  • Rigid Body Dynamics
  • Scene management
  • Line of sight
  • User Input
  • Scrolling
  • AI

Core parts of the physics solver and collision system are based on the C physics engine Chipmunk

Notes about Physaxe:

Physaxe is a 2D Rigid Body Library written in haXe. It’s been highly optimized for the Flash 9 Player, with the best optimizations available.

Physaxe is based on several existing physics engines, mainly :

  • Box2D, the reference open source physics engine
  • Glaze, an AS3 engine which is a port of Chipmunk, itself based on Box2D

Physaxe features are :

  • rigid body consisting in several shapes
  • shapes supported are circles, segments (with rounded edges) and arbitrary convex polygons
  • customizable broadphase (currently bruteforce and y-sorted list are available)
  • island resolution and sleeping (allow ~0 CPU to be spent when groups are sleeping)
  • constraint solver based on Box2D sequential impulses
  • customizable body properties, such as linear/angular friction and maximized motion

Updated list of physics engines are like this:

AS3 3D Physics Engines (Open Source)

AS3 2D Physics Engines (Open Source)

haXe 2D Physics Engines

Get your game on! It is best to get them out early and often. I need to take my own advice.

Thursday, March 20th, 2008

I have officially been sucked into the Python vortex. I recently have really been digging IronPython, Jython and good old plain Python but have not ventured here yet. Google (They employ Guido), Microsoft (IronPython) and Sun (Jython) are all becoming infected pythonistas as well. But this is just too cool, Python to AS3 code with flex-pypy. This project is very young but could be fun, source at Google Code.

Haxe has a similar premise where it can compile to Flash6-9 versions of actionscript 2-3 which makes for a system with better reach. Python code for this is lots of fun and very flexible. Python is becoming a baseplane language and one great language for transcending platform lock-in.

Check out this snippet pulled from here (click to see sample game)

#/usr/bin/env python
"""
This simple example has very little to do with the pygame
chimp example, except that it will act the same (more or less)
and it uses the same resources, only they got converted to
mp3s, pngs.
"""

#Import Modules
from pypy.translator.flex.modules.flex import *

class MyRect:
    def __init__(self,x,y,w,h):
        self.x, self.y,self.w,self.h = x,y,w,h

SCREEN_W = 468
SCREEN_H = 60

class Game:
    def __init__(self):pass

    def init(self,screen):
        self.screen = screen
        screen.layout = 'absolute'
        screen.setActualSize(SCREEN_W, SCREEN_H)

        screen.addEventListener('mouseMove',mousemotion)
        screen.addEventListener('enterFrame',do_loop)
        screen.addEventListener('click',chimp_whip)

        self.bg = load_sprite("py_background_png");
        self.screen.addChild(self.bg)

        self.chimp = load_sprite("py_chimp_png");
        self.screen.addChild(self.chimp)

        self.orig_y = self.chimp.y

        img2 = self.fist = load_sprite("py_fist_png")
        self.screen.addChild(img2)
        img2.move(400,img2.height/2)
        self.move = 1
        self.spin = 0
        self.hit = 0
        self.hit_move = 1

        self.sfx = {}
        self.sfx['whip'] = load_sound_resource("py_punch_mp3")
        self.sfx['nohit'] = load_sound_resource("py_whiff_mp3")

    def loop(self):
        img = self.chimp
        if self.spin:
            self.spin -= 1
            img.rotation = self.spin*24
        else:
            img.x += self.move * 8
            if img.x > SCREEN_W-img.width:
                self.move = -1
            if img.x < 0:
                self.move = 1

        if self.hit:
            self.hit -= 1
            self.fist.y += 6 * self.hit_move

            if self.hit  SCREEN_W - img_halfw:
        newx = SCREEN_W - img.width
    if newx  img.x and e.stageX < img.x+img.width:
        game.sfx['whip'].play()
        game.spin = 20
    else:
        game.sfx['nohit'].play()

def flash_main( x=1 ):
    game.init(castToWindow(x))
Tuesday, January 22nd, 2008

Seraf, True to the word WOWEngine was released today. It is still a work in progress but it is the first 3d physics engine out of the gate. It is built with many open source kits that are emerging. It can use any of the 3 major flash 3d engines (pv3d, sandy, away3d) and it is built on APE AS3 2d physics engine.

WOW-Engine use Sandy library for all the 3D mathematical computations (matrix, 3D vector, plane). The inner architecture of the engine is also inspired by Sandy’s one.

Collisions and physical reactions are possible thanks to the AS3 physic engine made by Alec Cove, named APE(version 0.2.).. Even if APE is a 2D physic engine, it is possible to extend the contraints on volumes, and that’s the purpose of WOW-engine. WOW-engine extends APE, and allows to simulate physics on 3D volumes.

WOW-Engine is capable to handle positions and rotations of abstract objects, which need to be linked to some visual objects (2D or 3D). The visual objects can be drawn thanks to another library (Sandy3D , Papervision3D, Away3D for 3D).

WOW-Engine use and depend of the Data Structures classes written by polygonal labs.

Basic technical Demos :

Advanced technical Demos:

Tutorials:

Wednesday, October 17th, 2007

Currently working on some motion detection with flash/c# and webcams right now. Here’s a basic overview of some motion detection source files and tricks. Most motion detection is based on snapshots and finding brightness of a pixel with all combined colors, then comparing that to previous snapshots to detect enough variance and thus movement. If you have a webcam hooked up, this sample in Flash AS3 highlights this well showing the camera on the left, then the brightness snapshots on the right. It also has an indicator to the amount of movement due to much brightness.

C#

Here is a nice example of motion detection using various motion detection algorithms in C#. This is built on the very slick AForge.NET Computer Imaging Library.

If you ever wanted your own motion detection or recording it is all possible with the basics of checking brightness and snapshots in the most simple form checking how much change or variance their was to bright pixels or the count of bright pixels compared to previous snapshots.

// Calculate white pixels

private int CalculateWhitePixels( Bitmap image )
{
    int count = 0;
    // lock difference image
    BitmapData data = image.LockBits( new Rectangle( 0, 0, width, height ),
        ImageLockMode.ReadOnly, PixelFormat.Format8bppIndexed );
    int offset = data.Stride - width;
    unsafe
    {
        byte * ptr = (byte *) data.Scan0.ToPointer( );
        for ( int y = 0; y < height; y++ )
        {
            for ( int x = 0; x < width; x++, ptr++ )
            {
                count += ( (*ptr) >> 7 );
            }
            ptr += offset;
        }
    }

    // unlock image
    image.UnlockBits( data );
    return count;
}

Flash AS2

In Flash this is also possible here is a good article from Flash8 that explains cycling through each pixel to compare the image data and implement motion detection from a webcam.

For instance the basics here show how you can compare each pixel and the change in the brightness for each pixel:

//accuracy
tolerance=10;

//color of the current pixel in the current snapshot
nc=now.getPixel(x,y);

//red channel
nr=nc>>16&0xff;

//green channel
ng=nc>>8&0xff;

//blue channel
nb=nc&0xff;

//brightness
nl=Math.sqrt(nr*nr + ng*ng + nb*nb)

//color of the same pixel in the previous snapshot
bc=before.getPixel(x,y);

//red channel
br=bc>>16&0xff;

//green channel
bg=bc>>8&0xff;

//blue channel
bb=bc&0xff;

//brightness
bl=Math.sqrt(br*br + bg*bg + bb*bb);

//difference in brightness between now and before
d=Math.round(Math.abs(bl-nl));

if(d>tolerance)
{
//there was a change in this pixel
}

Flash AS3

Here is a link to grab a conversion of the AS2 Flash motion detection above to AS3.

Source of AS3 motion detection here.

Grant Skinner has done some interesting things with motion detection with Flash and webcams in the past in the incomplet gallery.

C# or other hardware accelerated capable kits are faster but AS3 and Flash with the new AVM2 virtual machine  should be about 10 times faster than AS2 as much of the improvement in performance and the virtual machine is on iteration speed increases such as loops (i.e. pixel loop).

Sunday, September 30th, 2007

Zeh Fernando’s AS2 and AS3 Flash Animation Kit Tweener has inspired a JSTweener port to javascript, why thanks Yuichi Tateno (secondlife).

This actually could be used quite easily with Silverlight and an AgTweener could be very easily created from this. The Tweener like syntax with an object and adding tweens of available properties as an object or array is very simple and could make animation systems much more standard if everything used this not to mention easier for developers to animate in any presentation layer. The syntax makes for the best of the Animation Packages currently available for AS3. If this could be used in other kits it would make animation pretty standard and simple when changing platforms.

JQuery is very lightweight and has a similar syntax on their animate() call. There are many animation javascript kits such as mootools, jquery, dojokit and prototype and others that have similar functionality but it is all handled differently.

JSTweener

JSTweener.addTween(element.style, {
time: 3,
transition: 'linear',
onComplete: function() {},
width: 200,
height: 200,
left: 500,
top: 300
});

JSTweener Source

JSTweenerRepo

Samples:

Found via Zeh

Tuesday, September 4th, 2007

Recently the “seam carving” technology to size images in a content aware way to preserve the original intention of the photo has been really taking off. In fact, Joa Ebert and Mario Klingemann, two flash geniuses have created and optimized [2] an AS3 algorithm for seam carving based on the paper about this new technology that was highlighted at 2007 SIGGRAPH.