Close Show/hide page

Archive for the ‘flash’ Category

FPO Image Generator

Thursday, November 3rd, 2011
Thumbnail

Is it not the norm for the agency developer of whatever flavor to be asked make more progress than what’s reasonable based on the current status of a given project at any given point in time?

Thus, we continuously look for ways to make more progress with less information, even while increasing the risk of wasted work and unseemly displays of developer angst. At the very least, such experiences make a person receptive to finding a few tricks that might shave off a few extra minutes in one’s pursuit to meet the latest unreasonable deadline.

That having been said, the potential utility of this little tool should require no further explanation.

It has its origins in this capricious tweet from some time last winter.

- Download (uses Adobe AIR)

- Source (Flex project)

Updated FLV Encoder, 3.5x faster with Alchemy

Wednesday, March 30th, 2011
Thumbnail - Click me
Demo: Record and encode FLV’s from webcam in realtime, using Alchemy

Or, download AIR desktop version

This is an update to FLV Encoder which adds an optional Alchemy routine that’s about 3.5x faster, as well as FileStream support for writing directly to a local file using AIR. The library has been architected in such a way that you can use the package while targeting either the browser (no FileStream support) or AIR, and either Flash 9 (no Alchemy support) or Flash 10 – without getting class dependency compiler errors.

I’ve put the package on Github, along with a couple examples (including the one from the last post). The API has changed a little so be sure to also see the example code below. A method updateDurationMetadata() has been added so the video duration does not have to be declared before the video has been created. Also, a bug where the top-most line of pixels was not being written has been fixed.

Realtime encoding demo:

Because of the increased speed of the Alchemy version, it is now viable to encode FLV’s in realtime as the audio and video is being captured, at least within certain limits. Click on the thumbnail above for an online demo that encodes webcam video and audio to a file at 320×240 in real time. If your system is fast enough, you can keep the framerate set to 15FPS with minimal hiccups. The browser-based version must store the entire FLV in memory before saving to disk, but the equivalent AIR version can save its contents directly to a file so that the only limiting factor is disk space. I’m using a dynamic timing and queuing system to keep video and audio in sync which could be the topic of another post.

Updated usage examples:

(more…)

FLV Encoder with Audio

Saturday, March 12th, 2011
Thumbnail - Click me
FlvEncoder demo implementation: Records webcam video and audio to a local file

! Update: See updated FLV Encoder post + code here

A prospective client recently approached me about the possibility of adding audio support to SimpleFlvEncoder. They ultimately decided to go a different direction and so didn’t commission me for that work, but not before my curiosity had already gotten the better of me…

This class makes it possible to create FLV’s in AS3 that contain both video and audio, all on the client-side using the regular browser-based Flash Player. Like with the old version from 2007 (!), video is uncompressed (or rather, just zlib-compressed on a per-frame basis). Audio must be supplied in uncompressed PCM format with either 8 or 16 bits per sample, mono or stereo, and at 11, 22, or 44 KHz. It can also create FLV’s that contain only audio or only video.

Here is a quick-and-hand-wavey example of using the class (Please see the comments in the source for more detail.). (more…)

3D Character Configurator (maqet.com)

Thursday, February 3rd, 2011

Easily the most interesting and innovative commercial project I’ve been involved with over the last period of time has been maqet.com, which is created and run by artist Keith Cottingham.

I’ve been responsible for the site’s configurator component, which allows the user to create customized maquettes by changing their poses and skin. The “maqet” is then created in physical form through a 3D-printing process and delivered to the user.

Most recently, I’ve been working on the drawing tools that allow the user to paint on a two-dimensional canvas that updates the texture of the 3D model in real-time. Soon to be added is a freehand drawing-to-bezier curve tool.

This is a quick-and-dirty video capture of the configurator in action. But mostly, please feel encouraged to visit the site and try it for yourself.

Using NativeProcess in AIR 2 for screencaps

Sunday, April 18th, 2010
Thumbnail

Download installable AIR file
Requires AIR 2 Beta 2 Runtime +
Windows .NET v3.5

My aim here was to get familiar with AIR 2′s new capability of interacting with external processes’ standard streams.

One useful way of learning how to use a new feature is to proceed directly to trying to abuse it.

To that end, this AIR application takes in a fairly continuous stream of uncompressed binary image data from a native process’ standard output. My hope was to get real-time screen capture updates into AIR at a decent frame rate.

Details and source code after the break–

(more…)

More Fun With Texture Projection

Monday, March 22nd, 2010
Thumbnail - Click me

Here I’m just expanding upon the ‘texture extraction’ idea posted before. This version maps video onto 3D objects in a much more direct manner by using ray-casting, like the examples in the last several posts.

Controls:

  • Mouse rotates object
  • Mouse drag moves object
  • [SPACE] remaps the texturing of the 3d object
  • [ENTER] cycles through different 3D primitives
  • [H] shows full list of kludgey hotkey controls

Update with video (8/25/2010):

Although this piece dispenses with the encumbrances of an AR marker or any application-like functionality, I think the method being used here has some potentially interesting uses for an augmented reality-based design application. (Or for more whimsical uses like “upload-your-face” done in 3D). I’ve disabled backface detection, so the imagery gets mapped on all sides of the object rather than just the camera-facing polys, which makes it more visually interesting. Live demo above requires webcam.

Augmented Reality Texture Extraction Experiment

Saturday, September 19th, 2009

This is an AR-based experiment that enables the user to lift textures from real-world objects in live video and apply them onto 3D objects that are overlayed on top of them. Only box primitives are supported here, but the general idea could be extended to other types of 3D primitives or potentially even more complex objects with some clever image compositing and UV mapping.

Thumbnail - Click me
Click for live demo

Click the image on the right to run a live version of the experiment, in case you have the patience to suffer thru the quick-and-dirty hotkey-based UI.

Print the AR marker (PDF | PNG) and point your webcam at it.

It’s running Saqoosha’s (feature-incomplete) Alchemy branch of the FLAR Toolkit, along with Papervision3D.

In the future, it would be nice to figure out is how to apply bilinear filtering to the ‘deperspectivized’ textures. I could also add a feature to export the textured 3d objects into a 3D file format (probably OBJ) if there’s any interest.

Conceptually, this piece builds on these two video projection tests, and is a modest implementation of one of the themes from this post of ideas for augmented reality.

Complex Spotlight Shadow Caster for Papervision3D

Monday, June 8th, 2009
Thumbnail - Click me

Simulates the projection of shadows coming from a spotlight light source onto irregular surfaces. In the supplied example, an animated MD2 model (from Quake 2) is casting a shadow onto the inside of a sphere. Supported parameters include shadow color, alpha, blur, falloff and texture map size, as well as position, rotation and field of view. This evolves out of the projection work posted previously.

Source:

SpotlightShadowCasterManager.as

Usage:

After instantiating the manager –

	_shadowCaster = new SpotlightShadowCasterManager();

– assign one or more DisplayObject3D’s that will block the light from the spotlight:

	_shadowCaster.registerShadowCasterObject(myMesh);

Then register one or more meshes that can have shadows cast upon it with registerShadowCasterObject. As the second argument, you must supply a BitmapMaterial utilized by the mesh on which the manager will draw the shadows. Usually, you’ll want to create a CompositeMaterial, with the BitmapMaterial most likely at the top of the stack. It might look something like this:

	var compositeMaterial = new CompositeMaterial();
	compositeMaterial.addMaterial( new ColorMaterial(0x888888) );
	var mat:BitmapMaterial = new BitmapMaterial( new BitmapData(1,1) );
	// .. the bitmapdata will get overwritten,
	//    but must contain _something_
	var sphere:TriangleMesh3D = new Sphere(compositeMaterial, 1000);

	_shadowCaster.registerShadowReceiverObject(sphere, mat);

To update the shadow textures, call

	_shadowCaster.update();

– probably in your onEnterFrame or onRenderTick function.

That’s enough to get going. From there, it’s just a matter of adjusting the projector’s position and orientation in relation to the objects in your scene with the properties projectorPosition, projectorPitch, and projectorRoll. Check the source for the various configurable properties like blur, alpha, color, etc.

Limitations, bugs:

(more…)

Video Projector Effect, Advanced

Sunday, May 31st, 2009
Thumbnail - Click me

This version handles arbitrary rotations, field of view / focal length, and uses correct math; the previous example faked it somewhat, doing everything basically with 2D math (but why admit to that? :). I found it twice as difficult getting to this point compared to the version posted a few days ago. It turns out that when you want to rotate more than 90 degrees around the x-axis, it’s good to make friends with quaternions, if only superficially.

And it’s interactive this time. By the way, is it not a royal pain to design an interface to control more than two axes in Flash for the web?

There’s still a lot that could be done right / better with this: backface culling (already tried and failed); frustrum culling; per-triangle alpha based on distance and angle to simulate light intensity; per-triangle focus/blur based on distance, maybe (but probably not); a more straightforward way to implement video; shadows… Basically, anything short of building a renderer-inside-a-renderer.

Bonus points for identifying the band to whom the set list pictured in the third image belongs.

Sorry, still no source.

 

Video Projector Effect

Tuesday, May 26th, 2009
Thumbnail - Click me

My general goal for this was to approximate the look of a video projection hitting a ‘non-planar surface’ or otherwise intersecting objects in a 3d scene.

The underlying logic wasn’t too painful. The UV coordinates of each vertex are all that need to be solved for. There’s a linear relationship between the position and orientation of the ‘projector’, and the world space position and UV coordinates of each vertex in the scene — requiring just algebra, which is nice, because that’s about all the math I know. JiglibFlash is being used for the physics action.

In its current implementation, the projector is limited to looking straight down the z-axis. I have a feeling that the most elegant approach for all this would be to extend Camera3D or to piggyback on top of the plumbing of the Papervision framework in some other way (apologies for the mixed metaphor). Should I develop the ‘Projection Manager’ to handle arbitrary projector orientation, I’ll post the source along with an updated example.