reflection
Merry Christmas!
package { import flash.events.Event; import flash.filters.BlurFilter; import flash.geom.Point; import org.flintparticles.common.counters.Steady; import org.flintparticles.common.displayObjects.RadialDot; import org.flintparticles.common.initializers.ImageClass; import org.flintparticles.common.initializers.ScaleImageInit; import org.flintparticles.twoD.actions.DeathZone; import org.flintparticles.twoD.actions.Move; import org.flintparticles.twoD.actions.RandomDrift; import org.flintparticles.twoD.emitters.Emitter2D; import org.flintparticles.twoD.initializers.Position; import org.flintparticles.twoD.initializers.Velocity; import org.flintparticles.twoD.renderers.DisplayObjectRenderer; import org.flintparticles.twoD.zones.LineZone; import org.flintparticles.twoD.zones.PointZone; import org.flintparticles.twoD.zones.RectangleZone; import org.papervision3d.core.effects.view.ReflectionView; import org.papervision3d.materials.ColorMaterial; import org.papervision3d.materials.special.Letter3DMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; import org.papervision3d.typography.Text3D; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class MerryChristmas extends ReflectionView { private var pivotPoint:DisplayObject3D = new DisplayObject3D(); public function MerryChristmas() { viewportReflection.filters = [new BlurFilter(3,3,1)]; setReflectionColor(.5, .5, .5); surfaceHeight = -80; setupText(); setupSnow(); setupTree(); addEventListener(Event.ENTER_FRAME, enterFrameHandler); } private function setupText():void { var rockwell:Rockwell = new Rockwell(); var merryMaterial:Letter3DMaterial = new Letter3DMaterial(0xcc0000); var merry:Text3D = new Text3D("MERRY", rockwell, merryMaterial); var christmasMaterial:Letter3DMaterial = new Letter3DMaterial(0x00cc00); var christmas:Text3D = new Text3D("CHRISTMAS", rockwell, christmasMaterial); merry.z = -700; christmas.z = 500; christmas.rotationY = 180; pivotPoint.addChild(merry); pivotPoint.addChild(christmas); scene.addChild(pivotPoint); } private function setupTree():void { var radius:Number = 300; var height:Number = 500; var total:uint = 100; var looker:DisplayObject3D = new DisplayObject3D(); for(var i:int = 0; i < total; i++) { var material:ColorMaterial; if((i & 1) == 0) material = new ColorMaterial(0xaa0000); else material = new ColorMaterial(0x00aa00); material.doubleSided = true; var plane:Plane = new Plane(material, 30, 30, 1, 1); plane.x = Math.cos(i) * (radius - i * 3); plane.z = Math.sin(i) * (radius - i * 3); plane.y = i / total * height; looker.copyPosition(plane); looker.x = looker.z = 0; plane.lookAt(looker); pivotPoint.addChild(plane); } } private function setupSnow():void { var emitter:Emitter2D = new Emitter2D(); emitter.counter = new Steady(100); emitter.addInitializer(new ImageClass(RadialDot, 2)); emitter.addInitializer(new Position(new LineZone(new Point(-5,-5), new Point(645, -5)))); emitter.addInitializer(new Velocity(new PointZone(new Point(0, 65)))); emitter.addInitializer(new ScaleImageInit(0.75, 2)); emitter.addAction(new Move()); emitter.addAction(new DeathZone(new RectangleZone(-10, -10, 640, 250), true)); emitter.addAction(new RandomDrift(15, 15)); var flintRenderer:DisplayObjectRenderer = new DisplayObjectRenderer(); addChild(flintRenderer); flintRenderer.addEmitter(emitter); emitter.start(); } private function enterFrameHandler(event:Event):void { pivotPoint.rotationY += (viewport.containerSprite.mouseX - pivotPoint.rotationY) * .01; singleRender(); } } }
Carousel with proper rotation and reflection
I’m going to go out on a limb and say that this post will be popular
package { import flash.display.Bitmap; import flash.events.Event; import flash.filters.BlurFilter; import org.papervision3d.core.effects.view.ReflectionView; import org.papervision3d.core.math.Quaternion; import org.papervision3d.events.InteractiveScene3DEvent; import org.papervision3d.materials.BitmapMaterial; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.primitives.Plane; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class ClickThenRotateCarousel extends ReflectionView { [Embed(source="assets/pic.jpg")] private var picAsset:Class; private const RADIUS:Number = 400; private const NUM_OF_PLANES:int = 9; private var carousel:DisplayObject3D = new DisplayObject3D(); private var currentQuat:Quaternion = new Quaternion(); private var targetQuat:Quaternion = new Quaternion(); private var slerp:Number = 0; public function ClickThenRotateCarousel() { viewportReflection.filters = [new BlurFilter(3,3,3)]; viewport.interactive = true; surfaceHeight = -100; camera.z = 800; //move camera to the front var pic:Bitmap = Bitmap(new picAsset()); for(var i:int = 0; i < NUM_OF_PLANES; i++) { var material:BitmapMaterial = new BitmapMaterial(pic.bitmapData, true); material.doubleSided = true; material.interactive = true; var plane:Plane = new Plane(material, 100, 100); plane.rotationY = 360 / NUM_OF_PLANES * i; plane.moveForward(RADIUS); plane.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, objectOverHandler); plane.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, objectOutHandler); plane.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, objectClickHandler); carousel.addChild(plane); } scene.addChild(carousel); addEventListener(Event.ENTER_FRAME, enterFrameHandler); } private function objectOverHandler(event:InteractiveScene3DEvent):void { viewport.buttonMode = true; } private function objectOutHandler(event:InteractiveScene3DEvent):void { viewport.buttonMode = false; } private function objectClickHandler(event:InteractiveScene3DEvent):void { var radians:Number = (carousel.rotationY - event.displayObject3D.rotationY) * Quaternion.DEGTORAD; slerp = 0; currentQuat = Quaternion.createFromMatrix(carousel.transform); targetQuat = Quaternion.createFromAxisAngle(0, 1, 0, radians); } private function enterFrameHandler(event:Event):void { slerp += (1 - slerp) * .05; var quat:Quaternion = Quaternion.slerp(currentQuat, targetQuat, slerp); carousel.transform = quat.matrix; singleRender(); } } }
Search
Recommended Books
Speaking at FITC Toronto
Recent Posts
- Moving to johnlindquist.com
- AsyncCommand with Robotlegs, Signals, Flight, MinimalComps
- Search Widget – Robotlegs, Signals, Flight, Minimal Comps, Yahoo Astra
- FDT Super Awesome March Deal
- FDT Theme Designer
- haXe Tutorial
- AS3 Signals Tutorial
- Preferred Video Tutorial Resolution?
- TweenMax – Tweening a timeline (Advanced Tweening)
- Robotlegs + Flight + Union Platform
- Back in the saddle
- Eclipse Theme Designer Preview
- RobotLegs Hello World Video Tutorial
- 10 Things Every Senior Flash Developer Should Know
- Efflex – 3D Effects for Flex
Recent Comments
- software akuntansi terbaik on Back in the saddle
- loan rates on Augmented Reality – Recursive Webcam
- loan rates on Looking around the inside of a Sphere
- reverse phone lookup on Looking around the inside of a Sphere
- Oidhreachta on The Spotlight Effect (Dimming the unselected)
- Hosting company on archive
- aanbae on Back in the saddle
- Domain registration on Looking around the inside of a Sphere
- website designing company on Looking around the inside of a Sphere
- Honda Motor on Augmented Reality – Recursive Webcam
Categories
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « May | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | ||||
Archives
Preferred Video Tutorial Resolution
- 1024x768 (53%, 85 Votes)
- 1280x1024 (15%, 24 Votes)
- 1920x1080 (15%, 24 Votes)
- 800x600 (13%, 20 Votes)
- 480x320 (4%, 6 Votes)
- 640x480 (0%, 2 Votes)
Total Voters: 160



