Extended setter methods for DisplayObject3D (PV3D 1.5)

We have extended a little bit PV3D 1.5 DisplayObject3D.as code to have some handy methods to set position and orientation for scene objects. You can insert this snippet at about 927th line of DisplayObject3D.as.

// IFS Upgrade
public function setPos(_x:Number, _y:Number, _z:Number, rotX:Number=NaN, rotY:Number=NaN, rotZ:Number=NaN):void {
this.x = _x;
this.y = _y;
this.x = _z;
if (isNaN(rotX)) { } else {
this.rotationX = rotX;
this.rotationY = rotY;
this.rotationZ = rotZ;
}

}

setPos function simply set xyz and rotation variables of particular DisplayObject3D instance.

public function posFromStr(input:String):void {
var tmpArr:Array = input.split(”,”);

this.x = Number(tmpArr[0]);
this.y = Number(tmpArr[1]);
this.z = Number(tmpArr[2]);

if (tmpArr.length > 3) {

this.rotationX = Number(tmpArr[0]);
this.rotationY = Number(tmpArr[1]);
this.rotationZ = Number(tmpArr[2]);

}

}

We added this function in order to make setting position and rotate params from XML easier. Function uses setting from string formatet like: “49,50,30,30,40,20″ - where first 3 params are coords and second 3 rotation per axis.

public function getPos():Number3D {
return new Number3D(this.x, this.y, this.z);
}

getPos return Number3D object with position of object

public function setRotation3D(input:Number3D, axis:String=”xyz”):void {

if (axis.indexOf(”x”) > -1) {
this.rotationX = input.x; }

if (axis.indexOf(”y”) > -1) {
this.rotationY = input.y; }

if (axis.indexOf(”z”) > -1) {
this.rotationZ = input.z; }

}
//////////////

SetRotation3D sets rotation of object using values from Number3D. in axis input you’re choosing on which axis to apply change…

I simply couldn’t surrve developing without these methods, they are simple but usefull.
I’m distributing it to you in this form to make it easier to integrate in future versions of PV3D/Away3D.

Leave a Reply


tesseractstudio.org | all rights reserved 2005-2008. | tesseractstudio ltd, Serbia
omnetwork.net | tutorialautomated.info | osgamer.org | freeflashscripts.com | tesslabs.com | thefirstexodus.com | thefirstexodus.com