A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Papervision get Planes

  1. #1
    Junior Member
    Join Date
    Jun 2009
    Posts
    12

    Papervision get Planes

    Does anyone know how to set up Planes with papervision, then retrieve them later?

    I've set up the 3d scene like this:
    PHP Code:
    var con:Sprite = new Sprite();
    con.this.width 0.5;
    con.this.height 0.3;
    holder.addChild(con);

    var 
    scene:MovieScene3D = new MovieScene3D(con);
    var 
    camera:Camera3D = new Camera3D();
    camera.zoom 0
    I've set up a plane for each object in an xml file:
    PHP Code:
    var mam:InteractiveMovieMaterial = new InteractiveMovieMaterial(itemtrue);
            
    //mam.interactive = true;
            
    mam.oneSide false;
            
    mam.smooth true;
            
    mam.animated true;
            var 
    p:Plane = new Plane(mam13115077);
            
    p.Math.cos(i*anglePer) * radius;
            
    p.Math.sin(i*anglePer) * radius;
            
    p.rotationY = (-i*anglePer) * (180/Math.PI) + 270;
            
    scene.addChild(p);
            
    p.name "p" i;
            
    trace (p.name); 
    then later I want to change each plane's color tint, depending on distance from the camera....


    in my loop I've got:
    PHP Code:
    function loop(e:Event):void
    {
        
        
    camera.Math.cos(angleX) * 1000;
        
    camera.Math.sin(angleX) * 1000;
        
    scene.renderCamera(camera);

    in that loop I want to put something like

    PHP Code:
    for(var i=0i<scene.numChildren-1i++) 
        {     
        var 
    plane:DisplayObject DisplayObject(con.getChildAt(i));
        <
    change tint of each plane depending on distance from camera
    or retrieve the planes by name....

    PHP Code:
    for(var i=0i<scene.numChildren-1i++) 
    {
    var 
    p:Plane Plane(scene.getChildByName(p[i]));
    <
    change tint of each plane depending on distance from camera>

    but none of these methods seem to work,, possibly because you can't do the same things to Planes that you can to movieclips...(?)

    the scene.numChildren seems to work though.

    Hoping someone can help!

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Posts
    12

    solution

    I found a solution:
    it's all about this:
    PHP Code:
    for each (var p:Plane in scene.children
    so this is how I solved my little tinting problem

    PHP Code:
    //need for color transform
    import fl.motion.Color;

    var 
    blueTint:Color = new Color();

    // getting distance between camera and plane
    var dz:Number p.camera.z;
    var 
    dx:Number p.camera.x;
    var 
    dis:Number Math.sqrt(dz dz dx dx);

    //factor to get a 0 - 1 number depending on distance        
    var disFactor:Number = ((dis-690) / 300);
    trace(dis);
    trace(disFactor);
    if (
    disFactor 1)
    {
        
    disFactor 1;
    }
    if (
    disFactor 0)
    {
        
    disFactor 0;
    }
    //setting tint depending on disFactor
    blueTint.setTint(0xd4e1ebdisFactor);
    MovieMaterial(p.material).movie.ref.transform.colorTransform blueTint;
    MovieMaterial(p.material).movie.button.transform.colorTransform blueTint
    It works, but it slow it down loads....
    if anyone has any other ideas that'd be good

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center