View Single Post
# 6 09-10-2015 , 06:11 PM
EduSciVis-er
Join Date: Dec 2005
Location: Toronto
Posts: 3,374
I've made some progress on this. I've written an expression that gets the positions of the two cvs and controls the rotation of the nurbs circle.

Code:
//get world space positions of the CVs
vector $pos1 = `xform -q -t -ws curve1.cv[0]`;
vector $pos2 = `xform -q -t -ws curve1.cv[1]`;
vector $newVec = $pos2 - $pos1;

//calculate rotation
$rotation = `angleBetween -euler -v1 0.0 1.0 0.0 -v2 ($newVec.x) ($newVec.y) ($newVec.z)`;

//set rotation of nurbs circle
nurbsCircle1.rotateX = $rotation[0];
nurbsCircle1.rotateY = $rotation[1];
nurbsCircle1.rotateZ = $rotation[2];
It seems to work okay, aside from a weird error
Code:
Error: line 1: No object matches name: curve1.cv[0]
It's weird because the expression works. If I put a cluster deformer on the CV and animate its position, the nurbs circle will rotate. So far this only works with the circle lying flat (facing the y axis). I'm sure it could be made more robust. Now to see if it keeps the normals facing the right way!


-stwert

Website - Blog - YouTube - Vimeo - Facebook - Twitter

-->How to Effectively Ask Questions on Forums<--