Fork me on GitHub
Not signed in (Sign In)
    • CommentAuthorMatts
    • CommentTimeSep 8th 2008 edited
     
    I am thinking this should be done with GravityWells? The snowfall will not accumulate. It will originate randomly off stage. Anyone out there with a little extra time to give me a head start?

    Thanks,
    Matt
    • CommentAuthorRichard
    • CommentTimeSep 8th 2008
     
    Do you want to look down on the snow falling, so it's moving away from you?

    You could get a true perspective effect by using the 3D features of version 2 of Flint.

    Or you could create a custom initializer that sets the particle's velocity based on its position, so particles move in towards the center of the stage.

    Finally, yes you could use a gravity well, but you may find the acceleration of the particle's doesn't look right.
    • CommentAuthorMatts
    • CommentTimeSep 8th 2008
     
    Richard, this system is awesome! Thank you for creating it.

    I am a bit of noob, hopefully not too much so get done that which I am trying to do. I used to be proficient at c++, but it's been a while. Sorry for the noob questions.

    Yes, I want to look down on the snow falling, so it is moving away from me.

    I would like it to look as realistic as possible, but bare minimum, the particles move in towards the center of the stage with realistic acceleration towards the middle and degradation of size as it does so.

    I would prefer using the 3D features in Flint2. Given my unfortunate noob disposition, which would route would you recommend?

    Thanks!
    Matt
    • CommentAuthorMatts
    • CommentTimeSep 9th 2008
     
    So I have Flint2 installed and I have pouring over the documentation. I feel I have a small handle on it, but I'm not sure how I want to structure this. I don't know if I need to use 4 LineZones in the initializer or one BoxZone. They particles need to originate offstage and have somewhat of a convergence to the center as they fall. I am a little confused how to set this up. Can you give me a little guidance in the right direction?

    Thank you,
    Matt
    • CommentAuthorRichard
    • CommentTimeSep 9th 2008
     
    Basic set-up:

    The 3D camera is initially placed at the origin, pointing in the z direction. So, you can just leave it where it is. Set the snowflakes up to look like in the 2D version. Set the velocity away from the camera, e.g. (0, 0, 50). Which leaves creating and removing the particles.

    Two options for creating and removing...

    1. Initialize using four line zones around the scene, as you suggest. Destroy with a death zone in the shape of a box far from the camera, or set a lifetime for the particles so they die after a short period.

    2. Initialize using a thin box zone (I should probably add a rectangle zone for the 3D stuff, which is what you ideally need here) near the camera, set a lifetime on the particles, and use a fade action on the particles with a two-way easing function (see the TwoWay class) so particles fade in at the beginning and out again at the end.

    I prefer the latter, but haven't seen what the results look like.
    • CommentAuthorMatts
    • CommentTimeSep 9th 2008
     
    Richard,

    I implemented your second suggestion and its working! But it bogs down pretty quick because I haven't gotten the two-way easing function to work. I was unable to find an example of the two-way easing function in the examples. Can you give me an example of the syntax?

    Here's what I have so far of you have a minute to check these out:

    http://public.spaeth.sent.com/Frame1.as
    http://public.spaeth.sent.com/SnowfallTD.fla

    All the flakes are going into the corner near origin. I tried moving the Velocity PointZone to the middle but then it gives me what looks like an extreme closeup. Maybe my BoxZone is not setup right?

    Best,
    Matt
    • CommentAuthorRichard
    • CommentTimeSep 10th 2008 edited
     
    Matt

    You need a lifetime initializer and age action (so the snowflakes don't live indefinitely) and you pass the two-way easing function to the age action. Add a fade action so the snowflakes fade in and out. Also, place the renderer in the centre of the stage, and place the box for the position initializer further away from the camera. The result is like this.

    var emitter:Emitter3D = new Emitter3D();
    emitter.counter = new Steady( 50 );

    emitter.addInitializer( new ImageClass( Dot, 3 ) );
    emitter.addInitializer( new Position( new BoxZone ( 1366, 768, 10, new Vector3D( 0, 0, 400 ), new Vector3D( 0, 1, 0 ), new Vector3D( 0, 0, 1 ) ) ) );
    emitter.addInitializer( new Velocity( new PointZone ( new Vector3D ( 0, 0, 50 ) ) ) );
    emitter.addInitializer( new ScaleImageInit( 0.5, 1.5 ) );
    emitter.addInitializer( new Lifetime( 10 ) );

    emitter.addAction( new Move() );
    emitter.addAction( new Age( TwoWay.quintic ) );
    emitter.addAction( new Fade( 1, 0 ) );
    emitter.addAction( new RandomDrift( 15, 15, 15 ) );

    var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
    renderer.addEmitter( emitter );
    addChild( renderer );
    renderer.x = 684;
    renderer.y = 384;

    emitter.start();
    emitter.runAhead( 20 );
    • CommentAuthorMatts
    • CommentTimeSep 10th 2008
     
    That's gorgeous. Thank you! Do you take donations?

    One more question: ScaleImageInit()? I can't find what package that function is in.

    Thanks,
    Matt
    • CommentAuthorRichard
    • CommentTimeSep 11th 2008 edited
     
    Matt

    ScaleImageInit is a renaming of ScaleInit. In the SVN repository I've already renamed it, and the renaming will be in the next download (alpha 2) - it's because there's now a ScaleAllInit too. So if you're working off the alpha 1 download rather than the svn repository, change it to ScaleInit.

    I've been meaning to add a donate button but I keep getting distracted with developing the library. You've spurred me into action - there's now a donate button at the bottom of the page.

    Thanks
    Richard
    • CommentAuthorjoel
    • CommentTimeNov 3rd 2010
     
    Hello Richard (and Matt if you are still listening in) - I am also after this exact same effect but am not sure which classes to import at the beginning - could you help me out?

    http://public.spaeth.sent.com/Frame1.as is a dead link now so I am not sure where to begin.
    • CommentAuthorRichard
    • CommentTimeNov 5th 2010 edited
     
    Hi Joel

    Since this was written, I introduced the Point3D class to Flint's 3D geometry. So now the full script would be...

    import org.flintparticles.threeD.emitters.Emitter3D;
    import org.flintparticles.common.counters.Steady;
    import org.flintparticles.common.initializers.ImageClass;
    import org.flintparticles.common.displayObjects.Dot;
    import org.flintparticles.threeD.initializers.Position;
    import org.flintparticles.threeD.zones.BoxZone;
    import org.flintparticles.threeD.geom.Point3D;
    import org.flintparticles.threeD.geom.Vector3D;
    import org.flintparticles.threeD.initializers.Velocity;
    import org.flintparticles.threeD.zones.PointZone;
    import org.flintparticles.common.initializers.ScaleImageInit;
    import org.flintparticles.common.initializers.Lifetime;
    import org.flintparticles.threeD.actions.Move;
    import org.flintparticles.common.actions.Age;
    import org.flintparticles.common.energyEasing.TwoWay;
    import org.flintparticles.common.actions.Fade;
    import org.flintparticles.threeD.actions.RandomDrift;
    import org.flintparticles.threeD.renderers.DisplayObjectRenderer;

    var emitter:Emitter3D = new Emitter3D();
    emitter.counter = new Steady( 50 );

    emitter.addInitializer( new ImageClass( Dot, 3 ) );
    emitter.addInitializer( new Position( new BoxZone ( 650, 500, 10,
    new Point3D( 0, 0, 400 ), new org.flintparticles.threeD.geom.Vector3D( 0, 1, 0 ),
    new org.flintparticles.threeD.geom.Vector3D( 0, 0, 1 ) ) ) );
    emitter.addInitializer( new Velocity( new PointZone ( new Point3D ( 0, 0, 50 ) ) ) );
    emitter.addInitializer( new ScaleImageInit( 0.5, 1.5 ) );
    emitter.addInitializer( new Lifetime( 10 ) );

    emitter.addAction( new Move() );
    emitter.addAction( new Age( TwoWay.quintic ) );
    emitter.addAction( new Fade( 1, 0 ) );
    emitter.addAction( new RandomDrift( 15, 15, 15 ) );

    var renderer:DisplayObjectRenderer = new DisplayObjectRenderer();
    renderer.addEmitter( emitter );
    addChild( renderer );
    renderer.x = 275;
    renderer.y = 200;

    emitter.start();
    emitter.runAhead( 20 );


    (Yes, lots of imports!)
    • CommentAuthorjoel
    • CommentTimeNov 8th 2010
     
    Hi Richard,

    that is perfect, thank you very much for your help with this.
    • CommentAuthorlumenbeing
    • CommentTimeNov 29th 2013
     
    Richard, I'm trying to get this to work using the code posted above and, but I've run into an error.

    TypeError: Error #1034: Type Coercion failed: cannot convert 3 to Array
    at Snowfall_fla::MainTimeline/frame1()

    I'm on Flash CS5.
    • CommentAuthorlumenbeing
    • CommentTimeNov 30th 2013
     
    I tried putting brackets around the 3 like in the 2d example code, but now I get a new error,

    ReferenceError: Error #1065: Variable Point3D is not defined.
    at Snowfall_fla::MainTimeline/frame1()
  1.  
    Richard can you please give me the updated code for this? Now that Point3D is gone from the library, I can't make this work.