Lighting Bitmaps in Papervision

1 Comment

This is a technical article explaining how to code a light source into your Papervision 3D scene. Papervision is an open source 3d library for the Flash platform.

Lighting in Papervision is a very useful tool. It helps add realism to your 3D project. Often times, you will have a scene or 3D objects that have textures on them using bitmaps. You can easily add lighting effects to these textures.

First you’ll need to add the following import statements:
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shaders.PhongShader;
import org.papervision3d.materials.shaders.ShadedMaterial;

Phong Shading is a set of 3D rendering techniques which includes a model for reflecting light onto surfaces. It was invented by Bui Tuong Phong at the University of Utah, who published them in his 1973 Ph.D. dissertation.

Where you set up your scene, just create a light source
light = new PointLight3D();

In the part where you create your 3D objects that you want to light, you will create a PhongShader based on the light source and a ShadedMaterial based on your BitmapMaterial and your PhongShader. Please note that it HAS to be a BitmapMaterial and not a BitmapFileMaterial.

var earthBitmap:Bitmap = new earthAsset() as Bitmap;
var mat:BitmapMaterial = new BitmapMaterial(earthBitmap.bitmapData, true);

// create a shader using the light source
var phongShader:PhongShader = new PhongShader(light, 0xFFFFFF, 0x000000, 10);

// create the material based on the Phong shader
var phongShaderMat:ShadedMaterial = new ShadedMaterial(mat, phongShader);

globe = new Sphere(phongShaderMat, 200, 20, 20);

view.scene.addChild( globe );

The project source code is available for download here.

Popularity: 13% [?]

Twitter + Augmented Reality

9 Comments

What happens when you put together Flash, Augmented Reality, Papervision3D, the Twitter API, and a bored geek? You get this little webcam demo of a Flash app that tracks a marker and displays a speech bubble with your latest tweet.

Although Augmented Reality (AR) has been around for a while now, cheap webcams, 3D on the web, and other factors have only recently enabled the field of AR to be usable by the masses.

Thanks to John Lindquist’s tutorials, I was able to quickly put together a small demo of what you can do with AR and the Twitter API.

The commercial use of AR is still in it’s infancy and people are still trying to figure out how to use it. There have been some examples in the entertainment space, namely the PS3 game Eye of Judgement and the Topps Baseball trading cards.

Here’s a cool AR idea for a conference. Your registration badge can come with a marker that can be read by a big interactive wall installation with cameras. You can then walk up to it and it would show you your sessions. Not only that, but other people who walk up to it can also see their sessions and maybe, if the person standing next to you has the same sessions as you, it would let you know that so you can connect.

Here’s another cool AR idea for the web. Webcam Poker. Each player would have a marker on their desk. The webcam can then pick up the marker and project a virtual hand on your desk, so that your opponent would see your desk as if you had cards on them and you would be able to play virtual poker in a slightly more realist fashion than just clicking cards on screen.

Popularity: 4% [?]