[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38363] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Wed Jul 13 18:06:55 CEST 2011
Revision: 38363
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38363
Author: nazgul
Date: 2011-07-13 16:06:53 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Report an error if more than needed tracks are selected
for orientation operators.
- Added possibility to align bundle along X or Y axis.
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-07-13 15:09:45 UTC (rev 38362)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_clip.py 2011-07-13 16:06:53 UTC (rev 38363)
@@ -179,7 +179,10 @@
col.label(text="Scene Orientation:")
col.operator("clip.set_floor")
col.operator("clip.set_origin")
- col.operator("clip.set_x_axis")
+
+ 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'
else:
layout.operator('clip.open')
@@ -240,7 +243,6 @@
row.prop(settings, "frames_limit")
-
class CLIP_PT_tracking_camera(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-07-13 15:09:45 UTC (rev 38362)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/clip_intern.h 2011-07-13 16:06:53 UTC (rev 38363)
@@ -79,7 +79,7 @@
void CLIP_OT_set_origin(struct wmOperatorType *ot);
void CLIP_OT_set_floor(struct wmOperatorType *ot);
-void CLIP_OT_set_x_axis(struct wmOperatorType *ot);
+void CLIP_OT_set_axis(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-13 15:09:45 UTC (rev 38362)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/space_clip.c 2011-07-13 16:06:53 UTC (rev 38363)
@@ -215,7 +215,7 @@
WM_operatortype_append(CLIP_OT_set_origin);
WM_operatortype_append(CLIP_OT_set_floor);
- WM_operatortype_append(CLIP_OT_set_x_axis);
+ WM_operatortype_append(CLIP_OT_set_axis);
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-13 15:09:45 UTC (rev 38362)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c 2011-07-13 16:06:53 UTC (rev 38363)
@@ -1157,6 +1157,7 @@
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+ /* proeprties */
RNA_def_enum(ot->srna, "action", clear_path_actions, TRACK_CLEAR_REMAINED, "Action", "Clear action to execute");
}
@@ -1217,6 +1218,24 @@
/********************** set origin operator *********************/
+static int count_selected_bundles(bContext *C)
+{
+ SpaceClip *sc= CTX_wm_space_clip(C);
+ MovieClip *clip= ED_space_clip(sc);
+ MovieTrackingTrack *track;
+ int tot= 0;
+
+ track= clip->tracking.tracks.first;
+ while(track) {
+ if(TRACK_SELECTED(track))
+ tot++;
+
+ track= track->next;
+ }
+
+ return tot;
+}
+
static int set_origin_exec(bContext *C, wmOperator *op)
{
SpaceClip *sc= CTX_wm_space_clip(C);
@@ -1226,6 +1245,11 @@
Object *parent= scene->camera;
float mat[4][4], vec[3];
+ if(count_selected_bundles(C)!=1) {
+ BKE_report(op->reports, RPT_ERROR, "Track with bundle should be selected to define origin position");
+ return OPERATOR_CANCELLED;
+ }
+
if(scene->camera->parent)
parent= scene->camera->parent;
@@ -1237,11 +1261,6 @@
track= track->next;
}
- if(!track) {
- BKE_report(op->reports, RPT_ERROR, "Track with bundle should be selected to define origin position");
- return OPERATOR_CANCELLED;
- }
-
BKE_get_tracking_mat(scene, mat);
mul_v3_m4v3(vec, mat, track->bundle_pos);
@@ -1273,7 +1292,7 @@
/********************** set floor operator *********************/
-static void set_x_axis(Scene *scene, Object *ob, MovieTrackingTrack *track)
+static void set_axis(Scene *scene, Object *ob, MovieTrackingTrack *track, char axis)
{
float mat[4][4], vec[3], obmat[4][4];
@@ -1285,10 +1304,17 @@
unit_m4(mat);
- copy_v3_v3(mat[0], vec);
- mat[0][2]= 0.f;
- mat[2][0]= 0.f; mat[2][1]= 0.f; mat[2][2]= 1.0f;
- cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ if(axis=='X') {
+ copy_v3_v3(mat[0], vec);
+ mat[0][2]= 0.f;
+ mat[2][0]= 0.f; mat[2][1]= 0.f; mat[2][2]= 1.0f;
+ cross_v3_v3v3(mat[1], mat[2], mat[0]);
+ } else {
+ copy_v3_v3(mat[1], vec);
+ mat[1][2]= 0.f;
+ mat[2][0]= 0.f; mat[2][1]= 0.f; mat[2][2]= 1.0f;
+ cross_v3_v3v3(mat[0], mat[1], mat[2]);
+ }
normalize_v3(mat[0]);
normalize_v3(mat[1]);
@@ -1306,7 +1332,7 @@
SpaceClip *sc= CTX_wm_space_clip(C);
MovieClip *clip= ED_space_clip(sc);
Scene *scene= CTX_data_scene(C);
- MovieTrackingTrack *track, *sel, *xtrack= NULL;
+ MovieTrackingTrack *track, *sel, *axis_track= NULL;
Object *camera= scene->camera;
Object *parent= camera;
int tot= 0, sel_type;
@@ -1316,6 +1342,11 @@
{1.f, 0.f, 0.f, 0.f},
{0.f, 0.f, 0.f, 1.f}}; /* 90 degrees Y-axis rotation matrix */
+ if(count_selected_bundles(C)!=3) {
+ BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor");
+ return OPERATOR_CANCELLED;
+ }
+
if(scene->camera->parent)
parent= scene->camera->parent;
@@ -1332,7 +1363,7 @@
if(tot==0 || (sel_type==MCLIP_SEL_TRACK && track==sel))
copy_v3_v3(orig, vec[tot]);
else
- xtrack= track;
+ axis_track= track;
tot++;
}
@@ -1340,11 +1371,6 @@
track= track->next;
}
- if(tot!=3) {
- BKE_report(op->reports, RPT_ERROR, "Three tracks with bundles are needed to orient the floor");
- return OPERATOR_CANCELLED;
- }
-
sub_v3_v3(vec[1], vec[0]);
sub_v3_v3(vec[2], vec[0]);
@@ -1380,7 +1406,7 @@
}
where_is_object(scene, parent);
- set_x_axis(scene, parent, xtrack);
+ set_axis(scene, parent, axis_track, 'X');
DAG_id_tag_update(&clip->id, 0);
DAG_id_tag_update(&parent->id, OB_RECALC_OB);
@@ -1408,14 +1434,21 @@
/********************** set origin operator *********************/
-static int set_x_axis_exec(bContext *C, wmOperator *op)
+static int set_axis_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 axis= RNA_enum_get(op->ptr, "axis");
+ if(count_selected_bundles(C)!=1) {
+ BKE_report(op->reports, RPT_ERROR, "Track with bundle should be selected to define X-axis");
+
+ return OPERATOR_CANCELLED;
+ }
+
if(scene->camera->parent)
parent= scene->camera->parent;
@@ -1427,13 +1460,8 @@
track= track->next;
}
- if(!track) {
- BKE_report(op->reports, RPT_ERROR, "Track with bundle should be selected to define X-axis");
- return OPERATOR_CANCELLED;
- }
+ set_axis(scene, parent, track, axis==0?'X':'Y');
- set_x_axis(scene, parent, track);
-
DAG_id_tag_update(&clip->id, 0);
DAG_id_tag_update(&parent->id, OB_RECALC_OB);
@@ -1443,19 +1471,28 @@
return OPERATOR_FINISHED;
}
-void CLIP_OT_set_x_axis(wmOperatorType *ot)
+void CLIP_OT_set_axis(wmOperatorType *ot)
{
+ static EnumPropertyItem axis_actions[] = {
+ {0, "X", 0, "X", "Align bundle align X axis"},
+ {1, "Y", 0, "Y", "Align bundle align Y axis"},
+ {0, NULL, 0, NULL, NULL}
+ };
+
/* identifiers */
- ot->name= "Set X-axis";
- ot->description= "Set direction of scene X-axis";
- ot->idname= "CLIP_OT_set_x_axis";
+ ot->name= "Set Axis";
+ ot->description= "Set direction of scene axis";
+ ot->idname= "CLIP_OT_set_axis";
/* api callbacks */
- ot->exec= set_x_axis_exec;
+ ot->exec= set_axis_exec;
ot->poll= space_clip_frame_camera_poll;
/* flags */
ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_enum(ot->srna, "axis", axis_actions, 0, "Axis", "Axis to use to align bundle along");
}
/********************** slide marker opertaotr *********************/
More information about the Bf-blender-cvs
mailing list