Archive for December 22nd, 2008
Flint Pixels 2 – Random Drift and Rotate Emitter
package { import flash.events.Event; import flash.filters.BlurFilter; import flash.filters.ColorMatrixFilter; import org.flintparticles.common.actions.Age; import org.flintparticles.common.counters.Steady; import org.flintparticles.common.initializers.ColorInit; import org.flintparticles.common.initializers.Lifetime; import org.flintparticles.threeD.actions.Move; import org.flintparticles.threeD.actions.RandomDrift; import org.flintparticles.threeD.activities.RotateEmitter; import org.flintparticles.threeD.emitters.Emitter3D; import org.flintparticles.threeD.geom.Vector3D; import org.flintparticles.threeD.initializers.Velocity; import org.flintparticles.threeD.papervision3d.PV3DPixelRenderer; import org.flintparticles.threeD.zones.DiscZone; import org.papervision3d.core.effects.BitmapLayerEffect; import org.papervision3d.core.geom.Pixels; import org.papervision3d.view.BasicView; import org.papervision3d.view.layer.BitmapEffectLayer; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class FlintPixels2 extends BasicView { private var emitter:Emitter3D; private var emitter2:Emitter3D; private var flintRenderer:PV3DPixelRenderer; private var bitmapEffectLayer:BitmapEffectLayer; private var pixels:Pixels; public function FlintPixels2() { camera.z = -300; setupPixels(); setupEmitter(); setupEmitter2(); setupFlintRenderer(); emitter.start(); emitter2.start(); startRendering(); } private function setupPixels():void { bitmapEffectLayer = new BitmapEffectLayer(viewport); viewport.containerSprite.addLayer( bitmapEffectLayer ); pixels = new Pixels(bitmapEffectLayer); bitmapEffectLayer.addDisplayObject3D(pixels); scene.addChild(pixels); bitmapEffectLayer.addEffect(new BitmapLayerEffect(new BlurFilter(2, 2, 1))); //@see http://livedocs.adobe.com/flex/3/langref/flash/filters/ColorMatrixFilter.html bitmapEffectLayer.addEffect(new BitmapLayerEffect(new ColorMatrixFilter([1.09,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]))); } private function setupEmitter():void { emitter = new Emitter3D(); emitter.counter = new Steady(500); emitter.position.x = -150; emitter.addInitializer(new ColorInit(0xffcccc00, 0xffffffff)); emitter.addInitializer(new Velocity(new DiscZone(new Vector3D(340, 0, 0), new Vector3D(0, 1, 0), 100, 100))); emitter.addInitializer(new Lifetime(4)); emitter.addAction(new Move()); emitter.addAction(new Age()); emitter.addAction(new RandomDrift(3000, 3000, 3000)); emitter.addActivity(new RotateEmitter(new Vector3D(.1, .3, 0))); } private function setupEmitter2():void { emitter2 = new Emitter3D(); emitter2.counter = new Steady(500); emitter2.position.x = 150; emitter2.addInitializer(new ColorInit(0xffcccc00, 0xffffffff)); emitter2.addInitializer(new Velocity(new DiscZone(new Vector3D(-340, 0, 0), new Vector3D(0, 1, 0), 100, 100))); emitter2.addInitializer(new Lifetime(4)); emitter2.addAction(new Move()); emitter2.addAction(new Age()); emitter2.addAction(new RandomDrift(3000, 3000, 3000)); emitter2.addActivity(new RotateEmitter(new Vector3D(.1, -.3, 0))); } private function setupFlintRenderer():void { flintRenderer = new PV3DPixelRenderer(pixels); flintRenderer.addEmitter(emitter); flintRenderer.addEmitter(emitter2); } override protected function onRenderTick(event:Event = null):void { renderer.renderScene(scene, camera, viewport); } } }
Papervision3D with Box2DFlash Part 4 – Distance Joint
Please check the previous examples on box2dflash before jumping into this one.
This time around, we’re going to create a “Distance Joint” on the large heavy box in the middle:
private function createDistanceJoint():void { var boxWidth:Number = 50; var boxBody:b2BodyDef = new b2BodyDef(); boxBody.position = new b2Vec2(WIDTH/2/WORLD_SCALE, 420/WORLD_SCALE); var box:b2Body = world.CreateBody(boxBody); var boxShape:b2PolygonDef = new b2PolygonDef(); boxShape.SetAsBox(boxWidth/WORLD_SCALE, boxWidth/WORLD_SCALE); boxShape.density = .7; boxShape.friction = .3; boxShape.restitution = .4; box.CreateShape(boxShape); //instead of "SetMassFromShapes", I'm setting the box //mass extremely high to keep it swinging back and forth var massData:b2MassData = new b2MassData(); massData.mass = 1000; box.SetMass(massData); var joint:b2DistanceJointDef = new b2DistanceJointDef(); var anchor:b2Vec2 = new b2Vec2(); anchor = new b2Vec2(WIDTH/2/WORLD_SCALE, 250/WORLD_SCALE); joint.Initialize(box, world.m_groundBody, box.GetWorldCenter(), anchor); world.CreateJoint(joint); //start the box swinging box.m_linearVelocity = new b2Vec2(10, 0); var materialsList:MaterialsList = new MaterialsList(); materialsList.addMaterial(new WireframeMaterial(0xcc0000, 1, 6), "all"); var cube:Cube = new Cube(materialsList, boxWidth * 2, boxWidth * 2, boxWidth * 2); scene.addChild(cube); box.m_userData = cube; }
Flint Pixels
package { import flash.events.Event; import flash.filters.BlurFilter; import org.flintparticles.common.actions.Age; import org.flintparticles.common.counters.Steady; import org.flintparticles.common.initializers.ColorInit; import org.flintparticles.common.initializers.Lifetime; import org.flintparticles.threeD.actions.Accelerate; import org.flintparticles.threeD.actions.Move; import org.flintparticles.threeD.emitters.Emitter3D; import org.flintparticles.threeD.geom.Vector3D; import org.flintparticles.threeD.initializers.Velocity; import org.flintparticles.threeD.papervision3d.PV3DPixelRenderer; import org.flintparticles.threeD.zones.DiscZone; import org.papervision3d.core.effects.BitmapLayerEffect; import org.papervision3d.core.geom.Pixels; import org.papervision3d.view.BasicView; import org.papervision3d.view.layer.BitmapEffectLayer; [SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")] public class FlintPixels extends BasicView { private var emitter:Emitter3D; private var flintRenderer:PV3DPixelRenderer; private var bitmapEffectLayer:BitmapEffectLayer; private var pixels:Pixels; public function FlintPixels() { camera.z = -300; setupPixels(); setupEmitter(); setupFlintRenderer(); emitter.start(); startRendering(); } private function setupPixels():void { bitmapEffectLayer = new BitmapEffectLayer(viewport); viewport.containerSprite.addLayer( bitmapEffectLayer ); pixels = new Pixels(bitmapEffectLayer); bitmapEffectLayer.addDisplayObject3D(pixels); scene.addChild(pixels); bitmapEffectLayer.addEffect(new BitmapLayerEffect(new BlurFilter(2, 2, 1))); } private function setupEmitter():void { emitter = new Emitter3D(); emitter.counter = new Steady( 500 ); emitter.addInitializer(new ColorInit(0xffcc0000, 0xffffffff)); emitter.addInitializer(new Velocity(new DiscZone(new Vector3D(0, 340, 0), new Vector3D(0, 1, 0), 100, 100))); emitter.addInitializer(new Lifetime(3)); emitter.addAction(new Move()); emitter.addAction(new Accelerate(new Vector3D(0, -300, 0))); emitter.addAction(new Age()); } private function setupFlintRenderer():void { flintRenderer = new PV3DPixelRenderer(pixels); flintRenderer.addEmitter(emitter); } override protected function onRenderTick(event:Event = null):void { pixels.rotationY += (viewport.containerSprite.mouseX - pixels.rotationY) * .3; pixels.rotationX += (viewport.containerSprite.mouseY - pixels.rotationX) * .3; renderer.renderScene(scene, camera, viewport); } } }
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
- 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
- MorphController – Mighty Morphing Papervision3D
Recent Comments
- list of lpn courses on SpringCamera3D and Driving a Car
- rn to bsn in montgomery al on archive
- PowerPoint Recovery on Eclipse Theme Designer Preview
- cheat mw3 on Test if a plane is within the view of the camera (aka testing if culled)
- Goa Hotels on Looking around the inside of a Sphere
- cheat gratuit on Looking around the inside of a Sphere
- Application Development on Robotlegs + Flight + Union Platform
- nexium on Moving Faces
- buy nexium on Holy Sphere
- buy aldara online on Tweening a “moveForward()” behavior
Categories
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


