diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /release/scripts/scripttemplate_ipo_gen.py | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'release/scripts/scripttemplate_ipo_gen.py')
-rw-r--r-- | release/scripts/scripttemplate_ipo_gen.py | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/release/scripts/scripttemplate_ipo_gen.py b/release/scripts/scripttemplate_ipo_gen.py new file mode 100644 index 00000000000..a333b4f20bf --- /dev/null +++ b/release/scripts/scripttemplate_ipo_gen.py @@ -0,0 +1,92 @@ +#!BPY +""" +Name: 'IPO Example' +Blender: 245 +Group: 'ScriptTemplate' +Tooltip: 'Script template for setting the IPO' +""" + +from Blender import Window +import bpy + +script_data = \ +'''#!BPY +""" +Name: 'My Ipo Script' +Blender: 245 +Group: 'Animation' +Tooltip: 'Put some useful info here' +""" + +# Add a licence here if you wish to re-distribute, we recommend the GPL + +from Blender import Ipo, Mathutils, Window +import bpy, BPyMessages + +def makeRandomIpo(object, firstFrame, numberOfFrames, frameStep): + # Create an new Ipo Curve of name myIpo and type Object + myIpo = bpy.data.ipos.new('myIpo', 'Object') + + # Create LocX, LocY, and LocZ Ipo curves in our new Curve Object + # and store them so we can access them later + myIpo_x = myIpo.addCurve('LocX') + myIpo_y = myIpo.addCurve('LocY') + myIpo_z = myIpo.addCurve('LocZ') + + # What value we want to scale our random value by + ipoScale = 4 + + # This Calculates the End Frame for use in an xrange() expression + endFrame = firstFrame + (numberOfFrames * frameStep) + frameStep + + for frame in xrange(firstFrame, endFrame, frameStep): + + # Use the Mathutils Rand() function to get random numbers + ipoValue_x = Mathutils.Rand(-1, 1) * ipoScale + ipoValue_y = Mathutils.Rand(-1, 1) * ipoScale + ipoValue_z = Mathutils.Rand(-1, 1) * ipoScale + + # Append to the Ipo curve at location frame, with the value ipoValue_x + # Note that we should pass the append function a tuple or a BezTriple + myIpo_x.append((frame, ipoValue_x)) + + # Similar to above + myIpo_y.append((frame, ipoValue_y)) + myIpo_z.append((frame, ipoValue_z)) + + # Link our new Ipo Curve to the passed object + object.setIpo(myIpo) + print object + + +def main(): + + # Get the active scene, since there can be multiple ones + sce = bpy.data.scenes.active + + # Get the active object + object = sce.objects.active + + # If there is no active object, pop up an error message + if not object: + BPyMessages.Error_NoActive() + + Window.WaitCursor(1) + + # Call our makeRandomIpo function + # Pass it our object, Tell it to keys from the start frame until the end frame, at a step of 10 frames + # between them + + makeRandomIpo(object, sce.render.sFrame, sce.render.eFrame, 10) + + Window.WaitCursor(0) + +if __name__ == '__main__': + main() + +''' + +new_text = bpy.data.texts.new('ipo_template.py') +new_text.write(script_data) +bpy.data.texts.active = new_text +Window.RedrawAll() |