I work for a company called The Game Creators here in the UK. We publish all kinds of game development software, so I am very used to being in and around 3D applications, and coding in 3D environments. Image 3D relies on a number of similar facets to traditional 3D programming, such as transformation matrices (for object scaling and rotation), world coordinates and X, Y, Z placement. This is nothing to be scared of if you fancy trying out this package, but my previous experience certainly helped me 'get into' this quicker than I might otherwise have done. It was also what perked my interest in this release in the first place.
This package is PHP 5 only and although the 3DS loader doesn't run under Strict mode, the primitives seem to work without any warnings. I tested it on PHP 5.1 RC1 on a Pentium 4 3GHz Windows XP Pro machine running Apache, and very little else. The reason I state this is because of the world rendering speeds. At the end of the day, the faster your CPU, the quicker you'll get a final result.
Brave New Worlds
You start out by creating a new Image 3D object ($world), and can then set the background colour of your world with the setColor(new Image_3D_Color()) method. It takes standard RGB parameters (0-255 per channel). You must specify a background colour or the package will crash. As yet there is no provision for a background image to be used, but you could create a PNG and set the a background colour to be used as the transparency colour (providing it isn't used elsewhere in your scene).
Lights, Camera, Action
Once you've coloured the background you need to create a light object. This is as simple as calling the createLight method, and passing it an X, Y, Z location. Without a light your objects will render 100% black. Lights can be placed anywhere in the 3D world. Although not specified in the source or the example php files, the world appears to be limited in size to plus/minus 10,000 3D units. While you can place objects and lights beyond this, they will have no influence on your scene. Location X0, Y0, Z0 is the centre of your world, and everything will reside there unless relocated elsewhere. So to create a light that will influence objects from above, setting it around 0, 500, 0 will be directly above your object (depending on the objects scale). 0, -500, 0 will be below the object. To light an object from above, and to the left, you'd set a value such as 250, 250, 0.
Lights appear to be omni in their effect. There is no distance fall-off, shadowing or spotlight behaviour, but hey - this is native PHP code afterall! Once a light has been placed you can colour it using the same method as colouring the world backdrop. Image 3D will blend light colours together when they hit the destination object. So if you locate a blue light to the top of an object and a red light below, you'll get a smooth purple colour graduation where the two hues collide.
createObject
The real meat of the package comes in the form of the createObject method. To this you pass several parameters, depending on which object you want to make. There are 6 primitives included which are: Cube, Cone, Pie Chart, Sphere, 3D Text and a Torus. However you can also create '3DS' objects, Polygons and 3D Maps. Cubes are your standard affair. 8 points in total (12 polygons) and although quite unremarkable, very useful :)
Cones
The Cone object will create a standard cone shape, but you can pass in a detail level which will control how many polygons are used for overall smoothness. A detail of 8 will give you 18 polygons (11 points) in total, and a very rough cone! A detail of 32 is a lot smoother and a detail of 64 extremely smooth. The picture below shows a comparison, top left is a detail level of 8, top right is 16, bottom left is 32, bottom right is 64. I'm using two coloured lights on the scene.
Pie Chart
The Pie Chart is an interesting object. You have to actually create each segment of the pie chart in code by setting the start and end values, plus a detail level similar to the cone and an outside value. The Pie Chart needs to be passed through the Z-Buffer in order to avoid object overlaps in the wrong order, but this is a simple case of specifying the Driver as being 'ZBuffer' rather than GD or SVG (the end result is still a PNG however). The outside value is simply how "large" you want each piece to be, if you were to draw a line from the center of the circle out - how far should it extend? So a value of 150 will create a pie chart of 300 3D units circumfrance. You can apply transformations to each slice of the pie as you create it, in the picture next to this text you can see that I moved the blue slice outward slightly. While 3D Pie Charts look very impressive, they take quite a long time to render, as Image 3D needs to build up each slice of the pie polygon by polygon. The higher the detail level, the slower the render. So you can be sat a while there waiting for the end result. The image to the left took 14 seconds.
Spheres
Spheres are pretty much what you'd expect. A spherical shape made up from triangles. You can specify the radius and the level of detail used. Be very careful here! In the picture below you can see level of detail settings at 2, 4 and 6. The one at 6 took at least half a minute to generate. I attempted one at a level of 8 and Apache went nuts. Image 3D appeared to have been stuck in an iteration loop, trying its best to smooth everything down by a factor of 8, but in the process Apache started eating up memory like it was going out of fashion: 512MB, 1GB, 1.5GB.. at this point I had to kill it off and wait as my page file cleared itself up. Needless to say I never saw the end result. So if you're going to experiment with this object on a live server, watch your detail setting carefully!
3D Text
The 3D Text feature isn't exactly going to get Xara worried. There is no font selection, no control over the smoothness of the letters and the end result looks a little, well.. pixelated :) But it's still fun to see. It works by taking your string, converting each letter into a very small pixel variant, and then building that by letting 1 3D cube represent each pixel. Stack them all together and you get a sort of 3D text effect. The scaling on it seems to go very strange however, as if through a fish-bowl, as if the FOV is whacked out when scaled in the Z dimension. But to all intents and purposes it works.
3DS File Import
Creating cubes and cones is all very well, but let's face it - there is very little practical application for it. The ability to load and view a 3DS file however, now that's a different story. To load a 3DS you create an object just like any other, only you specify 3DS as the type and give it a single parameter which is the path to the 3DS file. It will then load it, parse it and (hopefully) display the object. You can move, scale and rotate it as with any other object, and it picks up the effects from lights.
The 3DS file format can be an esoteric thing. As well as traditional 3D Studio born files, numerous packages over the years have exported to 3DS, some adhering to the standard, some not. So your mileage will vary. Having said that, I was able to get a good variety of objects loaded and displayed without many issues. The 3DS loader uses a chunked method, so the 3DS files need to be in Mesh format and not ASCII. I was pleased to see that Image 3D supports Trimesh objects almost perfectly. For relatively low-poly objects the rendering time isn't too bad. In my scene with 3 ninjas there were 2172 polygons in total, and Image 3D loaded and rendered them all in an 800x600 PNG in just over 2.1 seconds. The loading of the 3DS files took approx. 0.32 seconds, which considering it was reading them all in word by word, is fair enough. It's the actual translation from binary data to polygon that took the time. The end image looked like this (click for a full version):

Keen to see how far I could push Image 3D I threw a larger object at it. This one had 23,056 polygons. It took 4 seconds to parse the file and 11 seconds to render it. Quite a bit longer than the previous object, but still acceptable. Considering the amount of computations going on here, I was very impressed. Here is the result of this render:
Happy, but not yet satisfied, I threw another object at it. This one was quite some monster with 36,887 polygons. But it managed, taking 6.4 seconds to load the file and 38.2 seconds to render it. I wonder what the limit is? Probably one defined by PHPs script memory allocation more than anything else!
Obviously you can forget having any textures your objects might contain being displayed. Same goes for animations, or accessing frames within an animation sequence. But I feel this is no downfall on the part of Image 3D.
The Document Contains No Data
Ok, this is an error you'll get quite a lot while playing with Image 3D! It happens when parsing or rendering an object, and I guess something borks inside and exits out. The end result is nothing gets sent to your browser, so it errors. But this package is in alpha, so it's fair enough. It doesn't happen that often, but I found that reloading the script with no modificatons was usually enough to resolve it.
Future Additions
I'd really like to see this package mature. Being able to extract the image it has created directly into PHP (i.e. having access to the GD image resource after it has drawn on it) would be very useful, and I would hope not too difficult to implement. Also layering 3D objects on-top of existing bitmaps could be fun, and if done via GD, not that complex. You can create your own primitives easily, they just insert into the Paintable / Object folder. Once inside, you can call them immediately via the createObject function.
The speed of rendering 3DS files isn't bad, but is a tad on the slow side even for local use. There are also issues with scale - depending on how the 3DS file was exported sometimes it'll appear as nothing but a dot in the middle of your PNG, and sometimes it'll fill the whole image. You have to tweak the scale values to get the best result. Most of the time you'd want to change the rotation values as well, often the orientation of an object can be totally out. But if you set up your 3DS files correctly in the first place, you can avoid both of these issues.
Depending on where the major slow point of the process is, I would like to be able to save out the world data into a format that Image 3D could load in and use much quicker than having to render it again every time. If of course the delay is in building the object up via GD then there is probably very little that can be done about it, even so hopefully it's something the developers could work on? For low-poly objects you could easily use this to create thumbnails in real-time, with full rotational control and feedback.
Well worth having a play with! You can grab the package from here: http://pear.php.net/package/Image_3D. All they need now is some decent documentation! (but then don't nearly all Pear packages suffer from this?!)
I was stumbling around the cool happenings on the internet (and I saw "cool" because I found Rasmus Lerdorf's personal site...original creator of PHP/FI, which came to be known as PHP in later revision...
Tracked: Feb 23, 03:19