Get image from nurb mesh

Software: Away3D 3.x

vegetable, Newbie
Posted: 13 January 2012 10:38 AM   Total Posts: 7

Hello im trying to warp image using nurb mesh. I have some good results, but still need some help.
My first question is how to get image (bitmapData) from nurb plane to bitmap image or movie clip.
Second question : can i apply nurb to simple plane (not with nurb mesh), so i could have irregular nurb points (not in a grid like right now).

https://lh6.googleusercontent.com/-6jMS8lQWtj0/TxAJdCw14kI/AAAAAAAAAB8/MqK_GevIzxc/s775/nuuurbfooox.png

package {
import away3d
.containers.View3D;
import away3d.events.MouseEvent3D;
import away3d.materials.BitmapMaterial;
import away3d.primitives.NURBS;
import away3d.primitives.data.WeightedVertex;
import flash.display.Bitmap;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.SecurityErrorEvent;


[SWF(backgroundColor="#1a1a1a"frameRate="31"width="870"height="470")]
    
public class MakeUp extends Sprite {

        
private var _view View3D;
        private var 
_material BitmapMaterial;
        private var 
nurbsMesh:NURBS;
        private var 
controlNet:Array;
        private var 
planeArray:Array = [];
        private var 
mouseDown:Boolean false;
        private var 
activePlane:int;
        private var 
resultBitmap:Bitmap;


        public function 
MakeUp():void {
            onImageReady
();
        
}

        
private function onLoadError(event SecurityErrorEvent) : void {
            trace
(event);
        
}

        
private function onImageReady() : void {
            try{
                _material 
= new BitmapMaterial(new BMPFox());
                
createScene();
            
}catch(e:Error){
                trace
("ERROR "e);
            
}
        }


        
private  function createScene() : void {
            _view 
= new View3D();
            
_view.stage.stageHeight 2;
            
_view.stage.stageHeight 2;
            
addChild(_view);

            
resultBitmap = new Bitmap (new BMPFox());
            
resultBitmap.500;
            
addChild(resultBitmap);
            
createStuff();
            
addEventListener(Event.ENTER_FRAMEonEnterFrame);
        
}

        
private function createStuff():void {
            controlNet 
getVertexs();

            
nurbsMesh = new NURBS(controlNet2020{ name:"xxx"uSegments:10vSegments:10 });
            
nurbsMesh.bothsides true;
            
nurbsMesh.material _material;
            
_view.scene.addChild(nurbsMesh);
            
_view.scene.addEventListener(MouseEvent3D.MOUSE_UP,mouseOffPlane);

            for(var 
i:int i<controlNet.length;i++){
                
var _newPlane:ControlPlane = new ControlPlane({x:controlNet[i].x,y:controlNet[i].y,width:10,height:10,rotationX:90});
                
_newPlane.myId i;
                
_newPlane.addEventListener(MouseEvent3D.MOUSE_DOWN,mouseOnPlane);
                
planeArray[i] _newPlane;
                
_view.scene.addChild(_newPlane);
            
}
        }

        
private function mouseOffPlane(event:MouseEvent3D):void {
            mouseDown 
false;

        
}

        
private function mouseOnPlane(event:MouseEvent3D):void {
            mouseDown 
true;
            
activePlane event.target.myId;
        
}


        
private function getVertexs() : Array // creating nurb grid
            
var _returnArray:Array = [];
            var 
pos:int 20;
            var 
step:int 400 pos;

            for(var 
y:int 0;pos;y++){
                
for(var x:int 0;pos;x++){
                    _returnArray
.push(new WeightedVertex( -200 + (step), -200 + (step), 01));
                
}
            }
            
return _returnArray;
        
}

        
private function onEnterFrame(event Event) : void {
            
if(mouseDown)// for draging planes
                
planeArray[activePlane]._view.mouseX 20;
                
planeArray[activePlane]._view.mouseY * -1;
                
nurbsMesh.controlNet[activePlane].planeArray[activePlane].x;
                
nurbsMesh.controlNet[activePlane].planeArray[activePlane].y;
            
}
            nurbsMesh
.refreshNURBS();
            
_view.render();
        
}
    }

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X