Posts Tagged ‘Papervision’

pv3d.org AR contest submission one

Tuesday, April 14th, 2009
Its still a work in progress, going to add further functionality. playlist, ID3 tags, other visualizations.
i wanted to make something with AR that was not only cool to look at but was some what functional. The song is courtesy of http://www.ModdJobs.com and mc chris, the rest of the album is available there too.
FREE DOWNLOAD!
Check it out.
http://www.ModdJobs.com

 Demo it works, yay.

ARMP3Player

Heres the source, demo swf’s, fla’s, DAE, java applett, short description, and prolly a bunch of stuff you dont need.

submissionexamples.zip Both submissions one zip. virus scanned right before upload.

Song

OC.mp3

DAE

PLP.DAE

credits where credit is due.
the spectrum analysis came directly from here. lee was the beginning of all my flash happieness, i owe alot to him.
http://www.gotoandlearn.com/play?id=63

the text is right out of johns papervision twitter tutorial(wich i still get an import error off)
http://pv3d.org/2009/03/31/twitter-papervision3d-using-tweetr/

the flar manager source was a combo of marcs tutorial and erics examples.
http://words.transmote.com/wp/20090328/flarmanager-v03/
http://www.marcpelland.com/2009/03/26/getting-started-with-augmented-reality-flartoolkit/

of course i got started in AR here
http://pv3d.org/2009/03/12/augmented-reality-flartoolkit-demo-reel/
http://saqoosha.net/en

the visualizer thing is loosely based on johns sound analysis project
http://pv3d.org/2008/12/06/papervision3d-sound-spectrum/

ive never considered my self a very creative programmer but more of a very selective coppier.

heres the mess that got me here. main time line in flash. i’ll put the song and DAE an other stuff up soon.

import com.transmote.flar.FLARManager;
import com.transmote.flar.marker.FLARMarkerEvent;
import com.transmote.flar.pattern.FLARPattern;
import com.transmote.flar.source.FLARCameraSource;
import com.transmote.utils.time.FramerateDisplay;
import com.transmote.flar.marker.FLARMarker;
import com.transmote.flar.utils.FLARPVGeomUtils;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.PixelSnapping;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.utils.ByteArray;
import flash.media.Camera;
import flash.media.Video;
import flash.media.Sound;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.events.Event;
import flash.utils.Dictionary;
import org.papervision3d.view.stats.StatsView;
import org.libspark.flartoolkit.core.param.FLARParam;
import org.libspark.flartoolkit.pv3d.FLARCamera3D;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.render.LazyRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.materials.BitmapAssetMaterial;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.Letter3DMaterial;
import org.papervision3d.typography.Text3D;
import org.papervision3d.typography.fonts.HelveticaBold;

import flash.display.Sprite;
import flash.events.Event;

 /**
  * standard FLARToolkit Papervision3D example, with our friends the Cubes.
  * code is borrowed heavily from Saqoosha, Mikko Haapoja, and Squidder.
  * http://saqoosha.net/en/flartoolkit/start-up-guide/
  * http://www.mikkoh.com/blog/?p=182
  * http://www.squidder.com/2009/03/06/flar-how-to-multiple-instances-of-multiple-markers/#more-285
  *
  * @author Eric Socolofsky
  * @url  http://transmote.com/flar
  */
//   var statsView:StatsView = new StatsView(); addChild(statsView);
   var stats:Boolean = true;  // display the stats view
   var CUBE_SIZE:Number=40;
  var viewport3D:Viewport3D;
  var camera3D:FLARCamera3D;
  var scene3D:Scene3D;
  var renderEngine:LazyRenderEngine;
  var pointLight3D:PointLight3D;

  var CAMERA_PARAMS_PATH:String = "../resources/flar/FLARparams.dat";
  var PATTERN_PATH:String = "../resources/flar/patterns/pat16/";
  var PATTERN_RESOLUTION:uint = 16;

  var patterns:Vector.;
  var _param:FLARParam;
  var flarManager:FLARManager;
  var markersByPatternId:Vector.>;// FLARMarkers, arranged by patternId
  var containersByMarker:Dictionary;// Cube containers, hashed by corresponding FLARMarker

  var plane:Plane;
  var s:Sound = new Sound(new URLRequest("OC.mp3"));
  var pointArray:Array = new Array();
  var ba:ByteArray = new ByteArray();
  var active:Boolean;
  var viz:Boolean;
  active = false;
  viz = false;
  var sc:SoundChannel;
  var pos:Number = new Number(0);
  var text3d:Text3D;
  var text3dtwo:Text3D;
  var text3dOther:Text3D;

  var bmd:BitmapData = new BitmapData(512, 450, true, 0x000000);
  var bm:Bitmap = new Bitmap(bmd);

  var spOne:Sprite = new Sprite();
  //addChild(spOne);

  var blur:BlurFilter = new BlurFilter(10,10,3);

  var colorMatrix:ColorMatrixFilter = new ColorMatrixFilter([
    1, 0, 0, 0, 0,
    0, 1, 0, 0, 0,
    0, 0, 20, 0, 0,
    0, 0, 0, 50, 0
  ]);

init();
////////////////////////
//Sound Movie material
////////////////////////
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill( 0xFF0000 );
mc.graphics.drawRect( 0, 0, 512, 450 );
mc.graphics.endFill();
mc.addChild(bm);
mc.addChild(spOne);
var mmTransparent:Boolean = false;
var mmAnimated:Boolean = true;
var mmPrecise:Boolean = true;
var mm:MovieMaterial = new MovieMaterial( mc, mmTransparent, mmAnimated, mmPrecise );

  function init () :void {
   // build list of FLARPatterns for FLARToolkit to detect
   patterns = new Vector.();
   patterns.push(new FLARPattern(PATTERN_PATH+"patt012.pat", PATTERN_RESOLUTION));
   patterns.push(new FLARPattern(PATTERN_PATH+"patt004.pat", PATTERN_RESOLUTION));
   patterns.push(new FLARPattern(PATTERN_PATH+"patt002.pat", PATTERN_RESOLUTION));
   patterns.push(new FLARPattern(PATTERN_PATH+"patt010.pat", PATTERN_RESOLUTION));
   patterns.push(new FLARPattern(PATTERN_PATH+"patt016.pat", PATTERN_RESOLUTION));

   // use Camera (default)
   flarManager = new FLARManager(CAMERA_PARAMS_PATH, patterns);
   addChild(FLARCameraSource(flarManager.flarSource));

   // begin listening for FLARMarkerEvents
   flarManager.addEventListener(FLARMarkerEvent.MARKER_ADDED, onMarkerAdded);
   flarManager.addEventListener(FLARMarkerEvent.MARKER_UPDATED, onMarkerUpdated);
   flarManager.addEventListener(FLARMarkerEvent.MARKER_REMOVED, onMarkerRemoved);

   var framerateDisplay:FramerateDisplay = new FramerateDisplay();
   addChild(framerateDisplay);

   flarManager.addEventListener(Event.INIT, onFlarManagerInited);
  }

  function onFlarManagerInited (evt:Event) :void {
   trace("FLAR Manager Inited");
   initPapervisionEnvironment(flarManager.cameraParams, stage.stageWidth, stage.stageHeight);
   var numPatterns:uint = new uint(patterns.length);
   initTwo(numPatterns);
  }

  function addMarker(marker:FLARMarker):void {
   // store marker
   var markerList:Vector.=markersByPatternId[marker.patternId];
   markerList.push(marker);
   // create a new thing, and place it inside a container (DisplayObject3D) for manipulation
   var container:DisplayObject3D = new DisplayObject3D();
   if (marker.patternId == 0){
   //Spectrum Analisys///////////////////////////
   for(var i:uint=0; i<64; i++)
    {
     //var saHolder:DisplayObject3D;
     var randomColor:Number = Math.random() * 0xffffff;
     var shape:Shape = new Shape();
     with(shape)
      {
       graphics.beginFill(randomColor);
       graphics.drawRect(0, 0, 2, 2);
       graphics.endFill();
      }
     var material:MovieMaterial = new MovieMaterial(shape);
     //animated needs to be true to tween the color
     material.animated = true;
     material.doubleSided = true;
     material.interactive = false;
     var plane:Plane = new Plane(material, 2, 2);
     var lineLeangth:Number = new Number(175);
     var xLoc:Number = new Number();
     xLoc = (lineLeangth/-2)+(i*3.5);
     plane.x = xLoc;
     plane.y = 0;
     plane.z = 120;
     plane.rotationX = 90;
     plane.rotationZ = 45;
     plane.name = "plane"+i;
     container.addChild(plane);
     pointArray[i] = container.getChildByName("plane"+i);

   }
    viz = true;
    trace("object one");
   }else if(marker.patternId == 1){
    //Text
    var msg:String;
    msg = "Splengy.com AR MP3 player";
    var letterMaterial:Letter3DMaterial = new Letter3DMaterial(0xcc0000);
    letterMaterial.doubleSided = true;
    text3d = new Text3D(msg, new HelveticaBold(), letterMaterial);
    text3d.scaleX = .25;
    text3d.scaleY = .25;
    text3d.scaleZ = .25;
    text3d.rotationX = 90;
    text3d.z = 30;
    container.addChild(text3d);

    //PLP extrusion
    var PLP:DAE;
    var cm:ColorMaterial;
    var holder:DisplayObject3D;
    var lMaterialsList:MaterialsList = new MaterialsList();
    lMaterialsList.addMaterial ( mm, "ERTransparent44");
   //DAE
    PLP = new DAE();
    PLP.load("PLP.dae", lMaterialsList);

    holder = new DisplayObject3D();
    holder.addChild(PLP);

    holder.rotationX = 90;
   //holder.rotationY = 45
    holder.scaleX = 15;
    holder.scaleY = 15;
    holder.scaleZ = 20;
    holder.z = 80;
    container.addChild(holder);
   if (active == false){
    sc = s.play(pos, 1000);
   }

    trace("object two");
   }else if(marker.patternId == 2){
        //Text
    var msgOther:String;
    msgOther = "Music by ModdJobs.com and mc chris, free download";
    var letterMaterialOther:Letter3DMaterial = new Letter3DMaterial(0xcc0000);
    letterMaterialOther.doubleSided = true;
    text3dOther = new Text3D(msgOther, new HelveticaBold(), letterMaterialOther);
    text3dOther.scaleX = .25;
    text3dOther.scaleY = .25;
    text3dOther.scaleZ = .25;
    text3dOther.rotationX = 90;
    text3dOther.z = 30;
    container.addChild(text3dOther);
    trace("object three");
   }else if(marker.patternId == 3){
    //Text
    var msgtwo:String;
    msgtwo = "I'm going to scream, yay scream";
    var letterMaterialtwo:Letter3DMaterial = new Letter3DMaterial(0xcc0000);
    letterMaterialtwo.doubleSided = true;
    text3dtwo = new Text3D(msgtwo, new HelveticaBold(), letterMaterialtwo);
    text3dtwo.scaleX = .25;
    text3dtwo.scaleY = .25;
    text3dtwo.scaleZ = .25;
    text3dtwo.rotationX = 90;
    text3dtwo.z = 30;
    container.addChild(text3dtwo);
    trace("object four");
   }else if(marker.patternId == 4){
    trace("object five");
   }

   // associate container with corresponding marker
   scene3D.addChild(container);
   containersByMarker[marker]=container;
  }

  function removeMarker(marker:FLARMarker):void {
   // find and remove marker
   var markerList:Vector.=markersByPatternId[marker.patternId];
   var markerIndex:uint=markerList.indexOf(marker);
   if (markerIndex!=-1) {
    markerList.splice(markerIndex, 1);
   }
   if (marker.patternId == 0){
    viz = false;
   }else if(marker.patternId == 1){
    active = false;
    pos = sc.position;
    sc.stop();
   }

   // find and remove corresponding container
   var container:DisplayObject3D=containersByMarker[marker];
   if (container) {
    scene3D.removeChild(container);
   }
   delete containersByMarker[marker];
  }

  function initTwo(numPatterns:uint):void {
   // set up lists (Vectors) of FLARMarkers, arranged by patternId
   markersByPatternId=new Vector.>(numPatterns,true);
   while (numPatterns--) {
    markersByPatternId[numPatterns] = new Vector.();
   }

   // prepare hashtable for associating Cube containers with FLARMarkers
   containersByMarker=new Dictionary(true);
  }

  function initPapervisionEnvironment(cameraParams:FLARParam, viewportWidth:Number, viewportHeight:Number):void {
   scene3D = new Scene3D();
   camera3D=new FLARCamera3D(cameraParams);

   viewport3D=new Viewport3D(viewportWidth,viewportHeight, true, true, true, true);
   addChild(viewport3D);

   renderEngine=new LazyRenderEngine(scene3D,camera3D,viewport3D);

   pointLight3D = new PointLight3D();
   pointLight3D.x=1000;
   pointLight3D.y=1000;
   pointLight3D.z=-1000;

   addEventListener(Event.ENTER_FRAME, onEnterFrame);
  }

  function onEnterFrame(evt:Event):void {
   updateCubes();
//   text3d.rotationX= text3d.rotationX +5;
   SoundMixer.computeSpectrum(ba, false, 2);
   if (viz == true){
    for(var i:uint=0; i<256; i++)
    {
     var j:uint = new uint(i/4);
     var num:Number = -ba.readFloat()*100+5;
     pointArray[j].scaleY = num;
     i = i+1;
    }
   }
   renderEngine.render();
  }

  function updateCubes():void {
   // update all Cube containers according to the transformation matrix in their associated FLARMarkers
   var i:int=markersByPatternId.length;
   var markerList:Vector.;
   var marker:FLARMarker;
   var container:DisplayObject3D;
   var j:int;
   while (i--) {
    markerList=markersByPatternId[i];
    j=markerList.length;
    while (j--) {
     marker=markerList[j];
     container=containersByMarker[marker];
     container.transform=FLARPVGeomUtils.convertFLARMatrixToPVMatrix(marker.transformMatrix);
    }
   }
  }

  function onMarkerAdded (evt:FLARMarkerEvent) :void {
   trace("["+evt.marker.patternId+"] added");
   addMarker(evt.marker);
  }

  function onMarkerUpdated (evt:FLARMarkerEvent) :void {
   //trace("["+evt.marker.patternId+"] updated");
  }

  function onMarkerRemoved (evt:FLARMarkerEvent) :void {
   trace("["+evt.marker.patternId+"] removed");
   removeMarker(evt.marker);
  }
///////////////////////////
//Sound Line thingy
///////////////////////////
addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void
{
 spOne.graphics.clear();
 spOne.graphics.lineStyle(3, 0xFFFFFF);
 spOne.graphics.moveTo(-1, 256);
 SoundMixer.computeSpectrum(ba);
 for(var i:uint=0; i<256; i++)
 {
  var num:Number = -ba.readFloat()*200 + 225;
  spOne.graphics.lineTo(i*2, num);
 }

}

So it appears as though my code wammy is eating all my <’s and >’s

details, details, details…

Saqoosha’s “hole” Effect

Friday, April 10th, 2009

http://saqoosha.net/

so after much searching and still not finding what i’m really looking for wich is the recipe to capture bitmapdata off the marker.rect or something along those lines, i tackled “the virtual hole” with the samples from Saqoosha’s site and a little hacking away of useless code i made it work. Woo!

virtual hole

and the code that got me here.


import flash.display.Bitmap;
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.filters.ColorMatrixFilter;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;

import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.WireframeMaterial;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.core.math.Matrix3D;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.render.*;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.view.stats.StatsView;
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.materials.*;
import org.papervision3d.materials.BitmapAssetMaterial;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.objects.primitives.Sphere;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.objects.DisplayObject3D;

import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.BitmapMaterialTools;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
import org.papervision3d.view.BasicView;

  [Embed(source='../assets/bg.png')]
  var bgTextureClass:Class;
  [Embed(source='../assets/cube-side.png')]
  var cubeSideTextureClass:Class;
  [Embed(source='../assets/cube-bottom.png')]
  var cubeBottomTextureClass:Class;

  var _green:Cube;

var sp:Sprite = new Sprite();
addChild(sp);

var viewport:Viewport3D = new Viewport3D( 960, 720, true, true, true, true );
sp.addChild(viewport);
viewport.buttonMode = false;

var renderer:BasicRenderEngine = new BasicRenderEngine();
var scene:Scene3D = new Scene3D();
var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100;

  var cmats:BitmapMaterial = BitmapMaterialTools.createBitmapMaterial(cubeSideTextureClass);
  var cmatb:BitmapMaterial = BitmapMaterialTools.createBitmapMaterial(cubeBottomTextureClass);
  var hole:Cube = this.scene.addChild(new Cube(new MaterialsList({all: cmats, bottom: cmatb}), 300, 300, 300, 1, 1, 1, Cube.ALL, Cube.TOP)) as Cube;
  this._green = this.scene.addChild(new Cube(new MaterialsList({all: new ColorMaterial(0x00ff00)}), 300, 300, 300, 1, 1, 1, 0, Cube.TOP)) as Cube;
  hole.y = this._green.y = -150;

  this.filters = [
   new ColorMatrixFilter([
    1, 0, 0, 0, 0,
    0, 1, 0, 0, 0,
    0, 0, 1, 0, 0,
    1, -1, 1, 1, 0
   ])
  ];

 this.addEventListener(Event.ENTER_FRAME, this._update);

  function _update(e:Event):void {
   renderer.renderScene(scene, camera, viewport);
   camera.orbit(this.stage.mouseY / 600 * 90, this.stage.mouseX / 800 * 180);
  }

You’ll need to find the newyears source on saqooshas blog for the .png’s but theyre just a grey-white gradient. could be generated on the spot.

Flart for Modd Jobs

Saturday, March 28th, 2009

Modd Flart

Modd Flart

A very happy birthday FLART!

Tuesday, March 24th, 2009

FIRST print this

then plug in your web cam. if you get a security window when you click the example thats to be expected, it wants your permission to use your webcam, please say yes.

this is easily some of the coolest stuff ive seen on the internet.

FLART is an acronym for FlashAugmentedRealityToolkit. fyi!

if nothing comes up please right click anywhere in the window, select settings, click allow and remember. this just gives the examples on my site access to your camers so we dont have to do this again. also check to see that the camera youre using is selected in the camera tab of the flash player security window. that concludes our breif tutorial on the flash players security settings, tune in next week when we learn to make a time machine out of things you may have lying around the house. and now the example.

just point your webcam at the paper you printed. 

Example below:

Enjoy

Birthday FLART

Birthday FLART

Ribbon evolution

Thursday, March 19th, 2009

so heres the next step in my ribon madness

multi ribbons and some nearly satisfactory motion. i was aiming for smooth elipses but got something not un pleasing, I did mention i need to learn a lot more math.

multi ribbons
Example: ribbons21
multi ribbons

 

Soulwire ribbon class and pv3d.org tutorial on it, fun stuff.

Tuesday, March 17th, 2009

ribbon fun

ribbon fun

Soulwire ribbon class and pv3d.org tutorial on it, fun stuff.

Example:

ribbon fun

Papervision BitmapViewport realization

Sunday, March 15th, 2009

i was playing with filters and papervision when i came up with this.

i set up a pretty simple ppv3D scene with a bitmapViewport and added this line


viewport.fillBeforeRender = false;

and presto insta trails. it just keeps rendering ontop of its self. add a little blur and this effect just happened.

Example: ppveffects123

and the code


//flash imports
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.display.Sprite;
import flash.events.Event;
import flash.system.Security;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Mouse;
import flash.display.DisplayObject;
import flash.display.Shape;
import gs.*;
import gs.easing.*;
import gs.TweenMax;
//papervision imports
import org.papervision3d.materials.MovieAssetMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.utils.Mouse3D;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.render.*;
import org.papervision3d.view.*;
import org.papervision3d.view.BasicView;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.core.effects.*;
//scene setup
var sp:Sprite = new Sprite();
addChild(sp);

var viewport:BitmapViewport3D = new BitmapViewport3D(960, 720, true, true, 0x000000, true, false );
viewport.fillBeforeRender = false;
sp.addChild(viewport);
viewport.buttonMode = false;

var renderer:BasicRenderEngine = new BasicRenderEngine();

var scene:Scene3D = new Scene3D();

var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100; 

//Filters
var cmf:ColorMatrixFilter = new ColorMatrixFilter([3,0,0,0,0,
               0,-3,0,0,0,
               0,0,3,0,0,
               0,0,0,0,0]);

var blur:BlurFilter = new BlurFilter(3, 3, 1);
var alphaTrans:ColorTransform = new ColorTransform(1, 1, 1, 1, 4, 5, 3, -10);
var pointArray:Array = new Array();
for(var i:uint=0; i&lt;10; i++)
  {
   var randomColor:Number = Math.random() * 0xEEEEEE;
   var shape:Shape = new Shape();
   with(shape)
    {
     graphics.beginFill(randomColor);
     graphics.drawRect(0, 0, 2, 2);
     graphics.endFill();
    }
   var mam:MovieMaterial = new MovieMaterial(shape);
   var mList = new MaterialsList({front:mam, back:mam, left:mam, right:mam,top:mam, bottom:mam})
   var cube:Cube = new Cube(mList, 20, 20, 20, 1, 1, 1);
   mam.animated = true;
   mam.doubleSided = false;
   mam.interactive = false;
   cube.x = Math.random()*700;
   cube.y = Math.random()*700;
   cube.z = Math.random()*700;
   cube.name = "cube"+i;
   scene.addChild(cube);
   pointArray[i] = scene.getChildByName("cube"+i);
   //addChild(planeBm);

   }
addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void
{
 camera.x -= (camera.x-(stage.stageWidth*0.5-mouseX)/(stage.stageWidth*0.5)*1600)*0.2;
 camera.y -= (camera.y-(stage.stageHeight*0.5-mouseY)/(stage.stageHeight*0.5)*1800)*0.2;

 renderer.renderScene(scene, camera, viewport);
 //viewport.bitmapData.colorTransform(viewport.bitmapData.rect, alphaTrans);
 viewport.bitmapData.applyFilter(viewport.bitmapData, viewport.bitmapData.rect, new Point(0,0), blur);
 //viewport.bitmapData.applyFilter(viewport.bitmapData, viewport.bitmapData.rect, new Point(0,0), cmf);
 viewport.bitmapData.scroll(0, -4);
}

more PPV sound fun

Wednesday, March 11th, 2009

this is built off my previous ppv sound example.

i added a tween to a circle, woo hoo. its still fun :)

oh i need to learn more math.

ppv sound fun
ppv sound fun

Example

midippvthingy31

and the code i added to tween

function circle(){
var angleOffset:Number = Math.PI*2/255;
var radius:Number = 300;
var angle:Number = 360;
var planeX:Number;
var planeZ:Number;

		for(var i:int =0;i&lt;255;i++)
	{
		planeX = Math.cos(angle)*radius;
		planeZ = Math.sin(angle)*radius;
		TweenLite.to(pointArray[i], 5, {x:planeX, z:planeZ});
		angle += angleOffset;
	}

}

enjoy

My first papervision spectrum analisys experiment

Monday, March 9th, 2009

pretty simple but i figured it out

music by ModdJobbs, my brother,  its an mc chris remix of  “Older Croud”
http://www.myspace.com/moddjobs

Go get the newest flash player if you dont have it please.

http://www.adobe.com/products/flashplayer/

Heres the example.

b00000010

midippvthingy2

And heres the code

WAY over imported, but its an experiment.

get TweenMax and the version of GreatWhite thats current with this post. both links are posted somewhere on this site.

the MP3 should be in the same folder as the SWF. its named OC.mp3 at the moment.


import flash.display.Sprite;
import flash.events.Event;
import flash.system.Security;
import flash.text.TextField;
import flash.text.TextFormat; 
import flash.events.Event;
import flash.ui.Mouse;
import flash.display.DisplayObject;
import flash.display.Shape;
import gs.*;
import gs.easing.*;
import gs.TweenMax;
 
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.utils.Mouse3D;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.shadematerials.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.render.*;
import org.papervision3d.view.*;
import org.papervision3d.view.BasicView;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.core.effects.*;


var sp:Sprite = new Sprite();
addChild(sp);

var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
sp.addChild(viewport);
viewport.buttonMode = true;
                       
var renderer:BasicRenderEngine = new BasicRenderEngine();
                       
var scene:Scene3D = new Scene3D();
                       
var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100; 
//Spectrum Analisys///////////////////////////
var s:Sound = new Sound(new URLRequest("OC.mp3"));
s.play(1, 0);

var pointArray:Array = new Array();
var ba:ByteArray = new ByteArray();
for(var i:uint=0; i<255; i++)
  {
   var randomColor:Number = Math.random() * 0xffffff;
   var shape:Shape = new Shape();
   with(shape)
    {
     graphics.beginFill(randomColor);
     graphics.drawRect(0, 0, 2, 2);
     graphics.endFill();
    }
   var material:MovieMaterial = new MovieMaterial(shape);
   //animated needs to be true to tween the color
   material.animated = true;
   material.doubleSided = true;
   material.interactive = false;
   var plane:Plane = new Plane(material, 3, 3);
   plane.x = i * 3.75 - stage.width/2 +5;
   plane.y = 0;
   plane.name = "plane"+i;
   scene.addChild(plane);
   pointArray[i] = scene.getChildByName("plane"+i);
   //trace(pointArray);
   
   
   }

addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  
  function enterFrameHandler(event:Event):void
  {
   SoundMixer.computeSpectrum(ba, false, 2);
   for(var i:uint=0; i<255; i++)
    {
     var num:Number = -ba.readFloat()*100;
     //trace(num);
     pointArray[i].scaleY = num;
     
    }
    camera.x -= (camera.x-(stage.stageWidth*0.5-mouseX)/(stage.stageWidth*0.5)*1600)*0.2;
   camera.y -= (camera.y-(stage.stageHeight*0.5-mouseY)/(stage.stageHeight*0.5)*800)*0.2;
   
   camera.y = Math.max(-300, camera.y);
    renderer.renderScene(scene, camera, viewport);
    
  }

 

 

 

A few words about papervision 3D

Sunday, March 8th, 2009

 http://www.papervision3d.org/ first go here, let it load, look around and come back if youre not allready familiar.

Before i jump into talking about papervision code and stuff i wanted to say a few words about it.

First the differance between papervision and pay per view(ive been asked a few times now) is you have to wait till tomorrow to download a pay per view event, but you can download papervision now. http://code.google.com/p/papervision3d/

you’ll need to download the tortise SNV whammy to get the full source. its not that hard. post if you cant work it out, i’ll put something up on how svn’s work to the best of my knowledge. please dont ask me to do it, you’re WAY better off finding a tutorial by someone who actually knows what theyre talking about.  Now that i think about it, there just isnt enough BS on the internet. maybe i’ll do a tut on it just because i dont know what i’m talking about. wait and see.

Papervision has become my white whale.

Papervision 3D is an open source 3d rendering “environment” for the flash player.

It can be compiled in a number of programs, flex and flash to name a few.

there in lies one of the major double edged swords. about 1/2 the tutorials out there are written in Flex( I dont flex) and half the remaining tutorials are written in AS3 class files. the remainder are written in flash on the main timeline or via “other” methods of compiling. so finding tutorials you can use without being nearly fluent in at least flex AND flash is frustrating at best.

NOW on to the branch trunk system. if you can find the branch(dead or not), or trunk version that the person writing any instructions or a tutorial used consider it an acomplishment. I stood up and did a little dance a few times here just after getting a demo running.

Papervision’s core and extended group of contributers are in my opinion some of the greatest minds AS programming has to offer at the moment. The stuff that comes from those labs makes my nipples more than a little stiff.
Just a side note. i love these guys taste in music. its allways nice to go to a computeSpectrum example and want to turn the music UP or hitting refresh just to hear the song again instead of leaping for mute. thx.

heres a few sites ive driven the hit counters up quite a bit recently.

http://blog.papervision3d.org/

i tripped out on this page for a while
http://mrdoob.com/

http://www.sebleedelisle.com/

http://blog.zupko.info/

http://rockonflash.wordpress.com/