[Papervision3D] Viewportlayers and child objects

nospam at therossman.org nospam at therossman.org
Fri Jul 31 08:59:37 PDT 2009


yeah....hopefully PapervisionX!!


> thats been on the "meaning to add" list for more than 1/2 a year.
> don't hold your breath. i think the dev team has higher priorities.
> _
> On Jul 31, 2009, at 11:40 AM, quinrou . wrote:
>
>> hi,
>>
>> has this feature been implemented?
>>
>> I have to re create the VPL every time i want add more object to it
>> otherwise i am getting some depth issue and display problems.
>>
>>
>> thanks
>> S
>>
>> On Mon, Apr 20, 2009 at 7:03 PM, Andy Zupko <azupko at zupko.info> wrote:
>> That functionality is something that i have been meaning to add.
>> I'll try and do it this week.  The concept would be:
>>
>> When an object is added to a layer and recurse is true, a flag is
>> set on that object
>>
>> when a child is added, it checks parent.recurseLayer (or whatever
>> the flag is) and if set, it adds itself to that layer as well, along
>> with its children.  So on and so forth.
>>
>> you could probably implement something yourself until i get a chance
>> too.
>>
>> hth
>>
>>
>> On Apr 20, 2009, at 11:41 AM, Erik Rave wrote:
>>
>>> Hey everybody,
>>>
>>> I have a question about viewportlayers.
>>>
>>> If I add a do3d to a viewportlayer and after that, that same do3d
>>> creates a child and does a 'addchild', this child doesn't
>>> automatically get added to the same viewportlayer as its parent.
>>> Why is this? And is there a way to automate this?
>>>
>>> In the following example I create 2 viewport layers. One holding a
>>> plane and one holding a Foo object which is an extended do3d.
>>> Inside this foo object runs a script that adds a sphere every
>>> 500ms. The thing is that only the first sphere gets added to the
>>> correct viewportlayer the rest doesn't.
>>>
>>> package
>>> {
>>>     import flash.display.Sprite;
>>>     import flash.events.Event;
>>>     import org.papervision3d.materials.ColorMaterial;
>>>     import org.papervision3d.objects.primitives.Plane;
>>>     import org.papervision3d.view.BasicView;
>>>     import org.papervision3d.view.layer.util.ViewportLayerSortMode;
>>>     import org.papervision3d.view.layer.ViewportLayer;
>>>
>>>     public class Main extends BasicView
>>>     {
>>>         public function Main():void
>>>         {
>>>             super();
>>>
>>>             var p:Plane = new Plane( new ColorMaterial(), 800, 800 );
>>>             var f:Foo = new Foo();
>>>
>>>             scene.addChild( p );
>>>             scene.addChild( f );
>>>
>>>             var v1:ViewportLayer = viewport.getChildLayer( p );
>>>             var v2:ViewportLayer = viewport.getChildLayer( f );
>>>
>>>             viewport.containerSprite.sortMode =
>>> ViewportLayerSortMode.INDEX_SORT;
>>>
>>>             v1.layerIndex = 1;
>>>             v2.layerIndex = 2;
>>>
>>>             v1.alpha = .8;
>>>
>>>             startRendering();
>>>         }
>>>     }
>>> }
>>>
>>> package
>>> {
>>>     import flash.utils.setTimeout;
>>>     import org.papervision3d.lights.PointLight3D;
>>>     import
>>> org.papervision3d.materials.shadematerials.FlatShadeMaterial;
>>>     import org.papervision3d.objects.DisplayObject3D;
>>>     import org.papervision3d.objects.primitives.Sphere;
>>>
>>>     public class Foo extends DisplayObject3D
>>>     {
>>>         public function Foo()
>>>         {
>>>             createSphere ( 80, 0, 0, 0 );
>>>         }
>>>
>>>         private function createSphere ( r:Number, x:Number,
>>> y:Number, z:Number ) :void
>>>         {
>>>             var s:Sphere = new Sphere( new FlatShadeMaterial( new
>>> PointLight3D() ), r );
>>>             s.x = x;
>>>             s.y = y;
>>>             s.z = z;
>>>             addChild( s );
>>>
>>>             var radius  :Number =   20 + ( Math.random() *  60 );
>>>             var xpos    :Number = -400 + ( Math.random() * 800 );
>>>             var ypos    :Number = -400 + ( Math.random() * 800 );
>>>             var zpos    :Number = -400 + ( Math.random() * 800 );
>>>
>>>             setTimeout( createSphere, 500, radius, xpos, ypos,
>>> zpos );
>>>         }
>>>     }
>>> }
>>>
>>>
>>> I did find a way to add the spheres to the correct viewportlayer by
>>> adding the following to the createSphere function:
>>>
>>> if ( container )
>>> {
>>>     var l:ViewportLayer = container.getChildLayer( this );
>>>     l.addDisplayObject3D( s );
>>> }
>>>
>>> But my gut tells me this is not the way to go and that it would be
>>> much more logical that a child object would always be added to the
>>> same viewport as its parent.
>>> Is there a way to do this automatically, or am i stuck with my own
>>> solution?
>>>
>>> Thanks in advance!
>>>
>>> Erik.
>>>
>>>
>>> _______________________________________________
>>> Papervision3D mailing list
>>> Papervision3D at osflash.org
>>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>>
>>
>> _______________________________________________
>> Papervision3D mailing list
>> Papervision3D at osflash.org
>> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>
> _______________________________________________
> Papervision3D mailing list
> Papervision3D at osflash.org
> http://osflash.org/mailman/listinfo/papervision3d_osflash.org
>





More information about the Papervision3D mailing list