Fork me on GitHub
Not signed in (Sign In)

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

    • CommentAuthorRPath
    • CommentTimeJun 23rd 2011 edited
     
    Hello Richard & forum users - I have a (hopefully) simple question that I'm not finding a straightforward answer to elsewhere in the forum or in the example files. I'm trying to make a 3D emitter of a particle sphere continually rotate around its Y axis, to appear as a spinning globe. It seems that adding the RotateEmitter activity should do this (since all other rotate functions look like they affect only particles, not the entire emitter), but the sphere doesn't spin. Since this is a blast of particles rather than a stream, how do I make that rotation activity affect an emitter with existing particles?
    An example of what I'm going for is here: http://professionalpapervision.wordpress.com/2009/04/22/flash-cs4-planetarium-in-49-lines/
    I'll eventually be placing a number of the spheres in 3D space and want them all spinning individually, so using the OrbitCamera isn't an option. "Pure AS3" code follows:

    package
    {
    import flash.display.Sprite;
    import flash.geom.Rectangle;
    import flash.geom.Vector3D;

    import org.flintparticles.threeD.emitters.Emitter3D;
    import org.flintparticles.threeD.renderers.PixelRenderer;

    [SWF(width='500', height='500', frameRate='31', backgroundColor='#000000')]

    public class ParticleSphere extends Sprite
    {
    private var emitter:Emitter3D;
    private var renderer:PixelRenderer;

    public function ParticleSphere()
    {
    emitter = new Sphere();
    renderer = new PixelRenderer( new Rectangle( 0, 0, 500, 500 ), false );
    renderer.camera.dolly( -300 );
    renderer.addEmitter( emitter );
    addChild( renderer );
    emitter.start( );
    }
    }
    }

    package
    {
    import flash.geom.Vector3D;
    import org.flintparticles.common.counters.Blast;
    import org.flintparticles.common.initializers.*;
    import org.flintparticles.threeD.actions.Move;
    import org.flintparticles.threeD.activities.RotateEmitter;
    import org.flintparticles.threeD.emitters.Emitter3D;
    import org.flintparticles.threeD.initializers.*;
    import org.flintparticles.threeD.zones.SphereZone;

    public class Sphere extends Emitter3D
    {
    public function Sphere()
    {
    counter = new Blast( 250 );

    addInitializer( new ColorInit( 0xFFCCCC00, 0xFF00FF00 ) );
    addInitializer( new Position ( new SphereZone( new Vector3D( 0, 0, 0 ), 50, 0 ) ) );

    addAction( new Move() );

    addActivity( new RotateEmitter (new Vector3D(0,10,0),2));
    }
    }
    }

    - Rich P.
    • CommentAuthorRichard
    • CommentTimeJul 15th 2011
     
    The only option I can think of is the brute force approach - rotate all the particles. You'll need a transform matrix for the rotation and to apply it to the position vector of each of the particles.