topical media & game development
student-ar-org-papervision3d-core-culling-RectangleParticleCuller.ax
student-ar-org-papervision3d-core-culling-RectangleParticleCuller.ax
[swf]
[flash]
flex
package org.papervision3d.core.culling {
import org.papervision3d.core.geom.renderables.Particle;
import org.papervision3d.core.geom.renderables.Vertex3DInstance;
import org.papervision3d.core.geom.renderables.Vertex3D;
import flash.geom.Rectangle;
import flash.geom.Point;
import org.papervision3d.core.math.util.FastRectangleTools;
public class @ax-student-ar-org-papervision3d-core-culling-RectangleParticleCuller implements IParticleCuller
{
private static var vInstance:Vertex3DInstance;
private static var testPoint:Point;
public var cullingRectangle:Rectangle;
public function @ax-student-ar-org-papervision3d-core-culling-RectangleParticleCuller(cullingRectangle:Rectangle = null)
{
this.cullingRectangle = cullingRectangle;
testPoint = new Point();
}
public function testParticle(particle:Particle):Boolean
{
vInstance = particle.vertex3D.vertex3DInstance;
// TODO I don't trust the speed of the built-in Rectangle.intersects function -
// and have a fast algorithm so I'll write a new intersect function! [Seb]
if(particle.material.invisible == false){
if(vInstance.visible)
{
if(FastRectangleTools.intersects(particle.renderRect, cullingRectangle))
{
return true;
}
}
}
return false;
}
}
}
(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.