diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a4ca89b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +backup \ No newline at end of file diff --git a/examples.hipnc b/examples.hipnc new file mode 100644 index 0000000..c4ce0fd Binary files /dev/null and b/examples.hipnc differ diff --git a/vex/include/myLib.h b/vex/include/myLib.h new file mode 100644 index 0000000..589d0f7 --- /dev/null +++ b/vex/include/myLib.h @@ -0,0 +1,205 @@ +// those two lines and #endif at the bottom will prevent multiple including of this header +#ifndef _myLib_ +#define _myLib_ + + + +// you can define constants and use them in your code +#define MY_INT 123 +#define MY_FLOAT 3.1415926 + +// you can also create alias to the function +#define RENAMEDPOWER pow + +// or use macros for defining new functions +#define ADDTEN(val) val+10 + + + +// void functions do not return anything +// "function" word is not required +function void myRemPoints(int ptnum) { + if (ptnum > 30) + removepoint(0, ptnum); +} + +// function parameters are passed by reference automatically, without additional syntax +// (function can modify value of original variable, not its copy) +void scaleByTen(vector P) { + P *= 10; +} + +// you can prevent changing input variable references +void changeA(int a; const int b; int c) { + a += 10; + //b += 10; // uncommenting this line will result in error + c = a; + c += 4; // even though arguments are passed as references, they are not true references, c is still independent from a +} + +// testing escaping of special characters +// here it requires two backslashes :D I am wondering about a legendary place where it needs only one :) +void printTestEscaping() { + string a = "from myLib.h: \\n \\t v\@P, %04.2f"; + printf(a + "\n"); +} + +// a function returning float value +float superRandom(vector4 seeds) { + float out = rand(seeds.x * seeds.y * seeds.z * seeds.w); + return out; +} + +// a function returnig an array +int[] range(int max) { + int out[]; + + for(int i=0; igetFullName() == B->getFullName()) match = 1; + + return match; +} + +// func returning hipFile type +// this function expects comma separated list of filenames and will +// return the first occurance of a hip file +hipFile findFirstHipFile(string text) { + string inFiles[] = split(text, ","); + string hipParts[]; + + foreach(string file; inFiles) { + string parts[] = split(file, "."); + if (parts[-1] == "hip" || parts[-1] == "hipnc") { + hipParts = parts; + break; + } + } + + // we can also return error state, warning() function is also available + if (len(hipParts) == 0) error("No houdini project found in this file list: %+s.", text); + + string prefix[] = split(hipParts[0], "_"); + int ver = atoi( prefix[-1] ); + string base = join( prefix[:-1], "_"); + string ext = hipParts[1]; + + hipFile out = hipFile(base, ext, ver); + return out; +} + +// we can as well return an array of structs +hipFile[] findAllHipFiles(string text) { + string inFiles[] = split(text, ","); + hipFile hips[]; + + foreach(string file; inFiles) { + string parts[] = split(file, "."); + if (parts[-1] == "hip" || parts[-1] == "hipnc") { + string prefix[] = split(parts[0], "_"); + int ver = atoi( prefix[-1] ); + string base = join( prefix[:-1], "_"); + string ext = parts[1]; + + hipFile out = hipFile(base, ext, ver); + push(hips, out); + } + } + + // output a warning when no Houdini projects were found + if (len(hips) == 0) warning("No Houdini projects found."); + + return hips; +} + + +#endif \ No newline at end of file