Great White, Meet Effects


demo1.jpg

So, after getting asked for the hundredth time the other day when I was going to integrate some of the features of the Effects Branch to Great White - I decided it was about time to do so. Things are settling in with my new job, and I've finished up my other obligations as well - so I put in the the time.

And now... They have been merged!!!

There are A LOT of changes though: creating layers, controlling layers, creating dynamic layers, sorting layers... its all different. Fortunately, I think for the better. I've comped up a set of VERY simple demos (all in one class) and will go over some of the new functionality here - just for you. Keep in mind this is still beta - so PLEASE report any bugs to me here or on the list.

--ViewportLayer has now replaced RenderLayer

Thats right - sorry. Forgot everything you ever knew about RenderLayers and RenderLayer syntax. Now - instead of layers being controlled by the objects - they are entirely controlled by the viewport. This means that you can create a layer for an object across multiple viewports.

Here's how you can create a new ViewportLayer:

Actionscript:
  1. var layer:ViewportLayer = viewport.getChildLayer(do3d, true);
  2. //now you can mess with your ViewportLayer all you want...
  3. layer.alpha = 0.5;

getChildLayer() is the function to receive or create a new ViewportLayer. The second parameter, createNew, specifies if a new ViewportLayer should be created if one is not found for the specified DisplayObject3D. If you set createNew to false- getChildLayer will simply return the ViewportLayer for the DO3D if it exists, otherwise it will return null.

Note that your DO3D is now going to be rendered to the layer created in getChildLayer(). If you want to add other DO3Ds to this layer, you can do so by using the following function of ViewportLayer:

Actionscript:
  1. //add a new DO3D to the layer created above.
  2. layer.addDisplayObject3D(new Sphere(new ColorMaterial()));

Likewise, you can remove DO3Ds from rendering to a specific layer by using removeDisplayObject3D.

--Nesting

Something else cool about ViewportLayers is they can be nested. Each ViewportLayer handles the sorting of its own children. So lets say you want to use INDEX sort for a COLLADA object with a fair number of z-fighting children - but you want that COLLADA to be z-sorted with the rest of your world. Now, you can.

Check out initNestingDemo() from the source. You will notice that we can create an empty ViewportLayer and add it to the viewport.containerSprite (also a ViewportLayer). Then we can create children inside that layer that will be INDEX sorted. Finally we create an external layer that will be Z sorted:

Actionscript:
  1. //s, s2, and s3 are three spheres added to the scene.
  2.  
  3. //create an empty viewport layer and add it to the container
  4. var parentLayer:ViewportLayer = new ViewportLayer(viewport, null);
  5. viewport.containerSprite.addLayer(parentLayer);
  6. parentLayer.sortMode = ViewportLayerSortMode.INDEX_SORT;
  7.  
  8. //create new layers inside the empty parentLayer and set some layer indexes for them
  9. parentLayer.getChildLayer(s, true).layerIndex = 1;
  10. parentLayer.getChildLayer(s2, true).layerIndex = 2;
  11.  
  12. //add s3 to a different layer off the main container - this will be z-sorted with parentLayer (with two index sorted children)
  13. viewport.getChildLayer(s3, true);

--useOwnContainer

This property gives you the ability to tell Papervision to dynamically create a layer for your DisplayObject3D when it is rendered in the viewport. By setting DisplayObject3D.useOwnContainer to true, your object will be rendered with its own ViewportLayer. Moreover, you can assign properties to your DisplayObject3D that will be passed along to your generated Layer. These properties are:

  • filters
  • blendMode
  • alpha

By setting these properties, you can add any filter to the layer, change the blendMode of your Layer, and control the alpha of the layer. Keep in mind that you can change these properties at runtime, as a new layer is generated every render, and it will inherit the updated settings. Here is a simple snippet of using these new properties:

Actionscript:
  1. var p:Plane = new Plane(new ColorMaterial());
  2. p.useOwnContainer = true;
  3. p.filters = [new BlurFilter(int(Math.random()*16)+2, int(Math.random()*16)+2)];
  4. p.blendMode= BlendMode.ADD;
  5. p.alpha = Math.random()+0.1;

You can see that we are creating a new plane, setting it to create a unique container, and then set an Additive blend mode, have a random alpha, and a random blur. In my code demo you will see that i create a large number of planes and change their filter's blur based on screenDepth (distance from the camera). Be sure to play with it.

--Effects

Effects have changed somewhat for GreatWhite too - but not too much. You still have BitmapEffectLayer - but it now extends ViewportLayer. You simply need to create a BitmapEffectLayer, at it to the containerSprite, and add your DisplayObject3Ds using addDisplayObject3D:

Actionscript:
  1. //create a new BitmapEffectLayer
  2. var bfx:BitmapEffectLayer = new BitmapEffectLayer(viewport, 500, 500);
  3. viewport.containerSprite.addLayer(bfx);
  4.  
  5. var s:Sphere = new Sphere(new WireframeMaterial());
  6. scene.addChild(s);
  7.  
  8. //add the sphere to the layer
  9. bfx.addDisplayObject3D(s);
  10.  
  11. //add a blur effect to the layer
  12. bfx.addEffect(new BitmapLayerEffect(new BlurFilter(2, 2, 8)));

You can add effects to other ViewportLayers by simply using the filters property inherent to all Sprites.

--Selective Layer Rendering

One other thing that has been added is the ability to render only selected ViewportLayers. I added this with the following scenario in mind: You have a large room, but the camera doesn't move much. You don't want to have to create a new Viewport for the floor, walls, etc - but also don't want them rendered every frame. Well, now you can tell your renderer which layers you want updated, and which to ignore. You can see this in the source under initLayerRenderDemo().

So how do we do it? All we need to do is create an Array with the ViewportLayers we want rendered - then call renderer.renderLayers(). Thats it! Here's a quick look:

Actionscript:
  1. layersToRender = new Array();
  2. layersToRender.push(viewport.getChildLayer(s, true));
  3. viewport.getChildLayer(s2, true);
  4. viewport.getChildLayer(s3, true);
  5. //pass the layer for s only to be rendered
  6. renderer.renderLayers(scene, camera, viewport, layersToRender);

Please note, that at this time, interaction will be lost for objects that aren't rendered again. I'll look into fixing this down the line.

--A Few Final Notes

Those sum up some of the biggest changes - there is some other stuff that might popup - if you have any questions, or need help figuring out whats going on - just let me know. Here are a few final tidbits:

DisplayObject3D.container - this references the last ViewportLayer your DO3D was rendered too. It is null before your object is rendered for the first time.

DisplayObject3D.createViewportLayer() - This function is another way to create a ViewportLayer. The first parameter is the viewport you want the layer created in. The second parameter specifies if you should set this to be the layer for all children of the current DO3D.

ViewportLayer.forceDepth - set this to true to set how far into the Z order your layer is rendered. Say, you know your floor should always be sorted 4500 away from the camera - but other things can sort around that. set forceDepth = true, and screenDepth = 4500 - and you've got it.

ViewportLayer.layerIndex - I mentioned it before - but you set this property when you have your layer.sortMode == RenderLayerSortMode.INDEX_SORT. Higher numbers will be higher on the DisplayList.

And again - this is beta - things will probably change. But let me or the team know if you find any bugs!!!

Get the Source

Enjoy!


69 Comments, Comment or Ping

  1. niiice… been looking fwd to this for a while now :)

    June 1st, 2008

  2. Very good job Andy :)
    now what’s going to happen to effects branch? is it to be abandoned? closed? or you’re going to put in it some other “extension” to gw? (maybe 3d effects such as melt mesh and so on..)

    thanx for sharing,
    bye from Venice :)

    June 1st, 2008

  3. Hi Andy!

    Thanks a lot for this update! I was troubled because I needed RenderLayers AND the latest GreatWhite updates in my project. Now it’s solved! Just a tiny question: do you know a fast and simple way to apply a nice fog effect on textured planes with the ViewportLayers? (An extension of your depth example) Thanks again for your great work!

    Barbara

    June 1st, 2008

  4. @Piergiorgio – Effects is going to be deleted. I haven’t deleted it yet just to make sure the new layering system is working well and doesn’t need any reworking. As for some future work – I’ve been playing with some fun mesh stuff I might throw in :)

    @Barbara – Something that might help is a distance shader i wrote: http://blog.zupko.info/?p=111. Use screenDepth instead of distance to a light and you can get a very nice fog effect. You could add that with a frustrum cam, and all objects outside the “foggy area” won’t be rendered.

    June 1st, 2008

  5. “ViewportLayer.forceDepth”

    Very nice! This is something I know a lot of the community has been adding in themselves, very nice to have it built in!

    June 1st, 2008

  6. Are the updates in SVN? Thanks for your hard work, I’m really excited that these branches will finally be merged :D

    June 1st, 2008

  7. Awesome Andy, and good luck with becoming DAD:)

    June 1st, 2008

  8. About time Andy!!!
    Naah, for real great job man ;)

    June 2nd, 2008

  9. gally

    Thx a lot.

    June 2nd, 2008

  10. gef

    Beautiful work!
    The depth demo running on FP10 is outstanding.

    June 2nd, 2008

  11. Hey Andy,

    great work man. I just update GreatWhitefrom SVN, and there are compile errors in BitmapViewport3D. Incompatible override for function updateAfterRender. Can you look at that?

    Thanks

    June 3rd, 2008

  12. you need to add default parameter , layers:Array = null to Viewport3D and IViewport3D to function updateAfterRender. At least after that, there are no compile errors. Can you check, if this is all what needs to be done?

    June 3rd, 2008

  13. @Franto – close! I just needed to delete that second parameter. I put it in originally when setting up selective layer rendering, but it uses a much cleaner way now. Update the SVN and you should be good to go!

    June 3rd, 2008

  14. Colby

    Hi Andy,

    I was trying to do your “initNestingDemo()” only I replaced the spheres with a plane and a Collada I imported. Even if that’s the only thing I change, the Collada is always rendered behind the plane. Is there something special you have to do with Colladas?

    Thanks!

    June 3rd, 2008

  15. @Colby – For Collada, you need to make sure that the entire collada file is loaded before you set its viewport layer – otherwise loaded children aren’t added to the viewport. Also, when you add it, you might try viewport.getChildLayer(dae, true, true); The second parameter, recurse, tells the viewport to set all children of the current object to that viewport as well.

    hth!

    June 3rd, 2008

  16. Mr. Zupko,

    You are a gentleman and a scholar.

    :0)

    June 6th, 2008

  17. Great work, thanks for your effort. But when I update GreatWhite from SVN (rev 585), there are several compile errors ( I was trying to create a swc in a Flex library project)….:(
    i know all problems will be solved :)

    June 8th, 2008

  18. Great demo. Can you please tell me how to increase the rate at which effects dissipate? (So that the trail is shorter)

    June 8th, 2008

  19. malte

    cool that the effect branch is merged with the rest of pv. Is there some documentation of the sound 3d object? i can t find anything, only definition. A tutorial would be great. Is it possible to use multiple sounds with the sound3d object?
    thanks a lot
    malte

    June 9th, 2008

  20. gally

    removeDisplayObject3D just don’t work, i dunno why :/

    June 18th, 2008

  21. @pickle – if you increase the blur or colortransform the trail will dissipate faster.

    @gally – thanks for the tip – i’ll check it out. i recently made some big changes to the backend of the layers so i might have broke it.

    June 19th, 2008

  22. Hey there…
    Question (if possible)..I tried to work with your ViewportLayer. Because in this way (by switching on and off rendering of certain layers) I thing I can manage to get a higher FPS. Cause now..it is getting too slow.

    But using this option of an array containing the layer to be rendered (renderer.renderLayers(scene, camera, viewport, layersToRender);) cause the script to place object over object over object. In other words. The same instance is created over and over again. Is this a bug? Or am I the bug?

    June 20th, 2008

  23. @Wink – I just tested the renderLayers and they were working fine for me with the newest revision. Feel free to send me a code snippet and I might be able to help out.

    azupko@zupko.info

    June 20th, 2008

  24. Hi.

    I’m trying to achieve the following setup using nesting of ViewportLayers:

    viewport.containerSprite
    |_container layer (Z_SORT)
    |_container layer (INDEX_SORT)
    |_layer 1
    |_layer 2
    |_layer 3
    |_(…)

    So the expected result will be some properly z-sorted layers
    which holds a layer with index-sorted layers.

    It’s almost like in your nesting demo but instead of adding INDEX_SORT’ed layer directly to the viewport.containerSprite I’m trying add it to ViewportLayer created via viewport.getChildLayer( myDo3D, true ).

    Sadly.. it doesn’t work :(
    I’m getting following error:

    Main Thread (Suspended: TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::Event@135b3041 to org.papervision3d.view.layer.ViewportLayerEvent.)
    flash.events::EventDispatcher/dispatchEventFunction [no source]
    flash.events::EventDispatcher/dispatchEvent [no source]
    org.papervision3d.view.layer::ViewportLayer/linkChild
    org.papervision3d.view.layer::ViewportLayer/onChildAdded
    flash.events::EventDispatcher/dispatchEventFunction [no source]
    flash.events::EventDispatcher/dispatchEvent [no source]
    org.papervision3d.view.layer::ViewportLayer/linkChild
    org.papervision3d.view.layer::ViewportLayer/addLayer
    org.papervision3d.view.layer::ViewportLayer/getChildLayerFor
    org.papervision3d.view.layer::ViewportLayer/getChildLayer
    MainView/initNestingDemo

    Take a look at code snippet:
    http://jkozniewski.com/test/nestingLayers.txt

    Regards.

    June 21st, 2008

  25. @jkozniewski – Thanks for pointing that out. There seems to be a weird issue with casting events. I fixed it and the newest revision in GW will work now. Also – your code snippet will need some revision. Right now you have zSortedLayer as the VPL that is created for set1Holder. To get correct z-sorting – set1Holder will need to be a child OF zSortedLayer – otherwise it will always be drawn to the graphics channel of zSortedLayer and will always be behind any layers added to it.

    hth!

    -andy

    June 21st, 2008

  26. Hi Andy!

    Thanks for such immediate response and support ! I’m realy appreciate your effort.

    Nevertheles I have to confess ;) that your advice is not 100% clear to me… Could you post a code example for clarification ? I would be grateful since I’m a bit lost between those layers ;)

    June 21st, 2008

  27. Hi.

    I’m posting a code snippet in which I’m trying to folow your advice… it doesn’t work as expected though.
    I’ve tried a lot of combinations (nesting structures, ViewportLayer methods… ) but none of them worked. I’m missing something fundamental or such setup is not possible currently ?

    A code snippet:

    // Create a layer of which all child-layers will be z-sorted and add it to
    // top-level VPL (containerSprite).
    var zSortedLayer:ViewportLayer = new ViewportLayer( viewport, null );
    viewport.containerSprite.addLayer( zSortedLayer );

    // Create a CHILD of zSortedLayer linked to set1Holder and
    // set sortMode to INDEX_SORT so any sublayers will be free of z-fighting
    // but as holderLayer is child of zSortedLayer it should be properly
    // z-sorted as a whole…
    var holderLayer:ViewportLayer = zSortedLayer.getChildLayer( set1Holder, true );
    holderLayer.sortMode = ViewportLayerSortMode.INDEX_SORT;

    // Create ViewportLayers for blue and red planes ( do3d objects holded by set1Holder )
    // so they would be index-sorted to avoid z-fighting.
    holderLayer.getChildLayer( s1red, true ).layerIndex = 1;
    holderLayer.getChildLayer( s1blue, true ).layerIndex = 2;

    // Add just another z-sorted ViewportLayer to test z-sorting….
    var anotherZSortedLayer:ViewportLayer = viewport.getChildLayer( whitePlane, true );

    Regards!

    June 22nd, 2008

  28. Hi,

    I think I’ve found a bug and solution for it in ViewportLayer…

    There was something bad with calculating screenDepth when sortMode was set to INDEX_SORT – it was higher than it should (in compare with standard “Z_SORT” mode) so every children od such layer where drawn behind Z_SORT’ed layers if the difference between z positions was relatively low.

    The problem sits in following piece of code:

    protected function reset():void{

    if( sortMode == “z” && !forceDepth)
    screenDepth = 0;

    this.weight = 0;

    }

    so in case of sortMode == INDEX_SORT depth wasn’t reset properly…
    just comment out >> sortMode = “z”

    June 23rd, 2008

  29. @jkozniewski – Thanks for the fix! The SVN has been updated with that fix plus some others – so layering *should* be working now. Please let me know if you find anything else though so i can get it up!

    -andy

    June 24th, 2008

  30. I’ve just tested, everything works great! :)

    Good stuff!

    July 2nd, 2008

  31. Ugo

    This has opened up ALOT of doors for projects I’m working so your hard work’s much appreciated. However I’m struggling with a bug mentioned by “WINK”. I’ve tested with the latest SVN and it seems that using:

    renderer.renderLayers(scene, camera, viewport, layersToRender)

    where ‘layersToRender’ containers a collada displayObject will cause multiple instances of the viewport to be redrawn eventually choking the framerate :(

    works fine with primitive objects though.

    July 8th, 2008

  32. Dinesh Peiris

    hi, get work :)
    I use the update version of the Great White, but when I try to compile it I will get this msg:
    1119: Access of possibly undefined property TYPE through a reference with static type Class.
    1061: Call to a possibly undefined method hover through a reference with static type org.papervision3d.cameras:Camera3D.
    How do I fix this pls guide me ?
    Thanks

    July 18th, 2008

  33. \m/ rock on andy! what a huge improvement!

    July 23rd, 2008

  34. NIITer

    good job for you, but not me. I can’t complete it in FlashIDE, it appear error:
    “1061: Call to a possibly undefined method hover through a reference with static type org.papervision3d.cameras:Camera3D.”

    I have check out new trunk of greatWhite but when I explore, I didn’t see hover method in Camera3D.as, it exits in old version GreatWhite.
    Can you show me the version of Opensource you use for this example
    Early thanks!

    July 23rd, 2008

  35. NITer, this method is stated as experimatal in the API docs ( http://www.papervision3d.org/docs/as3/org/papervision3d/cameras/Camera3D.html#hover() )
    I can´t find it implemented in the actuial repository neither. So use a alternative custom method instead. For example:

    private function renderMouseDependencyFrame():void
    {
    var fac:int = 5;
    camera.x-=(camera.x – Math.sin((stage.mouseX-(stage.stageWidth/2))*0.0001)*8000)/fac;
    camera.z-=(camera.z – Math.cos((stage.mouseX-(stage.stageWidth/2))*0.0001)*-1300)/fac;
    camera.y -= (camera.y – Math.sin((stage.mouseY-(stage.stageHeight/2))*0.0001)* -8000)/fac;
    }

    August 4th, 2008

  36. dave

    you can pull hover from papervision 1.5.

    August 11th, 2008

  37. William

    For the love of all that’s holy can someone PLEASE post something coherent that uses the Flash CS3 IDE AND the latest trunk of GreatWhite with integrated effects. Papervision has to be THE worst example of community documentation / milestone builds that I have ever seen. I’d love to use it. I’d love to spread the Papervision/Flash gospel. I can’t. It’s all such a mess of dependencies and incoherent Flex examples. Please, I implore someone to help me. I can take it forward from there and try to help others get this mess working.

    August 17th, 2008

  38. @William – If you are trying to learn Papervision, I would start with an introductory site, such as pv3d.org or papervision2.com. The Great White branch is ALPHA – the documents for the current trunk are up to date. If you want to use the ALPHA release, you have to do a bit of digging – but it shouldn’t even be that difficult given the number of community tutorials and threads on the topic. We are hoping to have the documents released within the next few weeks for the Great White branch. Papervision is also always changing and developing, so if you use a branch, rather than the trunk, you can’t expect all examples online from a couple months ago to work with the latest revision – no one would.

    As for Flex/Flash issues – go download FlashDevelop or Eclipse. My examples are pure AS3 – so for most of them (such as the one above) you simply need to make the file your document class in the IDE. If you aren’t sure how to do this, then you will need to go to some more introductory sites on learning Flash in general.

    hth.

    August 17th, 2008

  39. William

    Thanks, I appreciate it and should probably say that I’m extremely frustrated that I can’t easily work with something so incredibly wonderful – hence my hasty response. I’ll take a deeper look into this.

    August 17th, 2008

  40. Loockas

    Hi, I’ve noticed that z-sorting among sibling layers (while the parent one is set to z-sorting) doesn’t work. However index sorting runs fine.

    Example that works:
    parentLayer (INDEX_SORT)
    |_ child1Layer (index 1)
    |_ child2Layer (index 2)

    Example that doesn’t work:
    parentLayer (Z_SORT)
    |_ child1Layer
    |_ child2Layer

    child2Layer is ‘over’ child1layer because its do3d was set after child1layer’s do3d

    Is it really wrong or did I missed something?

    August 19th, 2008

  41. Saul

    Dear Andy, I have been watching your efforts from a far for some time now and very much like your work.

    I am using pure AS3 (proj) in flex IDE and am having the same problem as William who needs to chill a little but we all have days like that and i understand the frustration, though sometimes remind people that this is a free/open source 3D engine!

    Andy i get two errors when i try to compile. The first is 1061: Call to a possibly undefined method hover through a reference with static type org.papervision3d.cameras:Camera3D., the second is 1119: Access of possibly undefined property TYPE through a reference with static type Class.

    Andy I understand that these probably require simple fixes. I’ve done every tutorial out there but coding comes better to some than others – i’m no noob – some beg to differ and don’t you dare take an o outta there! ;)

    Nevertheless, Andy you were once new to this world, and for those of us who are simply not as talented as you or others out there it would be very kind and humbling if you could give definitive help with regards to the problems outlined herein this little message of love and thx for all your great efforts.

    September 1st, 2008

  42. saul

    Quick Fix to:

    a). 1119: Access of possibly undefined property TYPE through a reference with static type Class.
    b). 1061: Call to a possibly undefined method hover through a reference with static type org.papervision3d.cameras:Camera3D.

    a). In MainView in public function MainView use:

    super(640, 480, true, false, “CAMERA3D”);

    b). In MainView in layerDemoTick and tick use:

    camera.x = camera.x + (mouseX – stage.stageWidth * 0.5 – camera.x) * 0.1;
    camera.y = camera.y + (mouseY – stage.stageHeight * 0.5 – camera.y) * 0.1;
    //use where the camera reference was b4.

    Thats a very simple fix. It will allow you to compile and view some of the effects.

    September 2nd, 2008

  43. I can’t seem to get a blur affect applied to a Dae model. I make a LOAD_COMPLETE event that applies the blur to the layer that i added the dae to.

    red = new DAE();
    red.load(“red.dae”, materialList);
    red.addEventListener(FileLoadEvent.LOAD_COMPLETE, applyBlur);
    red.scale = 2;
    red.useOwnContainer = true;
    current_scene.addChild(red);
    var layer:ViewportLayer = new ViewportLayer(current_viewport, red).getChildLayer(red, true);

    and in the event function i added:
    var blur:BlurFilter = new BlurFilter(24,24, 2);
    red.filters = [blur];

    I’m not sure what i’m doing wrong, perhaps i handle the dae vs Layer thing wrong. Anyone able to throw me a bone?

    September 10th, 2008

  44. @Kevin – You need to either use useOwnContainer OR do a getChildLayer (not both). If you want to use useOwnContainer, set it after the load, where you set the filters. That *should* fix the problem.

    September 10th, 2008

  45. Thanks andy, worked like a charm!

    September 11th, 2008

  46. Andre Hines

    Thank you for your great work! Question though. When removing a do3D from a ViewportLayer, do we also have to remove the do3D from the layersToRender? When I remove from ViewportLayer, flash begins to chugg until crash, and it still renders do3D?

    October 1st, 2008

  47. Andre Hines

    OK, I saw another post in Nabble about children not being able to selective render.

    October 1st, 2008

  48. ben

    “Please note, that at this time, interaction will be lost for objects that aren’t rendered again.”

    The click seems to work and over and out work one time but then not again. Is these a workaround for this at all? I desperately need it! Thanks in advance if you can help.

    b

    December 11th, 2008

  49. Rohan Rehman

    Hi Andy,

    I am having an issue with useOwnContainer and nested DO3D.

    I have created a PlaneA with useOwnContainer set to true and added a filter to the plane ( no prob here).

    But once I add PlaneB inside of PlaneA, with PlaneB useOwnContainer set to true, with a filter added or an alpha change.

    PlaneB (nested in PlanA) has no alpha change nor any filters applied to it?

    Thank You for your help.

    Rohan

    December 22nd, 2008

  50. Hey genius boy!!!

    Thanks for your hard work!!! You’re a great developer

    With this effects I’m having a little struggle.

    I’m trying to make an inverse mask: I have DAE’s orbiting around a central object which I don’t want to be shown.

    So, I’ve been trying to use different methods to accomplish this.

    The only one that works more or less is to set a green ColorMaterial for that object, and then to apply a ColorMatrixFilter to THE VIEWPORT as follows:
    this.viewport.blendMode = BlendMode.LAYER;
    _object.filters = [new ColorMatrixFilter([ 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, -1, 1, 1, 0 ]);];

    But the edges are just… UGLY!

    Now, I wanted to use your viewportLayers, so I gave it a try with BlendMode:

    _object.useOwnContainer = true;
    _object.blendMode= BlendMode.ERASE;
    while orbiting DAEs’ .useOwnContainer prop is also set to true.

    And IT DOESN’T WORK. Which is kinda weird, because if I set the blendMode to BlendMode.ADD, EVERYTHING WORKS FINE (objects in the back are added to the object BUT DAEs that are in front are not affected)

    I wish this worked with BlendMode.ERASE so that I can set this inverse making properly.

    You have any idea on how to accomplish this?

    Thx buddy.

    May 2nd, 2009

  51. Your blog is really usefull ! thank you
    Just a question concerning initNestingDemo : how can I do to s3 sphère in front of parentLayer without fixing its z order ?

    May 3rd, 2009

  52. Hi Andy,

    You know if use set the useOwnContainer with true then the InteractiveScene3DEvent.OBJECT_CLICK no more works?

    I have an object of DisplayObject3D class which contains 3 planes and for one of them i have set useOwnContainer = true because I want to fade-in and fade-out the plane for which I have set useOwnContainer = true. I had following 3 lines:
    borderPlane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, planeClickHandler);
    borderPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, planeRolloverHandler);
    borderPlane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, planeRolloutHandler);

    the planeClickHandler event listener function never fired so I changed the first line to:
    borderPlane.addEventListener(InteractiveScene3DEvent.OBJECT_RELEASE, planeClickHandler);

    and worked like a charm. I think there is some kind of bug with the OBJECT_CLICK event.

    May 9th, 2009

  53. coolieu

    Hey!

    I lose the shader for all nonrendered Objects after a renderLayers call.

    I’m doing sth. like:

    loop creating planes:

    var plane : PaperPlane = new PaperPlane( id, myShadedMaterial, 400, 400, 6, 6 );
    scene.addChild( plane );

    then creating the layers:
    var layer : ViewportLayer = viewport.getChildLayer(plane, true);

    after a handlercall get the layer by id and render only the layer

    var renderLayers : Array = new Array( viewport.getChildLayer( _planes[ id ] ) );

    renderer.renderLayers( scene, camera, viewport, renderLayers );

    all other planes lose their shaders and get black. only a Scene Render bring the shaders back.
    Its a performanceboost but it dont help this way. The interaction bug is a little sad too.

    but cool thing it might be!

    August 28th, 2009

  54. HadiMetal

    Hi MR Zupko
    I’m working flash cs4 3d web designe. and i have problem with collada (DAE) import papervision 3d 2.0. I created an 3d model in 3d max 9.0 and put an image material it. i used UVW map modifier for best material coordinate and subdivide SWM Modifier for change quad meshes to triangle meshes.
    then export that project to 3ds format file . then i import that to blender and push textured button in blender . then exported that to DAE 1.4 format . i pushed triangle button when export from blender; now i’m using of DAE class in pv3d but when i rotate this collada model in papervision 3d , the faces of this model are broken . in rotation , material coordinate is particled and when angle of rotation is changing , its like that faces and borders are broken. how can i solve this problem???
    please help me…
    thx Andy…

    November 14th, 2009

  55. HadiMetal

    sure andy I’m HadiMetal
    my available e-mail add is :
    hadimetal_1981@yahoo.com
    with underline

    November 14th, 2009

  56. @Sher Ali

    “You know if use set the useOwnContainer with true then the InteractiveScene3DEvent.OBJECT_CLICK no more works?”

    you can edit:papervision3d/view/layer/ViewportLayer.as

    add this line:this.mouseChildren = false;

    public function ViewportLayer(viewport:Viewport3D, do3d:DisplayObject3D, isDynamic:Boolean = false)
    {
    super();
    this.viewport = viewport;
    this.displayObject3D = do3d;
    this.dynamicLayer = isDynamic;
    this.graphicsChannel = this.graphics;
    if(isDynamic){
    this.filters = do3d.filters;
    this.blendMode = do3d.blendMode;
    this.alpha = do3d.alpha;
    }
    if(do3d){
    addDisplayObject3D(do3d);
    do3d.container = this;
    }
    this.mouseChildren = false;
    init();
    }

    August 30th, 2010

  1. Seb Lee-Delisle - November 1, 2008

Reply to “Great White, Meet Effects”