Fix 3D tracks to mesh not aligning mesh properly

Also fixed wrong frame number used for reconstructed object
visualization in 3D viewport.
This commit is contained in:
2014-02-26 19:40:04 +06:00
parent cf0120b189
commit 3b44ca08a9
3 changed files with 83 additions and 1 deletions

View File

@@ -189,6 +189,15 @@ class CLIP_OT_bundles_to_mesh(Operator):
new_verts = []
scene = context.scene
camera = scene.camera
matrix = Matrix.Identity(4)
if camera:
reconstruction = tracking_object.reconstruction
framenr = scene.frame_current - clip.frame_start + 1
reconstructed_matrix = reconstruction.cameras.matrix_for_frame(framenr)
matrix = camera.matrix_world * reconstructed_matrix.inverted()
mesh = bpy.data.meshes.new(name="Tracks")
for track in tracking_object.tracks:
if track.has_bundle:
@@ -200,6 +209,8 @@ class CLIP_OT_bundles_to_mesh(Operator):
ob = bpy.data.objects.new(name="Tracks", object_data=mesh)
ob.matrix_world = matrix
context.scene.objects.link(ob)
return {'FINISHED'}