woodsman
1/3/2020 - 8:30 PM

Set Orient Attribute

Creates a quaternion attribute named 'orient' by making a matrix transformation of @N and a vector attribute '@up'. Used to determine instanced geometry's orientation as it moves.

// Set orient attribute
// More info on quaternions @ http://www.toadstorm.com/blog/?p=493
v@up = chv("up_vector"); // set this to {0,1,0}
 
// Create a 3x3 orientation matrix using N and up as the principal axes
matrix3 m = maketransform(@N, v@up);
 
// Make the orient quaternion from this matrix (the copy SOP reads this automatically)
p@orient = quaternion(m);