home *** CD-ROM | disk | FTP | other *** search
/ Computer Active 2010 August / CA08.iso / Multimedija / shufflr.air / ShufflrClient.swf / scripts / org / papervision3d / materials / special / ParticleMaterial.as < prev   
Encoding:
Text File  |  2010-06-23  |  2.3 KB  |  69 lines

  1. package org.papervision3d.materials.special
  2. {
  3.    import flash.display.Graphics;
  4.    import flash.geom.Rectangle;
  5.    import org.papervision3d.core.geom.renderables.Particle;
  6.    import org.papervision3d.core.log.PaperLogger;
  7.    import org.papervision3d.core.proto.MaterialObject3D;
  8.    import org.papervision3d.core.render.data.RenderSessionData;
  9.    import org.papervision3d.core.render.draw.IParticleDrawer;
  10.    
  11.    public class ParticleMaterial extends MaterialObject3D implements IParticleDrawer
  12.    {
  13.       public static var SHAPE_SQUARE:int = 0;
  14.       
  15.       public static var SHAPE_CIRCLE:int = 1;
  16.       
  17.       public var shape:int;
  18.       
  19.       public var scale:Number;
  20.       
  21.       public function ParticleMaterial(param1:Number, param2:Number, param3:int = 0, param4:Number = 1)
  22.       {
  23.          super();
  24.          this.shape = param3;
  25.          this.fillAlpha = param2;
  26.          this.fillColor = param1;
  27.          this.scale = param4;
  28.       }
  29.       
  30.       public function drawParticle(param1:Particle, param2:Graphics, param3:RenderSessionData) : void
  31.       {
  32.          param2.beginFill(fillColor,fillAlpha);
  33.          var _loc4_:Rectangle = param1.renderRect;
  34.          if(this.shape == SHAPE_SQUARE)
  35.          {
  36.             param2.drawRect(_loc4_.x,_loc4_.y,_loc4_.width,_loc4_.height);
  37.          }
  38.          else if(this.shape == SHAPE_CIRCLE)
  39.          {
  40.             param2.drawCircle(_loc4_.x + _loc4_.width / 2,_loc4_.y + _loc4_.width / 2,_loc4_.width / 2);
  41.          }
  42.          else
  43.          {
  44.             PaperLogger.warning("Particle material has no valid shape - Must be ParticleMaterial.SHAPE_SQUARE or ParticleMaterial.SHAPE_CIRCLE");
  45.          }
  46.          param2.endFill();
  47.          ++param3.renderStatistics.particles;
  48.       }
  49.       
  50.       public function updateRenderRect(param1:Particle) : void
  51.       {
  52.          var _loc2_:Rectangle = param1.renderRect;
  53.          if(param1.size == 0)
  54.          {
  55.             _loc2_.width = 1;
  56.             _loc2_.height = 1;
  57.          }
  58.          else
  59.          {
  60.             _loc2_.width = param1.renderScale * param1.size * this.scale;
  61.             _loc2_.height = param1.renderScale * param1.size * this.scale;
  62.          }
  63.          _loc2_.x = param1.vertex3D.vertex3DInstance.x - _loc2_.width / 2;
  64.          _loc2_.y = param1.vertex3D.vertex3DInstance.y - _loc2_.width / 2;
  65.       }
  66.    }
  67. }
  68.  
  69.