Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Rain Particle Effect

Author
Message
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 20th May 2003 01:24 Edited at: 1st Aug 2003 16:23
I've noticed that some people are wondering how to make a rain effect, so I made this. It is made in DB Classic, not sure if it works in Pro, but I dont see why not. Also, I'm not sure about the speed on other machines, as it goes pretty fast on mine, so it'll probably fly on most of yours

Edit: As I took down the image, I took the useless link away.



Whatever I did I didn't do it!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 20th May 2003 01:51
Ok, a small edit: This code will work better, the rain will not be overlapped by objects and it ignores the camera's movements so it is always on screen, so if you want to use the code in your programs, use this instead:



Whatever I did I didn't do it!
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 20th May 2003 03:47
Nice Ran at 62 FPS in classic for me That rain does seem a little big though, but might just be me. Great job kent

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
Kensupen
22
Years of Service
User Offline
Joined: 19th Sep 2002
Location: United States
Posted: 20th May 2003 14:31
You could save on polygons by making triangles instead of planes. just scale the y to stretch them. Would go from 100 polys to 50.

-Kensupen
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 20th May 2003 16:21
If they seem to big, you could try to place them back more, using the zPos() array. Add 30 instead of 20, or any other value. Doing this though, you might also have to adjust the height at which they start and stop. It's very customisable by just changing a few things.

Whatever I did I didn't do it!
ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 20th May 2003 19:37
yeah effect and thx

Newbie Now; Expert Later
Current project:The Sorus
ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 22nd May 2003 17:40
kentaree is there a way to randomsize where then fall in the scene so in a 3d scene it looks like they are in the scene there then just in front. would you increase the zpos randomiser thing to a great number

Newbie Now; Expert Later
Current project:The Sorus
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 22nd May 2003 19:41
Uhm, could you explain more clearly what you mean?
The zPos variable is for how close or far away it is. If you want the rain closer you'll change the +20 to a smaller number, if you want it further away, you increase it. Also, if you want the rain to be overlapped by objects, i.e, its not in the front, you can remove the line disable object zdepth i.

Whatever I did I didn't do it!
ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 22nd May 2003 21:59
what i want is at the moment it looks like it is just going over the screen. i want it to go in the 3d world. I know this isn't reallybare with me. the first is how it is at the moment the second how i would like it


okay that i kinda a side view of it

Newbie Now; Expert Later
Current project:The Sorus
sicjoshsic
21
Years of Service
User Offline
Joined: 8th May 2003
Location: United Kingdom
Posted: 23rd May 2003 01:59
i think you just need to increase the z variable (eg to 200) and remove the line 'disable object zdepth' (like kentaree already said )

ok, im feeling generous. try this:


Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 23rd May 2003 03:58 Edited at: 23rd May 2003 04:03
I don't think that would work because you also have to add 200 in the 'move particle' subroutine.

One way i found to add a lot more random depth is to change the random statement for the zpos into a big number like 500 instead of just 5 and then it well spread itself out. This works a lot better than just adding 200 cause that would just move all of the drops back to the same depth. here's the code incase you didn't understand what i said



you might have to take the disable object zdepth statement out of there but I haven't tried it in a scene yet so i don't know.

by the way, you will have to make all of the drops fill the screen again because when you put them farther back, they take up less screen so you get a smaller box of rain that doesn't fill the whole entire screen, and you could also always add more rain drops too.

Awesome code by the way
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 25th May 2003 18:30
Sorry for taking so long to reply.


Right on, Duncala . Changing the randomizing factor to get the z position increases the range of the particles' depth. Change the value in both for..next to a greater one, like from 50 to 100, or higher to get more particles. Obviously, because of the increased particle depth, some particles will seem to appear midscreen and they wont range to the sides. I'm currently working on a code to fix this, not sure when it'll be done though.

Whatever I did I didn't do it!
ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 25th May 2003 19:25
already there kentaree just increase the randomize factor for the xpos. personally i think it looks alot better if you increase the amount of drops by increaseing the for next loop but remember o increase the array by the same amount

Newbie Now; Expert Later
Current project:The Sorus
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 26th May 2003 03:36
K, I think i got it. I basically just work with it and found the proportion of the depth to the x and y max that's on the screen, that's what the .8 and .6 is. Now, it fills the whole screen. Now I need to figure out how to make the drops in the very back move faster cause they go really really slow. Hope this helps. I increased the number of drops to 500 to look more realistic.

Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 26th May 2003 18:07
To increase the speed of the drops in the back, just use something like:

rain(i-1,speed)=(int(rnd(3)+1))+rain(i-1,zPos)

The further back the drops are the faster they'll fall. Good code for getting the x and y values corresponding to the depth btw. I was working on something like it, but I was wondering just how the heck I'd get it to work properly, thanx

Whatever I did I didn't do it!
Duncanla
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location:
Posted: 29th May 2003 01:40 Edited at: 29th May 2003 01:43
All right, I think i got it. For the speed i just did the z position times the .6 for the y size, and then i just divided by 50 to slow it all down a little. Here it is:


by the way, is it allright if i use this in my code with you in the creds Kentaree?

Anybody up to makin it splash?

Peace
Critters
21
Years of Service
User Offline
Joined: 11th Apr 2003
Location: United Kingdom
Posted: 30th May 2003 11:53
it looks great !!!

but the rain is a little big, but that just might be my big ass computer

Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 31st May 2003 12:54
@Duncala: Sure you can! There'd be no point in releasing this code if people weren't allowed to use it

@CoDeR Of ThE NiGhT: If they are too big, you can adjust the size in the _setupParticles subroutine. For example, if you want them half the current size, you'd use make object plain i, .5,.5 instead of make object plain i, 1, 1.

Whatever I did I didn't do it!
optical r
22
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 3rd Jun 2003 12:15
I just drew a small vertical line in paint with a black background, coloured it light blue and saved it - the rain now looks incredibly realistic, unlike the original image - try it!

Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 3rd Jun 2003 13:07
lol yep, It looks far better this way, thanks for the tip.

Whatever I did I didn't do it!
optical r
22
Years of Service
User Offline
Joined: 23rd Oct 2002
Location: Prime
Posted: 4th Jun 2003 19:46
Dont' meantion it - i'm here to help!

ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 2nd Jul 2003 15:47 Edited at: 5th Jul 2003 17:22
hi guys sorry about bringing this back but how would i make it so when the rain starts is slow get more and more, or you could do an example that the closer to a position you get the more rain you get, yeah do the second one would help more thx

crystal

*edit sorry i was half a sleep at the time

Newbie Now; Expert Later
Current project:The Sorus
Guruchild
21
Years of Service
User Offline
Joined: 13th May 2003
Location: United States
Posted: 3rd Jul 2003 07:01
Stay in school kids... for the love of GOD

3dZmaster
21
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 3rd Jul 2003 16:54
Thanx Kentaree. You will see this effect in my newest game when it's finished or when the demo or beta comes out. It's cargame with split screen multiplayer possibility. Ofcourse if you let me use it...?

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 4th Jul 2003 00:01 Edited at: 6th Jul 2003 18:40
@guruchild: Uhm, whats wrong?

@3dZmaster: Cool. This code is for general use, anyone who wants to use it can use it, a thank you or mention in the credits would be nice, but not necessary .

Okay, this one lets you adjust the amount of rain thats falling, using a simple variable that can be changed in game. No version yet with distance finder, but working on it



Edit: Quick change to this code, I had a 1 where there was supposed to be an i, so objects didnt reappear when they had to. This is now fixed.

Whatever I did I didn't do it!
3dZmaster
21
Years of Service
User Offline
Joined: 30th Jun 2003
Location: Finland
Posted: 4th Jul 2003 14:56
I will give you a place in the credits. Thanx!

Current project: Dodge Viper Car Game (Not named yet) Other car models are going to be included soon
Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 4th Jul 2003 16:59
I did some rain code a while back (I'll try to dig it out) where each rain drop was created high up in a random position in a certain distance around the camera.
The rain then fell until it's 'life' counter had dropped to 0 (like the bullet counter in the original turorials). Once it had 'died' I repositioned it in a random spot around the camera again and so on. About 40 of these made nice rain that 'followed' you around the level.

I imagine if I went back to it, using the 'life' counter (and checking distance above the matrix at creation) you could make it splash. I.e....

Create the raindrop at 'players location +/- a random number' and a particular height.
Check the height above matrix ONCE.
Divide that by the distance it moves down every frame.
Make that the 'life counter'. Let it fall and reduce life counter.
When the counter reaches 0, create the splash effect at it's position.
Goto top.

Sorry - I'll look for the actual code and see if I can 'splash' - but I'm fairly sure it would be easily transferable.

Guruchild - Crystal may not actually have English as a first language. Sure, there are people who just don't take the time to try, but you have to give the benefit of the doubt.
Guruchild
21
Years of Service
User Offline
Joined: 13th May 2003
Location: United States
Posted: 4th Jul 2003 17:30
If she is living in the UK she had better pick it up.

ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 5th Jul 2003 17:33 Edited at: 5th Jul 2003 17:38
@guruchild just shut up okay, thx

Okay I finished off the code for the distance stuff I have not tested it though

ohh can you change it so that the particles are formed off scene because at the moment i create them at the start of the level and they are all on screen
*edit* durr just hide them sorry guys


Okay it would be cool if one of you could test it for me

Ohh btw English is my fist language and if you read the post again I have edit and the reason why it was so bad was because I did it at about 4:00 in the morning just before I went to sleep okay next time I will try to look over it

Clear Coder

P.S I am going to edit the code i bit more to make it use sprites coz with all those poly if doesn't do well for the FPS on my PC.

Newbie Now; Expert Later
Current project:The Sorus
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 5th Jul 2003 21:27
The snippet itself wont do the job due to the fact that object one and object two are particles, and thus the distance between them has nothing to do with this here. However, if you use this in your game, and make sure object 1 and 2 are not particles, and you move object 1 or 2, it will (should) work.
Also, sprites wont work if you want perspective, as sprite's just sit on one z axis, and a DBPro sprite is the same as a textured plain. As kensupen suggested, you could use triangles instead of plains, if you texture it right, it will lower the poly count by half.

Whatever I did I didn't do it!
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 6th Jul 2003 01:45
If a mod sees this thread, please delete the above two posts, as they have absolutely NO significance to the topic of this thread.
guruchild, please stop flaming, this is a programming forum, not a "speak excellent English" forum, if you complain about every spelling mistake in this forum I wonder why you're here, as you would obviously not have the time to do any programming. Say something helpfull, or say nothing at all.

Whatever I did I didn't do it!
ClearCoder
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 6th Jul 2003 02:34
sorry if i offended you guruchild can we just get back to what this post is about okay

any way thx for just clearing up the code kentaree i had to write it on a public pc so i couldn't test it.

Newbie Now; Expert Later
Current project:The Sorus
Guruchild
21
Years of Service
User Offline
Joined: 13th May 2003
Location: United States
Posted: 6th Jul 2003 10:04
Yes ClearCoder, I'm willing to forgive and forget. You said sleepiness was the excuse for your post, my excuse was I happened to be reading the forums when I was in a very bad mood on a very short fuse. Forgive me and let's get back to the thread.

Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 6th Jul 2003 18:39
Cheers, there's enough to be doing without fighting anyway.

@ClearCoder: No worries, it was clear what you were trying to do anyway.

This code fixes the errors and lets you test the distance aspect:



Whatever I did I didn't do it!
AzureZeal
21
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 29th Jul 2003 18:58
Couple things I noticed... Why do you reseed the randomizer every loop? You should only need to do it once at the start of your program unless im mistaken. Also, why do you increase the speed of the rain? Im no physics expert, but by the time rain gets down to earth in the real world im pretty sure its going just about as fast as it can go.

And btw, I think youll find out (as I did) that youre going to need a hell of alot more than 100 rain drops to make a realistic looking storm. It may look ok in your demo, but thats mainly because youre not really moving around like you would in a actual game. I just dont think the big boys do rain like this (correct me if im wrong). I think the rain effects in games like morrowind were done with scrolling/animated textures on big planes. How exactly youd do that I dont know, I just dont think they used a individual plain/triangle for each individual raindrop/snowflake.

Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 1st Aug 2003 16:21
No, particles are usually used, and definitely a lot more than 100. Thats why you can change the amount. The randomize each loop is not necessary, but as the timer changes each loop it makes for very accurate pseudo-random numbers. Also, we dont change the speed of particles in mid flight, we give the speed a random value so not all the rain drops drop at the same time. While the physics of this code is by no means correct, it looks realistic, which is what we need.
And hey, with a decent rain texture, it looks good

Cheers,
Kentaree

Whatever I did I didn't do it!
AzureZeal
21
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 1st Aug 2003 19:22
You sure games like morrowind use a individual plain for each individual drop? I hope youre right, because I know how to do rain like youve posted, but no idea how to do it any other way

AzureZeal
21
Years of Service
User Offline
Joined: 10th May 2003
Location:
Posted: 1st Aug 2003 19:36
Oh btw, even if big games do rain like this, your code still wont work in a 3d game. Try x rotating the camera and youll see what I mean. You cant lock plains onto the screen, thus you have to have them falling in a radius around the player, even behind him where he cant see them. Thats what I meant when I said youd need more than 100. I didnt mean just a few more, I meant thousands.

DarkSith
22
Years of Service
User Offline
Joined: 8th Nov 2002
Location: United Kingdom
Posted: 4th Aug 2003 14:21 Edited at: 4th Aug 2003 14:22
It might be possible to get the Particle effect in DBPro to do the rain? Maybe the make snow particles and just alter the speed? I'll look into it, this might help a few people for their 3D games.

"He will join us, or die my Master..." - Darth Vader
UnderLord
21
Years of Service
User Offline
Joined: 2nd Aug 2003
Location:
Posted: 5th Aug 2003 21:36
you can make snow in DBC too just use the above givin code and change the image to snow and yes slow it down a bit or atleast thats what my nooblet brain tells me

http://www.freewebs.com/independant
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 5th Aug 2003 22:26
Offensive posts sorted Cheers Kent

RPGamer

Current Project: Eternal Destiny
Porting all files to my new computer
Kentaree
22
Years of Service
User Offline
Joined: 5th Oct 2002
Location: Clonmel, Ireland
Posted: 10th Aug 2003 17:40
Thanks
That tidies everything up a bit.

Whatever I did I didn't do it!

Login to post a reply

Server time is: 2024-11-27 19:31:35
Your offset time is: 2024-11-27 19:31:35