[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38392] branches/soc-2011-tomato: Camera tracking integration

Sergey Sharybin g.ulairi at gmail.com
Thu Jul 14 14:52:51 CEST 2011


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

Initial implementation of Scale operator.

There's no access from operator panel to operators defined for
Clip Editor space, so distance can't be controlled as operator
property.
Added new property to MovieTrackingSettings for this.

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py
    branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
    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
    branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
    branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.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-07-14 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py	2011-07-14 12:52:50 UTC (rev 38392)
@@ -184,6 +184,10 @@
             row = col.row()
             row.operator("clip.set_axis", text="Set X Axis").axis = 'X'
             row.operator("clip.set_axis", text="Set Y Axis").axis = 'Y'
+
+            col = layout.column()
+            col.prop(settings, "distance")
+            col.operator("clip.set_scale")
         else:
             layout.operator('clip.open')
 

Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-07-14 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c	2011-07-14 12:52:50 UTC (rev 38392)
@@ -220,6 +220,7 @@
 	clip->tracking.settings.frames_limit= 20;
 	clip->tracking.settings.keyframe1= 1;
 	clip->tracking.settings.keyframe2= 30;
+	clip->tracking.settings.dist= 1;
 
 	return clip;
 }

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 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h	2011-07-14 12:52:50 UTC (rev 38392)
@@ -80,6 +80,7 @@
 void CLIP_OT_set_origin(struct wmOperatorType *ot);
 void CLIP_OT_set_floor(struct wmOperatorType *ot);
 void CLIP_OT_set_axis(struct wmOperatorType *ot);
+void CLIP_OT_set_scale(struct wmOperatorType *ot);
 
 void CLIP_OT_slide_marker(struct wmOperatorType *ot);
 

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 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c	2011-07-14 12:52:50 UTC (rev 38392)
@@ -216,6 +216,7 @@
 	WM_operatortype_append(CLIP_OT_set_origin);
 	WM_operatortype_append(CLIP_OT_set_floor);
 	WM_operatortype_append(CLIP_OT_set_axis);
+	WM_operatortype_append(CLIP_OT_set_scale);
 
 	WM_operatortype_append(CLIP_OT_clear_track_path);
 

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 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c	2011-07-14 12:52:50 UTC (rev 38392)
@@ -1514,6 +1514,72 @@
 	RNA_def_enum(ot->srna, "axis", axis_actions, 0, "Axis", "Axis to use to align bundle along");
 }
 
+/********************** set scale operator *********************/
+
+static int set_scale_exec(bContext *C, wmOperator *op)
+{
+	SpaceClip *sc= CTX_wm_space_clip(C);
+	MovieClip *clip= ED_space_clip(sc);
+	MovieTrackingTrack *track;
+	Scene *scene= CTX_data_scene(C);
+	Object *parent= scene->camera;
+	int tot= 0;
+	float vec[2][3], mat[4][4], scale;
+
+	if(count_selected_bundles(C)!=2) {
+		BKE_report(op->reports, RPT_ERROR, "Two tracks with bundles should be selected to scale scene");
+
+		return OPERATOR_CANCELLED;
+	}
+
+	if(scene->camera->parent)
+		parent= scene->camera->parent;
+
+	BKE_get_tracking_mat(scene, mat);
+
+	track= clip->tracking.tracks.first;
+	while(track) {
+		if(TRACK_SELECTED(track)) {
+			mul_v3_m4v3(vec[tot], mat, track->bundle_pos);
+			tot++;
+		}
+
+		track= track->next;
+	}
+
+	sub_v3_v3(vec[0], vec[1]);
+
+	if(len_v3(vec[0])>1e-5) {
+		scale= clip->tracking.settings.dist / len_v3(vec[0]);
+
+		mul_v3_fl(parent->size, scale);
+		mul_v3_fl(parent->loc, scale);
+
+		DAG_id_tag_update(&clip->id, 0);
+		DAG_id_tag_update(&parent->id, OB_RECALC_OB);
+
+		WM_event_add_notifier(C, NC_MOVIECLIP|NA_EVALUATED, clip);
+		WM_event_add_notifier(C, NC_SPACE|ND_SPACE_VIEW3D, NULL);
+	}
+
+	return OPERATOR_FINISHED;
+}
+
+void CLIP_OT_set_scale(wmOperatorType *ot)
+{
+	/* identifiers */
+	ot->name= "Set Scale";
+	ot->description= "Set scale of scene";
+	ot->idname= "CLIP_OT_set_scale";
+
+	/* api callbacks */
+	ot->exec= set_scale_exec;
+	ot->poll= space_clip_frame_camera_poll;
+
+	/* flags */
+	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+}
+
 /********************** slide marker opertaotr *********************/
 
 typedef struct {

Modified: branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h	2011-07-14 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/makesdna/DNA_tracking_types.h	2011-07-14 12:52:50 UTC (rev 38392)
@@ -100,6 +100,8 @@
 	short speed;	/* speed of tracking */
 	short frames_limit;	/* number of frames to be tarcked during single tracking session (if TRACKING_FRAMES_LIMIT is set) */
 	int keyframe1, keyframe2;	/* two keyframes for reconstrution initialization */
+	float dist;		/* distance between two bundles used for scene scaling */
+	float pad;
 } MovieTrackingSettings;
 
 typedef struct MovieTracking {

Modified: branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c	2011-07-14 12:05:40 UTC (rev 38391)
+++ branches/soc-2011-tomato/source/blender/makesrna/intern/rna_tracking.c	2011-07-14 12:52:50 UTC (rev 38392)
@@ -190,6 +190,12 @@
 	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
 	RNA_def_property_int_sdna(prop, NULL, "keyframe2");
 	RNA_def_property_ui_text(prop, "Keyframe 2", "Second keyframe used for reconstruction initialization");
+
+	/* distance */
+	prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+	RNA_def_property_float_sdna(prop, NULL, "dist");
+	RNA_def_property_ui_text(prop, "Distance", "Distance between two bundles used for scene scaling");
 }
 
 static void rna_def_trackingCamera(BlenderRNA *brna)




More information about the Bf-blender-cvs mailing list