BitmapDataã使ã£ãParticle Systemã®å®è£
åãããã£ã¨æ°ã«ãªã£ã¦ããParticle Systemã®å®è£ æ¹å¼ã«ã¤ãã¦èª¿ã¹ã¾ããã
調æ»ãé²ãã¦ã¿ãã¨ãSpriteãããBitmapDataã使ã£ã¦æç»ãããã¨ããé¸æè¢ãããã¨ãããã¨ãåããæ°é®®ã§ããã
ã¨ãããã¨ã§ãä»åã¯BitmapDataã使ã£ãParticleSystemã®å®è£
ã解説ãã¾ãã
ããããParticle Systemã¯ãç²å(particle)ã®åããã·ãã¥ã¬ã¼ã·ã§ã³ãç²åã®ç¶æ ã«åºã¥ãã¦ç»é¢æç»ããã¨ããåä½ãç¹°ãè¿ãã¾ãã
ãã®ãåãã®ã·ãã¥ã¬ã¼ã·ã§ã³ãã¨ãç»é¢æç»ããåããã®ãé常ã«éè¦ã§ã調æ»åã®ç§ã®ç解ã§ã¯ãã®å¢çãææ§ã§ããã
Spriteã使ã£ã¦æç»ããParticle Systemã®å®è£
ã¯ããã¾ã«è¦ãããã®ã§ããã¦ç§ã¯ããã¦BitmapDataã«ç´æ¥æ¸ãè¾¼ãæ¹å¼ã§å®è£
ãã¦ã¿ã¾ããã
å®è£
ããã«ããã£ã¦ãaM laboratoryã®particlesãåèã«ãã¾ãããã¨ããããã»ã¼ãã®ã¾ã¾ã§ãã
æç»æ¹æ³ï¼setPixel() + BlurFilter
BitmapDataä¸ã«ããParticleã®ä½ç½®ã«setPixel()ã§ç¹ãæç»ããBlurFilterãé©ç¨ããæ¹æ³ã§ãã
ãã®æ¹æ³ã¯ã¨ã¦ãåç´ã ãã©ãè²ã
ã¨ä½¿ãåæãããããã§ãã
ã³ã¼ãã¯ã以ä¸ã®ããã«ãªãã¾ãã
var buffer:BitmapData = new BitmapData(WIDTH, HEIGHT, false, 0); var blur:BlurFilter = new BulrFilter(2,2,1); ï¼ä¸ç¥ï¼ buffer.setPixcel(particle.x, particle.y, particle.color); buffer.applyFilter(buffer, buffer.rect, ORIGIN, blur);
ãã®æ¹æ³ã使ã£ããµã³ãã«ã¯ã次ã®éãã§ãã
ç»é¢ä¸å¤®ä¸ããParticleã沸ãåºãã¦ãã¾ãã沸ãåºããéã«åé度ãã©ã³ãã ã§ä¸ãã以éã¯y軸æ¹åãçéãx軸æ¹åãããã®åãã«ãã¦ãã¾ãã
以ä¸ã®è¨å®ã ã¨ç»é¢ä¸å¤®ä»è¿ã®Particleã®å¯åº¦ãé«ããªãçã£ã½ãè¦ãã¾ãã
æç»æ¹æ³ï¼setPixel()ã®ã¿
次ã¯åç´ã«setPixel()ã®ã¿ã§æç»ãããµã³ãã«ã§ãã
Particleãåãå§ããå¾ã«å¤åãå ãã¦ãªãã®ã§Particleã®çåæéãè¨é²ãã¦ããã°ãéåçã§ãã¨ã®ç¶æ
ã«æ»ããã¨ãã§ãã¾ãã
ãã®ãµã³ãã«ã§ã¯ãéåçããéã«ï¼ã¹ããããã¤æ»ããã¨ã§åéãå®ç¾ãã¦ãã¾ãã
for ( i = 0; i < particles.length; i++ ) { p = particles[i]; if ( p.lifetime > 0 ) { if ( p.lifetime % 2 != 0 ) { p.x -= p.vx; p.y -= p.vy; p.lifetime -= 1; } else { p.x -= p.vx * 2; p.y -= p.vy * 2; p.lifetime -= 2; } } output.setPixel(p.x, p.y, p.color); }
ã½ã¼ã¹ã³ã¼ã
ãããããã¦ã³ãã¼ãã§ãã¾ãã
ï¼ãã¾ãï¼Particle Systemã¨ã¯ï¼
ããããParticle Systemã®å®ç¾©ã£ã¦ãªããªã®ããã¾ãã¡ãã³ã¨æ¥ãªãã£ãã®ã§ãParticleã®åèï¼ï¼ï¼ã«å½ãã£ã¦ã¿ã¾ããã
åèã«ããã¨ãParticleã¯ã
- ä½ç½®
- é度
- ãµã¤ãº
- è²ï¼ã¢ã«ãã¡å«ãï¼
- å½¢
- çåæé
ã®å±æ§ãæã¡ãæéã¨ã¨ãã«ãã®ç¶æ ãå¤åããã¾ãã
ä½æããParticleãå¿ ããããã¹ã¦ã®å±æ§ãæããªããã°ãªããªãã¨ãã訳ã§ã¯ãªãã§ãããä¸è¨ã«ä¸ããé ç®ã¯ãã使ããã¾ãã
åè
- aM laboratoryã®particles
- ãããã®ãã¼ãã£ã¯ã«
- Particle Systems - A Technique for Modeling a Class of Fuzzy Objects googleã®è«ææ¤ç´¢ã®çµæã¯ãã¡ãPDFããã¦ã³ãã¼ãåºæ¥ã¾ãã