flint

Flint Particle System with Papervision3D

Monday, December 15th, 2008 | examples, requests | Comments

Flint -> http://flintparticles.org/

Flint is very cool. It just has a bit of a learning curve (as does Papervision3D). Here’s a “Hello Word” example that I hope will help. There are MANY other options that I’m not covering here. This is just about as simple as it gets with still having some kind of movement.


source

package
{
	import org.flintparticles.common.actions.Action;
	import org.flintparticles.common.actions.Age;
	import org.flintparticles.common.counters.Steady;
	import org.flintparticles.common.initializers.Lifetime;
	import org.flintparticles.threeD.actions.Move;
	import org.flintparticles.threeD.actions.RandomDrift;
	import org.flintparticles.threeD.emitters.Emitter3D;
	import org.flintparticles.threeD.geom.Vector3D;
	import org.flintparticles.threeD.initializers.Position;
	import org.flintparticles.threeD.initializers.Velocity;
	import org.flintparticles.threeD.papervision3d.PV3DRenderer;
	import org.flintparticles.threeD.papervision3d.initializers.PV3DObjectClass;
	import org.flintparticles.threeD.zones.PointZone;
	import org.flintparticles.threeD.zones.Zone3D;
	import org.papervision3d.objects.primitives.Sphere;
	import org.papervision3d.view.BasicView;
 
	[SWF(width="640", height="480", backgroundColor="#000000", frameRate="60")]
	public class Papervision3DWithFlint extends BasicView
	{
		private const NUM_SPHERES_PER_SECOND:Number = 1;
 
		private var emitter:Emitter3D;
		private var pv3dRenderer:PV3DRenderer;
 
		public function Papervision3DWithFlint()
		{
			emitter = new Emitter3D();
			emitter.counter = new Steady(NUM_SPHERES_PER_SECOND);
 
			//initializers
			var displayObject3dType:PV3DObjectClass = new PV3DObjectClass(Sphere);
			emitter.addInitializer(displayObject3dType);
 
			var starting3DPosition:Vector3D = new Vector3D( 0, -700, 0);
			var starting3DZone:Zone3D = new PointZone(starting3DPosition);
			var startingPosition:Position = new Position(starting3DZone);
			emitter.addInitializer(startingPosition);
 
			var direction:Vector3D = new Vector3D(0, 100, 0);
			var zone:Zone3D = new PointZone(direction);
			var velocity:Velocity = new Velocity(zone); 
			emitter.addInitializer(velocity);
 
			var lifetime:Lifetime = new Lifetime(20);
			emitter.addInitializer(lifetime);			
 
			//actions
			var ageAction:Action = new Age();
			emitter.addAction(ageAction);
 
			var moveAction:Action = new Move();
			emitter.addAction(moveAction);
 
			var drift:Action = new RandomDrift(1000, 0, 1000);
			emitter.addAction( drift );
 
 
			//Flint renderer matches emitter 3d coordinates to pv3d coordinates
			//*does not actually render the pv3d scene*
			pv3dRenderer = new PV3DRenderer(scene);
			pv3dRenderer.addEmitter(emitter);
 
			//start emitter		
			emitter.start();
			//start pv3d rendering
			startRendering();
		}
	}
}

Tags:

Search

Recommended Books

Speaking at FITC Toronto

 

May 2012
M T W T F S S
« May    
 123456
78910111213
14151617181920
21222324252627
28293031  

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

Loading ... Loading ...