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