[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40617] branches/soc-2011-tomato: Camera tracking integration
Sergey Sharybin
g.ulairi at gmail.com
Tue Sep 27 15:23:50 CEST 2011
Revision: 40617
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40617
Author: nazgul
Date: 2011-09-27 13:23:50 +0000 (Tue, 27 Sep 2011)
Log Message:
-----------
Camera tracking integration
===========================
- Bundles and camera path should be displayed correct
when there are several solved cameras in the same scene.
- Added option to use clip from active camera as background
in 3d viewport.
Modified Paths:
--------------
branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d.py
branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c
branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_snap.c
branches/soc-2011-tomato/source/blender/makesdna/DNA_view3d_types.h
branches/soc-2011-tomato/source/blender/makesrna/intern/rna_space.c
Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d.py 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_view3d.py 2011-09-27 13:23:50 UTC (rev 40617)
@@ -2270,16 +2270,24 @@
hasbg = True
elif bg.source == 'MOVIE':
- row = box.row()
- row.template_ID(bg, "clip", open="clip.open")
+ has_clip = False
+ box.prop(bg, 'use_camera_clip')
+ column = box.column()
+ column.active = not bg.use_camera_clip
+ column.template_ID(bg, "clip", open="clip.open")
+
if bg.clip:
- box.template_movieclip(bg, "clip", compact=True)
+ column.template_movieclip(bg, "clip", compact=True)
+
+ if bg.use_camera_clip or bg.clip:
hasbg = True
- if bg.clip.use_proxy:
- box.prop(bg.clip_user, "proxy_render_size", text="")
- box.prop(bg.clip_user, "use_render_undistorted")
+ column = box.column()
+ column.active = hasbg
+ column.prop(bg.clip_user, "proxy_render_size", text="")
+ column.prop(bg.clip_user, "use_render_undistorted")
+
if hasbg:
box.prop(bg, "opacity", slider=True)
if bg.view_axis != 'CAMERA':
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_object.h 2011-09-27 13:23:50 UTC (rev 40617)
@@ -50,6 +50,7 @@
struct bAction;
struct RenderData;
struct rctf;
+struct MovieClip;
void clear_workob(struct Object *workob);
void what_does_parent(struct Scene *scene, struct Object *ob, struct Object *workob);
@@ -149,6 +150,8 @@
void object_relink(struct Object *ob);
+struct MovieClip *object_get_movieclip(struct Scene *scene, struct Object *ob);
+
#ifdef __cplusplus
}
#endif
Modified: branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/BKE_tracking.h 2011-09-27 13:23:50 UTC (rev 40617)
@@ -41,6 +41,7 @@
struct MovieTrackingContext;
struct MovieClipUser;
struct Scene;
+struct Object;
void BKE_tracking_clamp_track(struct MovieTrackingTrack *track, int event);
void BKE_tracking_track_flag(struct MovieTrackingTrack *track, int area, int flag, int clear);
@@ -80,7 +81,7 @@
struct MovieReconstructedCamera *BKE_tracking_get_reconstructed_camera(struct MovieTracking *tracking, int framenr);
void BKE_tracking_get_interpolated_camera(struct MovieTracking *tracking, int framenr, float mat[4][4]);
-void BKE_get_tracking_mat(struct Scene *scene, float mat[4][4]);
+void BKE_get_tracking_mat(struct Scene *scene, struct Object *ob, float mat[4][4]);
void BKE_tracking_projection_matrix(struct MovieTracking *tracking, int framenr, int winx, int winy, float mat[4][4]);
void BKE_tracking_apply_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
void BKE_tracking_invert_intrinsics(struct MovieTracking *tracking, float co[2], float nco[2]);
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/constraint.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -3975,7 +3975,7 @@
copy_m4_m4(obmat, cob->matrix);
- BKE_get_tracking_mat(cob->scene, mat);
+ BKE_get_tracking_mat(cob->scene, NULL, mat);
mul_v3_m4v3(pos, mat, track->bundle_pos);
cob->matrix[3][0]+= pos[0];
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/movieclip.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -71,7 +71,6 @@
#include "BKE_moviecache.h"
#include "BKE_image.h" /* openanim */
#include "BKE_tracking.h"
-#include "BKE_animsys.h"
#include "IMB_imbuf_types.h"
#include "IMB_imbuf.h"
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/object.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -51,6 +51,7 @@
#include "DNA_material_types.h"
#include "DNA_meta_types.h"
#include "DNA_meshdata_types.h"
+#include "DNA_movieclip_types.h"
#include "DNA_scene_types.h"
#include "DNA_screen_types.h"
#include "DNA_sequence_types.h"
@@ -3286,3 +3287,26 @@
ID_NEW(ob->proxy);
ID_NEW(ob->proxy_group);
}
+
+MovieClip *object_get_movieclip(Scene *scene, Object *ob)
+{
+ MovieClip *clip= scene->clip;
+ bConstraint *con= ob->constraints.first, *scon= NULL;
+
+ while(con){
+ if(con->type==CONSTRAINT_TYPE_CAMERASOLVER){
+ if(scon==NULL || (scon->flag&CONSTRAINT_OFF))
+ scon= con;
+ }
+
+ con= con->next;
+ }
+
+ if(scon) {
+ bCameraSolverConstraint *solver= scon->data;
+ if((solver->flag&CAMERASOLVER_DEFAULTCLIP)==0)
+ clip= solver->clip;
+ }
+
+ return clip;
+}
Modified: branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c
===================================================================
--- branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/blenkernel/intern/tracking.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -1408,13 +1408,15 @@
}
}
-void BKE_get_tracking_mat(Scene *scene, float mat[4][4])
+void BKE_get_tracking_mat(Scene *scene, Object *ob, float mat[4][4])
{
- if(!scene->camera)
- scene->camera= scene_find_camera(scene);
+ if(!ob) {
+ if(!scene->camera) ob= scene->camera;
+ else ob= scene_find_camera(scene);
+ }
- if(scene->camera)
- where_is_object_mat(scene, scene->camera, mat);
+ if(ob)
+ where_is_object_mat(scene, ob, mat);
else
unit_m4(mat);
}
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-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/editors/space_clip/tracking_ops.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -1759,7 +1759,7 @@
track= track->next;
}
- BKE_get_tracking_mat(scene, mat);
+ BKE_get_tracking_mat(scene, NULL, mat);
mul_v3_m4v3(vec, mat, track->bundle_pos);
sub_v3_v3(parent->loc, vec);
@@ -1794,7 +1794,7 @@
{
float mat[4][4], vec[3], obmat[4][4];
- BKE_get_tracking_mat(scene, mat);
+ BKE_get_tracking_mat(scene, NULL, mat);
mul_v3_m4v3(vec, mat, track->bundle_pos);
if(len_v2(vec)<1e-3)
@@ -1860,7 +1860,7 @@
if(scene->camera->parent)
parent= scene->camera->parent;
- BKE_get_tracking_mat(scene, mat);
+ BKE_get_tracking_mat(scene, NULL, mat);
/* get 3 bundles to use as reference */
track= clip->tracking.tracks.first;
@@ -2025,7 +2025,7 @@
if(scene->camera->parent)
parent= scene->camera->parent;
- BKE_get_tracking_mat(scene, mat);
+ BKE_get_tracking_mat(scene, NULL, mat);
track= clip->tracking.tracks.first;
while(track) {
Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/drawobject.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -1450,7 +1450,7 @@
UI_GetThemeColor4ubv(TH_TEXT, col);
UI_GetThemeColor4ubv(TH_SELECT, scol);
- BKE_get_tracking_mat(scene, mat);
+ BKE_get_tracking_mat(scene, base->object, mat);
glEnable(GL_LIGHTING);
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
@@ -1597,14 +1597,15 @@
int i;
float drawsize;
const short is_view= (rv3d->persp==RV3D_CAMOB && ob==v3d->camera);
+ MovieClip *clip= object_get_movieclip(scene, base->object);
const float scax= 1.0f / len_v3(ob->obmat[0]);
const float scay= 1.0f / len_v3(ob->obmat[1]);
const float scaz= 1.0f / len_v3(ob->obmat[2]);
/* draw data for movie clip set as active for scene */
- if(scene->clip)
- draw_viewport_reconstruction(scene, base, v3d, scene->clip, flag);
+ if(clip)
+ draw_viewport_reconstruction(scene, base, v3d, clip, flag);
#ifdef VIEW3D_CAMERA_BORDER_HACK
if(is_view && !(G.f & G_PICKSEL)) {
Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c 2011-09-27 13:22:34 UTC (rev 40616)
+++ branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_draw.c 2011-09-27 13:23:50 UTC (rev 40617)
@@ -1487,9 +1487,16 @@
BKE_image_user_calc_frame(&bgpic->iuser, CFRA, 0);
ibuf= BKE_image_get_ibuf(ima, &bgpic->iuser);
} else {
- clip= bgpic->clip;
+ if(bgpic->flag&V3D_BGPIC_CAMERACLIP) {
+ if(!scene->camera)
+ scene->camera= scene_find_camera(scene);
+
+ clip= object_get_movieclip(scene, scene->camera);
+ } else clip= bgpic->clip;
+
if(clip==NULL)
continue;
+
BKE_movieclip_user_set_frame(&bgpic->cuser, CFRA);
ibuf= BKE_movieclip_acquire_ibuf(clip, &bgpic->cuser);
Modified: branches/soc-2011-tomato/source/blender/editors/space_view3d/view3d_select.c
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list