def __assignToLamp(self, lampObj, action_name=None): mmdLampInstance = MMDLamp.convertToMMDLamp(lampObj, self.__scale) mmdLamp = mmdLampInstance.object() lampObj = mmdLampInstance.lamp() lampAnim = self.__vmdFile.lampAnimation logging.info('(lamp) frames:%5d name: %s', len(lampAnim), mmdLamp.name) if len(lampAnim) < 1: return action_name = action_name or mmdLamp.name color_action = bpy.data.actions.new(name=action_name + '_color') location_action = bpy.data.actions.new(name=action_name + '_loc') lampObj.data.animation_data_create().action = color_action lampObj.animation_data_create().action = location_action for keyFrame in lampAnim: frame = keyFrame.frame_number + self.__frame_margin lampObj.data.color = mathutils.Vector(keyFrame.color) lampObj.location = mathutils.Vector(keyFrame.direction).xzy * -1 lampObj.data.keyframe_insert(data_path='color', frame=frame) lampObj.keyframe_insert(data_path='location', frame=frame) for fcurve in lampObj.animation_data.action.fcurves: self.detectLampChange(fcurve)
def execute(self, context): MMDLamp.convertToMMDLamp(context.active_object, self.scale) return {'FINISHED'}