AS3 flag using as3dmod

[ 2009-08-18 23:05:55 | Author: liuhuan ]
Font Size: Large | Medium | Small
uploads/200908/21_170001_untitled3.jpg

We can easily create flag effect in Actionscript 3 using as3dmod+PV3D.



refrence: http://as3.miguelmoraleda.com/2009/03/07/flash-actionscript-3-as3dmod-flag-effect-modify-objects/

download as3dmod: http://code.google.com/p/as3dmod/
package {
  import flash.display.*;
  import flash.events.Event;
  import flash.filters.*;
  import org.papervision3d.core.proto.MaterialObject3D;
  import org.papervision3d.materials.special.CompositeMaterial;
  import org.papervision3d.view.BasicView;
  import org.papervision3d.materials.*;
  import org.papervision3d.materials.shaders.*;
  import org.papervision3d.objects.*;
  import org.papervision3d.objects.primitives.*;
  import org.papervision3d.lights.PointLight3D;
  import com.as3dmod.ModifierStack;
  import com.as3dmod.plugins.pv3d.LibraryPv3d;
  import com.as3dmod.modifiers.Perlin;

  public class Flag extends BasicView {

    private var _perlin:Perlin;
    private var _plane:DisplayObject3D;
    private var m:ModifierStack;

    public function Flag() {

      var bmp:Bitmap=new Bitmap(new FlagBMP(576,260));
      var bmpMaterial:BitmapMaterial=new BitmapMaterial(bmp.bitmapData,true);
      bmpMaterial.doubleSided=true;
      bmpMaterial.smooth=true;

      _plane = new Plane(bmpMaterial, 576, 260, 12, 5);
      _plane.rotationZ = 10;
      _plane.rotationX = 15;
      _plane.rotationY = -15;
      scene.addChild(_plane);

      m = new ModifierStack(new LibraryPv3d(), _plane);

      _perlin = new Perlin(1);
      _perlin.setFalloff(0, 0);
      viewport.containerSprite.filters=[new DropShadowFilter(14,90,0,1,15,15,0.5)];
      m.addModifier(_perlin);
      camera.zoom = 70;
      startRendering();
    }

    protected override function onRenderTick(event:Event = null):void {
      super.onRenderTick(event);
      m.apply();
      _plane.rotationY += 1;
    }
  }
}
[Last Modified By liuhuan, at 2009-08-21 17:00:24]
Comments Feed Comments Feed: http://www.liuhuan.com/blog/feed.asp?q=comment&id=1014

There is no comment on this article.

You can't post comment on this article.