Skip to content

Commit

Permalink
updates for changes in blender.
Browse files Browse the repository at this point in the history
  • Loading branch information
ideasman42 committed Sep 3, 2010
1 parent 722806d commit 3c4c1ed
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions io_anim_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def writeCameras(context, filepath, frame_start, frame_end, only_selected=False)


for f in frame_range:
scene.set_frame(f)
scene.frame_set(f)
fw("# new frame\n")
fw("scene.set_frame(%d + frame)\n" % f)
fw("scene.frame_set(%d + frame)\n" % f)

for obj, obj_data in cameras:
fw("obj = cameras['%s']\n" % obj.name)
Expand Down
30 changes: 15 additions & 15 deletions io_export_directx_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ def WriteKeyedAnimationSet(Config):
if len(AllKeyframes):
Config.File.write("{}2;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)
Position = Vector()
Position[0] = ((PositionFCurves[0][Keyframe] if Keyframe in PositionFCurves[0] else Object.location[0]) if PositionFCurves[0] else Object.location[0])
Position[1] = ((PositionFCurves[1][Keyframe] if Keyframe in PositionFCurves[1] else Object.location[1]) if PositionFCurves[1] else Object.location[1])
Expand All @@ -678,7 +678,7 @@ def WriteKeyedAnimationSet(Config):
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Position[0], Position[1], Position[2]))
else:
Config.File.write("{}2;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace))
bpy.context.scene.set_frame(bpy.context.scene.frame_start)
bpy.context.scene.frame_set(bpy.context.scene.frame_start)
Position = Config.SystemMatrix * Object.location
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, ("0;3;").ljust(8), Position[0], Position[1], Position[2]))
Config.Whitespace -= 1
Expand All @@ -704,7 +704,7 @@ def WriteKeyedAnimationSet(Config):
if len(AllKeyframes):
Config.File.write("{}0;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)
Rotation = Euler()
Rotation[0] = ((RotationFCurves[0][Keyframe] if Keyframe in RotationFCurves[0] else Object.rotation_euler[0]) if RotationFCurves[0] else Object.rotation_euler[0])
Rotation[1] = ((RotationFCurves[1][Keyframe] if Keyframe in RotationFCurves[1] else Object.rotation_euler[1]) if RotationFCurves[1] else Object.rotation_euler[1])
Expand All @@ -713,7 +713,7 @@ def WriteKeyedAnimationSet(Config):
Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";4;").ljust(8), - Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
else:
Config.File.write("{}0;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace))
bpy.context.scene.set_frame(bpy.context.scene.frame_start)
bpy.context.scene.frame_set(bpy.context.scene.frame_start)
Rotation = (Config.SystemMatrix * (Object.rotation_euler.to_matrix().to_4x4()) * Config.InverseSystemMatrix).to_quat()
Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, ("0;4;").ljust(8), -Rotation[0], Rotation[1], Rotation[2], Rotation[3]))
Config.Whitespace -= 1
Expand All @@ -739,7 +739,7 @@ def WriteKeyedAnimationSet(Config):
if len(AllKeyframes):
Config.File.write("{}1;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)
Scale = Vector()
Scale[0] = ((ScaleFCurves[0][Keyframe] if Keyframe in ScaleFCurves[0] else Object.scale[0]) if ScaleFCurves[0] else Object.scale[0])
Scale[1] = ((ScaleFCurves[1][Keyframe] if Keyframe in ScaleFCurves[1] else Object.scale[1]) if ScaleFCurves[1] else Object.scale[1])
Expand All @@ -748,7 +748,7 @@ def WriteKeyedAnimationSet(Config):
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Keyframe - bpy.context.scene.frame_start) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2]))
else:
Config.File.write("{}1;\n{}1;\n".format(" " * Config.Whitespace, " " * Config.Whitespace))
bpy.context.scene.set_frame(bpy.context.scene.frame_start)
bpy.context.scene.frame_set(bpy.context.scene.frame_start)
Scale = Config.SystemMatrix * Object.scale
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, ("0;3;").ljust(8), Scale[0], Scale[1], Scale[2]))
Config.Whitespace -= 1
Expand Down Expand Up @@ -807,7 +807,7 @@ def WriteKeyedAnimationSet(Config):
AllKeyframes = [bpy.context.scene.frame_start]
Config.File.write("{}2;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)

if Bone.parent:
PoseMatrix = (Bone.parent.matrix * Matrix.Rotation(radians(-90), 4, "X")).invert()
Expand Down Expand Up @@ -843,7 +843,7 @@ def WriteKeyedAnimationSet(Config):
AllKeyframes = [bpy.context.scene.frame_start]
Config.File.write("{}0;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)

if Bone.parent:
PoseMatrix = (Bone.parent.matrix * Matrix.Rotation(radians(-90), 4, "X")).invert()
Expand Down Expand Up @@ -879,7 +879,7 @@ def WriteKeyedAnimationSet(Config):
AllKeyframes = [bpy.context.scene.frame_start]
Config.File.write("{}1;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, len(AllKeyframes)))
for Keyframe in AllKeyframes:
bpy.context.scene.set_frame(Keyframe)
bpy.context.scene.frame_set(Keyframe)

if Bone.parent:
PoseMatrix = (Bone.parent.matrix * Matrix.Rotation(radians(-90), 4, "X")).invert()
Expand Down Expand Up @@ -930,7 +930,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}2;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)
Position = Config.SystemMatrix * Object.location
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Position[0], Position[1], Position[2]))
Config.Whitespace -= 1
Expand All @@ -945,7 +945,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}0;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)
Rotation = Config.SystemQuaternion.cross(Object.rotation_euler.to_quat().cross(Config.InverseSystemQuaternion))
Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Frame) + ";4;").ljust(8), Rotation[0], Rotation[1], Rotation[2], Config.FlipZ * Rotation[3]))
Config.Whitespace -= 1
Expand All @@ -960,7 +960,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}1;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)
Scale = Config.SystemMatrix * Object.scale
Config.File.write("{}{}{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Frame) + ";3;").ljust(8), Scale[0], Scale[1], Scale[2]))
Config.Whitespace -= 1
Expand Down Expand Up @@ -990,7 +990,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}2;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)

if Bone.parent:
PoseMatrix = (Bone.parent.matrix * Matrix.Rotation(radians(-90), 4, "X")).invert()
Expand All @@ -1014,7 +1014,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}0;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)
#Whew! I'm sure this could be simplified.
Rotation = Config.SystemQuaternion.cross(Matrix.Rotation(radians(90), 4, "X").to_quat().cross(Bone.rotation_quaternion.cross(Matrix.Rotation(radians(-90), 4, "X").to_quat().cross(Config.InverseSystemQuaternion))))
Config.File.write("{}{}{:9f},{:9f},{:9f},{:9f};;\n".format(" " * Config.Whitespace, (str(Frame) + ";4;").ljust(8), Rotation[0], Rotation[1], Rotation[2], Config.FlipZ * Rotation[3]))
Expand All @@ -1030,7 +1030,7 @@ def WriteFullAnimationSet(Config):
Config.Whitespace += 1
Config.File.write("{}1;\n{}{};\n".format(" " * Config.Whitespace, " " * Config.Whitespace, KeyframeCount))
for Frame in range(0, KeyframeCount):
bpy.context.scene.set_frame(Frame + bpy.context.scene.frame_start)
bpy.context.scene.frame_set(Frame + bpy.context.scene.frame_start)

if Bone.parent:
PoseMatrix = (Bone.parent.matrix * Matrix.Rotation(radians(-90), 4, "X")).invert()
Expand Down
10 changes: 5 additions & 5 deletions io_export_unreal_psk_psa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ def parse_animation(blender_scene, blender_armatures, psa_file):
#print "This Frame: %i, Next Frame: NONE" % frame

#frame start from 1 as number one from blender
blender_scene.set_frame(frame)
blender_scene.frame_set(frame)

cur_frame_index = cur_frame_index + 1
for bone_data in ordered_bones:
Expand Down Expand Up @@ -1346,7 +1346,7 @@ def fs_callback(filename, context, user_setting):
print("//===============================")
parse_meshes(blender_meshes, psk)
except:
context.scene.set_frame(cur_frame) #set frame back to original frame
context.scene.frame_set(cur_frame) #set frame back to original frame
print ("Exception during Mesh Parse")
raise

Expand All @@ -1361,7 +1361,7 @@ def fs_callback(filename, context, user_setting):
parse_armature(blender_armature, psk, psa)

except:
context.scene.set_frame(cur_frame) #set frame back to original frame
context.scene.frame_set(cur_frame) #set frame back to original frame
print ("Exception during Armature Parse")
raise

Expand All @@ -1375,13 +1375,13 @@ def fs_callback(filename, context, user_setting):
parse_animation(current_scene, blender_armature, psa)

except:
context.scene.set_frame(cur_frame) #set frame back to original frame
context.scene.frame_set(cur_frame) #set frame back to original frame
print ("Exception during Animation Parse")
raise

# reset current frame

context.scene.set_frame(cur_frame) #set frame back to original frame
context.scene.frame_set(cur_frame) #set frame back to original frame

##########################
# FILE WRITE
Expand Down
4 changes: 2 additions & 2 deletions io_import_images_as_planes.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def main(filePath, options, mapping, dimension):
plane = createPlaneObj(img, dimension)

# Assign Material
plane.data.materials.link(mat)
plane.data.materials.append(mat)

# Put Image into UVTextureLayer
plane.data.uv_textures[0].data[0].image = img
Expand Down Expand Up @@ -356,7 +356,7 @@ def main(filePath, options, mapping, dimension):
plane = createPlaneObj(img, dimension)

# Assign Material
plane.data.materials.link(mat)
plane.data.materials.append(mat)

# Put image into UVTextureLayer
plane.data.uv_textures[0].data[0].image = img
Expand Down
2 changes: 1 addition & 1 deletion io_import_scene_mhx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ def parseMesh (args, tokens):
parseShapeKeys(ob, me, val, sub)
elif key == 'Material':
try:
me.materials.link(loadedData['Material'][val[0]])
me.materials.append(loadedData['Material'][val[0]])
except:
print("Could not add material", val[0])
else:
Expand Down
2 changes: 1 addition & 1 deletion io_import_scene_unreal_psk.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def printlog(strdata):
#= make sure the list isnt too big
for material in materials:
#add material to the mesh list of materials
me_ob.materials.link(material)
me_ob.materials.append(material)
#===================================================================================================
#
#===================================================================================================
Expand Down

0 comments on commit 3c4c1ed

Please sign in to comment.