Jump to content

Attirbutes in CHOPs, how can I use them?


Recommended Posts

OK, I've got a piece of geometry with a point attribute I've painted called "mass".

I bring this geometry into CHOPS with a geometry CHOP. I import this attribute as well with the attribute scope in the Geometry CHOP and rename the scoped attribute to "mymass". I guess this places the attribute into a channel. Since it's a point attribute, I end up with hundreds of channels; mymass1, mymass2, etc; one for each point, and I can see them all in the CHOPs channel display.

The problem is I cannot seem to do anything with these channels in an expression. I'm trying to use this per point attribute inside an expression in a spring CHOP. I finally went to the textport and tried to echo the value of some of these channels and I kept getting "0" (I am in the spring CHOP in the textport). Then I decided to give chexist() a try on a channel I can see in my channel viewer in CHOPS. It returned 0.

I really don't understand this at all... Can anyone tell me how to use these attributes within an expression in CHOPs?

Link to comment
Share on other sites

Well I stayed up very late playing with this and this is what I surmised, but I still need help....

If I use chop() it gets the value from the specified channel, and I guess I can use $C after the channel name to get the proper index. The problem is, if I understand the CHOPs documentation correctly, there are actually two versions of the channel in each CHOP (incoming and outgoing). The chop() function evaulates correctly when echoed in the textport, but gives me a infinite recursion error when I try to use it in a CHOP that's being directed back into SOPland via a Channel SOP.

Anone got any ideas at all?

Link to comment
Share on other sites

Hey Mike,

Here's a fix (i think :unsure: )

Few notes (although I'm sure you'll see all this right away):

*) I just import t[xyz] since I didn't see you use any of the other channels (this is just for my own sanity :) ). Anyway, this gives us 3 channels per point, but organized like this: all of tx, then all of ty, and finally all of tz -- i.e: three packed segments of $NPT length each. So if we needed to use the channel index ($C) as an index into point numbers, we'd need to use $C%($NC/3) -- where $NC is the num of chans in the chop ( = num_of_points_represented * 3).

*) I mention the indexing mapping because I chose to look up the mass from the geometry itself instead of chops. So this solution (and something tells me there are others, as usual ;) ) reads the mass through a point() function (instead of a chop() function).

*) I added a bit of a floor to the mass (+0.2) just so it doesn't diverge ( I think it uses a simple Euler solver, so it can blow up reeeeal good in no time! :P )

I think that's all...

Anyway; I don't know if this is the "best" solution, but it's the first one I tried (didn't want to spend time trying to figure out why it was recursing...), and it kind'a works, so I left it there.

Hope it helps,

Cheers!

MikeChops1.zip

  • Like 1
Link to comment
Share on other sites

Mario beat me to it but not that I would have solved it. :P

Oh, yes you would have. Of that I have no doubt.

There is one thing I *really* hate about my solution: it calls the point() function 3X as much as necessary -- that is a staggering amount of wasted computation. It means this puppy could run at least three times faster!

Please go ahead and see if you can remove that eyesore. It would be nice to have a more elegant solution, as I think this little trick could have quite a few applications.

Cheers!

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