[Papervision3D] displayobject boundary box?
quinrou .
quinrou at gmail.com
Thu Jul 3 13:54:26 PDT 2008
Niceone Michael, thanks a lot for that.
seb
On Wed, Jul 2, 2008 at 7:32 PM, T. Michael Pardon <codejockey1 at gmail.com>
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 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/20080703/202e6f42/attachment-0001.html
More information about the Papervision3D
mailing list