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