📄 particlematerial.as
字号:
package org.papervision3d.materials.special{ import flash.display.Graphics; import org.papervision3d.core.geom.renderables.Particle; import org.papervision3d.core.proto.MaterialObject3D; import org.papervision3d.core.render.data.RenderSessionData; import org.papervision3d.core.render.draw.IParticleDrawer; import flash.geom.Rectangle; /** * @Author Ralph Hauwert * * updated by Seb Lee-Delisle * - added size implementation * - added rectangle of particle for smart culling and drawing * */ public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer { public static var SHAPE_SQUARE:int = 0; public static var SHAPE_CIRCLE:int = 1;
public var shape : int;
public function ParticleMaterial(color:Number, alpha:Number, shape:int = 0 ) { super(); this.shape = shape; this.fillAlpha = alpha; this.fillColor = color; } public function drawParticle(particle:Particle, graphics:Graphics, renderSessionData:RenderSessionData):void { graphics.beginFill(fillColor, fillAlpha); var renderrect:Rectangle = particle.renderRect; if(shape == SHAPE_SQUARE) graphics.drawRect(renderrect.x, renderrect.y, renderrect.width, renderrect.height); else if(shape == SHAPE_CIRCLE) graphics.drawCircle(renderrect.x+renderrect.width/2, renderrect.y+renderrect.width/2, renderrect.width/2); else trace("warning - Particle material has no valid shape - Must be ParticleMaterial.SHAPE_SQUARE or ParticleMaterial.SHAPE_CIRCLE"); //trace(renderrect.width, particle.size, particle.renderScale); graphics.endFill(); renderSessionData.renderStatistics.particles++; } public function updateRenderRect(particle : Particle) :void { var renderrect:Rectangle = particle.renderRect; if(particle.size == 0){ renderrect.width = 1; renderrect.height = 1; }else{ renderrect.width = particle.renderScale*particle.size; renderrect.height = particle.renderScale*particle.size; } renderrect.x = particle.vertex3D.vertex3DInstance.x - (renderrect.width/2); renderrect.y = particle.vertex3D.vertex3DInstance.y - (renderrect.width/2); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -