• package {
     import flash.display.*;
     import flash.events.*;
     import flash.filters.*;
     import flash.utils.*;
     import org.papervision3d.core.proto.*;
     import org.papervision3d.materials.shadematerials.*;
     import org.papervision3d.objects.*;
     import org.papervision3d.objects.primitives.*;
     import org.papervision3d.view.*;
     import org.papervision3d.cameras.*;
     import org.papervision3d.lights.*;
     import org.papervision3d.materials.*;
     import org.papervision3d.materials.utils.*;
     import caurina.transitions.Tweener;

     [SWF(width = "720"height = "480", frameRate = "60"backgroundColor="#FFFFFF")];

     public class shadowex extends BasicView {
      static private  const CUBE_ROUND      :uint = 2500;
      static private  const CUBE_SIZE       :uint = 600;
      static private  const CUBE_SEGMENT    :uint = 1;
      static private  const CUBE_AMOUNT     :uint = 10;
      static private  const CAMERA_POSITION :uint = 4500;
      static private  const LIGHT_POSITION  :uint = 2000;
      static private  const PLANE_SIZE      :uint = 8000;
      private var rotXValue:Number;
      private var rotZValue:Number;
      private var rotYValue:Number;

      private var light        :PointLight3D = new PointLight3D();
      private var shadowCaster :ShadowCaster = new ShadowCaster("shadow"0, BlendMode.NORMAL, .25[new BlurFilter(16163)]); ;
      private var plane        :Plane;
      private var cube        :DisplayObject3D;
      private var lightModel   :DisplayObject3D;
      private var materials:MaterialsList;
      private var flatShaderMat:FlatShadeMaterial;
      public function shadowex() {
       super(00truefalse, CameraType.TARGET);

       // shadow caster and movie material
       shadowCaster.setType(ShadowCaster.SPOTLIGHT);

       var sprite : Sprite = new Sprite();
       sprite.graphics.beginFill(0xEEEEEE, 1);
       sprite.graphics.drawRect(00128128);
       sprite.graphics.endFill();
       var movieMat : MovieMaterial = new MovieMaterial(sprite, falsetruetrue);

       // add movieMaterial to plane
       plane = new Plane(movieMat, PLANE_SIZE, PLANE_SIZE, 44);
       plane.pitch(90);
       plane.y = - CUBE_ROUND;
       scene.addChild(plane);
       /*
       cubes = scene.addChild(new DisplayObject3D());
       
       
       var i:int = CUBE_AMOUNT;
       while(i--)
       {
       var cube:Cube = new Cube(
       new MaterialsList( { all:new FlatShadeMaterial(light, 0xCCCCCC) } ),
       CUBE_SIZE, CUBE_SIZE, CUBE_SIZE,
       CUBE_SEGMENT, CUBE_SEGMENT, CUBE_SEGMENT);
       cube.x = CUBE_ROUND * Math.random() - CUBE_ROUND / 2;
       cube.y = CUBE_ROUND * Math.random() - CUBE_ROUND / 2;
       cube.z = CUBE_ROUND * Math.random() - CUBE_ROUND / 2;
       cube.scale = .8 * Math.random() + .2;
       cube.rotationX = 360 * Math.random();
       cube.rotationY = 360 * Math.random();
       cube.rotationZ = 360 * Math.random();
       cubes.addChild(cube);
       }
       */

       flatShaderMat = new FlatShadeMaterial (light, 0x000000, 0x333333);
       materials = new MaterialsList ();
       materials.addMaterial(flatShaderMat, "all");
       cube = new Cube(materials, 500500500333);
       ///
       lightModel = new Sphere(new WireframeMaterial(0xFFFF00)10011);
       scene.addChild(lightModel);
       scene.addChild(light);
       scene.addChild(cube);
       recalcValues();
       startRendering();
      }
      private function recalcValues():void {
       rotXValue = randomize (0360);
       rotYValue = randomize (0360);
       rotZValue = randomize (0360);
       Tweener.addTween(cube, {rotationX:rotXValue, rotationY:rotYValue, rotationZ: rotZValue, onUpdate:startRendering, onComplete:recalcValues, transition:"easeInOutElastic"time:3});
      }
      private function randomize(min:Numbermax:Number):Number {
       return Math.random() * max - min + min;
      }
      override protected function onRenderTick(e:Event = null):void {
       shadowCaster.invalidate();
       shadowCaster.castModel(cube, light, plane);

       camera.x += (CAMERA_POSITION * Math.sin(mouseX / stage.stageWidth * 360 * Math.PI / 180) - camera.x) * .1;
       camera.z += (CAMERA_POSITION * Math.cos(mouseX / stage.stageWidth * 360 * Math.PI / 180) - camera.z) * .1;
       camera.y += (CAMERA_POSITION * mouseY / stage.stageHeight - CAMERA_POSITION / 2 - camera.y) * .1;

       light.x = LIGHT_POSITION * Math.sin(getTimer() / 2000);
       light.z = LIGHT_POSITION * Math.cos(getTimer() / 2000);
       light.y = LIGHT_POSITION * 1;

       lightModel.transform = light.transform
       ;
       super.onRenderTick(e);
      }
     }
    }

    ShadowCaster.as下载

  • 传统

    2009-03-10

    分类:

    传统 到底是什么? 不知道会不会有人想过这个东西 在我看来 所谓的那些个传统 只不过是利益的附属品 是用利益打造出来的枷锁 因为要的到某些利益不得不去保留的东西 传统其实是可以变通的 但是有这么一部分人为了保住自己的利益才会一直说我们这是 传统 传统 传统。。。 没有传统可是不行的 如果这些传统与你的利益无关 你会遵循传统办事吗? 我觉得是不会的 ­ 还不如就说 我们没有利益是不行的 一定要按照利益办事哦...因为这是传统!!