demoan666 Posted March 18, 2017 Share Posted March 18, 2017 hi everyone, how do i randomly colorize each object separately instead of each primitive? Thanks in advance, d Quote Link to comment Share on other sites More sharing options...
acey195 Posted March 18, 2017 Share Posted March 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
demoan666 Posted March 18, 2017 Author Share Posted March 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
Mzigaib Posted March 18, 2017 Share Posted March 18, 2017 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. Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted March 18, 2017 Share Posted March 18, 2017 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)); 1 Quote Link to comment Share on other sites More sharing options...
demoan666 Posted March 18, 2017 Author Share Posted March 18, 2017 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 Quote Link to comment Share on other sites More sharing options...
Atom Posted March 19, 2017 Share Posted March 19, 2017 (edited) 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 March 19, 2017 by Atom 1 Quote Link to comment Share on other sites More sharing options...
demoan666 Posted March 19, 2017 Author Share Posted March 19, 2017 (edited) 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 March 19, 2017 by demoan666 Quote Link to comment Share on other sites More sharing options...
Atom Posted March 19, 2017 Share Posted March 19, 2017 (edited) 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 March 19, 2017 by Atom 1 Quote Link to comment Share on other sites More sharing options...
demoan666 Posted March 20, 2017 Author Share Posted March 20, 2017 thanks for explanation... much appreciated, you guys are great! d. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.