Revision: 37597
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37597
Author:   nazgul
Date:     2011-06-17 14:47:41 +0000 (Fri, 17 Jun 2011)
Log Message:
-----------
Camera tracking integration
===========================

Test tool: convert track to location fcurves for object in 3d world.
1 pixel on footage is equal to 1 Blender unit.

Added for testing only, could be removed any time -- real
parenting to markers/bundles are only under design now.

Modified Paths:
--------------
    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_ui/space_clip.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py        
2011-06-17 14:47:22 UTC (rev 37596)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py        
2011-06-17 14:47:41 UTC (rev 37597)
@@ -159,6 +159,19 @@
         row.prop(sc, "path_length")
 
 
+class CLIP_PT_test(bpy.types.Panel):
+    bl_space_type = 'CLIP_EDITOR'
+    bl_region_type = 'TOOLS'
+    bl_label = "Test"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    def draw(self, context):
+        layout = self.layout
+        sc = context.space_data
+
+        layout.operator("clip.track_to_fcurves")
+
+
 class CLIP_PT_debug(bpy.types.Panel):
     bl_space_type = 'CLIP_EDITOR'
     bl_region_type = 'UI'

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-06-17 14:47:22 UTC (rev 37596)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h    
2011-06-17 14:47:41 UTC (rev 37597)
@@ -71,6 +71,8 @@
 void CLIP_OT_reset_tracking_settings(struct wmOperatorType *ot);
 void CLIP_OT_clear_track_path(struct wmOperatorType *ot);
 
+void CLIP_OT_track_to_fcurves(struct wmOperatorType *ot);
+
 /* clip_draw.c */
 void draw_clip_main(struct SpaceClip *sc, struct ARegion *ar, struct Scene 
*scene);
 void draw_clip_track_widget(const struct bContext *C, void *trackp, void 
*userp, void *clipp, rcti *rect);

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-06-17 14:47:22 UTC (rev 37596)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c     
2011-06-17 14:47:41 UTC (rev 37597)
@@ -210,6 +210,8 @@
 
        WM_operatortype_append(CLIP_OT_reset_tracking_settings);
        WM_operatortype_append(CLIP_OT_clear_track_path);
+
+       WM_operatortype_append(CLIP_OT_track_to_fcurves);
 }
 
 static void clip_keymap(struct wmKeyConfig *keyconf)

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-06-17 14:47:22 UTC (rev 37596)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c   
2011-06-17 14:47:41 UTC (rev 37597)
@@ -32,6 +32,7 @@
 #include "DNA_movieclip_types.h"
 #include "DNA_object_types.h"  /* SELECT */
 #include "DNA_scene_types.h"
+#include "DNA_anim_types.h"
 
 #include "BLI_utildefines.h"
 #include "BLI_math.h"
@@ -39,16 +40,20 @@
 #include "BLI_rect.h"
 #include "BLI_blenlib.h"
 
+#include "BKE_main.h"
 #include "BKE_context.h"
 #include "BKE_movieclip.h"
 #include "BKE_tracking.h"
 #include "BKE_global.h"
+#include "BKE_animsys.h"
+#include "BKE_depsgraph.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
 #include "ED_screen.h"
 #include "ED_clip.h"
+#include "ED_keyframing.h"
 
 #include "IMB_imbuf_types.h"
 
@@ -889,4 +894,88 @@
 
        /* flags */
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
-}
\ No newline at end of file
+}
+
+/********************** track to fcurves opertaotr *********************/
+
+static int track_to_fcurves_poll(bContext *C)
+{
+       Object *ob= CTX_data_active_object(C);
+       SpaceClip *sc= CTX_wm_space_clip(C);
+
+       if(ob && sc) {
+               MovieClip *clip= ED_space_clip(sc);
+               int type;
+               void *sel;
+
+               if(clip) {
+                       BKE_movieclip_last_selection(clip, &type, &sel);
+                       if(type==MCLIP_SEL_TRACK)
+                               return 1;
+               }
+       }
+
+       return 0;
+}
+
+static int track_to_fcurves_exec(bContext *C, wmOperator *op)
+{
+       SpaceClip *sc= CTX_wm_space_clip(C);
+       MovieClip *clip= ED_space_clip(sc);
+       Object *ob= CTX_data_active_object(C);
+       Scene *scene= CTX_data_scene(C);
+       KeyingSet *ks;
+       int kflag, fra= SFRA, type;
+       MovieTrackingTrack *track;
+       bAction *act= verify_adt_action(&ob->id, 1);
+       MovieClipUser user= {0};
+       int width, height;
+       float scale= RNA_float_get(op->ptr, "scale");
+
+       BKE_movieclip_last_selection(clip, &type, (void**)&track);
+
+       ks= ANIM_builtin_keyingset_get_named(NULL, "Location");
+       kflag= ks->flag;
+       kflag |= ANIM_get_keyframing_flags(scene, 1);
+
+       (void)op;
+
+       BKE_movieclip_acquire_size(clip, &user, &width, &height);
+
+       while(fra<EFRA) {
+               MovieTrackingMarker *marker= BKE_tracking_get_marker(track, 
fra);
+
+               if(marker) {
+                       FCurve *fcu;
+
+                       fcu= verify_fcurve(act, ks->name, "location", 0, 1);
+                       insert_vert_fcurve(fcu, fra, 
marker->pos[0]*width*scale, kflag);
+
+                       fcu= verify_fcurve(act, ks->name, "location", 1, 1);
+                       insert_vert_fcurve(fcu, fra, 
marker->pos[1]*height*scale, kflag);
+               }
+
+               fra++;
+       }
+
+       WM_main_add_notifier(NC_ANIMATION|ND_KEYFRAME|NA_EDITED, NULL);
+
+       return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_track_to_fcurves(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Convert Track To FCurves";
+       ot->description= "Convert active track to f-curves for active object in 
the scene";
+       ot->idname= "CLIP_OT_track_to_fcurves";
+
+       /* api callbacks */
+       ot->exec= track_to_fcurves_exec;
+       ot->poll= track_to_fcurves_poll;
+
+       /* flags */
+       ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+       RNA_def_float(ot->srna, "scale", 1.f, -FLT_MAX, FLT_MAX, "Scale", 
"Scale factor for generated coordinates", -100.f, 100.f);
+}

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

Reply via email to