- rna sequence sound was referencing unknown struct
[blender.git] / source / blender / nodes / intern / TEX_nodes / TEX_output.c
1 /**
2  *
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version. 
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  *
19  * The Original Code is Copyright (C) 2006 Blender Foundation.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 #include "../TEX_util.h"
30
31 /* **************** COMPOSITE ******************** */
32 static bNodeSocketType inputs[]= {
33         { SOCK_RGBA,   1, "Color",  0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
34         { SOCK_VECTOR, 1, "Normal", 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f},
35         { -1, 0, ""     }
36 };
37
38 /* applies to render pipeline */
39 static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
40 {
41         TexCallData *cdata = (TexCallData *)data;
42         TexResult *target = cdata->target;
43         
44         if(in[1]->hasinput && !in[0]->hasinput)
45                 tex_do_preview(node, in[1], data);
46         else
47                 tex_do_preview(node, in[0], data);
48         
49         if(!cdata->do_preview) {
50                 if(cdata->which_output == node->custom1)
51                 {
52                         tex_input_rgba(&target->tr, in[0], cdata->coord, cdata->thread);
53                 
54                         target->tin = (target->tr + target->tg + target->tb) / 3.0f;
55                         target->talpha = 1.0f;
56                 
57                         if(target->nor) {
58                                 if(in[1]->hasinput)
59                                         tex_input_vec(target->nor, in[1], cdata->coord, cdata->thread);
60                                 else
61                                         target->nor = 0;
62                         }
63                 }
64         }
65 }
66
67 static void init(bNode* node)
68 {
69    TexNodeOutput *tno = MEM_callocN(sizeof(TexNodeOutput), "TEX_output");
70    strcpy(tno->name, "Default");
71    node->storage= tno;
72 }
73
74
75 bNodeType tex_node_output= {
76         /* *next,*prev     */  NULL, NULL,
77         /* type code       */  TEX_NODE_OUTPUT,
78         /* name            */  "Output",
79         /* width+range     */  150, 60, 200,
80         /* class+opts      */  NODE_CLASS_OUTPUT, NODE_PREVIEW | NODE_OPTIONS, 
81         /* input sock      */  inputs,
82         /* output sock     */  NULL,
83         /* storage         */  "TexNodeOutput",
84         /* execfunc        */  exec,
85         /* butfunc         */  NULL,
86         /* initfunc        */  init,
87         /* freestoragefunc */  node_free_standard_storage,
88         /* copystoragefunc */  node_copy_standard_storage,  
89         /* id              */  NULL
90 };