home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Templates / Flash / flashmo_101_3d_carousel / org / papervision3d / materials / CompositeMaterial.as < prev    next >
Text File  |  2007-07-19  |  1KB  |  53 lines

  1. package org.papervision3d.materials
  2. {
  3.     import flash.display.Graphics;
  4.     import flash.geom.Matrix;
  5.     
  6.     import org.papervision3d.core.draw.IFaceDrawer;
  7.     import org.papervision3d.core.geom.Face3D;
  8.     import org.papervision3d.core.geom.Vertex2D;
  9.     import org.papervision3d.core.proto.MaterialObject3D;
  10.     import org.papervision3d.objects.DisplayObject3D;
  11.  
  12.     public class CompositeMaterial extends MaterialObject3D implements IFaceDrawer
  13.     {
  14.         
  15.         private var materials:Array;
  16.         
  17.         public function CompositeMaterial(initObject:Object=null)
  18.         {
  19.             super(initObject);
  20.             init();
  21.         }
  22.         
  23.         private function init():void
  24.         {
  25.             materials = new Array();
  26.         }
  27.         
  28.         public function addMaterial(material:MaterialObject3D):void
  29.         {
  30.             materials.push(material);
  31.         }
  32.         
  33.         public function removeMaterial(material:MaterialObject3D):void
  34.         {
  35.             materials.splice(materials.indexOf(material),1);
  36.         }
  37.         
  38.         public function removeAllMaterials(material:MaterialObject3D):void
  39.         {
  40.             materials = new Array();
  41.         }
  42.         
  43.         override public function drawFace3D(instance:DisplayObject3D, face3D:Face3D, graphics:Graphics, v0:Vertex2D, v1:Vertex2D, v2:Vertex2D):int
  44.         {
  45.             var num:int = 0;
  46.             for each(var n:MaterialObject3D in materials){
  47.                 num += n.drawFace3D(instance, face3D, graphics, v0, v1, v2);
  48.             }
  49.             return num;
  50.         }
  51.         
  52.     }
  53. }