hi fellas, im trying to simulate traffic using particle flow. my procedure so far is as follows.
1- created a group of various cars (15 cars)
2- created a pf source
3- created a spline along the road (for speed by icon to follow)
4- put a speed by icon operator in the event and path constraint it to the spline.
5- put a shape instance in the event and selected group of cars as the instance.
at this point the cars start to move along the spline but started to penetrate into each other. so i put a “keep apart” operator in the event.
now my problem is
A- the cars dont stick to the road (the road has a slope in some portions) i think i can solve it by using a deflector and gravity.
B- the particles are going too far from the spline path hence moving off the road (keep apart operator pushes them off and if i reduce its accel value they start to penetrate eachother)
so guys help me out here. im attaching the screenshot where particles go off the road and another screenshot of pf flow.
thanks in advance for your help guys.
help with traffic simulation with particle flow
adding boundary on the side of the road and adding road to a udeflactor is giving better result, but im having trouble keeping the cars stuck to the ground surface, few of them seem to be floating in the air.
Drop this into a script operator. It’s shaky, slow and untested, but it snaps particles to a surface. If you have trouble with particles under the surface, add a shell modifier with the inner and outer amount set to 0 (don’t render it like that though!).
on ChannelsUsed pCont do
(
pCont.usePosition = true
)
on Init pCont do
(
)
on Proceed pCont do
(
count = pCont.NumParticles()
for i in 1 to count do
(
pCont.particleIndex = i
for i=1 to count do (
offset = 0 --the Z offset of the particle
oldCoords = pCont.particlePosition at time (pCont.GetTimeStart() as float)-1
downRay = ray oldCoords [0, 0, -1]
upRay = ray oldCoords [0, 0, 1]
downIntersect = intersectRay $groundPlaneNode downRay
upIntersect = intersectRay $groundPlaneNode upRay
if downIntersect != undefined then ( hitCoords = downIntersect )
else if upIntersect != undefined then ( hitCoords = upIntersect )
if hitCoords != undefined then ( pCont.particlePosition = [oldCoords.x, oldCoords.y, hitCoords.pos.z + offset] )
)
)
)
on Release pCont do
(
)
no, its not solving the problem. or im doing something wrong (new to max script
)
here is the screen shot of odd cars floating in the air
Is the script doing anything or is it just flat out not working? I forgot to note that $groundPlaneNode in the lines
downIntersect = intersectRay $groundPlaneNode downRay
upIntersect = intersectRay $groundPlaneNode upRay
needs to be replaced by the actual name of your ground plane (don’t forget the $ before the name).
Also, the offset = 0 line can be changed if the cars are a bit too high or low.
yes now the script is working… but some of the cars are going inside the ground plane now…and also the cars look really messed up in viewport but they render fine.
See my note about the shell modifier in my first post. You need both a front and back face for your object, since the intersectRay function the script uses seems to not work for backfaces.
If all else fails, Orbaz has a PFlow operator called Lock/Bond (also included in Max 2010) that will lock objects to a surface/volume.
thanks alot noouch for your help. ill do some tests and see what kinda results i get and report back to you later.
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.