Posted: 4th Jun 2003 19:46
Dont' meantion it - i'm here to help!
Posted: 2nd Jul 2003 15:47
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
Posted: 3rd Jul 2003 7:01
Stay in school kids... for the love of GOD
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...?
Posted: 4th Jul 2003 0:01
@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

+ Code Snippet
`Rain particle generator v2.0
`By Kentaree 19/05/03, last modification 03/07/03
`Code added and/or modified by Duncala
`http://members.lycos.co.uk/darknessrising/

`Setup program environment.
sync on
sync rate 60
autocam off
backdrop on
color backdrop rgb(0,0,0): `Remove this line if you're using DBPro

`Load media.
load image "rain.jpg", 1

`Maximum particle amount and currently shown amount
particleAmount=100
amountShown=50
maxDistance=300


`Set up an array holding position and speed of particles
dim rain(particleAmount,4)
xPos=0
yPos=1
zPos=2
speed=3
`Make all the particles
gosub _setupParticles

do
`Simple test controls, increase or decrease the amount of shown particles if possible
if upkey()=1 and amountShown<particleAmount then inc amountShown
if downkey()=1 and amountShown>0 then dec amountShown
randomize timer()
gosub _moveParticles
text 0,0,"Amount = "+str$(amountShown)
sync
loop


_setupParticles:
`Make textured and ghosted plains numbered 1 to 50, and set transparency on
for i=1 to particleAmount
  make object plain i, 1,1
  set object i,1,0,0
  texture object i,1
  ghost object on i
  disable object zdepth i
  lock object on i
  `Setup array values for each particles holding the positional data
  rain(i-1,zPos)=(int(rnd(maxDistance)+1))+20: `Z coordinate of particle
  rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8: `X coordinate of particle
  rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1)): `Y coordinate of particle
  rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50))): `Speed of particle
  `Position object for start
  position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  if i>amountShown then hide object i
next i
return

_moveParticles:
for i=1 to particleAmount
  if i<=amountShown
  if object visible(i)=0 then show object i
    `Move particle down according to speed value, which makes a random effect
    rain(i-1,yPos)=rain(i-1,yPos)-rain(i-1,speed)
    `If particle goes too low, set new position
    if rain(i-1,yPos)<-15
      rain(i-1,zPos)=(int(rnd(500)+1))+20
      rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8
      rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1))
      rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50)))
    endif
    `Position particle
    position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  else
    if object visible(i)=1 then hide object i
  endif
next i
return


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.
Posted: 4th Jul 2003 14:56
I will give you a place in the credits. Thanx!
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.
Posted: 4th Jul 2003 17:30
If she is living in the UK she had better pick it up.
Posted: 5th Jul 2003 17:33
@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
+ Code Snippet
`Rain particle generator v2.0
`By Kentaree 19/05/03, last modification 03/07/03
`Code added and/or modified by Duncala
`http://members.lycos.co.uk/darknessrising/

`Setup program environment.
sync on
sync rate 60
autocam off
backdrop on
color backdrop rgb(0,0,0): `Remove this line if you're using DBPro

`Load media.
load image "rain.jpg", 1

`Maximum particle amount and currently shown amount
particleAmount=100
amountShown=50
maxDistance=300


`Set up an array holding position and speed of particles
dim rain(particleAmount,4)
xPos=0
yPos=1
zPos=2
speed=3
`Make all the particles
gosub _setupParticles

do
`Simple test controls, increase or decrease the amount of shown particles if possible
  1X# = Object position x(1)
  1Z# = Object position z(1)
  2X# = Object position x(2)
  2Z# = Object position z(2)  
 
  difX#=mX#-pX#
  difZ#=mZ#-pZ# 

  diffX#=difX#*difX#
  diffZ#=difZ#*difZ#
  differ#=diffZ#+diffX#
  distance#=sqrt(diff#)
if distance>50 then amountShown = 10
if distance<50 then amountShown = 20
if distance<40 then amountShown = 30
if distance<30 then amountShown = 40
if distance<20 then amountShown = 50
if distance<10 then amountShown = 60
randomize timer()
gosub _moveParticles
text 0,0,"Amount = "+str$(amountShown)
sync
loop


_setupParticles:
`Make textured and ghosted plains numbered 1 to 50, and set transparency on
for i=1 to particleAmount
  make object plain i, 1,1
  set object i,1,0,0
  texture object i,1
  ghost object on i
  disable object zdepth i
  lock object on i
  `Setup array values for each particles holding the positional data
  rain(i-1,zPos)=(int(rnd(maxDistance)+1))+20: `Z coordinate of particle
  rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8: `X coordinate of particle
  rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1)): `Y coordinate of particle
  rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50))): `Speed of particle
  `Position object for start
  position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  if i>amountShown then hide object i
next i
return

_moveParticles:
for i=1 to particleAmount
  if i<=amountShown
  if object visible(i)=0 then show object 1
    `Move particle down according to speed value, which makes a random effect
    rain(i-1,yPos)=rain(i-1,yPos)-rain(i-1,speed)
    `If particle goes too low, set new position
    if rain(i-1,yPos)<-15
      rain(i-1,zPos)=(int(rnd(500)+1))+20
      rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8
      rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1))
      rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50)))
    endif
    `Position particle
    position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  else
    if object visible(i)=1 then hide object i
  endif
next i
return


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.
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.
Posted: 6th Jul 2003 1: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.
Posted: 6th Jul 2003 2: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.
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.
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:

+ Code Snippet
`Rain particle generator v2.1
`By Kentaree 19/05/03, last modification 06/07/03
`Code added and/or modified by Duncala and ClearCoder
`http://members.lycos.co.uk/darknessrising/

`Setup program environment.
sync on
sync rate 60
autocam off
backdrop on
color backdrop rgb(0,0,0): `Remove this line if you're using DBPro

`Load media.
load image "rain.jpg", 1

`Maximum particle amount and currently shown amount
particleAmount=100
amountShown=50
maxDistance=300

`Set up an array holding position and speed of particles
dim rain(particleAmount,4)
xPos=0
yPos=1
zPos=2
speed=3
`Make all the particles
gosub _setupParticles

X1#=0.0
Z1#=0.0

X2#=50.0
Z2#=50.0

do
`Simple test controls, increase or decrease the amount of shown particles if possible

  difX#=X1#-X2#
  difZ#=Z1#-Z2#

  diffX#=difX#*difX#
  diffZ#=difZ#*difZ#
  differ#=diffZ#+diffX#
  distance#=sqrt(differ#)
if distance#>50 then amountShown = 10
if distance#<50 then amountShown = 20
if distance#<40 then amountShown = 30
if distance#<30 then amountShown = 40
if distance#<20 then amountShown = 50
if distance#<10 then amountShown = 60
if upkey()=1 then Z1#=Z1#+1.0
if downkey()=1 then Z1#=Z1#-1.0
if rightkey()=1 then X1#=X1#+1.0
if leftkey()=1 then X1#=X1#-1.0
randomize timer()
gosub _moveParticles
text 0,0,"Amount = "+str$(amountShown)
sync
loop


_setupParticles:
`Make textured and ghosted plains numbered 1 to 50, and set transparency on
for i=1 to particleAmount
  make object plain i, 1,1
  set object i,1,0,0
  texture object i,1
  ghost object on i
  disable object zdepth i
  lock object on i
  `Setup array values for each particles holding the positional data
  rain(i-1,zPos)=(int(rnd(maxDistance)+1))+20: `Z coordinate of particle
  rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8: `X coordinate of particle
  rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1)): `Y coordinate of particle
  rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50))): `Speed of particle
  `Position object for start
  position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  if i>amountShown then hide object i
next i
return

_moveParticles:
for i=1 to particleAmount
  if i<=amountShown
    if object visible(i)=0 then show object i
    `Move particle down according to speed value, which makes a random effect
    rain(i-1,yPos)=rain(i-1,yPos)-rain(i-1,speed)
    `If particle goes too low, set new position
    if rain(i-1,yPos)<-15
      rain(i-1,zPos)=(int(rnd(500)+1))+20
      rain(i-1,xPos)=(int(rnd(rain(i-1,zPos)*.8)*2+1))-rain(i-1,zPos)*.8
      rain(i-1,yPos)=(int(rnd(rain(i-1,zPos)*.6)*2+1))
      rain(i-1,speed)=(int(rnd(3)+1+(rain(i-1,zPos)*.6/50)))
    endif
    `Position particle
    position object i, rain(i-1,xPos), rain(i-1,yPos), rain(i-1,zPos)
  else
    if object visible(i)=1 then hide object i
  endif
next i
return
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.
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
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
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.
Posted: 4th Aug 2003 14:21
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.
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