Blender  V3.3
COM_TransformNode.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2011 Blender Foundation. */
3 
4 #include "COM_TransformNode.h"
5 #include "COM_RotateOperation.h"
6 #include "COM_ScaleOperation.h"
9 
10 namespace blender::compositor {
11 
12 TransformNode::TransformNode(bNode *editor_node) : Node(editor_node)
13 {
14  /* pass */
15 }
16 
18  const CompositorContext &context) const
19 {
20  NodeInput *image_input = this->get_input_socket(0);
21  NodeInput *x_input = this->get_input_socket(1);
22  NodeInput *y_input = this->get_input_socket(2);
23  NodeInput *angle_input = this->get_input_socket(3);
24  NodeInput *scale_input = this->get_input_socket(4);
25 
26  switch (context.get_execution_model()) {
28  ScaleRelativeOperation *scale_operation = new ScaleRelativeOperation();
29  converter.add_operation(scale_operation);
30 
31  RotateOperation *rotate_operation = new RotateOperation();
32  rotate_operation->set_do_degree2_rad_conversion(false);
33  converter.add_operation(rotate_operation);
34 
35  TranslateOperation *translate_operation = new TranslateOperation();
36  converter.add_operation(translate_operation);
37 
39  sampler->set_sampler((PixelSampler)this->get_bnode()->custom1);
40  converter.add_operation(sampler);
41 
42  converter.map_input_socket(image_input, sampler->get_input_socket(0));
43  converter.add_link(sampler->get_output_socket(), scale_operation->get_input_socket(0));
44  converter.map_input_socket(scale_input, scale_operation->get_input_socket(1));
45  converter.map_input_socket(scale_input,
46  scale_operation->get_input_socket(2)); // xscale = yscale
47 
48  converter.add_link(scale_operation->get_output_socket(),
49  rotate_operation->get_input_socket(0));
50  converter.map_input_socket(angle_input, rotate_operation->get_input_socket(1));
51 
52  converter.add_link(rotate_operation->get_output_socket(),
53  translate_operation->get_input_socket(0));
54  converter.map_input_socket(x_input, translate_operation->get_input_socket(1));
55  converter.map_input_socket(y_input, translate_operation->get_input_socket(2));
56 
57  converter.map_output_socket(get_output_socket(), translate_operation->get_output_socket());
58  break;
59  }
61  ScaleRelativeOperation *scale_operation = new ScaleRelativeOperation();
62  converter.add_operation(scale_operation);
63 
64  RotateOperation *rotate_operation = new RotateOperation();
65  rotate_operation->set_do_degree2_rad_conversion(false);
66  converter.add_operation(rotate_operation);
67 
68  TranslateOperation *translate_operation = new TranslateCanvasOperation();
69  converter.add_operation(translate_operation);
70 
72  scale_operation->set_sampler(sampler);
73  rotate_operation->set_sampler(sampler);
74  scale_operation->set_scale_canvas_max_size(context.get_render_size());
75 
76  converter.map_input_socket(image_input, scale_operation->get_input_socket(0));
77  converter.map_input_socket(scale_input, scale_operation->get_input_socket(1));
78  converter.map_input_socket(scale_input,
79  scale_operation->get_input_socket(2)); // xscale = yscale
80 
81  converter.add_link(scale_operation->get_output_socket(),
82  rotate_operation->get_input_socket(0));
83  converter.map_input_socket(angle_input, rotate_operation->get_input_socket(1));
84 
85  converter.add_link(rotate_operation->get_output_socket(),
86  translate_operation->get_input_socket(0));
87  converter.map_input_socket(x_input, translate_operation->get_input_socket(1));
88  converter.map_input_socket(y_input, translate_operation->get_input_socket(2));
89 
90  converter.map_output_socket(get_output_socket(), translate_operation->get_output_socket());
91  break;
92  }
93  }
94 }
95 
96 } // namespace blender::compositor
void set_sampler(PixelSampler sampler)
Overall context of the compositor.
void add_link(NodeOperationOutput *from, NodeOperationInput *to)
void map_output_socket(NodeOutput *node_socket, NodeOperationOutput *operation_socket)
void add_operation(NodeOperation *operation)
void map_input_socket(NodeInput *node_socket, NodeOperationInput *operation_socket)
NodeInput are sockets that can receive data/input.
Definition: COM_Node.h:190
NodeOperationOutput * get_output_socket(unsigned int index=0)
NodeOperationInput * get_input_socket(unsigned int index)
NodeOutput * get_output_socket(unsigned int index=0) const
Definition: COM_Node.cc:84
bNode * get_bnode() const
get the reference to the SDNA bNode struct
Definition: COM_Node.h:64
NodeInput * get_input_socket(unsigned int index) const
Definition: COM_Node.cc:89
void set_sampler(PixelSampler sampler)
void convert_to_operations(NodeConverter &converter, const CompositorContext &context) const override
convert node to operation
depth_tx sampler(1, ImageType::FLOAT_2D, "combined_tx") .sampler(2
short custom1