Infinite Loops

   4027   4   1
User Avatar
Member
19 posts
Joined: July 2005
Offline
Summary: How can I access a variable from the previous frame?

So I'm trying to re-write the normals for my particles. That in itself isn't hard - simply use a Point SOP. However, I want the new normal to be based off what the normal for the particle was in the previous frame.

How I tried to solve it thus far has been by creating a new vector attribute (call it $old_normal) and store off the $NX, $NY, and $NZ values. And then the next time it gets updated, before storing off the current normal values into $previous_normal, I use $previous_normal to somehow change the normal value. So that:

Normal = $previous_normal * 2 (well, a bit more complicated here)
$previous_normal = normal

However, therein lies my dillema. Before I can set the Normal = $previous_normal *2 — I have to declare and define $previous_normal as some value. What I'd love to do is have:

AttribCreate $previous normal = if ($F == 1, $normal, $previous_normal);
Normal = $previous_normal * 2 (etc etc)
$previous_normal = normal

However, life isn't that easy, and Houdini won't let me do that. Any suggestions/ideas on how to get this to work?
User Avatar
Member
60 posts
Joined: July 2005
Offline
Just a quick thought off the top of my head


1) “cache” sop set to `$FF-1`

2) add a “point” sop and set the original particles as the first input,
and the “cache” into the second. Set the normal to add to normal.

I think the expression would be some thing like $NX2 etc.

quick answer
maybe I can type more later if this doesn't do the trick
hope it helps

Jim
Jim Ellis
www.emsh.calarts.edu/~jim
User Avatar
Member
19 posts
Joined: July 2005
Offline
Thanks Jim, I'll give that a try when I get in tomorrow. I've never worked with the cache SOP before, so I might never have thought of that.
User Avatar
Member
7709 posts
Joined: July 2005
Offline
You're in POPs aren't you? Then you can just use the Attribute POP to create your new normals based on ($NX, $NY, $NZ) which would be the old values.
User Avatar
Member
60 posts
Joined: July 2005
Offline
I am still a bit new,
and Edwards's solution sounds like the most efficient…
and proper.

I think mine would work,
but if you never need to leave Pops,
all the better.
I'd check out his ideas first.
Jim Ellis
www.emsh.calarts.edu/~jim
  • Quick Links