Blender  V2.93
node_texture_translate.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2005 Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "NOD_texture.h"
25 #include "node_texture_util.h"
26 #include <math.h>
27 
29  {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f},
30  {SOCK_VECTOR, N_("Offset"), 0.0f, 0.0f, 0.0f, 0.0f, -10000.0f, 10000.0f, PROP_TRANSLATION},
31  {-1, ""},
32 };
33 
35  {SOCK_RGBA, N_("Color")},
36  {-1, ""},
37 };
38 
39 static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
40 {
41  float offset[3], new_co[3];
42  TexParams np = *p;
43  np.co = new_co;
44 
45  tex_input_vec(offset, in[1], p, thread);
46 
47  new_co[0] = p->co[0] + offset[0];
48  new_co[1] = p->co[1] + offset[1];
49  new_co[2] = p->co[2] + offset[2];
50 
51  tex_input_rgba(out, in[0], &np, thread);
52 }
53 static void exec(void *data,
54  int UNUSED(thread),
55  bNode *node,
56  bNodeExecData *execdata,
57  bNodeStack **in,
58  bNodeStack **out)
59 {
60  tex_output(node, execdata, in, out[0], &colorfn, data);
61 }
62 
64 {
65  static bNodeType ntype;
66 
69  node_type_exec(&ntype, NULL, NULL, exec);
70 
71  nodeRegisterType(&ntype);
72 }
void node_type_socket_templates(struct bNodeType *ntype, struct bNodeSocketTemplate *inputs, struct bNodeSocketTemplate *outputs)
Definition: node.cc:4527
#define NODE_CLASS_DISTORT
Definition: BKE_node.h:343
void node_type_exec(struct bNodeType *ntype, NodeInitExecFunction init_exec_fn, NodeFreeExecFunction free_exec_fn, NodeExecFunction exec_fn)
Definition: node.cc:4635
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1298
#define UNUSED(x)
#define N_(msgid)
@ SOCK_VECTOR
@ SOCK_RGBA
Group RGB to Bright Vector Camera Vector Combine Material Light Line Style Layer Add Ambient Diffuse Glossy Refraction Transparent Toon Principled Hair Volume Principled Light Particle Volume Image Sky Noise Wave Voronoi Brick Texture Vector Combine Vertex Separate Vector White RGB Map Separate Set Z Dilate Combine Combine Color Channel Split ID Combine Luminance Directional Alpha Distance Hue Movie Ellipse Bokeh View Corner Anti Mix RGB Hue TEX_NODE_TRANSLATE
@ PROP_TRANSLATION
Definition: RNA_types.h:140
OperationNode * node
static bNodeSocketTemplate outputs[]
void register_node_type_tex_translate(void)
static bNodeSocketTemplate inputs[]
static void colorfn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread)
static void exec(void *data, int UNUSED(thread), bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack **out)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_node_type_base(struct bNodeType *ntype, int type, const char *name, short nclass, short flag)
void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_output(bNode *node, bNodeExecData *execdata, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
const float * co
Compact definition of a node socket.
Definition: BKE_node.h:95
Defines a node type.
Definition: BKE_node.h:221