2
* $Id: SHD_normal.c,v 1.4 2007/04/04 13:58:12 jesterking Exp $
4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software Foundation,
18
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* The Original Code is Copyright (C) 2005 Blender Foundation.
21
* All rights reserved.
23
* The Original Code is: all of this file.
25
* Contributor(s): none yet.
27
* ***** END GPL LICENSE BLOCK *****
30
#include "../SHD_util.h"
32
/* **************** NORMAL ******************** */
33
static bNodeSocketType sh_node_normal_in[]= {
34
{ SOCK_VECTOR, 1, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
38
static bNodeSocketType sh_node_normal_out[]= {
39
{ SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
40
{ SOCK_VALUE, 0, "Dot", 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
44
/* generates normal, does dot product */
45
static void node_shader_exec_normal(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
47
bNodeSocket *sock= node->outputs.first;
50
/* stack order input: normal */
51
/* stack order output: normal, value */
53
nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
55
VECCOPY(out[0]->vec, sock->ns.vec);
56
/* render normals point inside... the widget points outside */
57
out[1]->vec[0]= -INPR(out[0]->vec, vec);
60
bNodeType sh_node_normal= {
61
/* *next,*prev */ NULL, NULL,
62
/* type code */ SH_NODE_NORMAL,
64
/* width+range */ 100, 60, 200,
65
/* class+opts */ NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
66
/* input sock */ sh_node_normal_in,
67
/* output sock */ sh_node_normal_out,
69
/* execfunc */ node_shader_exec_normal,
72
/* freestoragefunc */ NULL,
73
/* copystoragefunc */ NULL,