Promethe’s Blog Web, RIAs and chocolate spaghettis…

9Apr/1016

Apple makes its own compiler… illegal!


"3.3.1 … Applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine, and only code written in C, C++, and Objective-C may compile and directly link against the Documented APIs (e.g., Applications that link to Documented APIs through an intermediary translation or compatibility layer or tool are prohibited)."

This is the very bad (sad) addition (restriction) to the iPhone developers program everyone is talking about right now. And I feel very concerned about this... and now everyone is wondering if software like the Flash-to-iPhone packager, Mono or Unity are definitely banned from the iPhone programming tool-chain.

I never talked about it before, but Aerys is working on a project targeting the iPhone and the iPad (among a lot of other platforms). And this very project is leveraged by some home-made code generation tool. Therefore, we are very scared of what this kind of restrictions might imply for our business.

But as scary as this statement might look at first, it is actually even funnier when you understand it makes any iPhone/iPad application illegal. And it gets even better because even Apple's standard tool-chain finds itself... prohibited!

The reason is very simple: Objective-C, C or C++ never "link" to any library providing the Documented iPhone APIs. Objective-C, C or C++ actually never link to anything. When compiling your code, the compiler creates an intermediary representation of your program in order to make it easier to (eventually cross-)compile it. In the case of GCC, the compiler used to build such applications, those intermediary languages are:

(Source: Wikipedia - Intermediate language)

This very intermediate representation is built before the symbols resolution and before any linking is done. Thus, linking against the "Documented APIs" has always been done "through an intermediary translation or compatibility layer". And it won't change anytime soon! But, still, I wish good luck to Apple's engineers in their future work to patch GCC and make it "compliant" (sic!).

To me, it is the most obvious sign that Apple doesn't care about its developers (but I was still pretty thrilled to eventually become one of them about a few days ago...). Not because it bannishes any interesting cross-compiling software venture. And not even because any iPhone/iPad developper who knows about other platforms openness and ease of production will feel sick just by reading this kind of restrictions.

No. To me, Apple is losing it all simply because this kind of idiocy can only be written by someone who doesn't have a clue about how a computer/compiler works! Apple started building casual devices and ends up targeting casual developers. Could this be the first sign of how (so called) intuitiveness - when enforced by completely hermeticly closed devices - finally makes people... dumber? So now the real question is "What happens when your developers program EULA is written by a marketing control-freak moron?".

PS : The title of this article was desgined to attract the eye. It is my interpretation of the latest Apple's developers program EULA additions and I might be completely off or wrong. Anyway, the doubt and worry caused by this very fuzzy and unclear addition stands as a major issue for all the companies and developers targeting the iPhone and iPad platforms.

1Apr/100

AS3 Monitor released on Google Code

I just released a small but useful piece of software on Google Code: my ActionScript 3.0 Monitor class. This little class makes it possible to watch the properties of any object directly on the stage.

It was inspired by Mr. Doob's Stats class. But my Monitor class is entirely dynamic and you can watch any property of any object.

The following simple (and useless?) code sample show how to track the (x, y) position of the mouse cursor on the stage:

package
{
  import aerys.monitor.Monitor;
 
  import flash.display.Sprite;
 
  public class MonitorDemo extends Sprite
  {
    public function MonitorDemo()
    {
      var monitor : Monitor	= new Monitor(30);
 
      monitor.watch(stage, "mouseX", 0xff0000, 1. / stage.stageWidth);
      monitor.watch(stage, "mouseY", 0x008800, 1. / stage.stageHeight);
      addChild(monitor);
    }
  }
}

And here is the result:

Here is another simple use case: tracking the (x, y, z) rotation of a 3D camera (the actual application is available on the official Aerys website):

The code is open source and available on Google Code. Comments and suggestions would be greatly appreciated!

31Mar/106

Build Flash 10.1 applications with Flex Builder 3 or Flash Builder 4

It was one of my first posts on this blog: Work with Flash 10 in Flex Builder 3. This post has proven to be very helpful and is still read a lot every day!

As Flash 10.1 is currently accessible in beta. I thought it would be nice to have some tutorial to build applications targeting this new version of the player to take advantage of the new APIs (like multitouch for example). This tutorial will provide a generic solution to enable the creation of Flash 10.1 capable projects in both Flex Builder 3 and Flash Builder 4.

Step 0: Download the latest Flex SDK

This step is not mandatory and should not be necessary if you already have a Flash 10 capable Flex SDK. Still, keeping your SDK up to date is always a good thing and this tutorial might be a good opportunity to do it!

As the Flex 4 SDK was just released a few days ago, I recommend you download, install and use it for the rest of the tutorial.

In the rest of the tutorial, $SDK_DIR will designate the path to the Flex SDK you want to use (ie. "C:\Program Files\Adobe\Flash Builder 4\sdks\4.0.0" for example).

Step 1: Download and install playerglobal.swc

Step 2 : Setup your Flash 10.1 project

  • Open Flash Builder 4
  • Create a new Flash/Flex project or open the project you want to setup
  • Open the properties of your project (right click on your project in the Package Explorer > Properties)
  • If you are using Flash Builder 4, go to the "ActionScript compiler" panel and in the "Adobe Flash Player options" section, check "Use a specific version" and enter 10.1.0 as the version number

  • If you are using Flex Builder 3, go to the "Flex compiler" panel and in the "Additional compiler arguments" text input add "-target-player=10.1.0"
  • Click "OK"

Step 3 : Build your project

Press F11 to build and run your project. Everything should work fine and you should now be able to use the new Flash 10.1 APIs!

You can now create as much projects as you want and you just have to do Step 2 to make sure it will target Flash 10.1!

22Mar/100

Flash Builder 4 and Flex 4 SDK released

Flash Builder 4 and the Flex 4 SDK have just been both released! You can read more about the new features on the official release blog post:

Flex 4 SDK and Flash Builder 4 final releases are here...

And here come the download pages:

21Mar/103

Here we are!

This has been my project for the last two years: Aerys.

That's the name of the company I founded this very month with two friends, Warren Seine and François Rouge. And what business would that be, you will ask me? (thank you for asking!)

For now, our main activity will be to develop and provide creative and innovative solutions targeting rich multimedia platforms. This includes the 3D libary I've been working on lately and some other software I will soon speak about.

Filed under: Uncategorized 3 Comments
17Mar/102

Speaking at the french Flash user group

... or at least that's the plan! The next meeting of the Tonton Flexers - the closest thing to a "french Flash user group" - is taking place the 23rd of this March and I'll be there to present my 3D library.

I would be more than happy to talk about the software, the way I built it and the technical choices that drove its development. I will  also try to emphasize what makes this library different through a few demonstrations.

Depending on the agenda of one of my co-worker, we might also present a very cool piece of software I never spoke about!

You can read more about the event here (in french).

3Feb/102

Google Maps 3D Overlay

The Flash Google Maps API offers what they call a 3D map. It's nothing more than a component that enables a perspective view of a classic 2D map with the associated controls. Here is how it works:

  1. The 3D view is engine independant and uses Flash 10 3D maths and "drawTriangles" method if available
  2. The API provides everything one needs to integrate 3D graphics as an overlay using the library of its choice
  3. It works just the same as the good old 2D Google Maps API

The first point is very important. It ensures the library is lightweight and does not include any third party software you wouldn't want to use.

The second is what makes the magic possible: the API exposes the viewport and camera data and provides methods to convert latitude/longitude into 3D world coordinates. With a little math and a few hours of debugging it is then easy to wrap it with the 3D engine of your choice.

The Experiment

You can use CTRL + mouse drag or SHIFT + mouse drag to look around.

The Code

You might want to read the official Google Maps Flash API documentation first, including the dedicated 3D maps section.

The Viewport

The Google Maps API provides the viewport width and height and the focal length. I use the field-of-view instead of the focal length but there is a simple formula to convert from one to the other:

var fieldOfView : Number = 2. * Math.atan(viewportWidth / (2. * focalLength));

Another issue is to find proper values for the near and far clipping planes. I chose 0.000001 for the near plane and 0.2 for the far plane. Those values are extremely low and might cause floating point inconsistencies. The best thing to do would be to scale the whole scene to be able to use reasonable clipping values. Maybe for a later version! This problem does not seem to affect the experiment though...
The following function presents how to get the relevant viewport values from the Google Maps API:

public function buildViewport(myMap : Map3D) : void
{
	var g : TransformationGeometry = myMap.camera.getTransformationGeometry();
	var width : Number = g.viewportSize.x;
	var height : Number = g.viewportSize.y;
	var fieldOfView : Number = 2. * Math.atan(g.viewportSize.y / (2. * g.focalLength));
 
	// build viewport...
}
The Camera

The following function retrieves the camera position and look-at vectors from the Google Maps API:

public function buildCamera(myMap : Map3D) : void
{
	var cam : ICamera = myMap.camera;
	var mapCenter : Point = cam.latLngToWorld(cam.center);
	var g : TransformationGeometry = cam.getTransformationGeometry();
	var pos : Point3D = g.cameraPosition;
	var zAxis : Point3D = g.cameraZAxis;
	var yaw : Number = cam.attitude.yaw * (Math.PI / 180.);
	var lookAt : Vector3D = new Vector3D();
	var eye : Vector3D = new Vector3D();
 
	eye.x = pos.x - 128;
	eye.y = pos.z;
	eye.z = 128 - pos.y;
 
	if (!zAxis.x && !zAxis.y)
	{
		lookAt.x = eye.x + EPSILON * Math.sin(yaw);
		lookAt.z = eye.z + EPSILON * Math.cos(yaw);
	}
	else
	{
		lookAt.x = eye.x - zAxis.x;
		lookAt.z = eye.z + zAxis.y;
	}
 
	lookAt.y = eye.y - zAxis.z;
 
	// build camera using eye position, look-at and Vector3D.Y_AXIS as the up vector
}

I prefer computing the eye position and look-at vectors and using them to create the transform matrix rather than just creating the matrix directly. This way, you can expose the actual camera parameters (even if in read-only) and still use the transform matrix to do the math.

The Scene

The last step is to make it possible to position 3D objects on the map. What you actually want to do is to be able to add objects specifying their latitude/longitude instead of their actual (x, y, z) coordinates. Then again, the Google Maps API does it just fine:

public function computePosition(myLatitude : Number, myLongitude : Number) : Vector3D
{
	var pos : Point = _map.camera.latLngToWorld(new LatLng(myLatitude, myLongitude));
 
	return new Vector3D(pos.x - 128., 0., 128. - pos.y);
}

Know Issues

As said previously, the extremely low far and near clipping plane values might introduce float point inconsistencies. Therefore, some clipping glitches might appear and frustum culling is performed only on the far clipping plane.

Credits

Credits goes to Marc Fahmi for the low-polygon 3D model of the Eiffel Tower.

Filed under: Flash, Snippets 2 Comments
18Dec/093

BSP Tree Optimization in Flash 10

Binary Space Partitioning trees are the new trend to cure the lack of Z-Buffer when building 3D applications for the Flash Platform. Thus, building a fast and robust BSP system is one of the key for a successful 3D API targeting Flash. I won't discuss BSP theory here because it's very easy to find good documentation. I'll rather let you play with a little experiment and discuss what it actually features...

The Experiment

BSP tree optimization experiment

BSP tree optimization experiment

What It Does...

  • load a *.3DS file and use it as a mesh
  • load a *.PNG texture and use it as a material
  • display the mesh using a BSP tree

The vertical slider enables you to play with what I called the BSP precision. This value represents the thickness of the partition planes used to build the BSP tree: the lower the precision, the better the final rendering. When the precision is higher, the BSP is less deep and a lot faster to render. But if the precision is too high, some artifacts occur and the rendering is corrupted. The idea is to find the best rendering quality/number of artifacts ratio.

When checked , the "Optimized BSP" checkbox enables the build BSP where each partition plane will be chosen carefully. This very choice is based on the number of polygons that would have to be cut if that plane was ever used as a partition plane. This way, the final BSP tree features a lot less polygons and is faster to walk through/render.

And the "Wireframe" checkbox speaks for itself I guess... Anyway, wireframe rendering makes it possible to see how the BSP tree actually divides more or less polygons depending on the settings you chose.

And The Good News Is...

Keep an eye on the Triangles Per Second counter (TPS, on the top-left corner of the screen) as you play with the precision slider/optimization checkbox. Changing those values of the BSP tree has a huge impact on the amount of rendered polygons (and the overall performances of course!).

Filed under: Flash 3 Comments
17Dec/090

AIR 2.0 HTTP Web Server

AIR 2.0 brings a lot of new features. Among them is the new ServerSocket class. The Socket class exists since Flash 9 and enabled a lot of new client/server applications. But it has always been limited to client side sockets as long as AIR (and the Flash Platform as a whole for that matter) is concerned. Therefor, this new server socket feature makes it possible to build actual server software using AIR!

Rich of this new and incredible ability, Christophe Coenraets posted a small but yet very powerful code snippet to build an HTTP web server using AIR 2.0!

16Dec/090

Voice Recognition in Flash 10

The following video demonstrates a new "voice gesture" library targeting the Flash Platform. As you might have guessed, those "voice gestures" are pretty much like "mouse gestures" but they are activated by voice only. I guess it uses some kind of voice learning/recognition algorithm. I can't stress enough how trhilled I am to see this kind of new and powerful software coming to Flash. This enables a whole new kind of usages and applications...


Voice Gesture from didier.brun on Vimeo.