AS3 Perspective Texturemapping

This is the first step of a long journey. The example parses 3ds (3dmax) files and renders the scene pixel by pixel with a ‘real’ zBuffer for exact z-Sorting and a simple distance shading. There is a lot of space to increase performance. The most problem is drawing the pixels on the screen. The calculation of 236 faces connecting 190 vertices while clipping at the front plane is no performance problem. Commenting out the setPixel row, increases the FPS to 120.

Note: This example requires FlashPlayer 8.5

perspective texturemapping part 1 | based on Mikael Kalms 1997

BlendMode Math

If you wonder, what blendmodes are doing exactly, you can read this article about blendmodes in common. I tried to work with them in a accurate way to emulate complexer algorithms like animated water waves. Generically you can save a lot of performance, if you need to calculate every single pixel colorvalue from two bitmaps. In most cases, there is a simple solution using ColorTransform and Blendmodes. One problem is that the flash results are different in some cases, so here are my findings:

// **BLENDMODES
// based on: http://www.pegtop.net/delphi/blendmodes/
// modified to fit flash output

/*
	[for each color component] RGB
*/

// ADD
// c' = Math.min( 255, Math.max( 0, c0 + c1 ) )

// SUBTRACT
// c' = Math.max( 0, c0 - c1 )

// MULTIPLY
// c' = Math.floor( ( c1 * c0 ) / 0xff )

// SCREEN
// c' = 255 - Math.floor( ( 255 - c0 ) * ( 255 - c1 ) / 255 )

// LIGHTEN
// c' = c0 > c1 ? c0 : c1

// DARKEN
// c' = c0 < c1 ? c0 : c1

// DIFFERENCE
// c' = c0 > c1 ? c0 - c1 : c1 - c0

// INVERT ( no influence from c1 )
// c' = 255 - c0

// OVERLAY
// c' = c0 < 128 ? Math.floor( ( c1 * c0 ) / 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) / 127 )

// HARDLIGHT
// c' = c1 < 128 ? Math.floor( ( c1 * c0 ) / 127 ) : 255 - Math.ceil( ( 255 - c0 ) * ( 255 - c1 ) / 127 )

For example if you like to compute the average colors from 2 different bitmaps, you can follow like this:

import flash.display.*;
import flash.geom.*;

//-- test here 2 colorvalues
var c0: Number = 234;
var c1: Number = 255;

//-- source bitmaps
var b0: BitmapData = new BitmapData( 1, 1, false, c0 );
var b1: BitmapData = new BitmapData( 1, 1, false, c1 );

//-- resulting bitmap
var be: BitmapData = new BitmapData( 256, 256, false, 0 );

//-- compute average
var half: ColorTransform = new ColorTransform( .5, .5, .5, 1, 0, 0, 0, 0 );
be.draw( b0, new Matrix, half );
be.draw( b1, new Matrix, half, 'add' );

trace( be.getPixel( 0, 0 ) );
trace( Math.floor( ( c0 + c1 ) / 2 ) );

Of course this is a simple one, but you get the idea.

Speaking at spark europe

I’m proud to announce, that I will speak at the spark conference in amsterdam. There are a couple of the finest flashcoders and this will be the first time, I had to hold my session in english. Scary, scary :)
I will talk about some natural effects like fire, water and how to handle static bitmap transformation from other application like 3dmax with the new capabilities in flash8.

spark

Sphere Texturemapping via DisplacementMapFilter

I thought a long time about it and tried it the second time now. The idea is a freeze a current pixels displacement, as it naturally occur when projecting bitmaps into another enviroment like a sphere coordinate system. I created a gradient table in flash8 where the x and y values are stored as color-components (red/blue). I switch to 3dmax where I build my model (here a sphere) and map the gradient onto the mesh. The next step is to look, where the original positions of the texture was by comparing the source and the projected bitmap and compose a displacement map of it. I think, this is the screwiest workaround, I’ve ever done in flash.

Continue reading “Sphere Texturemapping via DisplacementMapFilter”

Flashkonferenz 05 (german)

Die Flashkonferenz 05, organisiert von Sascha Wolter und Marc Thiele, Betreiber des Flashforums steht an. Und diesmal geht das Ganze als Tour über die Bühne. Feste Referentenlisten oder Themen stehen noch aus, bis jetzt sind nur die Termine fest:

Berlin: 19. September
Hamburg: 20. September
Düsseldorf: 21. September
München: 22. September
Zürich: 26. September
Wien: 27. September

Ich denke ein Hauptthema wird Flash8 sein. Der Produktmanager von Flash ‘Mike Downey’ wird auch anwesend sein. Der Eintrittspreis beträgt 25 Euro. Auf Berlin freue ich mich besonders. Die Location ist gerade mal 3 Minuten von mir entfernt. Auch nett ist die Google Übersetzung ins Deutsche von diesem Post. “Sterben Sie Flashkonferenz…”

ffk05

Eightball examples

After flash8 is announced, the beta members are allowed to post their examples.
Unfortunatly I don’t have a lot of examples to publish, since they don’t work as expected yet. Anyway flash8 is a real milestone of flash itself, but in relation to performance, I’m furthermore disappointed. That includes the built-in native BitmapData methods and filters. But as in earlier versions, we might find workarounds to increase actionscript speed and rendering performance.

Continue reading “Eightball examples”

FDT – 2 weeks of testing

A lot of new feature were implemented in fdt last time and it really rocks. Never thought, that coding AS2 could be that easy. The handling of packages is awesome. You never need to open an explorer to move any of your classes and rewrite the class header. A simple move command and some shortcuts do the job. Errors and warnings are shown while writing your code in runtime. So you never have to test your movie to verify if you have errors. fdt checks your types and displays unsolveable properties as they occur on dynamic classes like MovieClips. This forces you to write typesave code and feel much better with your structure. Todays upgrade provides context tooltips for method parameters. This list would never end. I am impressed.

Thanks again, Nico for this usefull development tool.

SUSHI Multiuser Server V2.2

Bjoern Acker asked me to publish this anouncement. I havn’t tested the product, so get an eye on this for yourself.

Rawfish Software has just released the SUSHI Multiuser Server V2.2, a comprehensive framework for creating and running crossplatform multiuser applications. The SUSHI Multiuser Server provides a flexible and cost-efficient solution to create and run most diverse multiuser projects, like e.g. chats, games or collaboration tools using Flash MX AS1.0 & AS2.0, FlashLite and Java (J2SE/J2ME). SUSHI ships with a free 30 user license to get you started immediately. The new 2.2 release comes with the following new features:

  • New APIs for Macromedia FlashLite and Macromedia Flash MX Actionscript 2.0
  • The possibility to extend the server’s functionality with Actionscript or Java
  • New Tutorials, providing a complete overview in how to develop SUSHI multiuser content with FlashLite, Flash MX AS2.0 and J2SE. * Improved Flash MX APIs with e.g. advanced object serialization and sending Actionscript objects methods

Bezier clipping against all orthogonal axis

After I trying some studies with my AS1 solution I found a lot of misbehavior, while clipping. So I started to develope a completely new solution in AS2. The code provides to clip against any orthogonal axis and furthermore it’s easy to extend in 3D. The hardest issue was to solve a division by zero in a few cases. I’ve tested it for a long time and it seems to be solid for me. Anyway, if you found any bug, please leave a comment.
Continue reading “Bezier clipping against all orthogonal axis”

Tight FPS Solution

PercyPea (well known from flashkit – mario kart thread) sent me an email, where he describes a solution to force the browser plugin to hold the FPS very tight.
I tried it for my tileengine games/supermario. It seems to be true and I really would like you to give me your framerate at this example. It should be about 32/33 and actually firefox makes it fine. PercyPea makes also a thread on flashkit, where you can post your comments.

The idea is to adjust 120 FPS and slow down by running a loop untill the necessary milliseconds are passed. Simple as for example java do.

More information about FDT – Flash Development Tool

powerflasher launched a site for FDT to provide essential information about the new eclipse plugin. A forum is also be presented. FDT will be available at the end of july as a commercial product. The pricing is not fixed yet.

the FDT-Site went online today. You will find release information, a full feature list with the captivate demos and screenshots as well as the latest news including how to find us this week at the FlashForward conference in New York where we have a speakers room.

short review by Chafic Kazoun about FDT

FDT – not just another eclipse plugin !

powerflasher has developed an eclipse plugin for actionscript the last six months and it is currently entering the beta phase. I’m working with fdt for three days now and I can say that this is a killer plugin. Never thought, that any eclipse plugin for actionscript could be that intelligent. It saves a lot of time and writes a lot of code for you automatically. Once you’ve started developing with it, you don’t want to miss it anymore ! Congrats to Nico Zimmermann from powerflasher, who is the man behind fdt.

fdt will be a commercial product, different from asdt, which is still in alpha development and incommensurable. watch the fdt demo videos

Trust eclipse ?

After 3 hours of recovering and decompiling, I’m up to the state, which I left before I switched to eclipse. What was happend ? I don’t know exactly. I have coded my current project (after all 6 days of work) in scite and decided to work in eclipse, where I created a new actionscript project with asdt. I got an error message and after restarting eclipse, all my files are deleted, even the backups. I scanned my computer for any file and found nothing. Kind of heart attack. I could recover 100% of the FLAs, but only one actionscript class. The rest comes back by using a decompiler. Never thought, that I will love this tool.

I cannot say, that this could be happend to any users, but I won’t play with eclipse any longer. Time to make serious thoughts about a CVS and better backup systems. Well, 2 days left for the presentation. Back to work.

Flea World : another nice flashgame

I think tilemap based games are now completely arrived to the flashgamedeveloper.
Here is another nice flashgame in a classic tilemap enviroment. Guide 4 little points by your mouse to the level exit. Some nice extra items are placed in the higher levels.

update:

alex uhlmann realized, that this is not a flashgame at all – its shockwave.
Of course, this had be done in flash anyway. Wonder why not ?

Fleaworld

Four Elements IV Contest

gamedev.net arrange a gamedeveloper contest where macromedia flash is apparently mentioned.

The Four Elements IV contest is about bringing back the spirit of gaming. After years of research, we determined that every successful game requires one of four elements: robots, pirates, ninjas, and zombies. So what better than a contest that combines them all!
Your goal in the Four Elements IV contest is to take at least two of these four game elements and do what you do best: make a game!

Sounds cool. I have to think about.

four elements IV contest

Post your links

Can you satisfy my appetite of links to really nice made flash playgrounds and games ?
My personal feeling is that there are no new sites released the last time (years?) besides the long-established ones. On the other hand my list of blogs increases every day. Possible that the (frontend-) features of Flash7(-) do not entertain anymore. Surely eightball will reactivate our spirit of research. If you have links to mention in the sidebar link groups, do not hesitate to comment this post. Processing, Java, Shockwave files are also welcome.

Methods on primitives

Theodore Patrick posted a comparison of calling a method on primitives, once by themself and by creating an object before.

In my opinion the second line is faster than the first one, cause the interpreter can find the method faster from the object list. According to Theodore Patrick its about the garbage collection. The flashplayer creates an object, when you are not working with an instanced primitive and delete it after calling the method.

//-- Testing by Theodore Patrick

//primitive string
a = "Hello World";

//object string
a = new String("Hello World");

i=10000;
while(i--){
	a.split( " " );
}
trace( getTimer() );

Anyway, what you have to keep in mind is, that you have to instance any primitive by new when you need to call a method heavily. Simple computation like a*b or expressions like a = !b are much slower if you are using objects.

This is found is a similar way by holger kohnen in 2003!

More confusion can be found, when comparing primitive values

//a = true;
a = new Boolean( true);
trace( a === true); // false
//------------------------
//a = 3;
a = new Number( 3 );
trace( a === 3 ); // false

Keep this in mind…

Ess : Processing Sound Library

Krister Olsson from Tree-Axis has released the sound library Ess for processing.

Ess is a sound library that allows sound data to be loaded (AIFF, WAVE, AU, MP3), generated (sine, square, triangle and sawtooth waves, white and pink noise), manipulated (raw or via built-in effects), saved (AIFF, WAVE), analyzed (FFT) or simply played back. Ess is built on JavaSound and as such requires no additional plug-ins, just Java 1.3 or better.

After playing my first waveforms made with Ess I’m thinking of having this in flash. This kind of sound support would give me a new field of activity besides game development. I will definitely play with it the next time.

ess soundlibrary

New Blogdesign

I’ve done several attempts to make my own design for this blog, but I failed. I takes to much time for me as a non-designer to make a nice interface and provide the html/css. After browsing the templates on wordpress.org I found this one and I like it very much. There are some things to fix right now. I’m missing the link panel and I will try to change some colors next time. I installed the wordpress-php-exec-plugin to provide reading the last ten postings on the macromedia aggregator. I could also imagine to provide my experiments embedded in my blog as a page above.

Reinvigorate comes back

Reinvigorate was my favorite website tracking service before to many bugs and disconnections cast a bad light on the whole system. So, after a long time I’ve visited reinvigorate and found, that they are looking for beta testers from May 16th and will cooperate with mediatemple.

Quote:

Before Reinvigorate opens to the public a thorough stress test of the back end system is needed to catch any unexpected anomalies. Conducting a closed beta test allows us to control the load that the servers will receive initially. Once we’re sure all the systems are up to speed Reinvigorate will open to the public.

reinvigorate

I become a tutor in flash gamedevelopment

Now, it’s official – I will work as a tutor on the private academy L4 in berlin. After accompany a class to their intermediate examination in june, i will inherit a new class to teach new stuff while a complete study course. My part is flash actionscript game development and I hope to realize some nice projects with my students. The students also learn game design, real 3D programming and concepting games.

game flyer l4 – german

Sourcecode flashconference stuttgart 05

For everyone who joined the flashconference, especially the rigibody session by mario and me, I’ve uploaded the source code right now. As we said, there is much to do, but its like a short briefing, how rigid body can be simulated for starters. The source code isn’t optimized, so you can follow the instructions much better since we are using a vector class.

It was a very nice session and I hope we can repeat this. thanks to sabine, tibor, david, max and elias to come along with me on this conference. We had a great time ! Greetings to patrick thiel and holger eggert, not to forget frank baumgartner, who was accidentally in stuttgart the same time and joined for some beer in the evening (hehe).

related links:
read also marios blog entry
as2 gamepackage

Compute 3D rotations with localToGlobal

Driving home from the flashconference in stuttgart we had a nice conversation about MovieClip.localToGlobal. I thought it is possible to write a complete 3D camera class with it and it is.

//-- setup
var xClip: MovieClip = createEmptyMovieClip( '0', 0 );
var yClip: MovieClip = createEmptyMovieClip( '1', 1 );

//-- apply angles
	xClip._rotation = xa * 180 / Math.PI;
	yClip._rotation = ya * 180 / Math.PI;

//-- for each point
		pt = points[p];

		pp = { x: pt.y, y: pt.z };

		xClip.localToGlobal( pp );

		tmpy = pp.x;
		pp.x = pt.x;

		yClip.localToGlobal( pp );

		tmpx = pp.x;
		tmpz = pp.y;
//-- end

The trick is to rotate 2 MovieClips representing 2 axis in 3d space. But it has not the performance boost at all, even using the native MovieClip function. A simple sin/cos Matrix is a lot of faster, but the idea was nice :o)

localToGlobal3D.zip (Rotating around 2 Axis)

Processing goes beta 1.0

Processing is a java based application to create fast and solid animation and experiments.

Processing is a programming language and environment for people who want to program images, animation, and sound. It is used by students, artists, designers, architects, researchers, and hobbyists for learning, prototyping, and production.

I did three studies in processing and its real fun to have such a fast and easy to learn language. Hope that flash8 brings us similar possibilities.

Do not register to flasheurope

I didn’t participate the discussion about flasheurope yet, but it seems for now, that the organisers embezzles the money of the registrations. This is at least about 304 Euro each person in the early registration phase. Do not transfer your money to them !
I don’t know if this was planned from the very first. I have spoken with Harold in September and I didn’t noticed any criminal power.

read more:
scar trelles
aral balkan
flashmagazine
martijn de visser

Stop making things complicated

Never noticed such an hysteria in my 6 years flash time. The news bomb today was quite the fusion from adobe and macromedia. Most people are scared, thinking about if they can still work on their familiar applications in future. I say, stop thinking about. Nobody can change the whole world in just one day, but it will change anyway. For me, I’m going to avoid reading postings or articles about this issue. Try to think positive or/and write an email with your suggestions to adobe.

generel info
mike chambers article

rebuilding my flashexperiments

I redesigned my studies and move them to lab.andre-michelle.com.
I was tired of making screenshots and writing all the html for, so there is a light php/js enviroment to manage them in a faster way. Since my monitor turns all colors to red, I decided to make all designs in gray. I like it anyway. Most studies are very old, but I hope to add some new shortly.

Thanks to elias for php support.

There are slight problems on MACs. Safari browsers dublicates the swfs and IE(MAC) dies onClick. Well….well.

Actionscript Highlighter for WordPress

I really like wordpress. Never saw something to install that simple.
I also found a code highlighter plugin, which supports Actionscript.
Now I am using CodeHighlighter.

To show, how it works, here is a little codesnippet I found in a c++ code for getting Array Entries by pairs:

function connectIndices( array: Array ): Void
{
	var i: Number;
	var j: Number;
	var a: Number = array.length;

	for( j = a - 1, i = 0 ; i < a ; j = i, i++ )
	{
		trace( [i,j] );
	}
}
connectIndices([0,1,2]);

//-- Outputs
0,2
1,0
2,1

You need this frequently when connecting points of a polygon as segments. It's currently the fastest solution I found for this problem. ok. Actionscript highlighting works fine :)

speaker at flashconference 2005 stuttgart

I will speak at the flashconference in stuttgart in april 2005 and I’m looking forward to share a session with mario klingemann about rigidbody physics in flash. We both spend a lot of time the last days with them and we hope to get some nice and usefull results untill the conference begin. I will speak furthermore about tilemap-based-games and my current favorite work racing-game-engines in flash.

Hope to see some of you there !

read marios post also

rerere – design – build – fract

I switched to wordpress 1.5 and I’m changing everything from my site step my step from now on. I’m not a designer, so it take hours of testing untill I’m satisfied with my designwork. In blogs case I will leave it by default as long as I will grap an evening to try some new layouts. If you think, there are important links missing on the right panel, just leave me a note.