Primitive Maya CV Curves
From Animation
Jump to navigationJump to search
Shapes
Circle with pointer
// ==========================================
// Pointer Sphere Curve Tool (MEL)
// ==========================================
global proc createPointerSphereCurve(float $radius, float $length)
{
int $segments = 12;
float $angleStep = 360.0 / $segments;
string $cmd = "curve -d 1";
// Pointer tip at origin
$cmd += " -p 0 0 0";
// Tail connection
$cmd += (" -p 0 0 -" + $length);
// Sphere loop (YZ plane)
for ($i = 0; $i <= $segments; $i++)
{
float $angle = deg_to_rad($i * $angleStep);
float $y = sin($angle) * $radius;
float $z = cos($angle) * $radius - $length;
$cmd += (" -p 0 " + $y + " " + $z);
}
// Create curve
string $curve = `eval $cmd`;
rename $curve "pointerSphere_CRV";
// Pivot at origin
xform -ws -piv 0 0 0;
// Freeze transforms
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
}
// ==========================================
// UI
// ==========================================
global proc pointerSphereUI()
{
if (`window -exists pointerSphereWin`)
deleteUI pointerSphereWin;
window -title "Pointer Sphere Curve" -widthHeight 260 120 pointerSphereWin;
columnLayout -adj true -rowSpacing 6;
floatFieldGrp -label "Radius" -numberOfFields 1 -value1 1.0 radiusField;
floatFieldGrp -label "Length" -numberOfFields 1 -value1 3.0 lengthField;
separator -h 10;
button
-label "Create Curve"
-height 30
-command "float $r = `floatFieldGrp -q -value1 radiusField`; float $l = `floatFieldGrp -q -value1 lengthField`; createPointerSphereCurve($r, $l);";
showWindow pointerSphereWin;
}
// ==========================================
// Launch
// ==========================================
pointerSphereUI();
Sunburst with popup
// ==========================================
// Sunburst CV Curve Tool (MEL)
// ==========================================
global proc createSunburstCurve_UI(float $radius, int $spikes, float $burstOffset, string $plane)
{
if ($spikes < 3)
$spikes = 3;
float $angleStep = 360.0 / ($spikes * 2);
string $cmd = "curve -d 1";
for ($i = 0; $i <= ($spikes * 2); $i++)
{
float $angle = deg_to_rad($i * $angleStep);
float $currentRadius = ($i % 2 == 0) ? $radius : ($radius + $burstOffset);
float $a = sin($angle) * $currentRadius;
float $b = cos($angle) * $currentRadius;
// Plane selection
if ($plane == "X")
$cmd += (" -p 0 " + $a + " " + $b);
else if ($plane == "Y")
$cmd += (" -p " + $a + " 0 " + $b);
else
$cmd += (" -p " + $a + " " + $b + " 0");
}
string $curve = `eval $cmd`;
rename $curve "sunburst_CRV";
xform -ws -piv 0 0 0;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
}
// ==========================================
// UI
// ==========================================
global proc sunburstUI()
{
if (`window -exists sunburstWin`)
deleteUI sunburstWin;
window -title "Sunburst Curve" -widthHeight 280 200 sunburstWin;
columnLayout -adj true -rowSpacing 6;
floatFieldGrp -label "Circle Radius" -numberOfFields 1 -value1 2.0 radiusField;
intFieldGrp -label "Number of Spikes" -numberOfFields 1 -value1 12 spikesField;
floatFieldGrp -label "Burst Offset (+/-)" -numberOfFields 1 -value1 1.0 offsetField;
optionMenuGrp -label "Plane" planeMenu;
menuItem -label "X";
menuItem -label "Y";
menuItem -label "Z";
separator -h 10;
button
-label "Create Sunburst"
-height 30
-command "float $r = `floatFieldGrp -q -value1 radiusField`; int $s = `intFieldGrp -q -value1 spikesField`; float $o = `floatFieldGrp -q -value1 offsetField`; string $p = `optionMenuGrp -q -value planeMenu`; createSunburstCurve_UI($r, $s, $o, $p);";
showWindow sunburstWin;
}
// ==========================================
// Launch
// ==========================================
sunburstUI();
Forms
Hedron
curve -d 1 -p 0 0 -0.707107 -p 0.707107 0 0 -p 0 0 0.707107 -p -0.707107 0 0 -p 0 0 -0.707107 -p 0 1 0 -p 0 0 0.707107 -p 0 -1 0 -p 0 0 -0.707107 -p -0.707107 0 0 -p 0 1 0 -p 0.707107 0 0 -p 0 -1 0 -p -0.707107 0 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 ;
Hedron with pointer
curve -d 1 -p 0 0 0 -p 0 0 2.292893 -p 0.707107 0 3 -p 0 0 3.707107 -p -0.707107 0 3 -p 0 0 2.292893 -p 0 1 3 -p 0 0 3.707107 -p 0 -1 3 -p 0 0 2.292893 -p -0.707107 0 3 -p 0 1 3 -p 0.707107 0 3 -p 0 -1 3 -p -0.707107 0 3 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 ;
Sphere
curve -d 1 -p 0 1 0 -p 0 0.866025 -0.5 -p 0 0.5 -0.866025 -p 0 0 -1 -p 0 -0.5 -0.866025 -p 0 -0.866025 -0.5 -p 0 -1 0 -p 0 -0.866025 0.5 -p 0 -0.5 0.866025 -p 0 0 1 -p 0 0.5 0.866025 -p 0 0.866025 0.5 -p 0 1 0 -p -0.5 0.866025 0 -p -0.866025 0.5 0 -p -1 0 0 -p -0.866025 -0.5 0 -p -0.5 -0.866025 0 -p 0 -1 0 -p 0.5 -0.866025 0 -p 0.866025 -0.5 0 -p 1 0 0 -p 0.866025 0.5 0 -p 0.5 0.866025 0 -p 0 1 0 -p 0 0.866025 0.5 -p 0 0.5 0.866025 -p 0 0 1 -p 0.5 0 0.866025 -p 0.866025 0 0.5 -p 1 0 0 -p 0.866025 0 -0.5 -p 0.5 0 -0.866025 -p 0 0 -1 -p -0.5 0 -0.866025 -p -0.866025 0 -0.5 -p -1 0 0 -p -0.866025 0 0.5 -p -0.5 0 0.866025 -p 0 0 1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 ;
Sphere with pointer
curve -d 1 -p 0 0 0 -p 0 0 -2 -p -0.5 0 -2.133975 -p -0.866025 0 -2.5 -p -1 0 -3 -p -0.866025 0 -3.5 -p -0.5 0 -3.866025 -p 0 0 -4 -p 0.5 0 -3.866025 -p 0.866025 0 -3.5 -p 1 0 -3 -p 0.866025 0 -2.5 -p 0.5 0 -2.133975 -p 0 0 -2 -p 0 0.5 -2.133975 -p 0 0.866025 -2.5 -p 0 1 -3 -p 0 0.866025 -3.5 -p 0 0.5 -3.866025 -p 0 0 -4 -p 0 -0.5 -3.866025 -p 0 -0.866025 -3.5 -p 0 -1 -3 -p 0 -0.866025 -2.5 -p 0 -0.5 -2.133975 -p 0 0 -2 -p 0 0.5 -2.133975 -p 0 0.866025 -2.5 -p 0 1 -3 -p 0.5 0.866025 -3 -p 0.866025 0.5 -3 -p 1 0 -3 -p 0.866025 -0.5 -3 -p 0.5 -0.866025 -3 -p 0 -1 -3 -p -0.5 -0.866025 -3 -p -0.866025 -0.5 -3 -p -1 0 -3 -p -0.866025 0.5 -3 -p -0.5 0.866025 -3 -p 0 1 -3 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8 -k 9 -k 10 -k 11 -k 12 -k 13 -k 14 -k 15 -k 16 -k 17 -k 18 -k 19 -k 20 -k 21 -k 22 -k 23 -k 24 -k 25 -k 26 -k 27 -k 28 -k 29 -k 30 -k 31 -k 32 -k 33 -k 34 -k 35 -k 36 -k 37 -k 38 -k 39 -k 40 ;
Sphere with pointer Popup
// ==========================================
// Pointer + Sphere CV Control (MEL)
// ==========================================
global proc createPointerSphereCurve(float $radius, float $length)
{
int $seg = 12;
float $step = 360.0 / $seg;
string $cmd = "curve -d 1";
// --------------------------
// Pointer tip
// --------------------------
$cmd += " -p 0 0 0";
$cmd += (" -p 0 0 -" + $length);
// --------------------------
// Equator ring (XZ plane)
// --------------------------
for ($i = 0; $i <= $seg; $i++)
{
float $a = deg_to_rad($i * $step);
float $x = cos($a) * $radius;
float $z = sin($a) * $radius - $length;
$cmd += (" -p " + $x + " 0 " + $z);
}
// --------------------------
// Longitude arcs (4 directions)
// --------------------------
float $dirs[4] = {0, 90, 180, 270};
for ($d in $dirs)
{
for ($i = 0; $i <= $seg/2; $i++)
{
float $a = deg_to_rad(-90 + ($i * (180.0 / ($seg/2))));
float $y = sin($a) * $radius;
float $r = cos($a) * $radius;
float $x = cos(deg_to_rad($d)) * $r;
float $z = sin(deg_to_rad($d)) * $r - $length;
$cmd += (" -p " + $x + " " + $y + " " + $z);
}
}
// --------------------------
// Hemisphere arc (YZ plane)
// --------------------------
for ($i = 0; $i <= $seg/2; $i++)
{
float $a = deg_to_rad($i * (180.0 / ($seg/2)));
float $y = cos($a) * $radius;
float $z = sin($a) * $radius - $length;
$cmd += (" -p 0 " + $y + " " + $z);
}
// Create curve
string $crv = `eval $cmd`;
rename $crv "pointerSphere_CRV";
// Pivot at origin
xform -ws -piv 0 0 0;
// Freeze
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
}
// ==========================================
// UI
// ==========================================
global proc pointerSphereUI()
{
if (`window -exists pointerSphereWin`)
deleteUI pointerSphereWin;
window -title "Pointer Sphere Curve" -widthHeight 260 120 pointerSphereWin;
columnLayout -adj true -rowSpacing 6;
floatFieldGrp -label "Radius" -numberOfFields 1 -value1 1.0 radiusField;
floatFieldGrp -label "Length" -numberOfFields 1 -value1 3.0 lengthField;
separator -h 10;
button
-label "Create Curve"
-height 30
-command "float $r = `floatFieldGrp -q -value1 radiusField`; float $l = `floatFieldGrp -q -value1 lengthField`; createPointerSphereCurve($r, $l);";
showWindow pointerSphereWin;
}
// ==========================================
// Launch
// ==========================================
pointerSphereUI();