Published June 5, 2012
Tags: flash, geometry
As you might know, I have finally tested my idea to use my old drawTriangles() snippet for projector perspective reconstruction from webcam video. The thing is that, unless you duct-tape your webcam to projector, there is significant difference in perspective between projector and webcam that needs to be compensated in one way or another before you could use webcam to do something like this:
So I borrowed this projector from Denis Radin and wrote a wrapper around webcam and math and shit that is now hosted on github. There you get a sprite that waits for Ctrl+Space to show 4 white arrows for a second, and then you mark those arrows in webcam image. When you’re done, Ctrl+Space again to hide it. Using this “calibration” info, your code gets corresponding region of webcam video automatically transformed into rectangle – the way your projector would see it, if it was a webcam itself. What you do with that image next is up to you; I’ve included flashlight “painting” example above as well as basic edge highlighting example.
Published January 10, 2012
Tags: 3D, geometry, tutorial
A transformation matrix transforms a vector of point coordinates in given frame of reference into coordinates in another one (e.g. from child to parent in our beloved display lists or scene graphs) – Captain Obvious.
Many people think of transformation matrices as impenetrable black boxes filled with random numbers that are impossible to make sense of while fiddling with your application. So this 1st post of the year is my attempt to help those people, by providing as short and simple explanation for those numbers as possible.
P.S. Since matrices transform vectors, you need to know a thing or two about vectors 1st. Continue reading ‘WTF is Transformation Matrix?’
So, I have started cross-engine 3D primitives project at github. Just like as3dmod, it plugs seamlessly into your favorite engine to help you out whenever you feel limited by it. Initial commit supports Alternativa3D 8.12, Away3D 4 Alpha, Minko 1 and contains two spheric primitives: UniformSphere and Globe.
UniformSphere is a mesh built from the spiral of vertices uniformly distributed across the sphere. You have two options here: Rakhmanov formula (default, the spiral joins sphere poles) or Bauer formula (the spiral does not contain poles). This primitive was ported from my 3D metaballs code.
Globe is a mesh that minimizes texture distortions for classic plate carré projection. It does so by placing equilateral triangles along the equator and gradually compressing triangles towards each pole (where high triangle density is actually good property in terms of texture distortions). This primitive was ported from my globe component for FP9, which is now also hosted at github.
I plan to add few more primitives over time, both useful and not really, and maybe more engine proxies if there will be any interest.
Published October 21, 2010
Tags: flash, geometry, wonderfl
Flash player version 10+ native drawTriangles() method is perfect for programming homography (2D transformation that preserves lines) because of its support for UVT data. In general case, however, homography requires solving 8×8 linear equations system, so noone can be arsed to code that. Instead they implement one of two special cases - mapping rectangle to or from quadrilateral. So far, only 1st case was implemented using drawTriangles, while 2nd case was done using filters. Well, no longer so – it turned out, inverting T values in Zeh code was sufficient to make it work backwards:
One interesting thing about this code is that noone really knows exactly how it works :) I didn’t have to study all the math behind Zeh code in order to “invert” it, and Zeh… well, let me quote:
I was lucky enough to get what I wanted working after a good amount of crazy trial and error (and beer)
Published October 17, 2010
Tags: flash, geometry, wonderfl
Right. Today is the day of improving 2×2 marching squares flavor described in wikipedia. A year ago Sakri Rosenstrom found that it is flawed:
As you can see, two checkerboard-like patterns are ambiguous, but the algorithm ignores it, causing random deadlocks as a side effect. So I tried to find some solution to this by posting the problem at wonderfl; and then I just couldn’t wait :) Well, my solution uses 2 to 4 pixels out of 2×2 window and seems to work on crazy images, so I’m happy. But if you suddenly find some better way, let me know.