[Papervision3D] Get a 3d space location on a cube
xero
xero.nu at gmail.com
Thu Aug 30 08:07:51 PDT 2007
this *MIGHT* help, i dont know...
i create a cube, then load the positions
of all the vertexes into a pseudo-array.
for each(var i:* in cubeObj.geometry.vertices) {
i.extra={baseX:i.x,baseY:i.y,baseZ:i.z,b001:0}
}
then in the toggle function i tween they
position *4... thus expanding the cube.
[code]
package {
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.text.*;
import flash.media.Sound;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.ByteArray;
//p a p e r v i s i o n 3 D
import org.papervision3d.core.proto.*;
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
//z e h ' s . t w e e n e r
import com.caurina.transitions.Tweener;
[SWF(backgroundColor="0x000000", frameRate="300")]
public class cubeTween extends MovieClip {
// __________________________________________
// vars
public var container : Sprite;
public var scene : MovieScene3D;
public var camera : FreeCamera3D;
public var cubeObj : DisplayObject3D;
public var toggleFlag : Boolean=false;
public var label : TextField;
// __________________________________________
// constructor
Constructor
public function cubeTween(){
stage.frameRate = 60;
stage.quality = "MEDIUM";
stage.scaleMode = "noScale";
stage.align = StageAlign.TOP_LEFT;
this.stage.addEventListener(Event.RESIZE, onStageResize);
this.addEventListener(Event.ENTER_FRAME,loop3D);
init();
}
// __________________________________________
// init
public function init():void{
container = new Sprite();
addChild(container);
container.x = this.stage.stageWidth / 2;
container.y = this.stage.stageHeight / 2;
scene = new MovieScene3D( container );
camera=new FreeCamera3D(1,1000);
var drop:Array = new Array();
drop.push(new DropShadowFilter(5, 45, 0xCCCCCC, 1, 8, 8, 1, 1, false,
false));
drop.push(new GlowFilter(0x00FF00, 0.7, 6, 6, 2, 1, true, false));
label=new TextField();
label.autoSize=TextFieldAutoSize.LEFT;
label.x = 10;
label.textColor=0xCCCCCC;
label.htmlText = "<font face=\"verdana\" size=\"30\">the.fontvir.us
</font>";
label.selectable=false;
label.filters = drop;
this.addChild(label);
var material: WireframeMaterial = new WireframeMaterial(0xFFFF33, 100);
cubeObj = new Cube(material, 200, 200, 200, 4, 4, 4);
scene.addChild(cubeObj);
cubeObj.container.buttonMode=true;
cubeObj.container.addEventListener(MouseEvent.MOUSE_DOWN,toggle);
for each(var i:* in cubeObj.geometry.vertices) {
//add vertices to array
i.extra={baseX:i.x,baseY:i.y,baseZ:i.z,b001:0}
}
}
// __________________________________________
// resizeHandler
public function onStageResize(e:Event):void{
this.container.x = this.stage.stageWidth / 2;
this.container.y = this.stage.stageHeight / 2;
}
// __________________________________________
// loop3D
public function loop3D(event:Event):void {
//influence camera with mouse
cubeObj.rotationY+=container.mouseX/100;
cubeObj.rotationX+=container.mouseY/100;
//create filters
var filter:Array = new Array();
//outer blend glow
filter.push(new GlowFilter(0xCCCC00, 1, 10, 10, 2, 1, false, false));
//inner face glow
filter.push(new GlowFilter(0x00FF00, 1, 50, 50, 2, 1, true, false));
//shadow glow
filter.push(new GlowFilter(0x00AA00, 1, 90, 90, 1, 1, false, false));
//apply filters
this.container.filters = filter;
//render the scene
this.scene.renderCamera( camera );
}
// __________________________________________
// toggle
function toggle(e:MouseEvent):void{
var num:Number=1;
for each(var i:* in cubeObj.geometry.vertices) {
if(!toggleFlag){
Tweener.addTween( i, {
x :i.extra.baseX*2,
y :i.extra.baseY*2,
z :i.extra.baseZ*2,
time :2,
delay :Math.random(),
transition :"easeOutElastic"
} );
}else{
Tweener.addTween( i, {
x :i.extra.baseX,
y :i.extra.baseY,
z :i.extra.baseZ,
time :2,
delay :Math.random(),
transition :"easeOutElastic"
} );
}
}
num++;
toggleFlag=!toggleFlag;
}
}
}
[/code]
hope this helps!
____ ___
\ \/ /___________ ____
.\ // __ \_ __ \/ _ \
./ \ ___/| | \( <_> )
/___/\ \___ >__|---\____/
| \_/ \/ |
| xero harrison |
| x at xero.nu |
| http://xero.nu |
| http://fontvir.us |
| http://xero.owns.us |
`---------------------'
---------- Forwarded message ----------
> From: apostille <apostille at gmail.com>
> To: papervision3d at osflash.org
> Date: Thu, 30 Aug 2007 16:42:58 +0200
> Subject: Re: [Papervision3D] Get a 3d space location on a cube
> Well, I mean get a Vertex3D or a Number3D object to get the x, y, z
> coordinates.
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20070830/8453a063/attachment-0001.html
More information about the Papervision3D
mailing list