Box3D Class for Papervision3D
Reynaldo May 20th, 2008
Hi All!
Today I found myself with the need to create a cube, but in my case, I wanted to have all the sides of the cube treated as if they were planes. Also, I wanted to have more control over the inner workings of my cube hence the birth of the Box3D class.
All this class does is create a cube out of 6 planes primitives. It works very much like the EnhancedPlane class mentioned in an earlier post .
This is the result:
This movie requires Flash Player 9
You can get the source and example files here!
Tags: papervision, actionscript, papervision3d, pv3d, cube, box3d, box




Hey great class…i was wondering if you knew how I can make it so that the MovieMaterials that I’m using as the faces of the planes can contain RollOver/Out Events…i’ve written a baseclass for “Face” where the MouseEvent written in the class but when these are arranged on the face of the plane, the Event isn’t triggered…any ideas
i guess some code might help…
//in my papervision scene…
private function makeBoxes():void {
var frontFace = new FrontFace();
var fMat = new MovieMaterial(frontFace, true, true);
var mList:MaterialsList = new MaterialsList();
mList.addMaterial(fMat, ‘front’);
mList.addMaterial(fMat, ‘bottom’);
mList.addMaterial(fMat, ‘left’);
mList.addMaterial(fMat, ‘back’);
mList.addMaterial(fMat, ‘top’);
mList.addMaterial(fMat, ‘right’);
outerBox = new Box3D(mList, cubeW, cubeH, cubeW);
outerBox.interactive = true;
outerBox.y = yH;
innerBox = new Box3D(mList, cubeW * .8, cubeH * .8, cubeW * .8);
innerBox.interactive = true;
innerBox.y = yH;
}
//in the Face Class…
package {
import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
public class Face extends MovieClip {
private const TRANS_TIME:Number = .5;
public function Face() {
init();
}
private function init():void {
addEventListener(MouseEvent.ROLL_OVER, RollOver);
addEventListener(MouseEvent.ROLL_OUT, RollOut);
}
private function RollOver(e:MouseEvent):void {
Tweener.addTween(this.icon,{alpha:1, time:TRANS_TIME, transition:”linear”});
}
private function RollOut(e:MouseEvent):void {
Tweener.addTween(this.icon,{alpha:.5, time:TRANS_TIME, transition:”linear”});
}
}
}
FrontFace is a linked movieclip with Face as the baseclass…
Any help is greatly appreciated