| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * ***** BEGIN GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version.  | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * The Original Code is Copyright (C) 2011 Blender Foundation. | 
					
						
							|  |  |  |  * All rights reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Contributor(s): Blender Foundation, | 
					
						
							|  |  |  |  *                 Sergey Sharybin | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * ***** END GPL LICENSE BLOCK ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \file blender/editors/space_clip/clip_utils.c
 | 
					
						
							|  |  |  |  *  \ingroup spclip | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | #include "DNA_scene_types.h"
 | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | #include "DNA_object_types.h"   /* SELECT */
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "MEM_guardedalloc.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							|  |  |  | #include "BLI_math.h"
 | 
					
						
							|  |  |  | #include "BLI_listbase.h"
 | 
					
						
							| 
									
										
										
										
											2013-10-26 13:22:38 +00:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-26 13:22:38 +00:00
										 |  |  | #include "BKE_animsys.h"
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | #include "BKE_context.h"
 | 
					
						
							|  |  |  | #include "BKE_movieclip.h"
 | 
					
						
							|  |  |  | #include "BKE_tracking.h"
 | 
					
						
							|  |  |  | #include "BKE_depsgraph.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | #include "BIF_gl.h"
 | 
					
						
							|  |  |  | #include "BIF_glutil.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | #include "WM_api.h"
 | 
					
						
							|  |  |  | #include "WM_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "ED_screen.h"
 | 
					
						
							|  |  |  | #include "ED_clip.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "RNA_access.h"
 | 
					
						
							|  |  |  | #include "RNA_define.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | #include "UI_interface.h"
 | 
					
						
							|  |  |  | #include "UI_resources.h"
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | #include "UI_view2d.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | #include "clip_intern.h"    // own include
 | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-09 09:33:28 +00:00
										 |  |  | void clip_graph_tracking_values_iterate_track( | 
					
						
							|  |  |  |         SpaceClip *sc, MovieTrackingTrack *track, void *userdata, | 
					
						
							|  |  |  |         void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, int coord, | 
					
						
							|  |  |  |                      int scene_framenr, float val), | 
					
						
							|  |  |  |         void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), | 
					
						
							| 
									
										
										
										
											2013-10-13 22:26:29 +02:00
										 |  |  |         void (*segment_end)(void *userdata, int coord)) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-19 14:26:29 +00:00
										 |  |  | 	MovieClip *clip = ED_space_clip_get_clip(sc); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	int width, height, coord; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	BKE_movieclip_get_size(clip, &sc->user, &width, &height); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	for (coord = 0; coord < 2; coord++) { | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 		int i, prevfra = 0; | 
					
						
							|  |  |  | 		bool open = false; | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 		float prevval = 0.0f; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 		for (i = 0; i < track->markersnr; i++) { | 
					
						
							|  |  |  | 			MovieTrackingMarker *marker = &track->markers[i]; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 			float val; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 			if (marker->flag & MARKER_DISABLED) { | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 				if (open) { | 
					
						
							|  |  |  | 					if (segment_end) | 
					
						
							| 
									
										
										
										
											2013-10-13 22:26:29 +02:00
										 |  |  | 						segment_end(userdata, coord); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 					open = false; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				continue; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 			if (!open) { | 
					
						
							|  |  |  | 				if (segment_start) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 					segment_start(userdata, track, coord); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 				open = true; | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 				prevval = marker->pos[coord]; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			/* value is a pixels per frame speed */ | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 			val = (marker->pos[coord] - prevval) * ((coord == 0) ? (width) : (height)); | 
					
						
							|  |  |  | 			val /= marker->framenr - prevfra; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 17:09:35 +00:00
										 |  |  | 			if (func) { | 
					
						
							|  |  |  | 				int scene_framenr = BKE_movieclip_remap_clip_to_scene_frame(clip, marker->framenr); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				func(userdata, track, marker, coord, scene_framenr, val); | 
					
						
							|  |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 			prevval = marker->pos[coord]; | 
					
						
							|  |  |  | 			prevfra = marker->framenr; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 		if (open) { | 
					
						
							|  |  |  | 			if (segment_end) | 
					
						
							| 
									
										
										
										
											2013-10-13 22:26:29 +02:00
										 |  |  | 				segment_end(userdata, coord); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-09 09:33:28 +00:00
										 |  |  | void clip_graph_tracking_values_iterate( | 
					
						
							| 
									
										
										
										
											2013-10-15 15:21:28 +00:00
										 |  |  |         SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, | 
					
						
							| 
									
										
										
										
											2012-11-09 09:33:28 +00:00
										 |  |  |         void (*func)(void *userdata, MovieTrackingTrack *track, MovieTrackingMarker *marker, | 
					
						
							|  |  |  |                      int coord, int scene_framenr, float val), | 
					
						
							|  |  |  |         void (*segment_start)(void *userdata, MovieTrackingTrack *track, int coord), | 
					
						
							| 
									
										
										
										
											2013-10-13 22:26:29 +02:00
										 |  |  |         void (*segment_end)(void *userdata, int coord)) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-19 14:26:29 +00:00
										 |  |  | 	MovieClip *clip = ED_space_clip_get_clip(sc); | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	MovieTracking *tracking = &clip->tracking; | 
					
						
							| 
									
										
										
										
											2012-06-15 11:03:23 +00:00
										 |  |  | 	ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	MovieTrackingTrack *track; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 	for (track = tracksbase->first; track; track = track->next) { | 
					
						
							|  |  |  | 		if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (selected_only && !TRACK_SELECTED(track)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 		clip_graph_tracking_values_iterate_track(sc, track, userdata, func, segment_start, segment_end); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-15 15:21:28 +00:00
										 |  |  | void clip_graph_tracking_iterate(SpaceClip *sc, bool selected_only, bool include_hidden, void *userdata, | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  |                                  void (*func)(void *userdata, MovieTrackingMarker *marker)) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-06-19 14:26:29 +00:00
										 |  |  | 	MovieClip *clip = ED_space_clip_get_clip(sc); | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	MovieTracking *tracking = &clip->tracking; | 
					
						
							| 
									
										
										
										
											2012-06-15 11:03:23 +00:00
										 |  |  | 	ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	MovieTrackingTrack *track; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 	for (track = tracksbase->first; track; track = track->next) { | 
					
						
							|  |  |  | 		int i; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 		if (!include_hidden && (track->flag & TRACK_HIDDEN) != 0) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 		if (selected_only && !TRACK_SELECTED(track)) | 
					
						
							|  |  |  | 			continue; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 		for (i = 0; i < track->markersnr; i++) { | 
					
						
							|  |  |  | 			MovieTrackingMarker *marker = &track->markers[i]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if (marker->flag & MARKER_DISABLED) | 
					
						
							|  |  |  | 				continue; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-12 17:11:16 +00:00
										 |  |  | 			if (func) | 
					
						
							|  |  |  | 				func(userdata, marker); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | void clip_delete_track(bContext *C, MovieClip *clip, MovieTrackingTrack *track) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	MovieTracking *tracking = &clip->tracking; | 
					
						
							|  |  |  | 	MovieTrackingStabilization *stab = &tracking->stabilization; | 
					
						
							| 
									
										
										
										
											2012-06-15 11:03:23 +00:00
										 |  |  | 	MovieTrackingTrack *act_track = BKE_tracking_track_get_active(tracking); | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | 	MovieTrackingPlaneTrack *plane_track, *next_plane_track; | 
					
						
							|  |  |  | 	ListBase *tracksbase = BKE_tracking_get_active_tracks(tracking); | 
					
						
							|  |  |  | 	ListBase *plane_tracks_base = BKE_tracking_get_active_plane_tracks(tracking); | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 	bool has_bundle = false, update_stab = false; | 
					
						
							| 
									
										
										
										
											2013-10-26 13:22:38 +00:00
										 |  |  | 	char track_name_escaped[MAX_NAME], prefix[MAX_NAME * 2]; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-03 23:47:39 +00:00
										 |  |  | 	if (track == act_track) | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 		tracking->act_track = NULL; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	if (track == stab->rot_track) { | 
					
						
							|  |  |  | 		stab->rot_track = NULL; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 		update_stab = true; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* handle reconstruction display in 3d viewport */ | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	if (track->flag & TRACK_HAS_BUNDLE) | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 		has_bundle = true; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | 	/* Make sure no plane will use freed track */ | 
					
						
							|  |  |  | 	for (plane_track = plane_tracks_base->first; | 
					
						
							|  |  |  | 	     plane_track; | 
					
						
							|  |  |  | 	     plane_track = next_plane_track) | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2013-09-05 13:37:53 +00:00
										 |  |  | 		bool found = false; | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | 		int i; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		next_plane_track = plane_track->next; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		for (i = 0; i < plane_track->point_tracksnr; i++) { | 
					
						
							|  |  |  | 			if (plane_track->point_tracks[i] == track) { | 
					
						
							|  |  |  | 				found = true; | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (!found) { | 
					
						
							|  |  |  | 			continue; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		if (plane_track->point_tracksnr > 4) { | 
					
						
							|  |  |  | 			int track_index; | 
					
						
							|  |  |  | 			MovieTrackingTrack **new_point_tracks; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			new_point_tracks = MEM_mallocN(sizeof(*new_point_tracks) * plane_track->point_tracksnr, | 
					
						
							|  |  |  | 			                               "new point tracks array"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			for (i = 0, track_index = 0; i < plane_track->point_tracksnr; i++) { | 
					
						
							|  |  |  | 				if (plane_track->point_tracks[i] != track) { | 
					
						
							|  |  |  | 					new_point_tracks[track_index++] = plane_track->point_tracks[i]; | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			MEM_freeN(plane_track->point_tracks); | 
					
						
							|  |  |  | 			plane_track->point_tracks = new_point_tracks; | 
					
						
							|  |  |  | 			plane_track->point_tracksnr--; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		else { | 
					
						
							|  |  |  | 			/* Delete planes with less than 3 point tracks in it. */ | 
					
						
							|  |  |  | 			BKE_tracking_plane_track_free(plane_track); | 
					
						
							|  |  |  | 			BLI_freelinkN(plane_tracks_base, plane_track); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-26 13:22:38 +00:00
										 |  |  | 	/* Delete f-curves associated with the track (such as weight, i.e.) */ | 
					
						
							|  |  |  | 	BLI_strescape(track_name_escaped, track->name, sizeof(track_name_escaped)); | 
					
						
							|  |  |  | 	BLI_snprintf(prefix, sizeof(prefix), "tracks[\"%s\"]", track_name_escaped); | 
					
						
							|  |  |  | 	BKE_animdata_fix_paths_remove(&clip->id, prefix); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-15 11:03:23 +00:00
										 |  |  | 	BKE_tracking_track_free(track); | 
					
						
							| 
									
										
										
										
											2011-12-05 18:57:17 +00:00
										 |  |  | 	BLI_freelinkN(tracksbase, track); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-07 08:53:59 +00:00
										 |  |  | 	WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (update_stab) { | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 		tracking->stabilization.ok = FALSE; | 
					
						
							| 
									
										
										
										
											2012-05-07 08:53:59 +00:00
										 |  |  | 		WM_event_add_notifier(C, NC_MOVIECLIP | ND_DISPLAY, clip); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-03 23:15:01 +00:00
										 |  |  | 	DAG_id_tag_update(&clip->id, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-24 06:38:07 +00:00
										 |  |  | 	if (has_bundle) | 
					
						
							| 
									
										
										
										
											2012-05-07 08:53:59 +00:00
										 |  |  | 		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, NULL); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | void clip_delete_marker(bContext *C, MovieClip *clip, MovieTrackingTrack *track, | 
					
						
							|  |  |  |                         MovieTrackingMarker *marker) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	if (track->markersnr == 1) { | 
					
						
							| 
									
										
											  
											
												Merge plane track feature from tomato branch
This commit includes all the changes made for plane tracker
in tomato branch.
Movie clip editor changes:
- Artist might create a plane track out of multiple point
  tracks which belongs to the same track (minimum amount of
  point tracks is 4, maximum is not actually limited).
  When new plane track is added, it's getting "tracked"
  across all point tracks, which makes it stick to the same
  plane point tracks belong to.
- After plane track was added, it need to be manually adjusted
  in a way it covers feature one might to mask/replace.
  General transform tools (G, R, S) or sliding corners with
  a mouse could be sued for this. Plane corner which
  corresponds to left bottom image corner has got X/Y axis
  on it (red is for X axis, green for Y).
- Re-adjusting plane corners makes plane to be "re-tracked"
  for the frames sequence between current frame and next
  and previous keyframes.
- Kayframes might be removed from the plane, using Shit-X
  (Marker Delete) operator. However, currently manual
  re-adjustment or "re-track" trigger is needed.
Compositor changes:
- Added new node called Plane Track Deform.
- User selects which plane track to use (for this he need
  to select movie clip datablock, object and track names).
- Node gets an image input, which need to be warped into
  the plane.
- Node outputs:
  * Input image warped into the plane.
  * Plane, rasterized to a mask.
Masking changes:
- Mask points might be parented to a plane track, which
  makes this point deforming in a way as if it belongs
  to the tracked plane.
Some video tutorials are available:
- Coder video: http://www.youtube.com/watch?v=vISEwqNHqe4
- Artist video: https://vimeo.com/71727578
This is mine and Keir's holiday code project :)
											
										 
											2013-08-16 09:46:30 +00:00
										 |  |  | 		clip_delete_track(C, clip, track); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	else { | 
					
						
							| 
									
										
										
										
											2012-06-15 11:03:23 +00:00
										 |  |  | 		BKE_tracking_marker_delete(track, marker->framenr); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-07 08:53:59 +00:00
										 |  |  | 		WM_event_add_notifier(C, NC_MOVIECLIP | NA_EDITED, clip); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-26 22:41:40 +00:00
										 |  |  | void clip_view_center_to_point(SpaceClip *sc, float x, float y) | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | { | 
					
						
							|  |  |  | 	int width, height; | 
					
						
							|  |  |  | 	float aspx, aspy; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-26 22:41:40 +00:00
										 |  |  | 	ED_space_clip_get_size(sc, &width, &height); | 
					
						
							| 
									
										
										
										
											2012-06-20 10:28:51 +00:00
										 |  |  | 	ED_space_clip_get_aspect(sc, &aspx, &aspy); | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-03-25 23:19:21 +00:00
										 |  |  | 	sc->xof = (x - 0.5f) * width * aspx; | 
					
						
							|  |  |  | 	sc->yof = (y - 0.5f) * height * aspy; | 
					
						
							| 
									
										
										
										
											2011-10-29 07:14:31 +00:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	View2D *v2d = &ar->v2d; | 
					
						
							|  |  |  | 	float xscale, yscale; | 
					
						
							|  |  |  | 	float vec[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Draw a light green line to indicate current frame */ | 
					
						
							|  |  |  | 	vec[0] = (float)(sc->user.framenr * scene->r.framelen); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	UI_ThemeColor(TH_CFRAME); | 
					
						
							|  |  |  | 	glLineWidth(2.0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glBegin(GL_LINE_STRIP); | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | 	vec[1] = v2d->cur.ymin; | 
					
						
							|  |  |  | 	glVertex2fv(vec); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | 	vec[1] = v2d->cur.ymax; | 
					
						
							|  |  |  | 	glVertex2fv(vec); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 	glEnd(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	glLineWidth(1.0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	UI_view2d_view_orthoSpecial(ar, v2d, 1); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* because the frame number text is subject to the same scaling as the contents of the view */ | 
					
						
							|  |  |  | 	UI_view2d_getscale(v2d, &xscale, &yscale); | 
					
						
							| 
									
										
										
										
											2012-05-07 08:53:59 +00:00
										 |  |  | 	glScalef(1.0f / xscale, 1.0f, 1.0f); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-01 10:50:39 +00:00
										 |  |  | 	clip_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* restore view transform */ | 
					
						
							|  |  |  | 	glScalef(xscale, 1.0, 1.0); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void clip_draw_sfra_efra(View2D *v2d, Scene *scene) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	UI_view2d_view_ortho(v2d); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* currently clip editor supposes that editing clip length is equal to scene frame range */ | 
					
						
							|  |  |  | 	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); | 
					
						
							|  |  |  | 	glEnable(GL_BLEND); | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | 	glColor4f(0.0f, 0.0f, 0.0f, 0.4f); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-06-10 19:59:02 +00:00
										 |  |  | 	glRectf(v2d->cur.xmin, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); | 
					
						
							|  |  |  | 	glRectf((float)EFRA, v2d->cur.ymin, v2d->cur.xmax, v2d->cur.ymax); | 
					
						
							| 
									
										
										
										
											2012-04-29 12:32:26 +00:00
										 |  |  | 	glDisable(GL_BLEND); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	UI_ThemeColorShade(TH_BACK, -60); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* thin lines where the actual frames are */ | 
					
						
							|  |  |  | 	fdrawline((float)SFRA, v2d->cur.ymin, (float)SFRA, v2d->cur.ymax); | 
					
						
							|  |  |  | 	fdrawline((float)EFRA, v2d->cur.ymin, (float)EFRA, v2d->cur.ymax); | 
					
						
							|  |  |  | } |