Revision: 38395
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38395
Author:   nazgul
Date:     2011-07-14 14:35:04 +0000 (Thu, 14 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================

- Tracking camera presets.
- Reset principal to image center operator.

Things to think about:
- Unified presets for tracking camera and blender camera.
- If prinipal should be a part of preset.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
    branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
    branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c

Modified: 
branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-07-14 13:36:15 UTC (rev 38394)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_operators/presets.py    
2011-07-14 14:35:04 UTC (rev 38395)
@@ -277,6 +277,28 @@
     preset_subdir = "interaction"
 
 
+class AddPresetTrackingCamera(AddPresetBase, bpy.types.Operator):
+    '''Add a Tracking Camera Intrinsics  Preset'''
+    bl_idname = "clip.camera_preset_add"
+    bl_label = "Add Camera Preset"
+    preset_menu = "CLIP_MT_camera_presets"
+
+    preset_defines = [
+        "camera = bpy.context.edit_movieclip.tracking.camera"
+    ]
+
+    preset_values = [
+        "camera.focal_length",
+        "camera.sensor_width",
+        "camera.units",
+        "camera.k1",
+        "camera.k2",
+        "camera.k3"
+    ]
+
+    preset_subdir = "tracking_camera"
+
+
 class AddPresetKeyconfig(AddPresetBase, bpy.types.Operator):
     '''Add a Keyconfig Preset'''
     bl_idname = "wm.keyconfig_preset_add"

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py        
2011-07-14 13:36:15 UTC (rev 38394)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py        
2011-07-14 14:35:04 UTC (rev 38395)
@@ -266,6 +266,11 @@
         sc = context.space_data
         clip = sc.clip
 
+        row = layout.row(align=True)
+        row.menu('CLIP_MT_camera_presets')
+        row.operator("clip.camera_preset_add", text="", icon="ZOOMIN")
+        row.operator("clip.camera_preset_add", text="", 
icon="ZOOMOUT").remove_active = True
+
         layout.prop(clip.tracking.camera, "sensor_width")
 
         row = layout.row(align=True)
@@ -273,10 +278,14 @@
         sub.prop(clip.tracking.camera, "focal_length")
         sub.prop(clip.tracking.camera, "units", text="")
 
-        layout.label(text="Principal Point")
-        layout.prop(clip.tracking.camera, "principal", text="")
+        col = layout.column()
+        col.label(text="Principal Point")
+        row = col.row()
+        row.prop(clip.tracking.camera, "principal", text="")
+        col.operator("clip.set_center_principal", text="Center")
 
         col = layout.column(align=True)
+        col.label(text="Undistortion:")
         col.prop(clip.tracking.camera, "k1")
         col.prop(clip.tracking.camera, "k2")
         col.prop(clip.tracking.camera, "k3")
@@ -489,5 +498,13 @@
         layout.operator("clip.hide_tracks")
         layout.operator("clip.hide_tracks_clear", text="Show Tracks")
 
+
+class CLIP_MT_camera_presets(bpy.types.Menu):
+    bl_label = "Camera Presets"
+    preset_subdir = "tracking_camera"
+    preset_operator = "script.execute_preset"
+    draw = bpy.types.Menu.draw_preset
+
+
 if __name__ == "__main__":  # only for live edit.
     bpy.utils.register_module(__name__)

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h    
2011-07-14 13:36:15 UTC (rev 38394)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h    
2011-07-14 14:35:04 UTC (rev 38395)
@@ -82,6 +82,8 @@
 void CLIP_OT_set_axis(struct wmOperatorType *ot);
 void CLIP_OT_set_scale(struct wmOperatorType *ot);
 
+void CLIP_OT_set_center_principal(struct wmOperatorType *ot);
+
 void CLIP_OT_slide_marker(struct wmOperatorType *ot);
 
 /* clip_draw.c */

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c     
2011-07-14 13:36:15 UTC (rev 38394)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c     
2011-07-14 14:35:04 UTC (rev 38395)
@@ -218,6 +218,8 @@
        WM_operatortype_append(CLIP_OT_set_axis);
        WM_operatortype_append(CLIP_OT_set_scale);
 
+       WM_operatortype_append(CLIP_OT_set_center_principal);
+
        WM_operatortype_append(CLIP_OT_clear_track_path);
 
        WM_operatortype_append(CLIP_OT_slide_marker);

Modified: 
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c   
2011-07-14 13:36:15 UTC (rev 38394)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c   
2011-07-14 14:35:04 UTC (rev 38395)
@@ -1580,6 +1580,41 @@
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 }
 
+/********************** set principal center operator *********************/
+
+static int set_center_principal_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       SpaceClip *sc= CTX_wm_space_clip(C);
+       MovieClip *clip= ED_space_clip(sc);
+       int width, height;
+
+       BKE_movieclip_acquire_size(clip, &sc->user, &width, &height);
+
+       if(width==0 || height==0)
+               return OPERATOR_CANCELLED;
+
+       clip->tracking.camera.principal[0]= ((float)width)/2.0f;
+       clip->tracking.camera.principal[1]= ((float)height)/2.0f;
+
+       WM_event_add_notifier(C, NC_MOVIECLIP|NA_EDITED, clip);
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_set_center_principal(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Set Principal to Center";
+       ot->description= "Set principal point to center of footage";
+       ot->idname= "CLIP_OT_set_center_principal";
+
+       /* api callbacks */
+       ot->exec= set_center_principal_exec;
+       ot->poll= space_clip_tracking_poll;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
 /********************** slide marker opertaotr *********************/
 
 typedef struct {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to