Too late? Very simple but striking feature request for Flash10 3D!
August 17th, 2008
Oh dear! Two simple additional optional parameters for the following methods would allow you to use native performance and save memory.
Thinking of a simple 3d viewing pipeline, you have something like
- Setup geometrie, textures and lights
- Transform local coordinates to camera space
- Clipping against Frustum
- Project and render
They are a lot of helpers that helps you doing the transformation and projection, especially
- flash.geom.Matrix3D
- flash.geom.Utils3D
I assume that Matrix3D.transformVectors and Utils3d.projectVectors are lightning fast, cause you can pass a Vector (sources and targets) to them. A single(!) Vector could contain the entire 3d world geometry as a list of (x,y,z,x,y,z,x,y,z,x,y,z,...). That is why I am thinking that the Flashplayer is able to execute this well formatted list extremely fast! Much faster than calling the methods to transform several Vector3D objects in a AS3 loop.
So far so good. Where is the problem?
The worst thing from the memorys point of view is the clipping part, cause vertices are added and just valid for a single frame (if the Camera or Geometry is moving). A big case for the garbage collection.
Trying to figure out the best data structure for a 3d engine in Flash, I thought of something like this: All 3d world vertices are stored in a single Vector. Furthermore I would also leave some extra space for the expected vertices in the clipping process (increase the Vector length). With this setup, you reserve memory space and there is no reason for the garbage collection to remove used clipping data. You can easily access the clipped vertices with an offset in the Vector.

Note: The Vector would stay fixedSized. It is on you to allocate enough space for the clipping process when you setup.
But it won't work for now
Imagine you already clipped geometry: Next time you transform the Vector into a new coordinate space, all the clipped data from the last frames will be transformed as well. Two simple optional parameter would change that.
Solution
Matrix3D.transformVectors(vin:Vector, vout:Vector, startIndex: uint, endIndex: uint):void
Utils3D.projectVectors(m:Matrix3D, verts:Vector, projectedVerts:Vector, uvts:Vector, startIndex: uint, endIndex: uint):void
Thats it! That simple!
Now you could force the Flashplayer only to transform the necessary range. You simply overwrite the new clipped data in the Vector every frame, project and draw them. If you know the region, where a 3d-object has allocated its vertices you could use the startIndex and endIndex value to transform it at once.
Too late? I guess so. Too bad I started so late...
Update
I created an official feature request at Adobe bugbase. It would be a great feature!
Please vote. It may not be too late.
Filed under: actionscript
6 Responses to “Too late? Very simple but striking feature request for Flash10 3D!”
-
Benny Says:
August 17th, 2008 at 10:27 pmYes, sounds very useful. Did you put in a request at bugs.adobe.com? If so let us know then we can vote for it.
-
Andre Michelle Says:
August 17th, 2008 at 11:54 pmBenny, you are right. It may not be too late. It sounds quite simple to implement, doesn’t it?
-
drawlogic Says:
August 18th, 2008 at 2:26 amVoted… I think they should run some tests with it at a minimum.
-
Thomas P Says:
August 18th, 2008 at 2:50 pmHello Andre,
indeed, I had the same feeling. As a consequence I unrolled my transformations on my own, which works fine of course, but leads to more code and potentially less speed (?).Nice to see you playing with 3D again ;)
Thomas
-
simppa Says:
August 22nd, 2008 at 5:22 pmSo nice to see you experimenting again :)
-
Recent Links Tagged With "clipping" - JabberTags Says:
October 24th, 2008 at 1:49 pm[...] public links >> clipping Molly? Is that you???? Saved by benoitdegiovani on Fri 24-10-2008 Too late? Very simple but striking feature request for Flash10 3D! Saved by W1ngnu7 on Thu 23-10-2008 Something to think about Saved by thatswhack74 on Sun [...]