Attribute Functions
addpointattrib(geohandle, name, defval)
Adds a point attribute.
addpointattrib(0, "myattr", 0.0);
addprimattrib(geohandle, name, defval)
Adds a primitive attribute.
addprimattrib(0, "name", "");
addvertexattrib(geohandle, name, defval)
Adds a vertex attribute.
addvertexattrib(0, "uv", {0,0,0});
adddetailattrib(geohandle, name, defval)
Adds a detail attribute.
adddetailattrib(0, "total", 0);
point(geohandle, attribname, ptnum)
Reads a point attribute value.
vector pos = point(0, "P", 10);
prim(geohandle, attribname, primnum)
Reads a primitive attribute value.
string name = prim(0, "name", @primnum);
vertex(geohandle, attribname, linearidx)
Reads a vertex attribute value.
vector uv = vertex(0, "uv", @vtxnum);
detail(geohandle, attribname, detailnum)
Reads a detail attribute value.
int count = detail(0, "count", 0);
setpointattrib(geohandle, name, ptnum, value, mode)
Sets a point attribute value.
setpointattrib(0, "Cd", @ptnum, {1,0,0}, "set");
setprimattrib(geohandle, name, primnum, value, mode)
Sets a primitive attribute value.
setprimattrib(0, "name", @primnum, "piece_0", "set");
setvertexattrib(geohandle, name, primnum, vtxnum, value, mode)
Sets a vertex attribute value.
setvertexattrib(0, "uv", 0, 0, {0.5, 0.5, 0}, "set");
setdetailattrib(geohandle, name, value, mode)
Sets a detail attribute value.
setdetailattrib(0, "total", @numpt, "set");
attribsize(geohandle, attribclass, attribname)
Returns the size/component count of an attribute.
int sz = attribsize(0, "point", "P");
attribtype(geohandle, attribclass, attribname)
Returns the type of an attribute (0=int, 1=float, 2=string).
int tp = attribtype(0, "point", "Cd");
hasattrib(geohandle, attribclass, attribname)
Checks if an attribute exists.
if(hasattrib(0, "point", "Cd")) { ... }
Geometry Functions
addpoint(geohandle, pos_or_ptnum)
Creates a new point.
int pt = addpoint(0, {0, 1, 0});
addprim(geohandle, type, pt0, pt1, ...)
Creates a new primitive.
int pr = addprim(0, "poly", pt0, pt1, pt2);
addvertex(geohandle, primnum, ptnum)
Adds a vertex to a primitive.
addvertex(0, pr, pt);
removepoint(geohandle, ptnum, andprims)
Removes a point.
removepoint(0, @ptnum);
removeprim(geohandle, primnum, andpoints)
Removes a primitive.
removeprim(0, @primnum, 1);
npoints(geohandle)
Returns total number of points.
int n = npoints(0);
nprimitives(geohandle)
Returns total number of primitives.
int n = nprimitives(0);
nvertices(geohandle)
Returns total number of vertices.
int n = nvertices(0);
primpoints(geohandle, primnum)
Returns array of point numbers belonging to a primitive.
int pts[] = primpoints(0, @primnum);
pointprims(geohandle, ptnum)
Returns array of prim numbers connected to a point.
int prs[] = pointprims(0, @ptnum);
pointvertex(geohandle, ptnum)
Returns the first linear vertex index of a point.
int vtx = pointvertex(0, @ptnum);
vertexprim(geohandle, linearidx)
Returns the prim number of a vertex.
int pr = vertexprim(0, @vtxnum);
neighbours(geohandle, ptnum)
Returns array of connected neighbor point numbers.
int nbrs[] = neighbours(0, @ptnum);
neighbourcount(geohandle, ptnum)
Returns the number of connected neighbors.
int nc = neighbourcount(0, @ptnum);
Math Functions
abs(val)
Returns the absolute value.
float a = abs(-3.5);
ceil(val)
Rounds up to nearest integer.
float c = ceil(2.3); // 3.0
floor(val)
Rounds down to nearest integer.
float f = floor(2.7); // 2.0
round(val)
Rounds to nearest integer.
float r = round(2.5); // 3.0
rint(val)
Rounds to nearest integer.
int r = rint(2.5);
clamp(val, min, max)
Clamps value between min and max.
float c = clamp(val, 0.0, 1.0);
fit(val, omin, omax, nmin, nmax)
Remaps value from one range to another.
float f = fit(@P.y, -1, 1, 0, 1);
fit01(val, nmin, nmax)
Remaps value from 0–1 to new range.
float f = fit01(val, -1, 1);
fit10(val, nmin, nmax)
Remaps value from 1–0 to new range.
float f = fit10(val, 0, 10);
fit11(val, nmin, nmax)
Remaps value from -1..1 to new range.
float f = fit11(val, 0, 1);
min(a, b)
Returns the minimum of two values.
float m = min(a, b);
max(a, b)
Returns the maximum of two values.
float m = max(a, b);
pow(base, exp)
Returns base raised to the power of exp.
float p = pow(2.0, 3.0); // 8.0
sqrt(val)
Returns the square root.
float s = sqrt(16.0); // 4.0
log(val)
Returns the natural logarithm.
float l = log(2.718); // ~1.0
exp(val)
Returns e raised to the power val.
float e = exp(1.0); // ~2.718
radians(degrees)
Converts degrees to radians.
float r = radians(180.0); // PI
degrees(radians)
Converts radians to degrees.
float d = degrees(M_PI); // 180.0
sin(angle)
Returns the sine of angle in radians.
float s = sin(M_PI / 2); // 1.0
cos(angle)
Returns the cosine of angle in radians.
float c = cos(0); // 1.0
tan(angle)
Returns the tangent of angle in radians.
float t = tan(M_PI / 4); // 1.0
asin(val)
Returns the arcsine in radians.
float a = asin(1.0); // PI/2
acos(val)
Returns the arccosine in radians.
float a = acos(0.0); // PI/2
atan(val)
Returns the arctangent in radians.
float a = atan(1.0); // PI/4
atan2(y, x)
Returns the two-argument arctangent.
float a = atan2(1.0, 1.0); // PI/4
Vector Functions
cross(a, b)
Returns the cross product of two vectors.
vector c = cross({1,0,0}, {0,1,0}); // {0,0,1}
dot(a, b)
Returns the dot product of two vectors.
float d = dot(@N, {0,1,0});
length(v)
Returns the magnitude of a vector.
float len = length(@P);
distance(a, b)
Returns the distance between two points.
float d = distance(@P, {0,0,0});
normalize(v)
Returns a unit vector in the same direction.
vector n = normalize(@P);
lerp(a, b, t)
Linearly interpolates between a and b.
vector mid = lerp(posA, posB, 0.5);
slerp(a, b, t)
Spherically interpolates between quaternions.
vector4 q = slerp(q1, q2, 0.5);
set(x, y, z)
Creates a vector from components.
vector v = set(1, 2, 3);
reflect(dir, normal)
Reflects direction vector around normal.
vector r = reflect(dir, @N);
refract(dir, normal, ior)
Refracts direction through surface.
vector r = refract(dir, @N, 1.5);
Noise Functions
noise(pos)
Returns Perlin noise at position.
float n = noise(@P * 5.0);
onoise(pos)
Returns original Perlin noise (range -1 to 1).
float n = onoise(@P * 3.0);
snoise(pos)
Returns simplex noise.
float n = snoise(@P * 4.0);
anoise(pos)
Returns anti-aliased noise.
float n = anoise(@P * 2.0);
curlnoise(pos)
Returns curl of 3D noise (divergence-free).
vector c = curlnoise(@P);
curlnoise2d(pos)
Returns 2D curl noise.
vector c = curlnoise2d(@P);
rand(seed)
Returns pseudo-random value 0–1.
float r = rand(@ptnum);
random(seed)
Returns random value (alternative to rand).
float r = random(@ptnum);
random_shash(string)
Returns random value from string hash.
float r = random_shash("seed_string");
String Functions
printf(format, ...)
Prints formatted string to console.
printf("Point %d: %g\n", @ptnum, @P.y);
sprintf(format, ...)
Returns a formatted string.
string s = sprintf("piece_%04d", @ptnum);
split(str, sep)
Splits string by separator.
string parts[] = split("a,b,c", ",");
join(arr, sep)
Joins string array with separator.
string s = join(parts, "_");
len(str_or_array)
Returns length of string or array.
int n = len("hello"); // 5
find(str, substr)
Finds first occurrence of substring.
int pos = find("hello", "ll");
replace(str, old, new)
Replaces all occurrences.
string s = replace("hello", "l", "r");
itoa(int_val)
Converts integer to string.
string s = itoa(42);
atoi(str)
Converts string to integer.
int n = atoi("42");
atof(str)
Converts string to float.
float f = atof("3.14");
startswith(str, prefix)
Checks if string starts with prefix.
if(startswith(s@name, "piece")) { ... }
endswith(str, suffix)
Checks if string ends with suffix.
if(endswith(s@name, ".bgeo")) { ... }
match(pattern, str)
Wildcard pattern matching.
if(match("piece_*", s@name)) { ... }
Matrix Functions
ident()
Returns an identity matrix.
matrix3 m = ident();
invert(m)
Returns the inverse of a matrix.
matrix mi = invert(m);
transpose(m)
Returns the transpose of a matrix.
matrix mt = transpose(m);
determinant(m)
Returns the determinant of a matrix.
float d = determinant(m);
maketransform(tx_order, rot_order, t, r, s)
Creates a transform matrix.
matrix m = maketransform(0, 0, {0,1,0}, {0,45,0}, {1,1,1});
cracktransform(tx_order, rot_order, component, pivot, m)
Extracts component from matrix.
vector t = cracktransform(0, 0, 0, {0,0,0}, m);
optransform(objpath)
Returns the world transform of an object.
matrix m = optransform("/obj/geo1");
rotate(m, angle, axis)
Rotates a matrix around an axis.
rotate(m, radians(45), {0,1,0});
scale(m, s)
Scales a matrix.
scale(m, {2,2,2});
translate(m, t)
Translates a matrix.
translate(m, {1,0,0});
Point Cloud Functions
pcopen(geohandle, channel, pos, radius, maxpts)
Opens a point cloud for iteration.
int handle = pcopen(0, "P", @P, 1.0, 10);
pcfind(geohandle, channel, pos, radius, maxpts)
Finds nearby points, returns array.
int pts[] = pcfind(0, "P", @P, 0.5, 20);
pcfind_radius(geohandle, Pchannel, radchannel, pos, radius, maxpts)
Finds points with per-point radii.
int pts[] = pcfind_radius(0, "P", "pscale", @P, 1.0, 10);
pciterate(handle)
Advances to next point in cloud.
while(pciterate(handle)) { pcimport(...); }
pcimport(handle, attribname, value)
Imports attribute from current cloud point.
pcimport(handle, "P", pos);
pcclose(handle)
Closes a point cloud handle.
pcclose(handle);
nearpoint(geohandle, pos)
Finds the closest point.
int pt = nearpoint(0, @P);
nearpoints(geohandle, pos, maxdist, maxpts)
Finds nearby points sorted by distance.
int pts[] = nearpoints(0, @P, 0.5, 10);
Group Functions
setpointgroup(geohandle, name, ptnum, value, mode)
Adds/removes point from group.
setpointgroup(0, "selected", @ptnum, 1, "set");
setprimgroup(geohandle, name, primnum, value, mode)
Adds/removes prim from group.
setprimgroup(0, "top", @primnum, 1, "set");
setvertexgroup(geohandle, name, primnum, vtxnum, value, mode)
Adds/removes vertex from group.
setvertexgroup(0, "border", @primnum, 0, 1, "set");
inpointgroup(geohandle, name, ptnum)
Checks if point is in group.
if(inpointgroup(0, "selected", @ptnum)) { ... }
inprimgroup(geohandle, name, primnum)
Checks if prim is in group.
if(inprimgroup(0, "top", @primnum)) { ... }
expandpointgroup(geohandle, name)
Returns all point numbers in group.
int pts[] = expandpointgroup(0, "selected");
expandprimgroup(geohandle, name)
Returns all prim numbers in group.
int prs[] = expandprimgroup(0, "top");
npointsgroup(geohandle, name)
Returns number of points in group.
int n = npointsgroup(0, "selected");
nprimitivesgroup(geohandle, name)
Returns number of prims in group.
int n = nprimitivesgroup(0, "top");
Channel / UI Functions
ch(name)
Reads a float channel parameter.
float val = ch("scale");
chf(name)
Reads a float channel (explicit).
float f = chf("amplitude");
chi(name)
Reads an integer channel.
int i = chi("divisions");
chs(name)
Reads a string channel.
string s = chs("filepath");
chv(name)
Reads a vector channel.
vector v = chv("offset");
chramp(name, pos)
Evaluates a ramp parameter at position.
float r = chramp("falloff", @curveu);
Geometry Query Functions
getbbox(geohandle, min, max)
Gets bounding box min and max.
vector mn, mx; getbbox(0, mn, mx);
getbbox_min(geohandle)
Returns bounding box minimum corner.
vector mn = getbbox_min(0);
getbbox_max(geohandle)
Returns bounding box maximum corner.
vector mx = getbbox_max(0);
getpointbbox(geohandle, min, max)
Gets point bounding box.
vector mn, mx; getpointbbox(0, mn, mx);
relpointbbox(geohandle, pos)
Returns normalized position within bounding box (0–1).
vector rel = relpointbbox(0, @P);
xyzdist(geohandle, pos, primnum, primuv)
Finds closest distance to geometry surface.
float d = xyzdist(1, @P, prim, uv);
primuv(geohandle, attrib, primnum, uv)
Interpolates attribute at parametric UV on prim.
vector p = primuv(1, "P", prim, uv);
surfacedist(geohandle, startgroup, attrib, ...)
Computes geodesic distance along surface.
float d = surfacedist(0, "startpts", "dist", "edge");
intersect(geohandle, rayorig, raydir, pos, uvw)
Casts a ray and finds intersection.
int hit = intersect(0, orig, dir, hitpos, hituvw);
sample_hemisphere(u1, u2, normal)
Samples a direction on a hemisphere.
vector dir = sample_hemisphere(rand(@ptnum), rand(@ptnum+1), @N);
Quaternion Functions
quaternion(angle, axis)
Creates quaternion from angle/axis.
vector4 q = quaternion(radians(90), {0,1,0});
qrotate(quat, vec)
Rotates vector by quaternion.
vector r = qrotate(q, {1,0,0});
qmultiply(q1, q2)
Multiplies two quaternions.
vector4 q = qmultiply(q1, q2);
qinvert(q)
Returns the inverse quaternion.
vector4 qi = qinvert(q);
eulertoquaternion(angles, order)
Converts euler angles to quaternion.
vector4 q = eulertoquaternion({0,45,0}, 0);
quaterniontoeuler(q, order)
Converts quaternion to euler angles.
vector e = quaterniontoeuler(q, 0);
slerp(q1, q2, bias)
Spherical interpolation between quaternions.
vector4 q = slerp(q1, q2, 0.5);