topical media & game development

talk show tell print

student-ar-org-papervision3d-core-culling-RectangleLineCuller.ax

student-ar-org-papervision3d-core-culling-RectangleLineCuller.ax [swf] [flash] flex


  package org.papervision3d.core.culling {
        
          import flash.geom.Rectangle;        
        
        import org.papervision3d.core.geom.renderables.Line3D;        
        import org.papervision3d.core.culling.ILineCuller;
        
        import org.papervision3d.core.math.util.FastRectangleTools;        
        
        
        
*
author: Seb Lee-Delisle */ public class @ax-student-ar-org-papervision3d-core-culling-RectangleLineCuller implements ILineCuller { private var cullingRectangle : Rectangle; private var lineBoundsRect : Rectangle; // temporary rectangle to avoid object creation. private var rectIntersection : Rectangle; /** * @Author Seb Lee-Delisle * * @ax-student-ar-org-papervision3d-core-culling-RectangleLineCuller * * This Line Culler culls lines based upon whether they intersect the viewport rectangle. */ public function @ax-student-ar-org-papervision3d-core-culling-RectangleLineCuller(cullingRectangle:Rectangle = null):void { if(cullingRectangle){ this.cullingRectangle = cullingRectangle; } lineBoundsRect = new Rectangle(); rectIntersection = new Rectangle(); } public function testLine(line : Line3D) : Boolean { // if one or more of the points is behind the camera, then cull. if((!line.v0.vertex3DInstance.visible)||(!line.v1.vertex3DInstance.visible)) return false; var l0x : Number = line.v0.vertex3DInstance.x; var l0y : Number = line.v0.vertex3DInstance.y; var l1x : Number = line.v1.vertex3DInstance.x; var l1y : Number = line.v1.vertex3DInstance.y; // get the line bounds rect lineBoundsRect.width = Math.abs(l1x-l0x); lineBoundsRect.height = Math.abs(l1y-l0y); if(l0xrectIntersection.left) && (xcrossrectIntersection.left) && (xcrossrectIntersection.top) && (ycrossrectIntersection.top) && (ycross

(C) Æliens 04/09/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-2780434-1"; urchinTracker(); </script>