Would anyone care to share some code or a link to create a vector compass.
I would like to plug the result into field directions - say to control the animated direction of gravity or wind.
Would anyone care to share some code or a link to create a vector compass.
I would like to plug the result into field directions - say to control the animated direction of gravity or wind.
Do you mean one created with a curve set? If you have SOuP there is one in the tools menu down the bottom.

no need for curves, just need to plug values into the gravity direction on the nucleus or field. Don’t have soup either - cheers for the reply though.
Its a visual representation of direction that can be key framed if required where the outDirection values are piped into the field direction values. Pretty handy really.
Here you go !
I used to use it a lot in making rigs for fx.
It doesnt update in the viewport …you might have to play a frame or two to see the output result in the atttr.
// Arrow Compass
string $windArrow = curve -n "wind_direction_01" -d 1 -p -3 0 -1 -p -3 0 0 -p -3 0 1 -p 0 0 1 -p 0 0 2 -p 2 0 0 -p 0 0 -2 -p 0 0 -1 -p -3 0 -1 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 6 -k 7 -k 8;
setAttr ($windArrow+".rotateX") 90;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1 $windArrow;
addAttr -ln “windDirection” -at double3 $windArrow;
addAttr -ln “windDirectionX” -at double -p windDirection $windArrow;
addAttr -ln “windDirectionY” -at double -p windDirection $windArrow;
addAttr -ln “windDirectionZ” -at double -p windDirection $windArrow;
setAttr -e -keyable true ($windArrow + “.windDirectionX”);
setAttr -e -keyable true ($windArrow + “.windDirectionY”);
setAttr -e -keyable true ($windArrow + “.windDirectionZ”);
addAttr -ln “windMag” -nn “Wind Magnitude” -at double -dv 0 $windArrow;
setAttr -e-keyable true ($windArrow+".windMag");
string $windEx =("string $point1 =\"" + $windArrow + ".cv[1]\";
");
$windEx += ("string $point2 = “” + $windArrow + “.cv[5]”;
");
$windEx += ("vector $pointPos1 =pointPosition -w $point1;
");
$windEx += ("vector $pointPos2 =pointPosition -w $point2;
");
$windEx += ("vector $direction = unit($pointPos2-$pointPos1);
");
$windEx += ("windDirectionX = $direction.x;
");
$windEx += ("windDirectionY = $direction.y;
");
$windEx += ("windDirectionZ = $direction.z;
");
expression -s $windEx -o $windArrow;