Jump to content

Fish flocking system


Recommended Posts

Hello

I creating system for schooling fishes. I choose simple setup with wires and deformable geo. But i have some prolems. I split system onto two peaces. For detailed animation I deform fishes with wires, so they bend like curves with creap, but I cant find way how inside loop add velocity atribute to rippleSOP which simulate speed of fish swiming. I look at the couple of foreachSOP tutorials but cant find right way.

Second system is easier. There I only copy fishes on the end of each wire and thats all. But i found problem. dont know why, but if I take my vel, convert it to speed and use this for driving rippleSOP wave speed, when is attribute near zero, fish start swim fast. grrr, I custom visualize my parameter, all is ok. Dont know why ripple see high value. I cant find the mistake.

there is simple system. It is vissible when particles stopping, ripples go faster.

hip file.

flock_odforce.hip

Link to comment
Share on other sites

  • 3 weeks later...

well, 2 things

1. ripple SOP is based on global time and changing wave speed is just the same as changing temporal frequency, it is changing it from begining of the timeline (time = 0s)

as a little example to understand better:

imagine you are on 10s of your timeline

ripple wave speed is 1 which lets say means 1 wave per s (it might be different but it doesn't matter for now)

so by now it already advanced by 10 waves from the beginning

now imagine you are animating it between 10s and 11s from 1 to 2 so you expect it to start getting a little faster to twice the speed within that 1s which will be around 1.5 wave within that 1s

but

what it really does it will recompute how many waves should have passed from beginning till 11s at the speed of 2 and which is 22 that is the final wave count

so it is actually animating from 10 waves to 22 within that 1s which is 12 waves instead of 1.5 and therefore that sudden speedup

if you want it to behave correctly you need base your ripple system on time as a variable/parameter which is quite easy with just modifying the existing ripple solver code, or making one in VOPs

then you can accumulate speed within CHOPs or in your original particle network, so each fish contain exact swum distance at each frame which can be used to drive time of the ripple

2. to use any attribute within the ForEach, you can simply use point() expression inside of your foreach node in the parameter value of lets say that ripple sop

so for example

point("../each1", 0, "speed", 0)

will take value of the "speed" attribute of the first point of the geometry in ../each1 node

you can of course use other like prim() or detail() to access other types of attributes

Link to comment
Share on other sites

  • 4 weeks later...

well, 2 things

1. ripple SOP is based on global time and changing wave speed is just the same as changing temporal frequency, it is changing it from begining of the timeline (time = 0s)

as a little example to understand better:

imagine you are on 10s of your timeline

ripple wave speed is 1 which lets say means 1 wave per s (it might be different but it doesn't matter for now)

so by now it already advanced by 10 waves from the beginning

now imagine you are animating it between 10s and 11s from 1 to 2 so you expect it to start getting a little faster to twice the speed within that 1s which will be around 1.5 wave within that 1s

but

what it really does it will recompute how many waves should have passed from beginning till 11s at the speed of 2 and which is 22 that is the final wave count

so it is actually animating from 10 waves to 22 within that 1s which is 12 waves instead of 1.5 and therefore that sudden speedup

if you want it to behave correctly you need base your ripple system on time as a variable/parameter which is quite easy with just modifying the existing ripple solver code, or making one in VOPs

then you can accumulate speed within CHOPs or in your original particle network, so each fish contain exact swum distance at each frame which can be used to drive time of the ripple

2. to use any attribute within the ForEach, you can simply use point() expression inside of your foreach node in the parameter value of lets say that ripple sop

so for example

point("../each1", 0, "speed", 0)

will take value of the "speed" attribute of the first point of the geometry in ../each1 node

you can of course use other like prim() or detail() to access other types of attributes

Thats excelent, thanks a lot. Im going to integrate it. Thanks

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...