|
Blender
V2.59
|
00001 /* 00002 * 00003 * ***** BEGIN GPL LICENSE BLOCK ***** 00004 * 00005 * This program is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License 00007 * as published by the Free Software Foundation; either version 2 00008 * of the License, or (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software Foundation, 00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 * 00019 * The Original Code is Copyright (C) 2005 Blender Foundation. 00020 * All rights reserved. 00021 * 00022 * The Original Code is: all of this file. 00023 * 00024 * Contributor(s): Robin Allen 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #include "../TEX_util.h" 00035 #include "TEX_node.h" 00036 00037 /* **************** CURVE Time ******************** */ 00038 00039 /* custom1 = sfra, custom2 = efra */ 00040 static bNodeSocketType time_outputs[]= { 00041 { SOCK_VALUE, 0, "Value", 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f }, 00042 { -1, 0, "" } 00043 }; 00044 00045 static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(in), short UNUSED(thread)) 00046 { 00047 /* stack order output: fac */ 00048 float fac= 0.0f; 00049 00050 if(node->custom1 < node->custom2) 00051 fac = (p->cfra - node->custom1)/(float)(node->custom2-node->custom1); 00052 00053 fac = curvemapping_evaluateF(node->storage, 0, fac); 00054 out[0] = CLAMPIS(fac, 0.0f, 1.0f); 00055 } 00056 00057 static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) 00058 { 00059 tex_output(node, in, out[0], &time_colorfn, data); 00060 } 00061 00062 00063 static void time_init(bNode* node) 00064 { 00065 node->custom1= 1; 00066 node->custom2= 250; 00067 node->storage= curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f); 00068 } 00069 00070 void register_node_type_tex_curve_time(ListBase *lb) 00071 { 00072 static bNodeType ntype; 00073 00074 node_type_base(&ntype, TEX_NODE_CURVE_TIME, "Time", NODE_CLASS_INPUT, NODE_OPTIONS, 00075 NULL, time_outputs); 00076 node_type_size(&ntype, 140, 100, 320); 00077 node_type_init(&ntype, time_init); 00078 node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); 00079 node_type_exec(&ntype, time_exec); 00080 00081 nodeRegisterType(lb, &ntype); 00082 } 00083 00084 /* **************** CURVE RGB ******************** */ 00085 static bNodeSocketType rgb_inputs[]= { 00086 { SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f}, 00087 { -1, 0, "" } 00088 }; 00089 00090 static bNodeSocketType rgb_outputs[]= { 00091 { SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f}, 00092 { -1, 0, "" } 00093 }; 00094 00095 static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, short thread) 00096 { 00097 float cin[4]; 00098 tex_input_rgba(cin, in[0], p, thread); 00099 00100 curvemapping_evaluateRGBF(node->storage, out, cin); 00101 out[3] = cin[3]; 00102 } 00103 00104 static void rgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) 00105 { 00106 tex_output(node, in, out[0], &rgb_colorfn, data); 00107 } 00108 00109 static void rgb_init(bNode *node) 00110 { 00111 node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f); 00112 } 00113 00114 void register_node_type_tex_curve_rgb(ListBase *lb) 00115 { 00116 static bNodeType ntype; 00117 00118 node_type_base(&ntype, TEX_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, NODE_OPTIONS, 00119 rgb_inputs, rgb_outputs); 00120 node_type_size(&ntype, 200, 140, 320); 00121 node_type_init(&ntype, rgb_init); 00122 node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves); 00123 node_type_exec(&ntype, rgb_exec); 00124 00125 nodeRegisterType(lb, &ntype); 00126 } 00127