~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/blender/nodes/intern/SHD_nodes/SHD_curves.c

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2007-05-17 11:47:59 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20070517114759-yp4ybrnhp2u7pk66
Tags: 2.44-1
* New upstream release.
* Drop debian/patches/01_64bits_stupidity, not needed anymore: as of this
  version blender is 64 bits safe again. Adjust README.Debian accordingly.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * $Id: SHD_curves.c,v 1.4 2007/04/04 13:58:12 jesterking Exp $
 
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
 
 
33
/* **************** CURVE VEC  ******************** */
 
34
static bNodeSocketType sh_node_curve_vec_in[]= {
 
35
        {       SOCK_VECTOR, 1, "Vector",       0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 
36
        {       -1, 0, ""       }
 
37
};
 
38
 
 
39
static bNodeSocketType sh_node_curve_vec_out[]= {
 
40
        {       SOCK_VECTOR, 0, "Vector",       0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
 
41
        {       -1, 0, ""       }
 
42
};
 
43
 
 
44
static void node_shader_exec_curve_vec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
45
{
 
46
        float vec[3];
 
47
        
 
48
        /* stack order input:  vec */
 
49
        /* stack order output: vec */
 
50
        nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
 
51
        curvemapping_evaluate3F(node->storage, out[0]->vec, vec);
 
52
}
 
53
 
 
54
static void node_shader_init_curve_vec(bNode* node)
 
55
{
 
56
   node->storage= curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
 
57
}
 
58
 
 
59
bNodeType sh_node_curve_vec= {
 
60
        /* *next,*prev */       NULL, NULL,
 
61
        /* type code   */       SH_NODE_CURVE_VEC,
 
62
        /* name        */       "Vector Curves",
 
63
        /* width+range */       200, 140, 320,
 
64
        /* class+opts  */       NODE_CLASS_OP_VECTOR, NODE_OPTIONS,
 
65
        /* input sock  */       sh_node_curve_vec_in,
 
66
        /* output sock */       sh_node_curve_vec_out,
 
67
        /* storage     */       "CurveMapping",
 
68
        /* execfunc    */       node_shader_exec_curve_vec,
 
69
        /* butfunc     */       NULL,
 
70
        /* initfunc    */       node_shader_init_curve_vec,
 
71
        /* freestoragefunc    */        node_free_curves,
 
72
        /* copystoragefunc    */        node_copy_curves,
 
73
        /* id          */       NULL
 
74
        
 
75
};
 
76
 
 
77
/* **************** CURVE RGB  ******************** */
 
78
static bNodeSocketType sh_node_curve_rgb_in[]= {
 
79
        {       SOCK_RGBA, 1, "Color",  0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
 
80
        {       -1, 0, ""       }
 
81
};
 
82
 
 
83
static bNodeSocketType sh_node_curve_rgb_out[]= {
 
84
        {       SOCK_RGBA, 0, "Color",  0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f},
 
85
        {       -1, 0, ""       }
 
86
};
 
87
 
 
88
static void node_shader_exec_curve_rgb(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
 
89
{
 
90
        float vec[3];
 
91
        
 
92
        /* stack order input:  vec */
 
93
        /* stack order output: vec */
 
94
        nodestack_get_vec(vec, SOCK_VECTOR, in[0]);
 
95
        curvemapping_evaluateRGBF(node->storage, out[0]->vec, vec);
 
96
}
 
97
 
 
98
static void node_shader_init_curve_rgb(bNode *node)
 
99
{
 
100
   node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
 
101
}
 
102
 
 
103
bNodeType sh_node_curve_rgb= {
 
104
        /* *next,*prev */       NULL, NULL,
 
105
        /* type code   */       SH_NODE_CURVE_RGB,
 
106
        /* name        */       "RGB Curves",
 
107
        /* width+range */       200, 140, 320,
 
108
        /* class+opts  */       NODE_CLASS_OP_COLOR, NODE_OPTIONS,
 
109
        /* input sock  */       sh_node_curve_rgb_in,
 
110
        /* output sock */       sh_node_curve_rgb_out,
 
111
        /* storage     */       "CurveMapping",
 
112
        /* execfunc    */       node_shader_exec_curve_rgb,
 
113
        /* butfunc     */       NULL,
 
114
        /* initfunc    */   node_shader_init_curve_rgb,
 
115
        /* freestoragefunc    */        node_free_curves,
 
116
        /* copystoragefunc    */        node_copy_curves,
 
117
        /* id          */       NULL
 
118
};
 
119