Welcome to mirror list, hosted at ThFree Co, Russian Federation.

COM_TrackPositionNode.cpp « nodes « compositor « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bb8cecc60adae9965a6c921757b1ef7e6d63453c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright 2012, Blender Foundation.
 *
 * 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.
 *
 * Contributor:
 *		Jeroen Bakker
 *		Monique Dewanchand
 *		Sergey Sharybin
 */

#include "COM_TrackPositionNode.h"
#include "COM_ExecutionSystem.h"
#include "COM_TrackPositionOperation.h"

extern "C" {
#  include "DNA_movieclip_types.h"

#  include "BKE_node.h"
}

TrackPositionNode::TrackPositionNode(bNode *editorNode) : Node(editorNode)
{
	/* pass */
}

void TrackPositionNode::convertToOperations(ExecutionSystem *graph, CompositorContext *context)
{
	OutputSocket *outputX = this->getOutputSocket(0);
	OutputSocket *outputY = this->getOutputSocket(1);

	bNode *editorNode = this->getbNode();
	MovieClip *clip = (MovieClip *) editorNode->id;

	NodeTrackPosData *trackpos_data = (NodeTrackPosData *) editorNode->storage;

	int frame_number;
	if (editorNode->custom1 == CMP_TRACKPOS_ABSOLUTE_FRAME) {
		frame_number = editorNode->custom2;
	}
	else {
		frame_number = context->getFramenumber();
	}

	TrackPositionOperation *operationX = new TrackPositionOperation();
	TrackPositionOperation *operationY = new TrackPositionOperation();

	operationX->setMovieClip(clip);
	operationX->setTrackingObject(trackpos_data->tracking_object);
	operationX->setTrackName(trackpos_data->track_name);
	operationX->setFramenumber(frame_number);
	operationX->setAxis(0);
	operationX->setPosition(editorNode->custom1);
	operationX->setRelativeFrame(editorNode->custom2);

	operationY->setMovieClip(clip);
	operationY->setTrackingObject(trackpos_data->tracking_object);
	operationY->setTrackName(trackpos_data->track_name);
	operationY->setFramenumber(frame_number);
	operationY->setAxis(1);
	operationY->setPosition(editorNode->custom1);
	operationY->setRelativeFrame(editorNode->custom2);

	outputX->relinkConnections(operationX->getOutputSocket());
	outputY->relinkConnections(operationY->getOutputSocket());

	graph->addOperation(operationX);
	graph->addOperation(operationY);
}