Jump to content
jfrancis

Why does Switch not see my attribute?

Recommended Posts

1188251214_xmDbS-O.jpg

Hi,

New Houdini user here. So far so good, except for a little confusion here and there.

For example:

I am trying to do things based on a user-defined attribute I call the magnetic 'charge,' (0 or 1) of objects. At the moment I don't want to do anything too fancy - just change colors based on charge, Later I'll need to get more elaborate.

I have a sphere.

It has a new attribute called 'charge,' which is a detail integer attribute created by using $FF and noise to produce an integer that randomly flips between 0 and 1.

The color nodes see the $CHARGE variable

But when I try to use it in an expression in the swith the $CHARGE variable is undefined.

Any idea why?

Share this post


Link to post
Share on other sites

Uhm...first of all I'd say use a detail attribute. But even then, the switch sop does not accept it directly as $ATT, you need a detail() expression. But even then this is not a very clean way of doing it. Better would be a copy sop and stamping because with the switch you'd need to refer to a node higher up the network, not immediately before, or perhaps with opinput(), but it gets all rather messy later on I reckon.

However, I attached a file for you to inspect your case (press play to see switching) because I don't know what you would eventually like to do, so it may after all be the right solution for you!

switch.hipnc

Edited by Macha

Share this post


Link to post
Share on other sites

Why use a switch? It's just extra work for Houdini. If you know the charge at the time of setting the color, then use an expression to create a different color. You don't even need to create an attribute if that's all it's doing is changing the color.

Share this post


Link to post
Share on other sites

Why use a switch? It's just extra work for Houdini. If you know the charge at the time of setting the color, then use an expression to create a different color. You don't even need to create an attribute if that's all it's doing is changing the color.

Create a color where? In the color node? It doesn't seem to accept local variables, and I need that $CHARGE for something later.

Share this post


Link to post
Share on other sites

Uhm...first of all I'd say use a detail attribute. But even then, the switch sop does not accept it directly as $ATT, you need a detail() expression. But even then this is not a very clean way of doing it. Better would be a copy sop and stamping because with the switch you'd need to refer to a node higher up the network, not immediately before, or perhaps with opinput(), but it gets all rather messy later on I reckon.

However, I attached a file for you to inspect your case (press play to see switching) because I don't know what you would eventually like to do, so it may after all be the right solution for you!

This seems to work for me (although I replace the %2 with a more complex noise-based function)- thanks

I didn't realize I needed this detail() function to access the data. I thought a $ANDSOMECAPITALLETTERS would be enough of a way to reference the detail attribute data.

Share this post


Link to post
Share on other sites

Here's a few more ways to do it.

By the way, $ATT doesn't work always. If you look in the helpfile you'll see which node accepts wich local attributes. Often you can get it to work by using a point(), prim(), vertex() or detail() expression.

Also, vector attrib components are usually referred to as something like $ATTX $ATTY $ATTZ, whereas that is not true for 3 floats. Just something to be aware of. Color itself is a little unusual in that you refer to its components as $CR $CG and $CB, unless they are volumes in which case they are Cd.x Cd.y, Cd.z

Aaaahhh....

switch.hip

post-4013-129782406062_thumb.jpg

Edited by Macha

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×