I did a similar demo at the RMI classes in Toronto this last weekend and some of the students asked if I would post notes or a tutorial online about how to do this. So, here’s a quick 5 minute demo on how to make a movie, add some components, and with minimal code, make it interactive on a 3D object.
This demo was done with the new Papervision3D 1.9 and the InteractiveSceneManager, but it would work with 1.5 and the current ISM nearly the same way.
Here’s the code:
[as]
import org.papervision3d.objects.Plane;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.FreeCamera3D;
// create Sprite container to draw into, add to stage and center
var container:Sprite = new Sprite();
addChild(container);
container.x = stage.stageWidth * .5;
container.y = stage.stageHeight * .5;
// create Scene3D and Camera – pass ‘true’ as the 2nd argument to make the scene interactive
var scene:Scene3D = new Scene3D(container, true)
var camera:FreeCamera3D = new FreeCamera3D();
camera.zoom = 11;
// create MovieMaterial to use on the Plane object
var material:MovieMaterial = new MovieMaterial(movieSkinContainer, true, true);
// make the material interactive
material.interactive = true ;
material.oneSide = false;
material.smooth = true;
// create the plane to the same dimensions as the movieclip
var plane:Plane = new Plane(material, 250, 250, 10, 10);
// add to the Scene3D
scene.addChild(plane);
// add listener for ENTER_FRAME to render the scene
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
function handleEnterFrame(e:Event):void
{
// rotate the scene on the y axis
plane.yaw(.2);
// render scene
scene.renderCamera(camera);
}
[/as]
Get the FLA and make sure you're sync'd up with the Phunky branch in the google code repository