Jump to content
Sign in to follow this  
gazegaze

Can't access components of a vector with point()?

Recommended Posts

Hi,

Learning VEX and this is simply out of curiosity since I'm trying to build an intuition for how houdini works under the hood.

I know I can read a vector from say point 5, like so:

vector test = point(0, "P", 5);
printf("%f", test);

{0.091506,0.482963,-0.091506}

Is there a way I can directly access only a component, like P.x with the point function?

To my surprise, substituting "P" with "P.x" doesn't work, i.e:

float test = point(0, "P.x", 5);
printf("%f", test);

0.000000

 

I know I can access it via variable indices in the first example like

vector test = point(0, "P", 5);
printf("%f", test[0]);
 

0.091506

but it doesn't seem to work within the function. Neither "P.x" nor "P[0]" works. Is there a good reason for this?

Grateful for any input you may have!

GG

Edited by gazegaze

Share this post


Link to post
Share on other sites

You cannot retrieve point attribute components this way, you will have to read the vector and then as you already know, use the component from this vector.

Share this post


Link to post
Share on other sites

In order to access a single vector component, you would need to explicitly type cast the point() function to vector:  

float test = vector( point( 0, "P", @ptnum) )[0];

 

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
Sign in to follow this  

×