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) 2009 Blender Foundation. 00019 * All rights reserved. 00020 * 00021 * 00022 * Contributor(s): Joshua Leung, Arystanbek Dyussenov 00023 * 00024 * ***** END GPL LICENSE BLOCK ***** 00025 */ 00026 00032 #include <stdlib.h> 00033 #include <stdio.h> 00034 00035 #include "RNA_define.h" 00036 00037 #include "DNA_anim_types.h" 00038 #include "DNA_object_types.h" 00039 #include "DNA_scene_types.h" 00040 #include "BKE_utildefines.h" 00041 00042 #ifdef RNA_RUNTIME 00043 00044 #include "BKE_animsys.h" 00045 #include "BKE_depsgraph.h" 00046 #include "BKE_global.h" 00047 #include "BKE_image.h" 00048 #include "BKE_scene.h" 00049 #include "BKE_writeavi.h" 00050 00051 00052 00053 static void rna_Scene_frame_set(Scene *scene, int frame, float subframe) 00054 { 00055 scene->r.cfra= frame; 00056 scene->r.subframe= subframe; 00057 00058 CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME); 00059 scene_update_for_newframe(G.main, scene, (1<<20) - 1); 00060 00061 /* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call 00062 * scene_update_for_newframe which will loose any un-keyed changes [#24690] */ 00063 /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */ 00064 00065 /* instead just redraw the views */ 00066 WM_main_add_notifier(NC_WINDOW, NULL); 00067 } 00068 00069 static void rna_Scene_update_tagged(Scene *scene) 00070 { 00071 scene_update_tagged(G.main, scene); 00072 } 00073 00074 static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name) 00075 { 00076 if(BKE_imtype_is_movie(rd->im_format.imtype)) 00077 BKE_makeanimstring(name, rd); 00078 else 00079 BKE_makepicstring(name, rd->pic, G.main->name, (frame==INT_MIN) ? rd->cfra : frame, rd->im_format.imtype, rd->scemode & R_EXTENSION, TRUE); 00080 } 00081 00082 #ifdef WITH_COLLADA 00083 /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ 00084 #include "../../collada/collada.h" 00085 00086 static void rna_Scene_collada_export(Scene *scene, const char *filepath, int selected) 00087 { 00088 collada_export(scene, filepath, selected); 00089 } 00090 00091 #endif 00092 00093 #else 00094 00095 void RNA_api_scene(StructRNA *srna) 00096 { 00097 FunctionRNA *func; 00098 PropertyRNA *parm; 00099 00100 func= RNA_def_function(srna, "frame_set", "rna_Scene_frame_set"); 00101 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately"); 00102 parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set", MINAFRAME, MAXFRAME); 00103 RNA_def_property_flag(parm, PROP_REQUIRED); 00104 RNA_def_float(func, "subframe", 0.0, 0.0, 1.0, "", "Sub-frame time, between 0.0 and 1.0", 0.0, 1.0); 00105 00106 func= RNA_def_function(srna, "update", "rna_Scene_update_tagged"); 00107 RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators"); 00108 00109 #ifdef WITH_COLLADA 00110 /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */ 00111 func= RNA_def_function(srna, "collada_export", "rna_Scene_collada_export"); 00112 RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file"); 00113 parm= RNA_def_boolean(func, "selected", 0, "Export only selected", "Export only selected elements"); 00114 RNA_def_property_flag(parm, PROP_REQUIRED); 00115 RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */ 00116 RNA_def_function_ui_description(func, "Export to collada file"); 00117 #endif 00118 } 00119 00120 00121 void RNA_api_scene_render(StructRNA *srna) 00122 { 00123 FunctionRNA *func; 00124 PropertyRNA *parm; 00125 00126 func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path"); 00127 RNA_def_function_ui_description(func, "Return the absolute path to the filename to be written for a given frame"); 00128 RNA_def_int(func, "frame", INT_MIN, INT_MIN, INT_MAX, "", 00129 "Frame number to use, if unset the current frame will be used", MINAFRAME, MAXFRAME); 00130 parm= RNA_def_string_file_path(func, "filepath", "", FILE_MAX, "File Path", 00131 "The resulting filepath from the scenes render settings"); 00132 RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */ 00133 RNA_def_function_output(func, parm); 00134 } 00135 00136 #endif 00137