HIDIHO!

flash and you and me and you

PIXEL BENDER #5 Pitch-Roll-Yaw

Tags: , , , ,

Pixelbender5
that’s what the world would look like if penguins had won WW2.

after yesterday’s azimuthal projections today is Pitch Roll Yaw day!
woohoo!!
not much to say I’m afraid.
it is a spherical projection where you can tweak the pitch, the roll… and … the yaw.
well, well…
the PRYprojection method of the set of projections done for Mathmap by Peter Gawthrop.
well, well, well…

The Flash plugin is required to view this object.


press ‘s’ to switch the source picture.
you get the distorted picture on top, the original picture underneath and the distorted picture used as a material to map a PV3D sphere at the bottom right.
the important thing to notice here is that the PV3D sphere is NOT MOVING. I intentionnally gave a low number of edges to the sphere so that one can see that it doesn’t move. In fact when you drag / tweak, only the map is being distorted.
ain’t it wonderful ?

unlike the previous article, this one requires a 2:1 ratio to work properly.

now off you go with a ZIP:

no FLA (don’t have a CS4 at hand) but rejoyce ! here’s a snippet:

package  
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.display.Bitmap;
	import flash.display.Shader;
	import flash.display.Sprite;
	import flash.filters.ShaderFilter;
	/**
	 * http://en.nicoptere.net/
	 * @author nicoptere
	 */
	public class BasicPRY extends Sprite
	{
		private var stopped:Boolean = true;
		private var photo:Bitmap;
		[Embed(source = 'equirectangular_pano.jpg')]private var img:Class;
		private var shader:Shader;
		[Embed(source = "PRYprojection.pbj", mimeType = "application/octet-stream")]private var PRY:Class;
		public function BasicPRY() 
		{
			//creates a picture
			photo = new img() as Bitmap;
			addChild( photo );
			//creates the shader
			shader = new Shader(  new PRY() );
			shader.data.imageSize.value = [ photo.width, photo.height ];
			//update
			stage.addEventListener( Event.ENTER_FRAME, applyFilter );
			stage.addEventListener( MouseEvent.CLICK, startStop );	
		}
		private function applyFilter( evt:Event ):void
		{
			if ( stopped ) return;
			var w:Number = stage.stageWidth;
			var h:Number = stage.stageHeight;
			var P:Number = ( h / 2 - mouseY ) / h  * 360;
			var R:Number = 0;
			var Y:Number = ( w / 2 - mouseX ) / w  * 360;
			shader.data.rotation.value = [ P, R, Y ];
			photo.filters = [ new ShaderFilter( shader ) ];
		}
		private function startStop( e:MouseEvent ):void { stopped = ( !stopped ) ? true : false; }
	}
}

should give something like:

The Flash plugin is required to view this object.


click to start/stop.
again: that’s how I got it to work, no warranty you’ll get the same at home.

I found it cool, and somehow it might come in handy.
hope you’ll like it too.
:)

Tags: , , , ,

6 Responses to “PIXEL BENDER #5 Pitch-Roll-Yaw”


  1. Andy Li
    on Jul 28th, 2009
    @ 7:57 pm

    Great work!

    I find the last snippet very interesting if you drag it this way:
    http://www.flickr.com/photos/andy-li/3765718177/


  2. Kris
    on Jul 28th, 2009
    @ 9:11 pm

    Wow, it’s going fast with you and Pixel Bender ;)
    Great stuff!


  3. Dominic
    on Jul 28th, 2009
    @ 9:45 pm

    awsome stuff as usual :)


  4. subblue
    on Jul 28th, 2009
    @ 10:31 pm

    Very nice. It could form a the basis of a very smooth panorama viewer.


  5. sakri
    on Jul 29th, 2009
    @ 7:30 am

    What a preposterous idea! I love it! :D


  6. localToGlobal » Blog Archive » news review -> 31th week of 2009
    on Jul 31st, 2009
    @ 3:48 pm

    [...] PIXEL BENDER #5 Pitch-Roll-Yaw by nicoptere [...]

Leave a Reply

© 2009 HIDIHO!. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.