In an object that has a parent-child relationship It can be used when the child object moves when the parent object rotates.
Execution environment: Motionbuilder 2015
I made a process to draw a sphere with Null in MB.
The main processing is only the contents of getPosition ()
.
FB ○○
is for MB only.
Please change to the one that suits the software and language you want to use.# -*- coding: utf-8 -*-
from pyfbsdk import *
import math
#Method to find coordinates from two angles and distance
def getPosition(_angle1, _angle2, _radius):
x = _radius * math.sin(math.radians(_angle1)) * math.cos(math.radians(_angle2));
y = _radius * math.sin(math.radians(_angle1)) * math.sin(math.radians(_angle2));
z = _radius * math.cos(math.radians(_angle1));
return FBVector3d(x, y, z);
#If you change this for software for the software you want to use, it will draw a sphere.
## angle1,You can also draw a semicircle by adjusting the value that goes into angle2
##Note that executing step of the third argument of range with 1 (or not specified) is heavy.
parentPos = FBVector3d(50, 50, 50)
for angle1 in range(0, 360, 3):
for angle2 in range(0, 180, 3):
mdlNull = FBModelNull("Null_{0}_{1}".format(str(angle1), str(angle2)))
mdlNull.Show = True
mdlNull.Scaling = FBVector3d(1, 1, 1)
mdlNull.Translation = parentPos + getPosition(angle1, angle2, 100.0)
When you run it, you will get something like this. (This made the step of range () in 1!)
Recommended Posts