2 * Copyright 2014, Blender Foundation.
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "COM_CornerPinNode.h"
23 #include "COM_ExecutionSystem.h"
25 #include "COM_PlaneCornerPinOperation.h"
27 CornerPinNode::CornerPinNode(bNode *editorNode) : Node(editorNode)
31 void CornerPinNode::convertToOperations(NodeConverter &converter, const CompositorContext &/*context*/) const
33 NodeInput *input_image = this->getInputSocket(0);
34 /* note: socket order differs between UI node and operations:
35 * bNode uses intuitive order following top-down layout:
36 * upper-left, upper-right, lower-left, lower-right
37 * Operations use same order as the tracking blenkernel functions expect:
38 * lower-left, lower-right, upper-right, upper-left
40 const int node_corner_index[4] = { 3, 4, 2, 1 };
42 NodeOutput *output_warped_image = this->getOutputSocket(0);
43 NodeOutput *output_plane = this->getOutputSocket(1);
45 PlaneCornerPinWarpImageOperation *warp_image_operation = new PlaneCornerPinWarpImageOperation();
46 converter.addOperation(warp_image_operation);
47 PlaneCornerPinMaskOperation *plane_mask_operation = new PlaneCornerPinMaskOperation();
48 converter.addOperation(plane_mask_operation);
50 converter.mapInputSocket(input_image, warp_image_operation->getInputSocket(0));
51 for (int i = 0; i < 4; ++i) {
52 NodeInput *corner_input = getInputSocket(node_corner_index[i]);
53 converter.mapInputSocket(corner_input, warp_image_operation->getInputSocket(i + 1));
54 converter.mapInputSocket(corner_input, plane_mask_operation->getInputSocket(i));
56 converter.mapOutputSocket(output_warped_image, warp_image_operation->getOutputSocket());
57 converter.mapOutputSocket(output_plane, plane_mask_operation->getOutputSocket());