lordofduct
11-23-2008, 07:02 PM
Am I missing something here?
See I'm just drawing up a basic PV3D application and nothing is rendering on screen.
All I do is create a handful of planes that are textured with some bitmapData and sticking them into the scene. I set the camera to look at one of them and I don't see shit on screen!
so am I missing something?
package display
{
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.Papervision3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.objects.Plane;
import org.papervision3d.scenes.MovieScene3D;
import utils.CustomMath;
public class InverseCarousel extends Sprite
{
public static const DOUBLE_SIDED_PLANE:Boolean = true;
public static const SMOOTH_PLANE:Boolean = true;
public static const PLANE_QUALITY:int = 2;
public static const PLANE_WIDTH:int = 180;
public static const PLANE_HEIGHT:int = 180;
public static const PLANE_PADDING:int = 20;
protected var _scene:MovieScene3D;
protected var _camera:Camera3D;
protected var _sceneCanvas:Sprite;
protected var _planes:Array;
protected var _position:Number = 0;
public function InverseCarousel()
{
super();
Papervision3D.VERBOSE = false;
Papervision3D.useDEGREES = false;
init();
}
public function get position():Number { return _position; }
public function set position( value:Number ):void { _position = CustomMath.wrap( _position + value, Math.PI * 2 ); calculate(); }
protected function init():void
{
this.addEventListener(Event.ADDED_TO_STAGE, startSceneRender, false, 0, true);
this.addEventListener(Event.REMOVED_FROM_STAGE, stopSceneRender, false, 0, true);
_planes = new Array();
_sceneCanvas = new Sprite();
addChild(_sceneCanvas);
_scene = new MovieScene3D( _sceneCanvas );
_camera = new Camera3D();
_camera.z = 0;
_camera.zoom = 0;
_camera.y = -50;
}
public function registerImage( bmd:BitmapData ):void
{
//Bitmap Material
var bm:BitmapMaterial = new BitmapMaterial( bmd );
bm.doubleSided = DOUBLE_SIDED_PLANE;
bm.smooth = SMOOTH_PLANE;
var pl:Plane = new Plane(bm, PLANE_WIDTH, PLANE_HEIGHT, PLANE_QUALITY, PLANE_QUALITY);
_scene.addChild( pl );
_planes.push( pl );
calculate();
}
protected function calculate():void
{
var circ:Number = Math.max( 800 * Math.PI, _planes.length * ( PLANE_WIDTH + PLANE_PADDING ) );
var rad:Number = circ / (Math.PI * 2);
var split:Number = 2 * Math.PI / _planes.length;
for (var i:int = 0; i < _planes.length; i++)
{
var pl:Plane = _planes[i];
var a:Number = split * i;
var ix:Number = rad * Math.cos(a);
var iz:Number = -rad * Math.sin(a);
pl.x = ix;
pl.z = iz;
}
//TEST: to make sure we're seeing stuff
_camera.lookAt(_planes[0]);
trace(_camera.rotationX, _camera.rotationY, _camera.rotationZ);
//ENDTEST
}
/**
* SCENE RENDER EVENT HANDLERS
*/
/**
* startSceneRender - when added to the stage begin updating the 3D scene
*/
protected function startSceneRender(e:Event):void
{
this.addEventListener(Event.ENTER_FRAME, update, false, 0, true);
}
/**
* stopSceneRender - when removed from the stage stop updating the 3D scene
*/
protected function stopSceneRender(e:Event):void
{
this.removeEventListener(Event.ENTER_FRAME, update);
}
/**
* update - update the scene every frame when this is a member of the stage
*/
protected function update(e:Event):void
{
if ( !_scene || !_camera ) return;
_scene.renderCamera( _camera );
}
}
}
and I add it to the stage here:
package {
import display.InverseCarousel;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import utils.XmlGallery;
import utils.generateThumb;
public class Main extends Sprite
{
protected var _gallery:XmlGallery = new XmlGallery();
protected var _carousel:InverseCarousel = new InverseCarousel();
public function Main()
{
init();
}
protected function init():void
{
var url:String = (this.loaderInfo.parameters.hasOwnProperty( "xmldoc" )) ? this.loaderInfo.parameters.xmldoc : "default.xml";
_gallery.addEventListener(Event.COMPLETE, imagesLoaded, false, 0, true);
_gallery.load( url );
}
protected function imagesLoaded(e:Event):void
{
_gallery.removeEventListener(Event.COMPLETE, imagesLoaded);
var images:Array = _gallery.images;
_carousel.x = stage.stageWidth / 2;
_carousel.y = stage.stageHeight / 2;
addChild(_carousel);
for( var i:int = 0; i < images.length; i++ )
{
var thumb:BitmapData = generateThumb( images[i] );
_carousel.registerImage( thumb );
}
}
}
}
the update function at the bottom of the 3D app does fire and is updating the scene.
The annoying thing is I've worked with PV3D before... and I'm setting it up basically the same way... of course the objects are in different places and all the hunky dory stuff... but in essence it's the same. Yet they all work fine.
See I'm just drawing up a basic PV3D application and nothing is rendering on screen.
All I do is create a handful of planes that are textured with some bitmapData and sticking them into the scene. I set the camera to look at one of them and I don't see shit on screen!
so am I missing something?
package display
{
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.Papervision3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.BitmapMaterial;
import org.papervision3d.objects.Plane;
import org.papervision3d.scenes.MovieScene3D;
import utils.CustomMath;
public class InverseCarousel extends Sprite
{
public static const DOUBLE_SIDED_PLANE:Boolean = true;
public static const SMOOTH_PLANE:Boolean = true;
public static const PLANE_QUALITY:int = 2;
public static const PLANE_WIDTH:int = 180;
public static const PLANE_HEIGHT:int = 180;
public static const PLANE_PADDING:int = 20;
protected var _scene:MovieScene3D;
protected var _camera:Camera3D;
protected var _sceneCanvas:Sprite;
protected var _planes:Array;
protected var _position:Number = 0;
public function InverseCarousel()
{
super();
Papervision3D.VERBOSE = false;
Papervision3D.useDEGREES = false;
init();
}
public function get position():Number { return _position; }
public function set position( value:Number ):void { _position = CustomMath.wrap( _position + value, Math.PI * 2 ); calculate(); }
protected function init():void
{
this.addEventListener(Event.ADDED_TO_STAGE, startSceneRender, false, 0, true);
this.addEventListener(Event.REMOVED_FROM_STAGE, stopSceneRender, false, 0, true);
_planes = new Array();
_sceneCanvas = new Sprite();
addChild(_sceneCanvas);
_scene = new MovieScene3D( _sceneCanvas );
_camera = new Camera3D();
_camera.z = 0;
_camera.zoom = 0;
_camera.y = -50;
}
public function registerImage( bmd:BitmapData ):void
{
//Bitmap Material
var bm:BitmapMaterial = new BitmapMaterial( bmd );
bm.doubleSided = DOUBLE_SIDED_PLANE;
bm.smooth = SMOOTH_PLANE;
var pl:Plane = new Plane(bm, PLANE_WIDTH, PLANE_HEIGHT, PLANE_QUALITY, PLANE_QUALITY);
_scene.addChild( pl );
_planes.push( pl );
calculate();
}
protected function calculate():void
{
var circ:Number = Math.max( 800 * Math.PI, _planes.length * ( PLANE_WIDTH + PLANE_PADDING ) );
var rad:Number = circ / (Math.PI * 2);
var split:Number = 2 * Math.PI / _planes.length;
for (var i:int = 0; i < _planes.length; i++)
{
var pl:Plane = _planes[i];
var a:Number = split * i;
var ix:Number = rad * Math.cos(a);
var iz:Number = -rad * Math.sin(a);
pl.x = ix;
pl.z = iz;
}
//TEST: to make sure we're seeing stuff
_camera.lookAt(_planes[0]);
trace(_camera.rotationX, _camera.rotationY, _camera.rotationZ);
//ENDTEST
}
/**
* SCENE RENDER EVENT HANDLERS
*/
/**
* startSceneRender - when added to the stage begin updating the 3D scene
*/
protected function startSceneRender(e:Event):void
{
this.addEventListener(Event.ENTER_FRAME, update, false, 0, true);
}
/**
* stopSceneRender - when removed from the stage stop updating the 3D scene
*/
protected function stopSceneRender(e:Event):void
{
this.removeEventListener(Event.ENTER_FRAME, update);
}
/**
* update - update the scene every frame when this is a member of the stage
*/
protected function update(e:Event):void
{
if ( !_scene || !_camera ) return;
_scene.renderCamera( _camera );
}
}
}
and I add it to the stage here:
package {
import display.InverseCarousel;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
import utils.XmlGallery;
import utils.generateThumb;
public class Main extends Sprite
{
protected var _gallery:XmlGallery = new XmlGallery();
protected var _carousel:InverseCarousel = new InverseCarousel();
public function Main()
{
init();
}
protected function init():void
{
var url:String = (this.loaderInfo.parameters.hasOwnProperty( "xmldoc" )) ? this.loaderInfo.parameters.xmldoc : "default.xml";
_gallery.addEventListener(Event.COMPLETE, imagesLoaded, false, 0, true);
_gallery.load( url );
}
protected function imagesLoaded(e:Event):void
{
_gallery.removeEventListener(Event.COMPLETE, imagesLoaded);
var images:Array = _gallery.images;
_carousel.x = stage.stageWidth / 2;
_carousel.y = stage.stageHeight / 2;
addChild(_carousel);
for( var i:int = 0; i < images.length; i++ )
{
var thumb:BitmapData = generateThumb( images[i] );
_carousel.registerImage( thumb );
}
}
}
}
the update function at the bottom of the 3D app does fire and is updating the scene.
The annoying thing is I've worked with PV3D before... and I'm setting it up basically the same way... of course the objects are in different places and all the hunky dory stuff... but in essence it's the same. Yet they all work fine.