Dynamic effects on a material

9 messages Options
Embed this post
Permalink
Gibbah

Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink
Hi,

Im adding blurr to a material like this:

fx = new EffectLayer();
viewport.addRenderLayer(fx);
fx.addEffect(new LayerEffect(new BlurFilter(100, 0, 2)));
material1.renderLayer = fx;

This works with no problem. The material1 gets blurred nice and good.
Then onEnterFrame I would like to update this blurr with new values something like this:

function updateEffects(object,blurAmount):void {
    fx = null;
    fx = new EffectLayer();
    fx.addEffect(new LayerEffect(new BlurFilter(blurAmount, blurAmount, 2)));
    object.renderLayer = fx;
}
function onEnterFrame( e:Event ):void {
    updateEffects(material1,100,)
    renderer.renderScene( scene, camera, viewport );
}

But no matter what I do in the uppdateEffects-function I don't get it to work. As soon as I call updateEffects there are no blurr at all on the material.

How can I update the blurr-filter dynamicly?

Any help is very appreciated!

/Gibbah
Gibbah

Re: Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink
I guess it is not possible to update a effect when it allready set?

I've seen other DOF blurr-examples when they make several materials with different blurr-amount and then the object switch it's material between those. That works great if you have one object that is duplicated. But if you have many different objects I think it would be better to do what Im trying to do, updating the current effect on one material rather then changing the material to another. Or am I wrong?

Gibbah

Re: Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink
Oh, I just found out how to do it.

I used removeAllEffects() before I added a new effect

In other words, delete the old effect first and then set a new.

xero

Re: Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gibbah
yeah,
thats probally the best way.
but since filters are stored in
an array, you can just overwrite
your filters at run time as well
 
thing.filters = [new BlurFilter(...)];
 
 but using the remove call is
probally better on the memory
managment side... :D
____  ___
\   \/  /___________  ____
.\     // __ \_  __ \/ _  \
./     \  ___/ | | \( <_>  )
/___/\  \___  >__|---\____/
|     \_/   \/        |
| xero harrison       |
| xero.nu@gmail.com   |
| http://xero.nu      |
| http://fontvir.us   |
| http://0x000000.nu  |
| http://xero.owns.us |
`---------------------'
 
---------- Forwarded message ----------
From: Gibbah <[hidden email]>
To: [hidden email]
Date: Tue, 3 Jun 2008 01:26:36 -0700 (PDT)
Subject: Re: [Papervision3D] Dynamic effects on a material

Oh, I just found out how to do it.

I used removeAllEffects() before I added a new effect :-D

In other words, delete the old effect first and then set a new.


--
View this message in context: http://www.nabble.com/Dynamic-effects-on-a-material-tp17554046p17618612.html
Sent from the Papervision3D mailing list archive at Nabble.com.


_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
13Flo

Re: Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink
In reply to this post by Gibbah
Hi,

Maybe because you're executing updateEffects on your onEnterFrame loop no ? :)
In fact you see just the blur filter 100,100,2





Gibbah wrote:
Hi,

Im adding blurr to a material like this:

fx = new EffectLayer();
viewport.addRenderLayer(fx);
fx.addEffect(new LayerEffect(new BlurFilter(100, 0, 2)));
material1.renderLayer = fx;

This works with no problem. The material1 gets blurred nice and good.
Then onEnterFrame I would like to update this blurr with new values something like this:

function updateEffects(object,blurAmount):void {
    fx = null;
    fx = new EffectLayer();
    fx.addEffect(new LayerEffect(new BlurFilter(blurAmount, blurAmount, 2)));
    object.renderLayer = fx;
}
function onEnterFrame( e:Event ):void {
    updateEffects(material1,100,)
    renderer.renderScene( scene, camera, viewport );
}

But no matter what I do in the uppdateEffects-function I don't get it to work. As soon as I call updateEffects there are no blurr at all on the material.

How can I update the blurr-filter dynamicly?

Any help is very appreciated!

/Gibbah
Gibbah

Re: Dynamic effects on a material

Reply Threaded More More options
Print post
Permalink

13Flo wrote:
Hi,

Maybe because you're executing updateEffects on your onEnterFrame loop no ? :)
In fact you see just the blur filter 100,100,2
Im not sure how you mean.

Im calling the updateEffects from my onEnterFrame loop yes, but that is what I want it to do. The effect should update constantly onEnterFrame.

In my code example I first set the effect to blur 100,0. Then I wanted it to update to 100,100 by calling the updateEffects(material1,100) just to see a change if it worked. But it didn't. I just didn't get any blur att all (0,0) when I called the updateEffects function.

But now when I use removeAllEffects() first in the updateEffects function it works. And now when it works I change the blurAmount dynamicly when I call the updateEffects function from the onEnterFrame loop.
zanemx

removeChildByName??????????????

Reply Threaded More More options
Print post
Permalink
had anyone got the RemoveChildByName method of the DisplayObjectContainer3D class to work? I have been pulling my hair out trying to remove displayObject3D instances.


My Portfolio Website


_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

Daniel O' Brian

Re: removeChildByName??????????????

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)

Try

 

removeChild(getChildByName(‘instanceName’));

 

or if you’re looping through a range of objects

 

var n:uint  = 1;

while(getChildByName(‘instanceName’+n) {

removeChild(getChildByName(‘instanceName’+n));

n++;

}

 

D


From: [hidden email] [mailto:[hidden email]] On Behalf Of Avery
Sent: 04 June 2008 09:11
To: [hidden email]
Subject: [Papervision3D] removeChildByName??????????????

 

had anyone got the RemoveChildByName method of the DisplayObjectContainer3D class to work? I have been pulling my hair out trying to remove displayObject3D instances.

My Portfolio Website

 


This email transmission is confidential and intended solely
for the person or organisation to whom it is addressed. If you
are not the intended recipient, you must not copy, distribute
or disseminate the information, or take any action in relation
to it and please delete this e-mail. Any views expressed in
this message are those of the individual sender, except where
the sender specifically states them to be the views of any
organisation or employer. If you have received this message
in error, do not open any attachment but please notify the
sender (above). This message has been checked for all known
viruses powered by Messagelabs. For further information
visit www.messagelabs.com/stats.asp Please rely on your own
virus check as no responsibility is taken by the sender for
any damage rising out of any virus infection this communication
may contain.

LIDA Ltd 36 Golden Square, Soho, London, W1F 9EE, United Kingdom
Reg No. 03860916, registered in the United Kingdom.

_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org
zanemx

Re: removeChildByName??????????????

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Help please....I can't remove my displayObject3Ds. Is this a know issue? I've tried 300 different ways......here is my code. What it does is fire bullets toward the top of the screen. I only what to display 10 bullets at a time..so I want to remove the ones I no longer need. Any thoughts paperVision makers?



package RWClass {
   
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.parsers.Collada;
    import org.papervision3d.objects.primitives.Plane;
    import org.papervision3d.materials.MovieMaterial;
    import org.papervision3d.core.proto.DisplayObjectContainer3D;
    import flash.display.Sprite;
    import flash.events.*;
    import fl.motion.*;
    import flash.utils.Timer;
    import fl.transitions.easing.*;
    import gs.*;

    public class Car extends DisplayObject3D {
       
        //private vars
        private var c:*;
        private var cCon:DisplayObject3D;
        private var pCon:DisplayObjectContainer3D;
        private var bulletTimer:Timer = new Timer(200);//bullets spawned    //fire bullets funct
        private var bulletTimer2:Timer = new Timer(100);//firing rate
        private var bullet:Sprite = new Bullet();
        private var randomX:Number = Math.floor(Math.random() * 700 - 350);
        private var p:Plane;
        private var planeArray:Array = new Array();
        private var bulletName:Number = 0;
        //vars passed from main for bullet x/y direction
        private var objX:Number;
        private var objZ:Number;
       
        //--CONSTRUCTOR
        public function Car(x:Number, z:Number) {
            //trace(x);
            //trace(z);
            objX = x;
            objZ = z;
            initalize();
        }//constructor
       
        //--INITALIZE
        private function initalize():void{
            pCon = new DisplayObjectContainer3D();
            //this.addChild(pCon);
            buildCars();
            addListeners();
        }
       
        //--ADD LISTENERS
        private function addListeners():void{
            bulletTimer.addEventListener(TimerEvent.TIMER, fireBullets);
            bulletTimer2.addEventListener(TimerEvent.TIMER, plotPath);
        }
       
        //--BUILD CARS
        private function buildCars():void {
            //var p:* = new Plane();//new MovieMaterial(dust, false, true, false), 700, 1000);
            c = new Collada("Assets/dae/car.dae");
            cCon = new DisplayObject3D();
            cCon.addChild(c);
            addChild(cCon);
            //var t:* = new Collada("Assets/dae/hturret.dae");
            //--PLANE
            /*with (p) {
                rotationX = 270;
                x = 0;
                y = 0;
                z = -1000;
            }*/
            //--CAR
            with (cCon) {
                scale = .1;//.1 is ideal
                y = -450;
                rotationY = 180;
                rotationX = 270;
                rotationZ = 180;
                x = randomX;
            }
            //--TURRET
            /*with (t) {
                scale = .035;
                x = -30;//side to side
                y = 207;//up and down
                z = -280;//front to back
                //rotationY = 120;
            }*/
           
            TweenLite.to(cCon, 7, {delay:0, y:Math.random()*350 - 300});
           
            bulletTimer.start();
        }//--buildCars end
       
//____________________________________________________________________
//                                             BULLETS

        //-------FIRE BULLETS
        private function fireBullets(e:TimerEvent):void{
            p = new Plane(new MovieMaterial(bullet, false, true, false), 50, 10);
            with (p) {
                        rotationX = 270;
                        rotationY = 90;
                        x = 0;
                        y = 0;
                        z = 0;
                       
            }
            //trace(p.name);
            var doCon:* = new DisplayObject3D();
            with(doCon){
                scale = .4;
                y = cCon.y;
                x = cCon.x;
                rotationX = 20;
                addChild(p);
                name = "bullet";
            }
            addChild(doCon);
            pCon.addChild(doCon);
            planeArray.push(doCon);
            bulletTimer2.start();
           
            //trace(c.numChildren);
            if(planeArray.length > 10){
                planeArray.shift();
                pCon.removeChild(getChildByName("bullet"));
                trace(pCon.numChildren);
            }
           
           
            bulletName++;
        }
       
        //-------PLOT BULLET PATH
        private function plotPath(e:TimerEvent):void{
           
            for(var i:Number = 0; i < planeArray.length; i++){
                planeArray[i].moveUp(10);
            }
        }
    }//class
}//package





Daniel O' Brian <[hidden email]> wrote:
Try
 
removeChild(getChildByName(‘instanceName’));
 
or if you’re looping through a range of objects
 
var n:uint  = 1;
while(getChildByName(‘instanceName’+n) {
removeChild(getChildByName(‘instanceName’+n));
n++;
}
 
D

From: [hidden email] [mailto:[hidden email]] On Behalf Of Avery
Sent: 04 June 2008 09:11
To: [hidden email]
Subject: [Papervision3D] removeChildByName??????????????
 
had anyone got the RemoveChildByName method of the DisplayObjectContainer3D class to work? I have been pulling my hair out trying to remove displayObject3D instances.

 

This email transmission is confidential and intended solely
for the person or organisation to whom it is addressed. If you
are not the intended recipient, you must not copy, distribute
or disseminate the information, or take any action in relation
to it and please delete this e-mail. Any views expressed in
this message are those of the individual sender, except where
the sender specifically states them to be the views of any
organisation or employer. If you have received this message
in error, do not open any attachment but please notify the
sender (above). This message has been checked for all known
viruses powered by Messagelabs. For further information
visit www.messagelabs.com/stats.asp Please rely on your own
virus check as no responsibility is taken by the sender for
any damage rising out of any virus infection this communication
may contain.

LIDA Ltd 36 Golden Square, Soho, London, W1F 9EE, United Kingdom
Reg No. 03860916, registered in the United Kingdom.
_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org



My Portfolio Website


_______________________________________________
Papervision3D mailing list
[hidden email]
http://osflash.org/mailman/listinfo/papervision3d_osflash.org