PDA

View Full Version : PV3D 1.5 Help


RedSuns
10-03-2008, 10:57 PM
Hey there, new to these forums.

Anyway, I'm pretty new to papervision and AS3, so forgive me if this is a dumb question.

So far I am trying to make a 3D Menu, which consists of a lot of duplicated planes with movieclips assigned as a material. These planes need to be structured in some sort of grid pattern and load in images through dynamic instance names through xml.

anyway, is the best way to achieve the grid and xml loading by using arrays to give each duplicate an instance name??? then matching it up with the xml?

Also really need help with making a camera that zooms in on and targets the plane that has been clicked..

anyone have some code that could create this effect please????

thanks.

this is my code below:

//-----------IMPORT PV3D-------------//

import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import caurina.transitions.Tweener;

//-----------DEFINE VARIABLES --------//

var container:Sprite=new Sprite();
container.x=stage.stageWidth*0.5;
container.y=stage.stageHeight*0.5;
addChild(container);

var scene:Scene3D=new MovieScene3D(container);

var camera:Camera3D = new Camera3D();
camera.x = 0;
camera.y = 0;
camera.zoom=5;

var material:MovieAssetMaterial = new MovieAssetMaterial("F");
material.oneSide=false;
material.smooth=true;

var itemWidth:int;
itemWidth += 200;
var itemDistance:int
itemDistance += 10;
var columnAmount:int
columnAmount = 4;

var iTest:int
iTest = 0

var mcArray:Array = new Array();
mcArray[i] = p;


//--------------PLANE CONSTRUCTOR/ADD TO SCENE---------------//

var myPlaneDictionary:Dictionary=new Dictionary();
for (var i:uint=0; i<50; i++) {


container.getChildByName(name)

var p:Plane=new Plane(material,itemWidth,200,2,2);

scene.addChild(p);

p.x = (itemWidth + itemDistance) * iTest;

iTest ++;


//----------USE THE CONTAINER SPRITE PROPERTY FOR PLANE-----------//
//----------CONTAINER AS KEY AND PLANE AS VALUE-------------------//

var myPlaneContainer:Sprite = p.container;
myPlaneDictionary[myPlaneContainer]=p;
myPlaneContainer.buttonMode = true;

//-----------DEFINE MOUSE EVENTS----------------------------------//

myPlaneContainer.addEventListener( MouseEvent.ROLL_OVER, doRollOver );
myPlaneContainer.addEventListener( MouseEvent.CLICK, clicker );
myPlaneContainer.addEventListener( MouseEvent.ROLL_OUT, doRollOut );
}


//------------------DEFINE MOUSE EVENT FUNCTIONS---------------------//
//USE THE CONTAINER SPRITE TO CHANGE ALPHA, NOT THE PLANE ITSELF


function doRollOver(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 0.5;
}

function doRollOut(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
sprit.alpha = 1;
}

//we have our index value ( container sprite )
//we use the value to retrieve the correct plane

function clicker(evt:MouseEvent) {
var sprit:Sprite=evt.target as Sprite;
var p:Plane=myPlaneDictionary[sprit]
var newY:int = p.rotationY+180;

Tweener.addTween( camera, {zoom: 6, time: 2} );

Tweener.addTween(p,{rotationY:newY,time:1,transiti on:"easeoutquint"});



}

//------------------------------CAMERAS----------------------------------//

this.addEventListener(Event.ENTER_FRAME,render);
function render(e:Event):void {

Tweener.addTween(camera,{x:stage.mouseX-(stage.stageWidth),time:2,transition:"easeoutquint"});
Tweener.addTween(camera,{y:stage.mouseY-(stage.stageHeight),time:2,transition:"easeoutquint"});



scene.renderCamera(camera);
}

Scorche
10-04-2008, 09:32 PM
first of all, I'd eveluate the scope of your entire project.
why?
there might be simpler tools for faster results.

I tried PV3D, didn't like it and switched to Away3d, not a big difference, but a better fit. But by the complexity (which seems fairly minimal in you case) I would highly recomend five3d. It's dead simple. One big restiction I should warn you about, is that you cannot have movieclips in 3d, you need to create them for the 3d layers. This gives you the added benefit of not having to saterize each sprite every frame and gives you clean lines. New in the last version is the ability to use bitmaps aswell.

and lastly, to really drive home the simplicity of the engine..
check out this link (http://www.thetechlabs.com/3d/building-a-3d-album-with-five3d-and-tweenlite/). I did a similar project in away3d, and I see now how five3d would have been better (but it(v2.0) wasn't available at the time I needed it).

this tutorial, though I didn't use it, does a good job of showing what goes into making it with five3d, but at the same time you can apply these techniques to your pv3d project.

hoever, with pv3d and away3d be prepared to account for the added complexity, so if you're new to as3 it might be worth checking out.

also, if you're working with 3d interfaces (or anything in as3 really), it's good to familiarize yourself with class abstraction, and some of the design patterns that use it like factory & template, or decorator.


anyhow, I know this doesn't answer your question, but hope it helps