Jump to content

beginner VEX question / set @Cd with custom value does not work


jon3de

Recommended Posts

Hi,

For educational purposes I try to replace things I can do with point SOPs with small VEX codes in attributeWrangle. I do that to get a little bit warm with the language also I read that it computes faster than a regular point SOP. ( Not that it would be necessary for my small learning scenes but....anyway)

 

I created  a attribute called "displaceValue" and wanted to use this to color the CD attribute. But there has to be a mistake in the code and I can´t find it. 

The attached picture explains it better. I would be thankful for some help.

I also tried something like " @Cd = {(@ptnum/@numpt),0,0};" which also does not work.

 

 

kind regards 

Jonathan

 

EDIT:

 

Ah....it works with:

 

@displaceValue = float(@ptnum)/float(@numpt);
 
@Cd = set(@displaceValue,0,0);
 
So i think the curly brackets caused the error...
Are the curly brackets just for fast "values" and no attributes or variables?
If someone wants to explain the error in more detail to me I would appreciate that.

post-12840-0-42682400-1445634710_thumb.j

Edited by jon3de
Link to comment
Share on other sites

Another way which can sometimes be easier to read is dot syntax:

 

@Cd = 0;

@Cd.r = @displaceValue;

 

@Cd is one of the few special values that automatically converts itself to a vector, so @Cd=0; gets converted to @Cd={0,0,0};

 

You can also call the suffix as r/g/b, or x/y/z, or an array index, all are useful depending on circumstance. Ie,

 

@Cd.x = 1;

@Cd.r  = 1;

@Cd[0] = 1;

 

are all the same, and will make the points red component to 1.

Edited by mestela
  • Like 1
Link to comment
Share on other sites

Thanks a lot for the additional info. 

By the way...I always get a zero value  if I write the @ptnum and @numpt without the "float" is that because that are integers by default?

And is the way I converted them the right way? Or is there a better way to handle this? Thanks again for all the help.

Jon

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