Jump to content

more trouble with expression functions


fixxorion

Recommended Posts

Hi,

I've run into yet another problem with the way that Houdini works with expression functions. For some strange reason, I can't access a custom attribute that I create and then actually modify it. It's kinda hard to explain, so I've attached a little example. It's supposed to be a particle system with POPs that, at random intervals, blows the particles up, but doing this with a expression function. I realize that there are other ways to do this, but I would like to do this with expression functions.

Thanks,

fixxorion

SimpleExpression.hipnc

Link to comment
Share on other sites

Everything seems to be working fine. Your expression function is doing what it is supposed to as written. Here is the expression:

float moveParticles(float value)
{
    if (value > 0)
    {
        temp = value - 1;
        return temp;            
    }
    else
    {
        if (rand($F) < 0.5)
            return 0;
        else
            return 150;
    }
}

How I tested your file is I first created a spreadsheet pane in POPs and clicked on first the attribute POP and then the force POP for just the newpos attribute. Now I played forward and saw that the values first are 0 then get bumped to 150 if rand($F) was greater than 0.5. I opened a textport and to see what rand($F) evaluated to, I typed in:

echo `eval(rand($F))`

which returns the random value of $F at that frame. If it was greater than 0.5, your numbers would then be bumped to 150 then count down from there. If less than 0.5, then they would remain at 0 until rand($F) was greater than 0.5.

Now where in this expression are you trying to access a local variable? Do you mean $F? It is evaluating just fine in your expression.

Beware: Always use $FF in POPs. $F is an integer and increments on ones whereas $FF is a floating point current frame. If you increase your oversampling, $F will break things as it will jump at half frame steps.

I also saw that you put a condition expression in the force POP's activation field. This is global to the current evaluation of the rules and not selective per point. In other words, all or nothing. Secondly, it will evaluate this value on a single particle, most likely the first or last particle to evaluate. Any way, this won't work. A better use would be to actually put your rand($F) test in there as this is a global per time-step evaluation.

You will have to place a condition right in the Force POP's parameters. Then you will have per-particle evaluation of your expressions.

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...