« Return to Thread: displayobject boundary box?

Re: displayobject boundary box?

by quinrou . :: Rate this Message:

Reply to Author | View in Thread

cool thanks for the tip J-reon

On Sat, Jul 5, 2008 at 6:57 PM, J-roen <me@...> wrote:
Hello Seb,

There is actually a method built into papervision that does exactly that:
It is in DisplayObject3D.
So you can do something like:

bbox = this.boundingBox();

and then get properties like:
bbox.min.x / y / z
bbox.size.x / y / z

documentation is here:
http://www.flashbookmarks.com/PV3D-GreatWhite-DOC/org/papervision3d/core/geom/Vertices3D.html#boundingBox()

J-roen

quinrou . schreef:
> Niceone Michael, thanks a lot for that.
> seb
>
> On Wed, Jul 2, 2008 at 7:32 PM, T. Michael Pardon
> <codejockey1@... <mailto:codejockey1@...>> wrote:
>
>     I found this utility class a while back when I was trying to do
>     the same thing.  I don't remember who posted it originally, but if
>     I find the original post I will update this thread.
>
>     package
>     {
>             import org.papervision3d.core.geom.renderables.Vertex3D;
>             import org.papervision3d.objects.DisplayObject3D;
>
>             public class BoundingBox
>             {
>                     public var maxX :Number = 0;
>                     public var minX :Number = 0;
>                     public var maxY :Number = 0;
>                     public var minY :Number = 0;
>                     public var maxZ :Number = 0;
>                     public var minZ :Number = 0;
>
>                     public var sizeX :Number = 0;
>                     public var sizeY :Number = 0;
>                     public var sizeZ :Number = 0;
>
>                     public function BoundingBox( object:DisplayObject3D )
>                     {
>                             parseMesh( object );
>
>                             sizeX = maxX - minX;
>                             sizeY = maxY - minY;
>                             sizeZ = maxZ - minZ;
>                     }
>
>                     private function
>     parseMesh(object:DisplayObject3D):void
>                     {
>                             if (object.children)
>                                     for each(var child:DisplayObject3D
>     in object.children)
>                                             parseMesh(child);
>
>                             if ( !object.geometry)
>                                     return;
>
>                             for each(var vertex:Vertex3D in
>     object.geometry.vertices)
>                             {
>                                     maxX = Math.max(maxX, vertex.x);
>                                     minX = Math.min(minX, vertex.x);
>                                     maxY = Math.max(maxY, vertex.y);
>                                     minY = Math.min(minY, vertex.y);
>                                     maxZ = Math.max(maxZ, vertex.z);
>                                     minZ = Math.min(minZ, vertex.z);
>                             }
>                     }
>             }
>     }
>
>     _______________________________________________
>     Papervision3D mailing list
>     Papervision3D@... <mailto:Papervision3D@...>


_______________________________________________
Papervision3D mailing list
Papervision3D@...
http://osflash.org/mailman/listinfo/papervision3d_osflash.org

 « Return to Thread: displayobject boundary box?