Nothing to do with the Grateful Dead, but a Python script for making rain with an EcoSytem.
Here it is:
Code:
# File BoxOfRain.py
# Simple rainfall using an EcoSystem populated with spheres
# By John Whitham - http://www.jwhitham.plus.com/VuePython.html - December 2005
# ******************************************************************************
# Useage:
# 1. Create a transparent plane and populate it with 1 unit diameter spheres.
# 2. Name the plain "Rain".
# 3. Place the plane above the area to be rained on.
# 4. Run script.
# 5. That's it!
# ******************************************************************************
# Imports
import random
# Globals
Rain = None
#-------------------------------------------------------------------------------
# This function Positions the "raindrop" spheres at random altitudes above the
# "cloud" plane, this function is called once, when the script is first run.
# ------------------------------------------------------------------------------
def SetDropPos():
eco = GetEcosystemOnObject(Rain)
for drop in range(0,eco.GetInstanceCount()):
pos = eco.GetInstancePosition(drop)
cloudpos = Rain.Position()
offset = random.random() * cloudpos[2]
eco.SetInstancePosition(drop,pos[0],pos[1],offset + cloudpos[2] + 5)
# ------------------------------------------------------------------------------
# This function is called by Vue each time an animation frame is about to be
# rendered.
# ------------------------------------------------------------------------------
def RainCallback(k):
eco = GetEcosystemOnObject(Rain)
for drop in range(0,eco.GetInstanceCount()):
pos = eco.GetInstancePosition(drop)
# ------------------------------------------------------------------------------
# Collision detection. A selection ray is fired from a point on the suface of
# the "raindrop" sphere, to the position it would occupy when the frame is
# rendered. Be sure to keep the ray starting position *outside* the geometry of
# the "raindrop" or only collisions with itself, or with intersecting geometry,
# will be detected.
# ------------------------------------------------------------------------------
z = pos[2] - 0.5
startv = pos[0],pos[1],z
z = pos[2] - 5.5
endv = pos[0] - 1,pos[1],z
hittest = GetFirstHitObject(startv,endv)
# ------------------------------------------------------------------------------
# I'm moving the "raindrop" by -1 unit in X, as well as by -5 in in Z, per frame.
# If you wish to move it by a different increment in X then:
# drift = CurrentFrame() * MyIncrement
# ------------------------------------------------------------------------------
drift = CurrentFrame()
cloudpos = Rain.Position()
offset = random.random() * cloudpos[2]
# ------------------------------------------------------------------------------
# If the "raindrop" would hit nothing, or a sibling, then:
# move it by -1,0,-5
# else: put it back in the sky, compensating for drift.
# ------------------------------------------------------------------------------
if (hittest == None) or (hittest.Name() == "Rain"):
eco.MoveInstance(drop,-1,0,-5)
else:
eco.SetInstancePosition(drop,pos[0] + drift,pos[1],offset + cloudpos[2])
Rain = ObjectByName("Rain")
if Rain != None:
SetDropPos()
Rain.SetInitFrameCallback(RainCallback)
else:
print "No such object"
I hope the commenting within the script is sufficient for anyone to use it, if not please ask! A couple of tips though; don't bother going much above 15% density on the Eco, use it for rain that is quite close to the camera.
P.S. The script assumes 15fps, for higher frame rates reduduce the -5 to something smaller throughout. _________________ Moderator
I think a lot of Vue users (myself included initially) are quite intimidated by the idea of Python, but when you see great examples like this of how powerful it can be such as your movie clip, then people are more willing to start playing around.
No, thank you, Roderick. It's great to get some feedback!
I've got some big improvements worked out for this script, also fully commented versions of the scripts from my site, and a simple particle emitter using Vue primitives, on the drawing board ATM. RL is tending to get in the way a bit just now though. _________________ Moderator
Woo - i'm having a *lot* of fun with this script right now - it's amazing how much fun you can get with new toys to play with!
What I did was to create a metablob raindrop using a cone and a sphere, then bake it to a low polygon model, and used Clear Water material.
My own raindrops were a bit chunkier (about 2 units) but about 10-15% of the EcoSystem as you recommended.
I also animated the Rain plane to have the rain to drive slowly in a direction.
I've got a test render running right now and might post under the Animations gallery and link here and on the E-On forums, as I think a lot of users might miss out on this cool feature.
I know a lot of people would love see some more particle related effects ideas - of course changing raindrops to expanding smoke or light balls could be interesting, so I look forward to hear of what you come up with next John!
Rain has never been so welcome! (and that's saying a LOT from a Welsh man)
Rain has never been so welcome! (and that's saying a LOT from a Welsh man)
Me granny and, by extension, me mam were from Llandudno, bach. So North Wales was where I came to see the beauty of rain, it never looked like that though - at least not until I fell in with a bad crowd, as smoked funny looking cigarettes - wow! _________________ Moderator
... at least not until I fell in with a bad crowd, as smoked funny looking cigarettes - wow!
I should like to point out that the water droplets are static, and in fact it was raining psychadelic primitives and marijuana plants in that pic ... (*cough*)
What next - raining Cats and Dogs or hailing Taxis? ...? (Cue for someone from the Vue community to do just that...)
Sorry, yes, I should have put a comment in the script. HyperVue requires the script to be set as the startup script for the scene.
I haven't tried this script yet with HyperVue, I'm at work ATM and can't test until I get home tonight, but I think it should work OK as a startup script. _________________ Moderator
Nothing to do with the Grateful Dead, but a Python script for making rain with an EcoSytem.
Here it is:
Code:
# File BoxOfRain.py
# Simple rainfall using an EcoSystem populated with spheres
# By John Whitham - http://www.jwhitham.plus.com/VuePython.html - December 2005
# ******************************************************************************
# Useage:
# 1. Create a transparent plane and populate it with 1 unit diameter spheres.
# 2. Name the plain "Rain".
# 3. Place the plane above the area to be rained on.
# 4. Run script.
# 5. That's it!
# ******************************************************************************
# Imports
import random
# Globals
Rain = None
#-------------------------------------------------------------------------------
# This function Positions the "raindrop" spheres at random altitudes above the
# "cloud" plane, this function is called once, when the script is first run.
# ------------------------------------------------------------------------------
def SetDropPos():
eco = GetEcosystemOnObject(Rain)
for drop in range(0,eco.GetInstanceCount()):
pos = eco.GetInstancePosition(drop)
cloudpos = Rain.Position()
offset = random.random() * cloudpos[2]
eco.SetInstancePosition(drop,pos[0],pos[1],offset + cloudpos[2] + 5)
# ------------------------------------------------------------------------------
# This function is called by Vue each time an animation frame is about to be
# rendered.
# ------------------------------------------------------------------------------
def RainCallback(k):
eco = GetEcosystemOnObject(Rain)
for drop in range(0,eco.GetInstanceCount()):
pos = eco.GetInstancePosition(drop)
# ------------------------------------------------------------------------------
# Collision detection. A selection ray is fired from a point on the suface of
# the "raindrop" sphere, to the position it would occupy when the frame is
# rendered. Be sure to keep the ray starting position *outside* the geometry of
# the "raindrop" or only collisions with itself, or with intersecting geometry,
# will be detected.
# ------------------------------------------------------------------------------
z = pos[2] - 0.5
startv = pos[0],pos[1],z
z = pos[2] - 5.5
endv = pos[0] - 1,pos[1],z
hittest = GetFirstHitObject(startv,endv)
# ------------------------------------------------------------------------------
# I'm moving the "raindrop" by -1 unit in X, as well as by -5 in in Z, per frame.
# If you wish to move it by a different increment in X then:
# drift = CurrentFrame() * MyIncrement
# ------------------------------------------------------------------------------
drift = CurrentFrame()
cloudpos = Rain.Position()
offset = random.random() * cloudpos[2]
# ------------------------------------------------------------------------------
# If the "raindrop" would hit nothing, or a sibling, then:
# move it by -1,0,-5
# else: put it back in the sky, compensating for drift.
# ------------------------------------------------------------------------------
if (hittest == None) or (hittest.Name() == "Rain"):
eco.MoveInstance(drop,-1,0,-5)
else:
eco.SetInstancePosition(drop,pos[0] + drift,pos[1],offset + cloudpos[2])
Rain = ObjectByName("Rain")
if Rain != None:
SetDropPos()
Rain.SetInitFrameCallback(RainCallback)
else:
print "No such object"
I hope the commenting within the script is sufficient for anyone to use it, if not please ask! A couple of tips though; don't bother going much above 15% density on the Eco, use it for rain that is quite close to the camera.
P.S. The script assumes 15fps, for higher frame rates reduduce the -5 to something smaller throughout.
hi .. i liked ur work very much , i did a test and it's wonderfull and here wt idid ..
i model a drop in my maya and exported it as a (.obj) then i import it in the vue , iput the material then saved it as (.vop) without background then i populated it and run the script
and i like to ask u about somthings
1- the raining is continues from the begaining how could i make it started then continue then stopped the rain
2-how could i reduce the speed of falling
Woo - i'm having a *lot* of fun with this script right now - it's amazing how much fun you can get with new toys to play with!
What I did was to create a metablob raindrop using a cone and a sphere, then bake it to a low polygon model, and used Clear Water material.
My own raindrops were a bit chunkier (about 2 units) but about 10-15% of the EcoSystem as you recommended.
I also animated the Rain plane to have the rain to drive slowly in a direction.
I've got a test render running right now and might post under the Animations gallery and link here and on the E-On forums, as I think a lot of users might miss out on this cool feature.
I know a lot of people would love see some more particle related effects ideas - of course changing raindrops to expanding smoke or light balls could be interesting, so I look forward to hear of what you come up with next John!
Rain has never been so welcome! (and that's saying a LOT from a Welsh man)
Good luck with RL.exe
Kind regards
hi , i liked ur work and i did the same as u did and the resault was perfect but about the raindrop material , how did u get that reality in ur scene
mean i model a drop in my maya and exported it as a (.obj) then i import it in the vue , i assigned the clear water material on the drop then saved it as (.vop) without background then i populated it and run the script but the drops didn't keep the transperency and it looks flat so how and when did u assign the material ?
thank u
If I recall, I did a very simple Metablob using a Cone on top of a stretched Sphere - It wasn't perfect, but I think I might have also Baked To Polys and made a very low poly version to make the Eco populate faster.
I think I then applied a basic Water material to the raindrop.
Once I created the Raindrop I saved it as a VOB, and then created the EcoSystem using the VOB only, before running the Python Script.
(If you get stuck, let me know and I will upload my raindrop scene for you).
Kind regards
P.S. To answer your question about changing speed, find this line in the Python script:
Quote:
eco.MoveInstance(drop,-1,0,-5)
Change -5 to a smaller value (e.g. -3 or -4) if you wish the raindrop to move slower vertically per frame.
If I recall, I did a very simple Metablob using a Cone on top of a stretched Sphere - It wasn't perfect, but I think I might have also Baked To Polys and made a very low poly version to make the Eco populate faster.
I think I then applied a basic Water material to the raindrop.
Once I created the Raindrop I saved it as a VOB, and then created the EcoSystem using the VOB only, before running the Python Script.
(If you get stuck, let me know and I will upload my raindrop scene for you).
Kind regards
P.S. To answer your question about changing speed, find this line in the Python script:
Quote:
eco.MoveInstance(drop,-1,0,-5)
Change -5 to a smaller value (e.g. -3 or -4) if you wish the raindrop to move slower vertically per frame.
hi Roderick i am very thankful for ur nobility .. thanx a lot .hope to b friends
in the SetDropPos() function and remove the "+ cloudpos[2]". That should place the drops between the Rain and the ground, though also possibly inside any intervening objects!
Next find the lines:
Code:
if (hittest == None) or (hittest.Name() == "Rain"):
eco.MoveInstance(drop,-1,0,-5)
else:
eco.SetInstancePosition(drop,pos[0] + drift,pos[1],offset + cloudpos[2])
in the RainCallback() function, and modify it so:
Code:
if (hittest == None) or (hittest.Name() == "Rain"):
eco.MoveInstance(drop,-1,0,-5)
else:
if (CurrentFrame() == 200):
eco.DeleteInstance(drop)
else:
eco.SetInstancePosition(drop,pos[0] + drift,pos[1],offset + cloudpos[2])