Note
These interface classes are not intended for direct usage; rather they should be inherited by your own subclass. (See Anatomy of a LightWave Python Plug-in)
Bases: lwsdk.lwsdk.IHandlerFuncs, lwsdk.lwsdk.IInterfaceFuncs, lwsdk.lwsdk.IGizmoFuncs, lwsdk.lwsdk.IItemFuncs
Proxy of C++ PCore::IItemMotion class
This is where the motion handler does its work. LightWave calls the evaluation function at every point in the animation at which an item's motion parameters need to be calculated. The LWItemMotionAccess
instance (described below) tells you the item being animated and the frame and time of the evaluation, and provides functions to set motion parameters for the current time and to get the item's motion parameters for any time.
Returns an integer containing flags combined using bitwise-or. Currently the only flag is lwsdk.LWIMF_AFTERIK
, which specifies that the plug-in will be evaluated after LightWave has performed the inverse kinematics calculations for the item.
Bases: object
Proxy of C++ PCore::LWItemMotionAccess class
The animation pass for which the motion should be evaluated. It holds one of the following values:
lwsdk.LWANIMPASS_MAIN
lwsdk.LWANIMPASS_PRELIMINARY
lwsdk.LWANIMPASS_BLUR
lwsdk.LWANIMPASS_RESTORE
lwsdk.LWANIMPASS_DYNAMICS
The frame number at which the motion should be evaluated.
Returns a motion parameter for the item at any given time. Only one of lwsdk.LWIP_POSITION
, lwsdk.LWIP_ROTATION
or lwsdk.LWIP_SCALING
may supplied as arg1
.
The ID for the item to be affected by the procedural motion.
Used by the evaluation function to set the computed motion of the item at the current time. Only one of lwsdk.LWIP_POSITION
, lwsdk.LWIP_ROTATION
or lwsdk.LWIP_SCALING
may be supplied as arg1
.
The animation time for which the motion should be evaluated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | class sol(lwsdk.IItemMotion):
def __init__(self, context):
super(sol, self).__init__()
self._itemid = context
self._name = lwsdk.LWItemInfo().name(self._itemid)
# pre-calculate some values for performance
self._r = planet_au[self._name] * AU;
self._s = (planet_r[self._name] * math.pow(10, 3)) / AU;
self._b = planet_tilt[self._name];
[...]
# LWItemMotion ----------------------------------------
def evaluate(self, ma):
a = ((ma.time * self._scale) / self._p) * (2 * math.pi)
x = (self._r / AU) * math.cos(a)
z = (self._r / AU) * math.sin(a)
ma.setParam(lwsdk.LWIP_POSITION, [x, 0.0, z])
ma.setParam(lwsdk.LWIP_SCALING, [self._s] * 3)
ma.setParam(lwsdk.LWIP_ROTATION, [0.0, 0.0, self._b])
[...]
ServerRecord = { lwsdk.ItemMotionFactory("LW_PySol", sol) : ServerTagInfo }
|