Categories
General

Papervision3D snow

I don’t know about you guys, but at the moment I’m getting several calls a day asking for Flash Christmas cards. And what do you need in a Flash Christmas card? Christmas snow! Remember last year I completed the 3D-Flash-snow-in-15-minutes challenge at FlashBrighton’s Big Day Out? Well this year I thought I’d do the same thing with Papervision; now you can add snow to your own 3D scenes!

[kml_flashembed movie=”/wp-content/uploads/manual/2008/ChristmasCard2008.swf” width=”480″ height=”370″ FVERSION=”9″ QUALITY=”high” /]

Snowstorm is a DisplayObject3D so you just add it to your scene. And there’s also a Snowflake.as file too.

new SnowStorm( quantity, flakeSize, cubesize);

It basically makes a big cube full of snow flakes! The parameters should be fairly self explanatory. πŸ™‚

Download the source here.

29 replies on “Papervision3D snow”

Very nice effect! It was a little disorienting when it spun so it was going away from you. Thanks for sharing. Merry Christmas!

real nice Seb – I really need to have a proper look at that particle stuff – makes me realise how shallow my PV (and AS3!) knowledge is when I read your classes! Very cool.
RIP 2d snow… you have served me well …. :o)

[…] In fact, there really was no let up in December, I built a particle based sparkly Christmas card for the BBC and put together a Christmassy Flash augmented reality demo for local geek group Β£5app which utilised my Papervision snow. […]

Hi there! Thanks for sharing this!
I have a problem though…I addChild the snowstorm to my scene, but I see nothing, yet I don’t get any output error.

Am I missing something?

There is another thing to, When I first published, the output yielded this:

SnowFlake.as, Line21 1152:A conflict exists with inherited definition org.papervision3d.core.geom.renderables:Particle.rotationZ in namespace public

so I commented the line in SnowFlake.as. Does this have to do with the aforementioned problem?

Thanks a lot
-g

Awesome looking storm script, thanks. No matter how I add this line to my AS project I get an error saying its expecting a right paran before the colon:
new SnowStorm(quantity:int=200, flakeSize:Number=32, cubesize : Number = 400);
This is what I was trying actually:
var snow:SnowStorm = new SnowStorm( quantity:int=200, flakeSize:Number=32, cubesize:Number = 400);

Any ideas why I get a syntax error there? Thanks.

Thanks, fixed it. Now I get the same error as Guille above: 1152: A conflict exists with inherited definition org.papervision3d.core.geom.renderables:Particle.rotationZ in namespace public.

Sorry to bug you man(and merry christmas!)

Same results as Guille, as in no error, no snow. I was trying to add your snow to a FLAR project that existed. I’m gong to try and implement just your snow in a new flex project. I’m rusty though!

Hi, to make it work you hace to call snowStorm.update() on each frame. For example:

this.addEventListener(Event.ENTER_FRAME, onEnterFrame);

private var snowStorm:SnowStorm

private function onEnterFrame (evt:Event) :void {
if (this.snowStorm)
snowStorm.update();

}

I’m trying to use this code in augmentation reality using Flar but it doesnt seem to be working. Anyone have made this work in Flar AR?

THanks

Error 1046! whatΒ΄s that? i am new on this 3d flash and i do not understand what do i hace to write in the timeline appart from importing the class… please i d love to give this for my mom in these xmas! forgive me for my bad english, kisses from montevideo, Urugua… id love to learn papervision

Anyone else having problems getting this to work with the latest build of PV3D? I am extending basic view, adding the SnowStorm instance to the scene and calling the update function inside an ENTER_FRAME event handler.

I am not getting any errors, just don’t see anything being rendered.

Never mind, got it figured out. SnowStorm var I was referencing was created at a local scope rather than global, so the update function wasn’t being called properly. Oops πŸ™‚

hi Christian,
can you please publish your code here,
because I have a problem like yours and I cant figure it out.
thanks mate

Thanks Seb! I was on a tight deadline to make it snow on the holiday page. Your class did the trick. //www.mattel.com/holiday
I’m usually involved in non 3D interfaces so I did not have time to experiment. I am sure I will be doing more game development though so I will keep reading your blog. Too bad for me your on a different continent.

Thanks again
Greg

Hi everybody
I am using the exact instructions but it seems that I cant make this work.
please share the complete code here.
I really need to make it work right now.
thanks

In order to make it work with the latest PV3D release and FLARToolkit:

First, comment out the following line in SnowFlake.as:
//public var rotationZ : Number = 0;

Next, somewhere in the class where your PV3D Scene and Viewport etc. are:

var snow:SnowStorm = new SnowStorm(100, 0.1, 150);
snow.z = 30;
snow.rotationZ = -90;

var container:DisplayObject3D = new DisplayObject3D();
container.addChild(snow);

scene.addChild(container);

Most important in my case was to make the snowflakes really small (0.1) and add a little Z-value (30) to the SnowStorm Object.

This works for me!

Ok i got it to work with AR.

This is how:

first download the snowstorm stuff (link above). Then extract it so you can use it. First thing (also in the comments above) remove the line

– “public var rotationZ : Number = 0;”

from SnowFlake.as if you don’t do it it will throw errors.

Second create a snowstorm… my code:
snow = new SnowStorm(500, 0.5, 1000); //play with the number so it suits your wishes
snowHolder = new DisplayObject3D();
snowHolder.rotationZ = 90;
snowHolder.addChild(snow);

this.scene3D.addChild(snowHolder);

This should do the trick for adding it. Next you want to animate it. So you should have a event:

this.addEventListener(Event.ENTER_FRAME, this.onEnterFrame);

then in the onEnterFrame event handler do

if (this.snow)
{
snow.update();
}

Comments are closed.