peter nitsch.net

peternitsch.net

Textmode experiments using Alchemy and C++

Star Wars ASCII

Recently, I’ve been playing a lot with Alchemy, an Adobe Labs project that allows developers to compile C/C++ code for use in AVM2. Brandon Hall does a great job of explaining exactly how Alchemy works, so I won’t bother.

Read the rest of this entry »

3D ultrasound in Papervision.

Yesterday my wife and I had an appointment for a 3D ultrasound. We wanted some better images of our new daughter, who we’re expecting in the fall, and this technology seemed like the best way. If you’re unfamiliar with 3D ultrasound, it’s essentially a machine which broadcasts the same ultrasonic waves used in a traditional 2D ultrasound but on multiple planes to simulate a 3D effect.

I thought it was super cool tech, but I could tell the nurse didn’t know how to respond to questions like “What formats can this thing export the spacial data?”. But really, playing around with 3D imagery of my unborn daughter is just too good an opportunity to pass-by. Luckily they gave us a CD of JPG’s.

Here’s an image from the set:

Original ultrasound image

I thought this would be a great chance to play with the Pixel3D class Andy Zupko added to Papervision a while ago. It took some tweaking, but I like the end result.

Ultrasound image in Papervision

View demo.

New Papervision3D Effects

I spent a couple hours today playing with Andy Zupko’s Effects addition to Papervision3D 2.0. Great White is proving to be a huge step forward for the framework. My hats off to the PV3D team.

type=”application/x-shockwave-flash”>

Leveraging existing 2D code in Papervision3D

It's truly a testament to Papervision3D's ease-of-use that developers can leverage existing routines from previous 2D projects by simply modifying Movieclip references to DisplayObject3D. I put this little demo together with a set of stacked Mistubishi logos reacting to some slinky physics I built for a 2D AS2 project.

Spring physics demo in Papervision3D

Here's an excerpt from the frame code that reproduces the slinky effect. You'll probably recognize this as a fairly conventional method of producing the same result in 2D. The only major difference are the references to Decoration3D which is just a class I built to extend DisplayObject3D.

Actionscript:
  1. //Spin the stack around slowly 
  2. __rootNode.rotationY += 1;
  3.  
  4. for( var i:Number = 0; i<__bubbleArray.length; i++){
  5. var currentBubble:Decoration3D = __bubbleArray[i]; //Decoration3D extends DisplayObject3D
  6.  
  7. if( i == 0 ){
  8.   //Case of first logo in the stack
  9.   var dx:Number = currentBubble.x - __container.mouseX;
  10.   var dy:Number = currentBubble.y - __container.mouseY;
  11.   var angle:Number = Math.atan2(dy, dx);
  12.   var targetX : Number =  __container.mouseX + Math.cos(angle) * __springLengthValue;
  13.   var targetY : Number =  __container.mouseY + Math.sin(angle) * __springLengthValue;
  14. } else {
  15.   //Case of every logo following the first
  16.   var lastBubble:Decoration3D = __bubbleArray[i-1];   //Decoration3D extends DisplayObject3D
  17.  
  18.   var dx:Number = currentBubble.x - lastBubble.x;
  19.   var dy:Number = currentBubble.y - lastBubble.y;
  20.   var angle:Number = Math.atan2(dy, dx);
  21.   var targetX : Number =  lastBubble.x + Math.cos(angle) * __springLengthValue;
  22.   var targetY : Number =  lastBubble.y + Math.sin(angle) * __springLengthValue;
  23. }
  24.  
  25. currentBubble.vx += ( targetX - currentBubble.x ) * __springValue;
  26. currentBubble.vy += ( targetY - currentBubble.y ) * __springValue;
  27.  
  28. currentBubble.vy += __gravityValue;
  29. currentBubble.vx *= __frictionValue;
  30. currentBubble.vy *= __frictionValue;
  31. currentBubble.x += currentBubble.vx;
  32. currentBubble.y += currentBubble.vy;
  33.  
  34. currentBubble.rotationZ = currentBubble.vx * __frictionValue;
  35.  
  36. __scene.renderCamera( __camera );         
  37. }