fill_animators.py
1 from DreamTalk.animation.abstract_animators import ProtoAnimator 2 from DreamTalk.xpresso.userdata import * 3 from DreamTalk.constants import WHITE 4 import c4d 5 6 7 class Fill(ProtoAnimator): 8 9 def __init__(self, *objs, filling=1, **kwargs): 10 self.set_values(filling) 11 return super().__init__(self, *objs, category="constructive", **kwargs) 12 13 def specify_desc_ids(self): 14 self.desc_ids = { 15 "fill_transparency": c4d.DescID(c4d.DescLevel(c4d.MATERIAL_TRANSPARENCY_BRIGHTNESS, c4d.DTYPE_REAL, 0)) 16 } 17 18 def set_values(self, filling): 19 self.values = [filling] 20 21 def specify_xpression(self): 22 self.parameter_name = "FillTransparency" 23 self.interpolate = True 24 self.reverse_parameter_range = True 25 26 27 class UnFill(Fill): 28 29 def __init__(self, *objs, filling=0, **kwargs): 30 self.set_values(filling) 31 return super(Fill, self).__init__(self, *objs, category="destructive", **kwargs) 32 33 34 class Pulse(Fill): 35 36 def __init__(self, *objs, n=1, filling_lower=0, filling_upper=1, **kwargs): 37 self.set_values(n, filling_lower, filling_upper) 38 return super(Fill, self).__init__(self, *objs, category=None, **kwargs) 39 40 def set_values(self, n, filling_lower, filling_upper): 41 self.values = [n, filling_lower, filling_upper] 42 43 def specify_xpression(self): 44 self.parameter_name = "FillTransparency" 45 self.udatas = [(UCount, "n"), (UStrength, "filling_lower"), 46 (UStrength, "filling_upper")] 47 self.formula = "filling_lower + sin(n*Pi*t) * sin(n*Pi*t) * (filling_upper - filling_lower)" 48 self.reverse_parameter_range = True 49 50 51 class ChangeFillColorR(ProtoAnimator): 52 53 def __init__(self, *objs, color_r=1, **kwargs): 54 self.set_values(color_r) 55 return super().__init__(self, *objs, **kwargs) 56 57 def specify_desc_ids(self): 58 self.desc_ids = { 59 "filler_color_r": c4d.DescID(c4d.DescLevel(c4d.MATERIAL_LUMINANCE_COLOR, c4d.DTYPE_COLOR, 0), 60 c4d.DescLevel(c4d.COLOR_R, c4d.DTYPE_REAL, 0)) 61 } 62 63 def set_values(self, color_r): 64 self.values = [color_r] 65 66 def specify_xpression(self): 67 self.parameter_name = "FillColorR" 68 self.interpolate = True 69 70 71 class ChangeFillColorG(ProtoAnimator): 72 73 def __init__(self, *objs, color_g=1, **kwargs): 74 self.set_values(color_g) 75 return super().__init__(self, *objs, **kwargs) 76 77 def specify_desc_ids(self): 78 self.desc_ids = { 79 "filler_color_g": c4d.DescID(c4d.DescLevel(c4d.MATERIAL_LUMINANCE_COLOR, c4d.DTYPE_COLOR, 0), 80 c4d.DescLevel(c4d.COLOR_G, c4d.DTYPE_REAL, 0)) 81 } 82 83 def set_values(self, color_g): 84 self.values = [color_g] 85 86 def specify_xpression(self): 87 self.parameter_name = "FillColorG" 88 self.interpolate = True 89 90 91 class ChangeFillColorB(ProtoAnimator): 92 93 def __init__(self, *objs, color_b=1, **kwargs): 94 self.set_values(color_b) 95 return super().__init__(self, *objs, **kwargs) 96 97 def specify_desc_ids(self): 98 self.desc_ids = { 99 "filler_color_b": c4d.DescID(c4d.DescLevel(c4d.MATERIAL_LUMINANCE_COLOR, c4d.DTYPE_COLOR, 0), 100 c4d.DescLevel(c4d.COLOR_B, c4d.DTYPE_REAL, 0)) 101 } 102 103 def set_values(self, color_b): 104 self.values = [color_b] 105 106 def specify_xpression(self): 107 self.parameter_name = "FillColorB" 108 self.interpolate = True