In this code, I also used the model JessicaCasual which comes with Poser 6 as in my blinking example.
This scripts adjusts the size of the chest and abdomen in a cyclical manner.
Here is the generated video. Please note that the blinking script was also used.
--- BEGIN Script ---
# Copyright (C) 2007 Hideyuki Inada. All rights reserved.
#
# Note: Please adjust the end frame of the animation using the UI.
# Parameters
nStartFrame = 0
nEndFrame = 300
nFramePerSecond = 30
sParameterName = "xScale"
sParameter2Name = "zScale"
nBreathingPerMinute = 16 # See ref 1 below
nCycleDurationInFrame = 60 * nFramePerSecond / nBreathingPerMinute
nHalfCycleDurationInFrame = int(nCycleDurationInFrame / 2)
# Helper method
def debugPrint(sArg):
print(sArg)
def insertKeyFrameAndSetValue(nFrame, oScene, oActor, sParameterName, nParameterValue):
oScene.SetFrame(nFrame)
oActor.SetParameter(sParameterName, nParameterValue)
oActor.AddKeyFrame(nFrame)
# main start
debugPrint("Script starting")
debugPrint("Running on Poser version " + poser.Version())
# Obtain the reference to the Scene object
sce = poser.Scene()
# Setting ranges
sce.SetOutputRange(nStartFrame, nEndFrame)
mm = sce.MovieMaker()
mm.SetOutputStartFrame(nStartFrame)
mm.SetOutputEndFrame(nEndFrame)
fig = sce.Figure("JessicaCasual")
actor = fig.Actor("Chest")
actor2 = fig.Actor("Abdomen")
# Setting poses and inserting key frames
insertKeyFrameAndSetValue(0, sce, actor, sParameterName, 0)
bLastState = 1
# See ref 2 if you can use the keyword "True" here in your environment
# In my enviroment, 1 is used since "NameError: name 'True' is not defined" was displayed
# during run-time
for i in range(nStartFrame, nEndFrame):
if (i % nHalfCycleDurationInFrame == 0):
if(bLastState == 1):
insertKeyFrameAndSetValue(i, sce, actor, sParameterName, 0.98)
insertKeyFrameAndSetValue(i, sce, actor, sParameter2Name, 0.98)
insertKeyFrameAndSetValue(i, sce, actor2, sParameterName, 0.98)
insertKeyFrameAndSetValue(i, sce, actor2, sParameter2Name, 0.98)
bLastState = 0
else:
insertKeyFrameAndSetValue(i, sce, actor, sParameterName, 1.02)
insertKeyFrameAndSetValue(i, sce, actor, sParameter2Name, 1.02)
insertKeyFrameAndSetValue(i, sce, actor2, sParameterName, 1.02)
insertKeyFrameAndSetValue(i, sce, actor2, sParameter2Name, 1.02)
bLastState = 1
debugPrint("Script completed")
# end of code
# References
# 1. http://answers.yahoo.com/question/index?qid=20070715141510AAaQ71b
# 2. http://docs.python.org/lib/node8.html
--- END Script ---