Glow Cube for Papervision3D 2.0 (发光箱体练习)

http://www.newflash3d.com---flash3D先锋队:北京贝武易科技公司】
有疑问请联系我QQ:363596350
Papervision3d的物体发光练习,一个箱体发光,看看效果。

代码如下:
// forked from nilab's GuruGuru Cube for Papervision3D 2.0 
package { 
  
  import flash.events.*;
  import flash.filters.GlowFilter;
  
  import org.papervision3d.materials.*;
  import org.papervision3d.materials.utils.*;
  import org.papervision3d.objects.primitives.*;
  import org.papervision3d.view.*; 
  
  [SWF(backgroundColor="#000000", frameRate=30 ,width="500", height="400")] 
  
  // for Papervision3D 2.0 
  public class glowCube extends BasicView { 
  
    private var cube:Cube; 
  
    public function glowCube(){ 
  
      // make material list 
      var wfm:WireframeMaterial = new WireframeMaterial(0x00FF00); 
      var mlist:MaterialsList = new MaterialsList(); 
      mlist.addMaterial(wfm, "all"); 
  
      // make filters 
      var filterList:Array = new Array(); 
      var glowFilter:GlowFilter = new GlowFilter(0xFFFFFF, 1, 16, 16, 2, 1, false, false); 
      filterList.push(glowFilter); 
  
      // make cube 
      cube = new Cube(mlist, 600, 400, 100, 4, 2, 3); 
      cube.useOwnContainer = true; // for filters 
      cube.filters = filterList; 
	  
      // make world 
      scene.addChild(cube); 
      stage.addEventListener(Event.ENTER_FRAME, enterFrameListener); 
    } 
  
    private function enterFrameListener(event:Event):void { 
      cube.yaw  ((200 - mouseX) / 120); 
      cube.pitch((200 - mouseY) / 120); 
    
      startRendering(); 
    } 
  } 
} 

分析一下代码。
      // make material list 
      var wfm:WireframeMaterial = new WireframeMaterial(0x00FF00); 
      var mlist:MaterialsList = new MaterialsList(); 
      mlist.addMaterial(wfm, "all"); 
  
      // make filters 
      var filterList:Array = new Array(); 
      var glowFilter:GlowFilter = new GlowFilter(0xFFFFFF, 1, 16, 16, 2, 1, false, false); 
      filterList.push(glowFilter); 
  
      // make cube 
      cube = new Cube(mlist, 600, 400, 100, 4, 2, 3); 
      cube.useOwnContainer = true; // for filters 
      cube.filters = filterList; 

生成材质,然后生成滤镜,把滤镜直接加到cube物体上,这是这里基本思路,其实我们还可以把滤镜加到视图和层上,通过Dae导入的物体好像目前还不支持直接发光,如
cube.filters = filterList; 

这样的方式,下面我们继续看看。

你可能感兴趣的:(qq,Flash)