Thursday, December 20, 2007

Papervision3D GreatWhite : Animated Particles

What for?
  1. learn to modify more complicate package
  2. x-mas fun/gift ;D

  1. PaperVision3D 2.0 GreatWhite rev 385
  2. John Grden Shader demo :
  3. 2 brains
How to?
  1. i don't want to mess up original "Particle" , so just clone "all" packages that related to "Particle "
  2. hange "Particle" to "Clip" packages
  3. merge MovieMaterial to ClipMaterial then i got "MovieClipMaterial" (huh?)
  4. add "size" to "ParticleField" (call ClipField for now)

package org.papervision3d.materials.special
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Graphics;
import flash.geom.Matrix;
import org.papervision3d.materials.MovieMaterial;

import org.papervision3d.core.geom.renderables.Clip;
import org.papervision3d.core.render.draw.IClipDrawer;

public class MovieClipMaterial extends ClipMaterial implements IClipDrawer

private var scaleMatrix : Matrix;
private var movie : DisplayObject;
private var movieMaterial : MovieMaterial;

public function MovieClipMaterial( movieAsset:DisplayObject=null, transparent:Boolean=false, animated:Boolean=false )
super(0, 0); = movieAsset;
this.movieMaterial = new MovieMaterial( movie, transparent, animated );

this.bitmap = movieMaterial.bitmap;
this.scaleMatrix = new Matrix();

override public function drawClip(clip:Clip, graphics:Graphics, renderSessionData:RenderSessionData):void
this.bitmap = movieMaterial.bitmap;

scaleMatrix.a = clip.renderScale;
scaleMatrix.d = clip.renderScale;
scaleMatrix.tx = clip.vertex3D.vertex3DInstance.x;
scaleMatrix.ty = clip.vertex3D.vertex3DInstance.y;

graphics.beginBitmapFill(this.bitmap, scaleMatrix, false, smooth);
graphics.drawRect(clip.vertex3D.vertex3DInstance.x, clip.vertex3D.vertex3DInstance.y,clip.renderScale*this.bitmap.width,clip.renderScale*this.bitmap.height);


after finish doing this, i found this thing useless in "snow" case lol,
maybe it's better to use 2d particles for "Environment effect" like rain, snow or wot ever
full source code 'll be release later (actually nothing just rename) it's too dirty for now
and need to clean/add method for another case (more useful lol)

happy coding!
Post a Comment