def add_roll(duration=12.0,loop=1,axis='y',start=0,_self=cmd): cmd = _self if not start: start = cmd.get_movie_length()+1 duration = float(duration) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d"%n_frame,start,freeze=1) cmd.mview("store",start,power=1,freeze=1) cmd.turn(axis,120) cmd.mview("store",start+n_frame/3,power=1,freeze=1) cmd.turn(axis,120) cmd.mview("store",start+(2*n_frame)/3,power=1,freeze=1) if loop: if (start == 1): cmd.mview("interpolate",wrap=1) cmd.turn(axis,120) cmd.mview("store",start+n_frame-1,power=1,freeze=1) cmd.turn(axis,120) else: adjustment = 360.0/n_frame cmd.turn(axis,120 - adjustment) cmd.mview("store",start+n_frame-1,power=1,freeze=1) cmd.mview("interpolate") cmd.turn(axis,adjustment) else: cmd.turn(axis,120) cmd.mview("store",start+n_frame-1,power=1,freeze=1) cmd.mview("interpolate") cmd.frame(start)
def add_state_loop(factor=1, pause=2.0, first=-1, last=-1, loop=1, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 loop = int(loop) fps = float(cmd.get('movie_fps')) n_state = cmd.count_states() duration = (pause) + (factor * n_state) / fps n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d" % n_frame, start, freeze=1) cmd.mview("store", start, state=1, freeze=1) cmd.mview("store", start + (n_frame * pause * 0.5) / duration, state=1, freeze=1) cmd.mview("store", start + n_state * factor + (n_frame * pause * 0.5) / duration, state=n_state, freeze=1) cmd.mview("store", start + n_frame - 1, state=n_state, freeze=1) if loop and (start == 1): cmd.mview("interpolate", wrap=1) else: cmd.mview("interpolate") cmd.frame(start)
def add_roll(duration=12.0, loop=1, axis='y', start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 duration = float(duration) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d" % n_frame, start, freeze=1) cmd.mview("store", start, power=1, freeze=1) cmd.turn(axis, 120) cmd.mview("store", start + n_frame / 3, power=1, freeze=1) cmd.turn(axis, 120) cmd.mview("store", start + (2 * n_frame) / 3, power=1, freeze=1) if loop: if (start == 1): cmd.mview("interpolate", wrap=1) cmd.turn(axis, 120) cmd.mview("store", start + n_frame - 1, power=1, freeze=1) cmd.turn(axis, 120) else: adjustment = 360.0 / n_frame cmd.turn(axis, 120 - adjustment) cmd.mview("store", start + n_frame - 1, power=1, freeze=1) cmd.mview("interpolate") cmd.turn(axis, adjustment) else: cmd.turn(axis, 120) cmd.mview("store", start + n_frame - 1, power=1, freeze=1) cmd.mview("interpolate") cmd.frame(start)
def add_blank(duration=12.0, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 duration = float(duration) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d" % n_frame, start) cmd.frame(start)
def add_blank(duration=12.0,start=0,_self=cmd): cmd = _self if not start: start = cmd.get_movie_length()+1 duration = float(duration) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d"%n_frame,start) cmd.frame(start)
def add_rock(duration=8.0, angle=30.0, loop=1, axis='y', start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 duration = float(duration) angle = float(angle) loop = int(loop) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d" % n_frame, start, freeze=1) cmd.turn(axis, angle / 2.0) cmd.mview("store", start + n_frame / 4, power=-1, freeze=1) cmd.turn(axis, -angle) cmd.mview("store", start + (3 * n_frame) / 4, power=-1, freeze=1) if loop and (start == 1): cmd.mview("interpolate", wrap=1) else: cmd.mview("interpolate") cmd.frame(start)
def add_state_loop(factor=1,pause=2.0,first=-1,last=-1,loop=1,start=0,_self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 loop = int(loop) fps = float(cmd.get('movie_fps')) n_state = cmd.count_states() duration = (pause) + (factor * n_state) / fps n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d"%n_frame, start, freeze=1) cmd.mview("store",start, state=1, freeze=1) cmd.mview("store",start + (n_frame * pause * 0.5) / duration, state=1, freeze=1) cmd.mview("store",start + n_state * factor + (n_frame * pause * 0.5) / duration, state=n_state, freeze=1) cmd.mview("store",start + n_frame-1, state=n_state, freeze=1) if loop and (start == 1): cmd.mview("interpolate",wrap=1) else: cmd.mview("interpolate") cmd.frame(start)
def add_rock(duration=8.0,angle=30.0,loop=1,axis='y',start=0,_self=cmd): cmd = _self if not start: start = cmd.get_movie_length()+1 duration = float(duration) angle=float(angle) loop=int(loop) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if n_frame > 0: cmd.mset("1 x%d"%n_frame,start,freeze=1) cmd.turn(axis,angle/2.0) cmd.mview("store",start+n_frame/4,power=-1,freeze=1) cmd.turn(axis,-angle) cmd.mview("store",start+(3*n_frame)/4,power=-1,freeze=1) if loop and (start == 1): cmd.mview("interpolate",wrap=1) else: cmd.mview("interpolate") cmd.frame(start)
def add_scenes(names=None, pause=8.0, cut=0.0, loop=1, rock=-1, period=8.0, animate=-1, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length() + 1 animate = float(animate) pause = float(pause) period = float(period) if period > pause: period = pause rock = int(rock) if animate < 0: animate = float(cmd.get("scene_animation_duration")) if names == None: names = cmd.get_scene_list() elif cmd.is_str(names): names = cmd.safe_alpha_list_eval(names) n_scene = len(names) duration = n_scene * (pause + animate) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if not loop: act_n_frame = int(round(fps * (duration - animate))) else: act_n_frame = n_frame if rock < 0: sweep_mode = int(cmd.get('sweep_mode')) elif rock: sweep_mode = rock - 1 else: sweep_mode = 0 if n_frame > 0: cmd.mset("1 x%d" % act_n_frame, start, freeze=1) cnt = 0 for scene in names: frame = start + int((cnt * n_frame) / n_scene) cmd.mview("store", frame, scene=scene, freeze=1) if rock: cmd.mview("interpolate", cut=cut, wrap=0) sweep_first = frame + 1 sweep_last = start + int(pause * fps + (cnt * n_frame) / n_scene) - 1 if sweep_last > act_n_frame: sweep_last = act_n_frame n_sweep_frame = sweep_last - sweep_first + 1 if n_sweep_frame > 0: if sweep_mode == 1: # x-axis rock _rock(sweep_mode, 'x', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode < 3: # y-axis rock _rock(sweep_mode, 'y', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode == 3: _nutate(sweep_mode, sweep_first, sweep_last, period, pause, _self=_self) frame = start + int(pause * fps + (cnt * n_frame) / n_scene) if frame <= act_n_frame: if sweep_mode != 3: cmd.mview("store", frame, scene=scene, freeze=1) cnt = cnt + 1 cmd.mview("interpolate", cut=cut, wrap=loop) if rock: cmd.mview("smooth") cmd.frame(start)
def add_scenes(names=None, pause=8.0, cut=0.0, loop=1, rock=-1, period=8.0, animate=-1, start=0, _self=cmd): cmd = _self if not start: start = cmd.get_movie_length()+1 animate = float(animate) pause = float(pause) period = float(period) if period>pause: period = pause rock = int(rock) if animate<0: animate = float(cmd.get("scene_animation_duration")) if names == None: names = cmd.get_scene_list() elif cmd.is_str(names): names = cmd.safe_alpha_list_eval(names) n_scene = len(names) duration = n_scene*(pause+animate) fps = float(cmd.get('movie_fps')) n_frame = int(round(fps * duration)) if not loop: act_n_frame = int(round(fps * (duration - animate))) else: act_n_frame = n_frame if rock<0: sweep_mode = int(cmd.get('sweep_mode')) elif rock: sweep_mode = rock - 1 else: sweep_mode = 0 if n_frame > 0: cmd.mset("1 x%d"%act_n_frame,start,freeze=1) cnt = 0 for scene in names: frame = start+int((cnt*n_frame)/n_scene) cmd.mview("store",frame,scene=scene,freeze=1) if rock: cmd.mview("interpolate",cut=cut,wrap=0) sweep_first = frame + 1 sweep_last = start + int(pause*fps+(cnt*n_frame)/n_scene) - 1 if sweep_last > act_n_frame: sweep_last = act_n_frame n_sweep_frame = sweep_last - sweep_first + 1 if n_sweep_frame > 0: if sweep_mode==1: # x-axis rock _rock(sweep_mode, 'x', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode<3: # y-axis rock _rock(sweep_mode, 'y', sweep_first, sweep_last, period, pause, _self=_self) elif sweep_mode == 3: _nutate(sweep_mode, sweep_first, sweep_last, period, pause, _self=_self) frame = start+int(pause*fps+(cnt*n_frame)/n_scene) if frame <= act_n_frame: if sweep_mode!=3: cmd.mview("store",frame,scene=scene,freeze=1) cnt = cnt + 1 cmd.mview("interpolate",cut=cut,wrap=loop) if rock: cmd.mview("smooth") cmd.frame(start)