I need to skin a bezier curve…basically the same as the new taper curve feature only I’ll be doing more advanced stuff with it later. I’m using RipSting’s bezier4 function to get the positions along the curve, but what I need is to rotate the vertex loops according to the angle of the current position on the curve. Any ideas? Here’s the blend file. The updateMatrix() function is what I’m using to do the math and it’s called for each vertex ring of the tube the script is creating. The rotations are incorrect for some reason. I don’t know if the angle is the problem or the rotation axis. Here’s updateMatrix():
##########Creates/Modifies segment transformation/rotation matrix
def updateMatrix(self,h,curveRes,matrixList,prevVec):
z = h * (1.0/curveRes) #location for current segment (percentage)
curLoc = Bezier4(self.pl[0][1],self.pl[0][2],self.pl[1][0],self.pl[1][1],z)
#get location along the current bezier curve
curLoc = Vector(curLoc) #change that location to a vector
vecLoc = curLoc - prevVec[0] #subtract last segment location from current location
vecTrans = Vector([0.0,0.0,vecLoc.length]) #create translation vector
if (h == 0): #create previous vector from first curve handle
vecLoc = Vector([0.0,0.0,1.0])
prevVec[1] = Vector(self.pl[0][2])
#prevVec[1].negate()
curveAngle = AngleBetweenVecs(vecLoc, prevVec[1]) #get angle between segments
if (h > 0):
curveAngle = curveAngle * -1
vecRot = CrossVecs(vecLoc, prevVec[1]) #get vector for rotation axis
matrixTrans = TranslationMatrix(vecTrans) #create translation matrix
matrixRot = RotationMatrix(curveAngle, 4, 'r', vecRot) #create rotation matrix
matrixList[1] = matrixRot * matrixTrans * matrixList[1] #multiply rot, trans, and previous matrix
prevVec[0] = curLoc
if (h > 0):
prevVec[1] = vecLoc
return matrixList
thanks in advance,
bydesign