Initial commit. Not in build system so shouldn't interfere with anything at this...
[blender-staging.git] / source / blender / nodes / intern / SHD_nodes / SHD_output.c
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
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. 
10  *
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.
15  *
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.
19  *
20  * The Original Code is Copyright (C) 2005 Blender Foundation.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #include "../SHD_util.h"
31
32 /* **************** OUTPUT ******************** */
33 static bNodeSocketType sh_node_output_in[]= {
34         {       SOCK_RGBA, 1, "Color",          0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
35         {       SOCK_VALUE, 1, "Alpha",         1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
36         {       -1, 0, ""       }
37 };
38
39 static void node_shader_exec_output(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
40 {
41         if(data) {
42                 ShadeInput *shi= ((ShaderCallData *)data)->shi;
43                 float col[4];
44                 
45                 /* stack order input sockets: col, alpha, normal */
46                 nodestack_get_vec(col, SOCK_VECTOR, in[0]);
47                 nodestack_get_vec(col+3, SOCK_VALUE, in[1]);
48                 
49                 if(shi->do_preview) {
50                         nodeAddToPreview(node, col, shi->xs, shi->ys);
51                         node->lasty= shi->ys;
52                 }
53                 
54                 if(node->flag & NODE_DO_OUTPUT) {
55                         ShadeResult *shr= ((ShaderCallData *)data)->shr;
56                         
57                         QUATCOPY(shr->combined, col);
58                         shr->alpha= col[3];
59                         
60                         //      VECCOPY(shr->nor, in[3]->vec);
61                 }
62         }       
63 }
64
65 bNodeType sh_node_output= {
66         /* type code   */       SH_NODE_OUTPUT,
67         /* name        */       "Output",
68         /* width+range */       80, 60, 200,
69         /* class+opts  */       NODE_CLASS_OUTPUT, NODE_PREVIEW,
70         /* input sock  */       sh_node_output_in,
71         /* output sock */       NULL,
72         /* storage     */       "",
73         /* execfunc    */       node_shader_exec_output,
74    /* butfunc     */ NULL,
75                      NULL
76         
77 };
78