You are hereForums / Papervision3D / Question and Answer / Particle Field
Particle Field
Hello! My Particles are huge! Really, they are big and I need them to be small like stars. I'm trying to do an outer space thing w/ stars and my stars are big!!!! Why is that happening?
Oh - sometimes my particles are square....
var particleMaterial:ParticleMaterial = new ParticleMaterial(0xCC33CC, 1, 1);
If I only put 2 parameters in there ex:(0xCC33CC, 1);, thay are square....
also, particleField = new ParticleField(particle material applied to object, particle quantity, width, height, depth);
Nothing here for size of particles!!!!
Any help on this would be great!
Tags
ohhhh....I've been playing!!!!!
Here is some code, just put it in frame one of your flash document...you also need to have a movie clip symbol of a circle in your library that has a class name of "Sphere".
I hope it works for you. Sorry this is a bit jumbled, I don't know how else to get the code on here. But this line...
"var p:Particle = new Particle(spm,.5,600,0,0);" the .5 is where the size parameter is.
I borrowed some stuff from a lot of different examples, this seems to work!
import flash.display.Sprite;
import flash.events.Event;
import org.papervision3d.view.Viewport3D;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.special.ParticleMaterial;
import org.papervision3d.objects.special.ParticleField;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.view.BasicView;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.geom.Particles;
import org.papervision3d.core.geom.renderables.Particle;
import org.papervision3d.materials.special.MovieAssetParticleMaterial;
var scene:Scene3D = new Scene3D();
var camera:Camera3D = new Camera3D();
var renderer:BasicRenderEngine = new BasicRenderEngine();
var viewport:Viewport3D = new Viewport3D(766, 357, false, true);
addChild(viewport);
var particleContainer:DisplayObject3D;
var particles : Array;
init();
function init():void
{
particleContainer = new DisplayObject3D("Particle Container");
particles = new Array();
for(var i:int = 0; i<400; i++)
{
var spm:MovieAssetParticleMaterial = new MovieAssetParticleMaterial("Sphere",true);
spm.interactive = true;
spm.smooth = true;
var particles3D:Particles = new Particles("ParticleContainer#"+i);
var p:Particle = new Particle(spm,.5,600,0,0);
particles3D.addParticle(p);
particles3D.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, particleOver);
particles3D.rotationY = Math.random()*360;
particles3D.rotationZ = Math.random()*180;
particles3D.extra = {spin: 0};
particleContainer.addChild(particles3D);
particles.push(particles3D);
}
scene.addChild(particleContainer);
//singleRender();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
addEventListener(Event.ENTER_FRAME, frameLoop);
}
function particleOver(e : InteractiveScene3DEvent) : void
{
e.displayObject3D.extra["spin"] = 10;
}
function frameLoop(e:Event): void
{
particleContainer.rotationY+=((stage.stageWidth/2)-mouseX)/200;
particleContainer.rotationX+=((stage.stageHeight/2)-mouseY)/200;
var drag:Number = 0.99;
for(var i:int=0; i0.1)
{
p.extra["spin"]*=drag;
p.rotationY+=spin;
}
else
{
p.extra["spin"] = 0;
}
}
}
//singleRender();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
function onEnterFrame(e:Event):void
{
renderer.renderScene(scene, camera, viewport);
}