GenerateOffCurve

From scripting
Jump to: navigation, search
global proc string GenerateOffCurve(vector $Pt1, vector $Pt2, float $OffDist, string $NameStr) {
	vector $MidVec = OffMidVector($Pt1, $Pt2, $OffDist);
	vector $M1 = OffMidVector($MidVec, $Pt1, 0.01);
	vector $M2 = OffMidVector($MidVec, $Pt2, 0.01);
	string $Curv = `curve -d 3 -p ($Pt1.x) ($Pt1.y) ($Pt1.z) -p ($M1.x) ($M1.y) ($M1.z) -p ($MidVec.x) ($MidVec.y) ($MidVec.z) -p ($M2.x) ($M2.y) ($M2.z) -p ($Pt2.x) ($Pt2.y) ($Pt2.z) -k 0 -k 0 -k 0 -k 1 -k 2 -k 2 -k 2 -n ($NameStr)`;
	
	return $Curv;
}


Old Versions...

global proc string GenerateOffCurve(vector $Pt1, vector $Pt2, float $OffDist) { 
	vector $MidVec = OffMidVector($Pt1, $Pt2, $OffDist);
	vector $M1 = OffMidVector($MidVec, $Pt1, 0.01);
	vector $M2 = OffMidVector($MidVec, $Pt2, 0.01);
	string $Curv[] = `curve -d 3 -p ($Pt1.x) ($Pt1.y) ($Pt1.z) -p ($M1.x) ($M1.y) ($M1.z) -p ($MidVec.x) ($MidVec.y) ($MidVec.z) -p ($M2.x) ($M2.y) ($M2.z) -p ($Pt2.x) ($Pt2.y) ($Pt2.z) -k 0 -k 0 -k 0 -k 1 -k 2 -k 2 -k 2 `;
	
	return $Curv[0];
}


More information on vectors and vector mathematics, read pages 14-16, 20-21 in YSYT.