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 * Contributor(s): Tom Edwards 00019 * 00020 * ***** END GPL LICENSE BLOCK ***** 00021 */ 00022 00028 #include <stdlib.h> 00029 #include <stdio.h> 00030 #include <string.h> 00031 00032 00033 #include "RNA_define.h" 00034 #include "BKE_utildefines.h" 00035 00036 #ifdef RNA_RUNTIME 00037 00038 #include "IMB_imbuf.h" 00039 #include "IMB_imbuf_types.h" 00040 #include "DNA_scene_types.h" 00041 #include "BKE_context.h" 00042 #include "BKE_global.h" 00043 #include "RE_pipeline.h" 00044 #include "RE_shader_ext.h" 00045 00046 void save_envmap(struct EnvMap *env, bContext *C, ReportList *reports, const char* filepath, struct Scene *scene, float layout[12]) 00047 { 00048 if (scene == NULL) { 00049 scene = CTX_data_scene(C); 00050 } 00051 00052 RE_WriteEnvmapResult(reports, scene, env, filepath, scene->r.im_format.imtype, layout); 00053 } 00054 00055 void clear_envmap(struct EnvMap *env, bContext *C) 00056 { 00057 Main *bmain = CTX_data_main(C); 00058 Tex *tex; 00059 00060 BKE_free_envmapdata(env); 00061 00062 for (tex=bmain->tex.first; tex; tex=tex->id.next) 00063 if (tex->env == env) { 00064 WM_event_add_notifier(C, NC_TEXTURE|NA_EDITED, tex); 00065 break; 00066 } 00067 } 00068 00069 void texture_evaluate(struct Tex *tex, float value[3], float color_r[4]) 00070 { 00071 TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL}; 00072 multitex_ext(tex, value, NULL, NULL, 1, &texres); 00073 00074 color_r[0] = texres.tr; 00075 color_r[1] = texres.tg; 00076 color_r[2] = texres.tb; 00077 color_r[3] = texres.tin; 00078 } 00079 00080 #else 00081 00082 void RNA_api_texture(StructRNA *srna) 00083 { 00084 FunctionRNA *func; 00085 PropertyRNA *parm; 00086 00087 func= RNA_def_function(srna, "evaluate", "texture_evaluate"); 00088 RNA_def_function_ui_description(func, "Evaluate the texture at the coordinates given"); 00089 00090 parm= RNA_def_float_vector(func, "value", 3, NULL, -FLT_MAX, FLT_MAX, "", "", -1e4, 1e4); 00091 RNA_def_property_flag(parm, PROP_REQUIRED); 00092 00093 /* return location and normal */ 00094 parm= RNA_def_float_vector(func, "result", 4, NULL, -FLT_MAX, FLT_MAX, "Result", NULL, -1e4, 1e4); 00095 RNA_def_property_flag(parm, PROP_THICK_WRAP); 00096 RNA_def_function_output(func, parm); 00097 00098 } 00099 00100 void RNA_api_environment_map(StructRNA *srna) 00101 { 00102 FunctionRNA *func; 00103 PropertyRNA *parm; 00104 00105 static const float default_layout[] = { 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 }; 00106 00107 func= RNA_def_function(srna, "clear", "clear_envmap"); 00108 RNA_def_function_ui_description(func, "Discard the environment map and free it from memory"); 00109 RNA_def_function_flag(func, FUNC_USE_CONTEXT); 00110 00111 00112 func= RNA_def_function(srna,"save", "save_envmap"); 00113 RNA_def_function_ui_description(func, "Save the environment map to disc using the scene render settings"); 00114 RNA_def_function_flag(func, FUNC_USE_CONTEXT|FUNC_USE_REPORTS); 00115 00116 parm= RNA_def_string_file_name(func,"filepath","",FILE_MAX,"File path","Location of the output file"); 00117 RNA_def_property_flag(parm, PROP_REQUIRED); 00118 00119 RNA_def_pointer(func, "scene", "Scene", "", "Overrides the scene from which image parameters are taken"); 00120 00121 RNA_def_float_array(func, "layout", 12, default_layout, 0.0f, 0.0f, "File layout", 00122 "Flat array describing the X,Y position of each cube face in the " 00123 "output image, where 1 is the size of a face - order is [+Z -Z +Y -X -Y +X] " 00124 "(use -1 to skip a face)", 0.0f, 0.0f); 00125 } 00126 00127 #endif