Swimming with the Fishes
After some insightful comments on my previous post about rendering vector graphics in 3D I’ve changed the way the fishes are drawn, using the localToGlobal() method instead of projectVectors(). I also animated the fishes by giving them a random velocity in 3D, and pointed them in the direction of their motion using Matrix3D.pointAt() which worked for me this time, unlike last time. Thanks Chris for pointing me in the right direction
flash 10 required
August 17th, 2009 at 2:13 pm
Hi,
I’m working on a 3D API for Flash 10 (http://directflex.net). I am very interested by your example and I would like to know why you use localToGlobal instead of projectVectors.
Thank you very much
August 17th, 2009 at 7:32 pm
Hi
You can do it with projectVectors… http://wonderfl.net/code/36fd6419f66be343e9b0e8860d689f773f1cf7ac
See comments on previous post (now not working very well after change to new revision of flash player 10 fixed bugs I was somehow relying on) :
http://www.dafishinsea.com/blog/2008/11/08/prevent-bitmapification/
Apart from the fact that using a projection derived Matrix 3D object is sometimes buggy ( see comments here http://www.dafishinsea.com/blog/2008/11/09/pointing-at-something-in-3d/ ) it seemed simpler to use localToGlobal() since because each FishSwim is a Sprite, and is positioned correctly in 3D (although not actually in the display list) all I need to do is translate its local x,y values to the global space (ie the flash player is already doing the projection automatically for me). Indeed this is no different than the built in Postcards in Space type of 3D that the flash player does automatically, except that I’m choosing to draw the vector shapes myself to avoid the bitmapification effect noted previously.
Hope this makes sense. For most ‘real’ mesh-based 3D like you’re doing you’d want to use projectVectors + drawTriangles.