POP event into SOPs?

   6582   8   1
User Avatar
Member
27 posts
Joined: July 2005
Offline
how should I set up getting a POP collision event back into SOPs?

I have a POP net set up with referenced collision SOPs - when a particle collides with one of the objects I want to modify the SOP geometry, trigger a sound and maybe change the shader

I'm not sure how to access a collision event from within SOPs (or anywhere else)
I guess I'm looking for a generic description and I cant find anything in the pdf's

any help appreciated, thanks!
mark creer
User Avatar
Staff
1072 posts
Joined: July 2005
Offline
In general, there is no way to get popevent type information out of the simulation. However, there are some tricks that occur to me from time to time. For each collision POP, keep a seperate group of particles that have just hit it. Then in SOPs, to determine if a particular SOP has been hit, you just have to check whether this group contains any points or not. Hmmmm… looking through my trusty exhelp I fail to see something like ngrppoints or ngrpprims. Still, why should we let that stop us? We can have a geometry CHOP for each SOP that we care about, which extracts the id attribute from the collision group for its particular SOP. Then we can use the trusty chopn expression to count the number of channels, and if it returns 0, the groups was empty, otherwise it contains an entry. This can now be used as a trigger in SOPs.

I admit it's messy, and a bit limited. For instance it doesn't worry about which primitive was struck in the SOP. Hopefully others can think of better approaches.
User Avatar
Member
27 posts
Joined: July 2005
Offline
Ondrej - thanks that helps a lot

–after posting the question I figured out a bit more - I knew I'd be using CHOPS but I didn't realise the whole thing is controlled from there…

(seems a bit odd to have to use a workaround for ‘events’ though, I'd have thought it would be a fairly common need)

mark
User Avatar
Member
27 posts
Joined: July 2005
Offline
um - well I can't get anything to work - how should I enter the “query number of items in group” in the POP CHOP?

I get events to occur in the POP net and to put particles in a subgroup for that frame but I cant transfer any of that information to CHOPs

(also I realised particle acceleration or velocity would be handy to work with… )

- there seems to be a gap in the documentation between lists of what OPs do, lists of expressions etc, but not much on tying it all together - are there any web pages anywhere or sample files to dissect?

thanks mark
User Avatar
Staff
1072 posts
Joined: July 2005
Offline
To do what I suggested previously, you have to bring your simulation into SOPs, and use a Geometry CHOP, which has the ability of extracting channels from a specific group. For instance, just set both the attribute scope and the rename scope to id, and then you can use the chopl expression on this chop to determine the number of elements in the group.

Another way to get event information out is use two attribute pops, both setting the same attribute. The first, which should be always active, should set the value to zero. The second, which is activated by the event can set the value to 1. Then in sops, to determine if the event is happening that frame, it should be enough just to check that attribute value for any point using the point expression. That may be an easier way to do this.

I'm sure that there are lots of files out there to look through, though I unfortunately cannot point you to them. Hopefully someone else can.
User Avatar
Member
27 posts
Joined: July 2005
Offline
apologies Ondrej - I'm still struggling here

I can get an id number that changes (there's very few particles - it's a rigid body sim- a pinball table - seemed like a good idea at the time) in the geometry chop and if I connect it to an export CHOP, the current particle ID number passes through and will control a sop parameter but as soon as I add a Count or Trigger nothing happens -

I'm wondering if the jump from id=6 to id=9 (for example) is not regarded as a change over time,
and appending a lag fails to slow down any change

I've tried adding an expression chop after the geometry chop, but this one gives an infinite recursion error:

if (chopf(“/ch/ch1/geom1/chan1”, $F)!=chopf(“/ch/ch1/geom1/chan1”, $F-1),1,0)
(I hoped it would check for a change in ID number)

I did see a note in the online scripting help saying ‘single line’ if statements are not valid but I assume that refers to full script mode??

I've tried many other solutions too
(I once built a modular analog synthesiser so I thought I'd be able to get CHOPS to work fairly easily!)

any pointers much appreciated
User Avatar
Staff
1072 posts
Joined: July 2005
Offline
No need to apologize… after all, this is a bit convoluted. When we're using the geometry chop here, we're not actually interested in the value of the channel at all. What we actually care about is whether or not the group contains any particles. To determine this, we count the number of samples in the channel through the chopl expression (note, not the chopf).

So, for example, if you have a switch sop, with two different inputs, you can use an expression such as if(chopl(<chop_path>) > 0, 1, 0) and this will select input 0 if the group is empty, and input 1 if the group is not empty. Does this make sense?

The comment about the single line if statements refers to the if in the scripting language, not the expression function if.
User Avatar
Member
27 posts
Joined: July 2005
Offline
Ondrej - thanks for your help - it works now - I am using hitid (without chop expressions):

I wanted to know change in id because there is usually only one particle hitting my targets at any time - so I would have thought chopf at current and previous frame would give what I wanted ie: a change in id, with id evaluating as a value

there's some oddities :
if I put an unlinked Expression CHOP in the CHOP network with this expression:
print(test,chopf(“/ch/ch1/geom1/id”,$F))
I get a correct reading in the console… but if I run it without the “print” I get no display in the channel
I guess I'm stubborn and curious to know why something isn't doing what I would expect


should elaborate ‘if’ statements really just be left to vex?


currently I have the geometry chop feeding to a math chop feeding to export -
but I'd really like to generate an AD envelope from every event but i cant get Trigger to trigger from an incoming pulse out of math…
(changing threshold does nothing) - any suggestions?

thanks again Mark
User Avatar
Staff
1072 posts
Joined: July 2005
Offline
The unlinked Expression CHOP will not actually cook correctly as the expression CHOP is not a generator. It is a filter, and needs input. The print out you're seeing is probably when the UI updates by evaluating the parameter.

I'm not really an expert on CHOPs, so I'll leave this to other people to respond to.

In regards to whether elaborate “if” statements should be done in vex, well, that's a matter of preference and also differs on a case by case basis.
  • Quick Links