Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
commitbdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch)
treed00eb50b749cb001e2b08272c91791e66740b05d /release/scripts/bpymodules/BPyArmature.py
parent78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff)
parent7e4db234cee71ead34ee81a12e27da4bd548eb4b (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/bpymodules/BPyArmature.py')
-rw-r--r--release/scripts/bpymodules/BPyArmature.py75
1 files changed, 45 insertions, 30 deletions
diff --git a/release/scripts/bpymodules/BPyArmature.py b/release/scripts/bpymodules/BPyArmature.py
index d0b41dc35c5..63df02d080c 100644
--- a/release/scripts/bpymodules/BPyArmature.py
+++ b/release/scripts/bpymodules/BPyArmature.py
@@ -11,13 +11,19 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# Version History:
+# 1.0 original release bakes an armature into a matrix
+# 1.1 optional params (ACTION_BAKE, ACTION_BAKE_FIRST_FRAME, direct function to key and return the Action
import Blender
+from Blender import sys
import bpy
-def getBakedPoseData(ob_arm, start_frame, end_frame):
+def getBakedPoseData(ob_arm, start_frame, end_frame, ACTION_BAKE = False, ACTION_BAKE_FIRST_FRAME = True):
'''
If you are currently getting IPO's this function can be used to
- return a list of frame aligned bone dictionary's
+ ACTION_BAKE==False: return a list of frame aligned bone dictionary's
+ ACTION_BAKE==True: return an action with keys aligned to bone constrained movement
+ if ACTION_BAKE_FIRST_FRAME is not supplied or is true: keys begin at frame 1
The data in these can be swaped in for the IPO loc and quat
@@ -77,7 +83,13 @@ def getBakedPoseData(ob_arm, start_frame, end_frame):
# --------------------------------- Main loop to collect IPO data
frame_index = 0
+ NvideoFrames= end_frame-start_frame
for current_frame in xrange(start_frame, end_frame+1):
+ if frame_index==0: start=sys.time()
+ elif frame_index==15: print NvideoFrames*(sys.time()-start),"seconds estimated..." #slows as it grows *3
+ elif frame_index >15:
+ percom= frame_index*100/NvideoFrames
+ print "Frame %i Overall %i percent complete\r" % (current_frame, percom),
ob_arm.action = backup_action
#pose.update() # not needed
Blender.Set('curframe', current_frame)
@@ -88,9 +100,7 @@ def getBakedPoseData(ob_arm, start_frame, end_frame):
for index, parent_index, bone_name, rest_bone, rest_matrix, rest_matrix_inv, pose_bone, ipo in armature_bone_data:
matrix= pose_bone.poseMatrix
-
parent_bone= rest_bone.parent
-
if parent_index != -1:
parent_pose_matrix = armature_bone_data[parent_index][6].poseMatrix
parent_bone_matrix_inv = armature_bone_data[parent_index][5]
@@ -98,40 +108,45 @@ def getBakedPoseData(ob_arm, start_frame, end_frame):
rest_matrix= rest_matrix * parent_bone_matrix_inv
matrix=matrix * rest_matrix.copy().invert()
-
pose_bone.quat= matrix.toQuat()
pose_bone.loc= matrix.translationPart()
- pose_bone.insertKey(ob_arm, 1, POSE_XFORM) # always frame 1
-
- # THIS IS A BAD HACK! IT SUCKS BIGTIME BUT THE RESULT ARE NICE
- # - use a temp action and bake into that, always at the same frame
- # so as not to make big IPO's, then collect the result from the IPOs
+ if ACTION_BAKE==False:
+ pose_bone.insertKey(ob_arm, 1, POSE_XFORM) # always frame 1
+
+ # THIS IS A BAD HACK! IT SUCKS BIGTIME BUT THE RESULT ARE NICE
+ # - use a temp action and bake into that, always at the same frame
+ # so as not to make big IPO's, then collect the result from the IPOs
- # Now get the data from the IPOs
- if not ipo: ipo = armature_bone_data[index][7] = new_action.getChannelIpo(bone_name)
+ # Now get the data from the IPOs
+ if not ipo: ipo = armature_bone_data[index][7] = new_action.getChannelIpo(bone_name)
- loc = Vector()
- quat = Quaternion()
+ loc = Vector()
+ quat = Quaternion()
- for curve in ipo:
- val = curve.evaluate(1)
- curve_name= curve.name
- if curve_name == 'LocX': loc[0] = val
- elif curve_name == 'LocY': loc[1] = val
- elif curve_name == 'LocZ': loc[2] = val
- elif curve_name == 'QuatW': quat[3] = val
- elif curve_name == 'QuatX': quat[0] = val
- elif curve_name == 'QuatY': quat[1] = val
- elif curve_name == 'QuatZ': quat[2] = val
+ for curve in ipo:
+ val = curve.evaluate(1)
+ curve_name= curve.name
+ if curve_name == 'LocX': loc[0] = val
+ elif curve_name == 'LocY': loc[1] = val
+ elif curve_name == 'LocZ': loc[2] = val
+ elif curve_name == 'QuatW': quat[3] = val
+ elif curve_name == 'QuatX': quat[0] = val
+ elif curve_name == 'QuatY': quat[1] = val
+ elif curve_name == 'QuatZ': quat[2] = val
- bake_data[frame_index][bone_name] = loc, quat
-
-
+ bake_data[frame_index][bone_name] = loc, quat
+ else:
+ if ACTION_BAKE_FIRST_FRAME: pose_bone.insertKey(ob_arm, frame_index+1, POSE_XFORM)
+ else: pose_bone.insertKey(ob_arm, current_frame , POSE_XFORM)
frame_index+=1
-
+ print "\nBaking Complete."
ob_arm.action = backup_action
- Blender.Set('curframe', backup_frame)
- return bake_data
+ if ACTION_BAKE==False:
+ Blender.Set('curframe', backup_frame)
+ return bake_data
+ elif ACTION_BAKE==True:
+ return new_action
+ else: print "ERROR: Invalid ACTION_BAKE %i sent to BPyArmature" % ACTION_BAKE