Flying along with Away3d

[Sorry – link not working here, Feb 2011 – I’ll take a look when I can]

Managed to squeeze in some time to practice my 3d in Flash. I put together an example of an aeroplane on a flight path. It forms the basis of what might be done if we were to get the job of taking positional data from an aerobatic plane and putting it into Flash for some interactive experience. The company that I was talking to have put sensors in the planes to give back data such as position, speed, rotation in space, G forces etc We might have a go a taking these in live to a Flash based browser system.

This is what the test looked like. flightpathClick to go to the Flash version. Use the arrow keys to zoom in/out or pan left/right. I went on the Away3d talk with Rob Bateman a couple of weeks ago and this example is based heavily on the example code that he gave us; in this case the sky box, mixing textures etc. (I would thoroughly recommend the course, by the way). I spent a while looking around the web to understand the maths behind the Flash beziers. All the paths in Away3d are based on these quadratic splines. Each curve needs to have a start point, end point and a control point. The spline curves that I’m used to are the quadratic type and are a bit easier to manipulate (or at least I have the code from previous projects). I was struggling with the creation of the path, using the format,

flightPath.push(new Number3D(0, -200, 0), new Number3D(200, -200, 0), new Number3D(500, -200, 0));
flightPath.push(new Number3D(500, -200, 0), new Number3D(600, -200, 0), new Number3D(1000, -200, -400));
flightPath.push(new Number3D(1000, -200, 0), new Number3D(1000, -200, 300), new Number3D(1000, -200, 500));

The last point of each curve is the first of the next, but I was definitely finding it hard to fill in control points based on the individual end points. It took me back to de Casteljau curves and drawing cubic splines and I spent a couple of days trying to work out the maths for the Flash quadratic curves. A useful page to help understanding is an old one from Timothée Groleau Eventually, however, I stumbled upon the the smoothing routine built into the Away3d library. Someone has obviously been there before. I must remind Rob to tell people about that. The lines then become easy; just define the end points and the smoothing fills in the rest,

flightPath.push(new Number3D(0, -200, 0), null, new Number3D(500, -200, 0));
flightPath.push(null, null, new Number3D(1000, -200, -400));
flightPath.push(null, null, new Number3D(1000, -200, 500));

The system will figure out to copy the last point from one curve to the first point in the next and will fill in the control point to suit. Phew. This is so much easier. When creating a flight path, just do,

trackPath = new Path(flightPath);

and everything works a treat. The plane is just a quick obj from 3dsMax. I’ll try and put a texture on it, if I get a moment. I need to work out how to do the banking angles next.


~ by ianm on December 18, 2008.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: