Search - User list
Full Version: How to get the value of impulse field for the current impact
Root » Houdini Indie and Apprentice » How to get the value of impulse field for the current impact
sadhu
Hello everyone,
I was studying this file (attached) . Torus dents on each impact with ground.
I want it to dent only when impulse value of it's impact with ground is more than 34. I used the following expression

if(dopfield(“/obj/dopnet1”, “torus”, “Impacts”, “Impacts”, $PT, “impulse”)>34,-0.2,0) in magnet2 translate parameters,

thinking translate parameter will be -0.2 when impulse is greater than 34 else 0.

But it is not working. The error is ‘undefined variable’ so I replaced $PT with 0, then I am not getting the desired result. What should I use instead of $PT or 0 to get the impulse value for the current impact? Is this is the problem &/or something else?
Can someone please help me out with this?
Thanks.
old_school
Magnet SOP doesn't support local variables. In the help card for this SOP, you do not see a listing of supported local variables. A very good indicator that this particular SOP does not work as a loop over points/prims.
Now this doesn't mean you can't use variables in there. It just means you can't pass in varying variables. You can use point() expressions in there to pick up attributes from points and more.


Two ways to go about this.

Put the Magnet SOP inside a ForEach SOP and loop through the magnet each time picking up the impact value with each iteration.

or

Scale the metaballs coming in to the Magnet SOP using, for example, the pscale point attribute in a Point SOP.
sadhu
Thanks a lot Sir for the reply.
But I understood only the last option. It was easy, I wish I could have figured it out myself.
Can you please the describe the other two options little more.

Point function

point(“../object_merge1”,$PT,“impulse”,0) It didn't work

I guess the problem is with source and attribute, what is going to be my source and attribut? ops:

Replacing “impulse” by dopfield(“/obj/dopnet1”,“torus”,“Impacts”,“Impacts”,$PT,“impulse”) giving the same error report ‘undefined variable’


and

Foreach sop

I am not comfortable with Foreach sop. Could you please upload the file?

Thanks a lot.
old_school
Again you can't use $PT in the Magnet SOP. It only knows to process the data just once! It doesn't do any iteration over the incoming data what so ever.

I attached a file that uses the ForEach SOP in all three modes (by group, by attribute and by iteration) for you to study and use.

You can make any SOP that doesn't support local variables behave like one that does using either of the three methods in the attached file.
sadhu
Thanks again for posting the file.
How would you use foreach sop ‘each attribute value’ and ‘each number’ when object to which it is applied gets created and dies (like metaballs in this case)
The torus is seen only when it collides with the metaball (see the attached file)
Sorry for the trouble.
Thanks
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB