Aug/080
3D Engine V0.3
Made quite some progress lately. Got the constructSphere function up quite quickly, the UV mapping and copyPixels took a little longer but in the end really paid off:
Currently the UV mapping only works with spheres, but it will be easy to implement it into other models later. I’m quite pleased already with the performance; the demo above renders 529 polygons with a high resolution texture (1350×675 pixels). However there is still room for lots of improvement;
Bugfixes:
- Added function moveObject, wich if drawing faces should be used instead of moveGroup. (Otherwise the midPoints don’t move and thus making the z-sorting work incorrectly.)
- Reversed the y transformation in the process of making 2D points from 3D coordinates, because in the flash coordinate system the y axis is reversed
Known bugs:
- For some reason transparent bitmaps don’t work yet, I’ll have to look into the different copyPixels and beginBitmapFill functions for this one…
- For some reason looking down from above gives a distorted and unreallistic view, I’m not sure where this problem came from.
- Faces that have one, two or three points behind the camera are rendered ackwardly, but this will be fixed in the next version with view frustum culling.
- The backface culling function is not perfect yet, the top of the sphere shows about 3 faces beeing culled that shouldn’t be culled.
- The edges of UV faces are visible sometimes, this is due to the repeat parameter I use to create parts of the bitmap fill might be able to fix this with a bit of a different matrix algorithm.
New features:
- Textures from images
- The function moveObject to move objects
- A debug mode
- The sphere primitive
- UV mapping for spheres
- Backface culling
Upcoming features:
- Phong shading
- More primitives
- View frustum culling
- Lighting and shadows
- Performance improvements
- Rotate object functions
- And a few more…
The navigation is still somewhat ackward for the sake of simplicity;
- W,S let you move along the z-axis
- A,D let you move along the x-axis
- Numpad 2 and 8 let you move along the y-axis
- Left and right arrow keys let you rotate left and right
- Up and down arrow keys let you rotate up and down
Thanks to Senocular and Lifeztream for these two classes;
Senocular’s keyObject class – for detecting multiple keyboard presses at once
Lifeztream’s FPS class – for displaying the 3D engine performance