Search the Community
Showing results for tags 'functions'.
-
How do i write function that can override it variables like the &prim and &uv in xyzdist. float xyzdist(<geometry>geometry, vector origin, int &prim, vector &uv) float myProcess(float &space; float sideBar ) { float space=1; space = 15 * sideBar; }
-
Harder, Better, Faster, Stronger please! Looking for some voodoo to optimize these snippets... Find Unique Elements in One Array function int[] unique_elements (int arr[]) { int _arr[] = sort(arr); for (int i=0; i<len(_arr); i++) { while(_arr[i] == _arr[i+1]) pop(_arr,i); } return _arr; } Get Duped Elements in One Array function int[] duped_elements (int arr[]) { int _arr[] = sort(arr); int result[] = {}; int dupe; for (int i=0; i<len(_arr); i++) { while(_arr[i] == _arr[i+1]) { dupe = pop(_arr,i); } append(result, dupe); } return result; } Find Common Elements in Two Arrays function int[] common_elements (int arr1[]; int arr2[]) { int result[]; foreach (int i; unique_elements(arr1)) { foreach (int j; unique_elements(arr2)) { if (i==j) push(result,j); } } return result; } Find Different Elements in Two Arrays function int[] different_elements (int arr1[]; int arr2[]) { int result[]; int _arr1[] = unique_elements(arr1); int _arr2[] = unique_elements(arr2); foreach(int i; _arr1) { if(find(_arr2,i)<0) append(result,i); } foreach(int j; _arr2) { if(find(_arr1,j)<0) append(result,j); } return result; } Swap Arrays function int[] swap (int arr1[]; int arr2[]) { int temp[] = arr1; arr1 = arr2; arr2 = temp; return {1}; } Here's some of what I was using to test it... these are all based on arrays of integers but could be tweaked obviously for other types. i[]@arr1 = {3, 2, 15, 27, 1, 3}; i[]@arr2 = {3, 2, 3, 15, 41, 41, 1, 2, 2}; i[]@arr_comm = common_elements (@arr1, @arr2); i[]@arr_diff = different_elements (@arr1, @arr2); i[]@arr_uniq = unique_elements (@arr1); i[]@arr_dupe = duped_elements (@arr2);
-
Hi Is it possible to modify, from inside a function, a variable that was declared outside that function? For example this code wont work: void functionX() { y = 5; } int y; functionX(); Is there a way to reference that variable inside the function?
-
Hi, Is there an possibility to have @ working to create write attributes in a vex function? Something similar to the following function void test() { i@test_attrib = 10; } The reason I want to avoid setattrib is that it is much slower as implementation. Are there any other idea's? does the *.vcc compiler optimize the setting of attributes? Cheers
-
I'm a bit confused as to which VEX functions these two nodes have access to? Is this noted in the documentation anywhere? For example I can create geometry in an attribWrangle node using addPoint(), addPrim() and addVertex(), however these functions don't seem to work in the pointWrangle. And I can create groups using the addgroup() function in a pointWrangle node but this is not recognised in the attribWrangle node....
- 15 replies
-
- VEX
- pointWrangle
-
(and 2 more)
Tagged with: