Sandy3D, C++, Haxe

March 18th, 2010  |  Published in Uncategorized

I’ve been learning Haxe since the last few months. Beside the reason of many Flash guys moved/moving to Haxe because of better performance of compiled swf, I was tempted to try using its C++ target, which runs even faster(at least in theory, in most parts). Its language feature is also very nice, which is quite similar to AS3 but more powerful in many aspects. Check out its feature page if you want to know more.

And because of I need to write some 3D stuff in a project, I tried finding a Haxe 3D engine  that can compiled to C++, but who knows, there wasn’t one. Actually the 3D engines in Haxe are all quite young. There are 3 I found, all targeting only Flash: Sandy3D, originally written in AS, has switched its trunk to Haxe; Away3D, again originally written in AS, now has a Haxe branch inside its SVN in active development; Haxe3D, developed by Nicolas(the creator of Haxe), written in Haxe from the very beginng, seems to be very light-weight but I can’t found much info about it.

So I decide to work on one of them to enable a Haxe C++ 3D engine. Because Sandy3D should be the most complete and stable one(which actually stopped active development…), I chose it.

In the development of it, some issues are related to nme/neash, which are the re-invented cross-platform Haxe version of the Flash API. With the help from Hugh and Niel, project owner of neash and developer of Sandy3D, most of the problems are solved. However as I can see, re-inventing the Flash API is a hard job as consideration of other target is also needed, eg. JS/Canvas. I really hope Adobe can help this.

Currently some very basic demos of Sandy can be compiled to C++ and it shows that, in OpenGL rendering mode, the performance can goes over 300% of the Flash(Haxe, not AS3) version. However in normal rendering mode, the frame rate may actually be reduced if the window size is large. Anyway, I think the performance is quite depend on hardware/OS, also the 3D scene you’re showing.

Thanks for the Sandy3D team, they added me as a committer in their official Google project. And I have just committed the changes to the trunk :) There should be a new release soon if everything is fine.

A note to the ones can’t wait for a release:

1.Install hxcpp, nme, neash from haxelib.

2.Replace contents in neash’s neash/display/IBitmapDrawable.hx to a simple “typedef IBitmapDrawable =
nme.display.IBitmapDrawable;”.

3.To make mouse event work, in neash’s neash/Lib.hx, the code:

// Process pending timers …
neash.Timer.CheckTimers();
// Send frame-enter event
var event = new Event( Event.ENTER_FRAME );
mStage.Broadcast(event);

should be moved to the end of the do-while loop, just before the:

mStage.RenderAll();

4.For mouse event in opengl mode to work, additional fix which required a recompile of nme is needed. I haven’t tried
yet. Now just ingore this…

5.You should be able to use Sandy3D in C++ without the above patches for the next release of nme/neash. But for now, please do it.

BTW, I am also porting ported casalib, which I often use in AS3 development, to Haxe, see casahx.

Tags: , ,

Miream Explained

June 30th, 2009  |  Published in Uncategorized

YouTube Preview Image

Mirage‘s extension, re-work of The Scream, “Miream” is exhibited at Playful Media this year (2009).

I get Miream re-constructed in PhotoSynth too!

Read the rest of this entry »

Tags: , , , , ,

Vector Sound Wave Morphing

May 20th, 2009  |  Published in Uncategorized

This my my final project for the course “Interactivity I”. For this final project, my aim is to explore the vector nature of sound wave while making a tool to let people create their own waveform which can then be saved for other use.

The waveform in the program consists of 10 control points. The first point and the last point are fixed at zero so that the wave can be looped smoothly to form a sound wave. The controls points can be adjusted by dragging or by using keyboard. The points are assigned with keys labeled near them, which are number keys (+shift to move points up instead of down). I recommend using the keyboard as you may adjust multiple points at the same time (which feels like using multitouch surface 8-) ).

Degrafa is used to construct the wave form. I choose to use cubic bezier curve as it is easier for me to implement the algorithm (with the still-in-beta AdvancedCubicBezier which available via SVN).

The 3D cylinder is made by Flash Player 10′s 3D API. It looks quite nice as similar to landscapes.

Sound is synthesized dynamically in real-time (with some delay… okay? ;-) ). If you hear some “clicks” or “pops”, try to export the sound first by clicking on the export button at the bottom-right corner (it will be in wav format, encoded by the WavEncoder from popforge) .

If you hear nothing, you may try to increase the buffer size or use the export function.

http://get.adobe.com/flashplayer

source

Tags: , , , ,