[Papervision3D] re nderLayer and ViewportLayer Problem
Moses Gunesch
fuse at mosessupposes.com
Thu Oct 2 08:01:21 PDT 2008
I've also been struggling with renderLayers() issues. I've discussed
it with andy a bit off list and run a bunch of tests. I'll share what
I've learned in case it helps you out.
The main issues that I've discovered have to do with *nesting*
DisplayObject3D's. I guess it makes sense that viewport layers should
not target nested objects directly, since the viewport wants to render
the layer at a top level, while the child DO3D's are not at that level.
So I've found that as long as you target *only DO3D's at the top level
of the scene* with your ViewportLayers / BitmapEffectLayers, and you
are sure to set useOwnContainer=true on those top-level DO3Ds, that
*renderLayers() will indeed work perfectly.*
(The top-layer DO3D's can be a clear container with solid child
objects and all of them will get rendered correctly by the viewport
layer in this scenario.)
The only drawback here is that if you have one container DO3D that you
would like to hold multiple children, there's no way to target each
child in its own viewportlayer, at least that I can figure out. I
tried creating a viewport layer for the container, then adding the
child-object viewportLayers to the top-level viewportLayer, but no
dice there. (So, nested viewportLayers don't really seem to be very
beneficial except maybe for z-ordering special cases.) In other words
it seems like the only way to get separate renderable viewportLayers
for each child object would be to literally create an extra, separate
parent container for each one. Which means a lot of extra code to
track and update those multiple parent containers etc.
Again, this kind of makes sense, since viewport layers exist at the
top viewport level. Even if we were just dealing with Sprites, it
would be a little absurd to say that you want to render separate
bitmaps of two child objects within a parent container from the top
level... here as well you would have to separate them into two
separate parent Sprites or do some kind of visibility-toggling
trickery when you capture each bitmap. So in general, nested
containers are convenient only until you start working with bitmap-
captures, then they are problematic – not just in PV3D but in the
plain old display list as well.
Maybe what we need is a special BitmapData.draw() feature that would
allow you to draw only selective sub-objects? Maybe I'll work on
writing a utility for this issue... it seems important.
m
On Oct 1, 2008, at 1:12 PM, charliek wrote:
>
> Hey guys,
>
> I'm having trouble with ViewportLayers and renderLayers. In my scene
> I have
> a collada model, which doesn't need to be rendered all the time, so
> I use
> renderLayers. By itself it works fine. But then primitives have to
> moved
> through holes in the dae model, so I need ViewportLayers for index
> sorting.
> By itself it works fine! But when I combine both the collada doesnt
> seem
> right. When dae moves number of triangles go up like crazy and
> framerate of
> course down.
> I've read about adding the children of the dae to the scene for both
> to work
> properly together, but I can't figure it out.
>
> Can someone please help me.
>
> Here is my code:
>
> //after dae LOAD_COMPLETE
>
> scene
> .addChild
> (dae.getChildByName("COLLADA_Scene").getChildByName("cube_a"));
> scene
> .addChild
> (dae.getChildByName("COLLADA_Scene").getChildByName("cube_b"));
> //couple of more children same
>
> dae.getChildByName("COLLADA_Scene").getChildByName("cube_a").scale =
> 600;
> dae.getChildByName("COLLADA_Scene").getChildByName("cube_b").scale =
> 600;
> //couple of more children same
>
> //renderLayers
>
> backLayer = new Array();
> frontLayer = new Array();
>
> backLayer.push(viewportMain.getChildLayer(dae, true, true));
> frontLayer.push(viewportMain.getChildLayer(pl, true, false));
>
> //Viewport Layers
>
> zBack = new ViewportLayer(viewportMain, null);
> viewportMain.containerSprite.addLayer(zBack);
> zBack.sortMode = ViewportLayerSortMode.INDEX_SORT;
>
> zBack.getChildLayer(dae, true,true).layerIndex = 0;
> zBack.getChildLayer(pl,true,true).layerIndex = 1;
>
>
> public funtion onEnterFrame(e.Event):void{
>
> renderer.renderLayers(scene, cameraMain, viewportMain, frontLayer);
>
> if (daeMoving){
> renderer.renderLayers(scene, cameraMain, viewportMain, backLayer);
> }
>
> --
> View this message in context: http://www.nabble.com/renderLayer-and-ViewportLayer-Problem-tp19764115p19764115.html
> Sent from the Papervision3D mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/papervision3d_osflash.org/attachments/20081002/63fc95a5/attachment.html
More information about the Papervision3D
mailing list