2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2009 Blender Foundation.
19 * All rights reserved.
22 * Contributor(s): Joshua Leung, Arystanbek Dyussenov
24 * ***** END GPL LICENSE BLOCK *****
27 /** \file blender/makesrna/intern/rna_scene_api.c
35 #include "BLI_path_util.h"
37 #include "RNA_define.h"
39 #include "DNA_anim_types.h"
40 #include "DNA_object_types.h"
41 #include "DNA_scene_types.h"
43 #include "rna_internal.h" /* own include */
47 #include "BKE_animsys.h"
48 #include "BKE_depsgraph.h"
49 #include "BKE_global.h"
50 #include "BKE_image.h"
51 #include "BKE_scene.h"
52 #include "BKE_writeavi.h"
56 static void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
58 scene->r.cfra = frame;
59 scene->r.subframe = subframe;
61 CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
62 BKE_scene_update_for_newframe(G.main, scene, (1 << 20) - 1);
63 BKE_scene_camera_switch_update(scene);
65 /* cant use NC_SCENE|ND_FRAME because this causes wm_event_do_notifiers to call
66 * BKE_scene_update_for_newframe which will loose any un-keyed changes [#24690] */
67 /* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */
69 /* instead just redraw the views */
70 WM_main_add_notifier(NC_WINDOW, NULL);
73 static void rna_Scene_update_tagged(Scene *scene)
75 BKE_scene_update_tagged(G.main, scene);
78 static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name)
80 if (BKE_imtype_is_movie(rd->im_format.imtype))
81 BKE_movie_filepath_get(name, rd);
83 BKE_makepicstring(name, rd->pic, G.main->name, (frame == INT_MIN) ? rd->cfra : frame, rd->im_format.imtype,
84 rd->scemode & R_EXTENSION, TRUE);
88 /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
89 #include "../../collada/collada.h"
91 static void rna_Scene_collada_export(
99 int include_armatures,
100 int deform_bones_only,
103 int include_uv_textures,
104 int include_material_textures,
105 int use_texture_copies,
107 int use_object_instantiation,
111 collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
112 include_children, include_armatures, deform_bones_only,
113 active_uv_only, include_uv_textures, include_material_textures,
114 use_texture_copies, use_object_instantiation, sort_by_name, second_life);
121 void RNA_api_scene(StructRNA *srna)
126 func = RNA_def_function(srna, "frame_set", "rna_Scene_frame_set");
127 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately");
128 parm = RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set", MINAFRAME, MAXFRAME);
129 RNA_def_property_flag(parm, PROP_REQUIRED);
130 RNA_def_float(func, "subframe", 0.0, 0.0, 1.0, "", "Sub-frame time, between 0.0 and 1.0", 0.0, 1.0);
132 func = RNA_def_function(srna, "update", "rna_Scene_update_tagged");
133 RNA_def_function_ui_description(func,
134 "Update data tagged to be updated from previous access to data or operators");
137 /* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
138 func = RNA_def_function(srna, "collada_export", "rna_Scene_collada_export");
139 parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file");
140 RNA_def_property_flag(parm, PROP_REQUIRED);
141 RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
142 parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers");
143 parm = RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX,
144 "Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
145 parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
146 parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)");
147 parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)");
148 parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures");
150 parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer");
151 parm = RNA_def_boolean(func, "include_uv_textures", 0, "Include UV Textures", "Export textures assigned to the object UV maps");
152 parm = RNA_def_boolean(func, "include_material_textures", 0, "Include Material Textures", "Export textures assigned to the object Materials");
153 parm = RNA_def_boolean(func, "use_texture_copies", 0, "copy", "Copy textures to same folder where the .dae file is exported");
155 parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data");
156 parm = RNA_def_boolean(func, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name");
157 parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life");
158 RNA_def_function_ui_description(func, "Export to collada file");
163 void RNA_api_scene_render(StructRNA *srna)
168 func = RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path");
169 RNA_def_function_ui_description(func, "Return the absolute path to the filename to be written for a given frame");
170 RNA_def_int(func, "frame", INT_MIN, INT_MIN, INT_MAX, "",
171 "Frame number to use, if unset the current frame will be used", MINAFRAME, MAXFRAME);
172 parm = RNA_def_string_file_path(func, "filepath", "", FILE_MAX, "File Path",
173 "The resulting filepath from the scenes render settings");
174 RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
175 RNA_def_function_output(func, parm);