Mohu™

03. Blog » Simple 3D

Back to Blog
Posted by: Art Comben on Sat 18th Apr 2009 at 7:30pm
Tags: 3D, ActionScript, Labs

A couple of weeks ago a friend of mine showed me some impressive 3d demos of roxik's 3d engine 'sharikura' and after I had wiped the drool off my desk it got me wondering how difficult it would be to write my own 3d engine, rather than relying on Papervision and Away3D.

After trying for several hours to simply position points in 3d space and failing I came across the very simple formula:

scale = focal depth / ( focal depth + z )

so you can just do:

x3d = scale * x; y3d = scale * y; scaleX = scaleY = scale;

now you can position in 3d! Of course this logic doesn't constitute an actual 3d engine; most of the difficult stuff is doing the 3d transformations, applying textures, z sorting etc, but if you were to say, import a list of 3d points from a 3d program like Maya in an animation I suppose you could theoretically use just this logic to display the points in sequence.

As a quick test I created a bunch of points and rotated them in one plane using simple trig and this is the result.

This version is just fp9, next task is learning 3d Matrices in fp10, should have some demos up soon!

There are no comments made so far.