Jump to content
demoan666

how to get connected primitives

Recommended Posts

hi everyone,

how do i randomly colorize each object separately instead of each primitive?

Thanks in advance,
d

Capture.PNG

Share this post


Link to post
Share on other sites

there is a connectivity SOP :P, you can use the attribute that that creates to assign a color.

alternatively you can color the points in your "point wrangle" and transfer the color in the "copytopoints1" node.

Share this post


Link to post
Share on other sites

hi acey195,

thanks for the reply... i tried both ways (within my noobility).

i did get random colors for each box using the connectivity node and used it's detail ( 'class')  inside a point VOP. 

however the second method i can't seem to be able to colorize it anything other than random gray values.
here is the snippet i used on the point wrangle (which works on each box rather than primitive or points):
@Cd =  set (random(@ptnum),random(@ptnum),random(@ptnum));

either that snippet is not proper or i didn't quite get and transfer the color in the "copytopoints1" node  from your answer

i would appreciate if anyone can point me to the right direction.

d.

Share this post


Link to post
Share on other sites

You have to use a foreach for that, try to use and "assemble" SOP after the copy to create the "name" attribute that the foreach uses by default to iterate at each object and use the 'attribute randomizer' inside the foreach, that should do the trick. I hope that helps.

Share this post


Link to post
Share on other sites

For non-gray colors, you should vary the seed value for each color component, e.g:

@Cd =  set (random(@ptnum + 123),random(@ptnum + 456),random(@ptnum + 789));

 

  • Like 1

Share this post


Link to post
Share on other sites
4 minutes ago, konstantin magnus said:

For non-gray colors, you should vary the seed value for each color component, e.g:


@Cd =  set (random(@ptnum + 123),random(@ptnum + 456),random(@ptnum + 789));

 

thanks konstantin magnus :)

 

d

Share this post


Link to post
Share on other sites

Another thing of note is that there are random() and rand() vex functions. The output from random() is not assumed to be in the range of 0-1. However, the output of rand() is. This may be more suited to constructing colors and other data fields that typically fall in the range of 0-1.

v@Cd = set(rand(@ptnum+123), rand(@ptnum+456), rand(@ptnum+789));

 

Edited by Atom
  • Like 1

Share this post


Link to post
Share on other sites

thanks Atom... that was a cool tip.

 

also it would be great of you can explain what does the v in the beginning stand for?

 

m.

Edited by demoan666

Share this post


Link to post
Share on other sites

v is the explicit type cast for the attribute. v= vector, f = float, i = integer and s= string. So you may see those other prefixes in posted code as well. Most common attributes, such as, P, v, ptnum, Cd etc don't need explicit casting but every once in a while you will find that VEX may complain about automatic type casting not working. In those cases you need to specify the type or explicitly convert to the destination type manually by using int() or float() functions.

Edited by Atom
  • Like 1

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

×