|
Blender
V2.59
|
00001 /* 00002 * $Id: TEX_valToRgb.c 36276 2011-04-21 15:53:30Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2005 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): Robin Allen 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00035 #include "../TEX_util.h" 00036 #include "TEX_node.h" 00037 00038 /* **************** VALTORGB ******************** */ 00039 static bNodeSocketType valtorgb_in[]= { 00040 { SOCK_VALUE, 1, "Fac", 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f}, 00041 { -1, 0, "" } 00042 }; 00043 static bNodeSocketType valtorgb_out[]= { 00044 { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00045 { -1, 0, "" } 00046 }; 00047 00048 static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) 00049 { 00050 if(node->storage) { 00051 float fac = tex_input_value(in[0], p, thread); 00052 00053 do_colorband(node->storage, fac, out); 00054 } 00055 } 00056 00057 static void valtorgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) 00058 { 00059 tex_output(node, in, out[0], &valtorgb_colorfn, data); 00060 } 00061 00062 static void valtorgb_init(bNode *node) 00063 { 00064 node->storage = add_colorband(1); 00065 } 00066 00067 void register_node_type_tex_valtorgb(ListBase *lb) 00068 { 00069 static bNodeType ntype; 00070 00071 node_type_base(&ntype, TEX_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTOR, NODE_OPTIONS, 00072 valtorgb_in, valtorgb_out); 00073 node_type_size(&ntype, 240, 200, 300); 00074 node_type_init(&ntype, valtorgb_init); 00075 node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage); 00076 node_type_exec(&ntype, valtorgb_exec); 00077 00078 nodeRegisterType(lb, &ntype); 00079 } 00080 00081 /* **************** RGBTOBW ******************** */ 00082 static bNodeSocketType rgbtobw_in[]= { 00083 { SOCK_RGBA, 1, "Color", 0.5f, 0.5f, 0.5f, 1.0f, 0.0f, 1.0f}, 00084 { -1, 0, "" } 00085 }; 00086 static bNodeSocketType rgbtobw_out[]= { 00087 { SOCK_VALUE, 0, "Val", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f}, 00088 { -1, 0, "" } 00089 }; 00090 00091 00092 static void rgbtobw_valuefn(float *out, TexParams *p, bNode *UNUSED(node), bNodeStack **in, short thread) 00093 { 00094 float cin[4]; 00095 tex_input_rgba(cin, in[0], p, thread); 00096 00097 *out = cin[0] * 0.35f + cin[1] * 0.45f + cin[2] * 0.2f; 00098 } 00099 00100 static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) 00101 { 00102 tex_output(node, in, out[0], &rgbtobw_valuefn, data); 00103 } 00104 00105 void register_node_type_tex_rgbtobw(ListBase *lb) 00106 { 00107 static bNodeType ntype; 00108 00109 node_type_base(&ntype, TEX_NODE_RGBTOBW, "RGB to BW", NODE_CLASS_CONVERTOR, 0, 00110 rgbtobw_in, rgbtobw_out); 00111 node_type_size(&ntype, 80, 40, 120); 00112 node_type_exec(&ntype, rgbtobw_exec); 00113 00114 nodeRegisterType(lb, &ntype); 00115 } 00116