4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Joshua Leung, Arystanbek Dyussenov
26 * ***** END GPL LICENSE BLOCK *****
32 #include "RNA_define.h"
34 #include "DNA_anim_types.h"
35 #include "DNA_object_types.h"
36 #include "DNA_scene_types.h"
37 #include "BKE_utildefines.h"
41 #include "BKE_animsys.h"
42 #include "BKE_depsgraph.h"
43 #include "BKE_global.h"
44 #include "BKE_image.h"
45 #include "BKE_scene.h"
46 #include "BKE_writeavi.h"
50 static void rna_Scene_set_frame(Scene *scene, int frame, float subframe)
53 scene->r.subframe= subframe;
55 CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
56 scene_update_for_newframe(G.main, scene, (1<<20) - 1);
58 WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
61 static void rna_Scene_update_tagged(Scene *scene)
63 scene_update_tagged(G.main, scene);
66 static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports,
67 char name[], int absolute, int insertkey_needed, int insertkey_visual)
70 short flag=0, keyingflag=0;
74 flag |= KEYINGSET_ABSOLUTE;
76 keyingflag |= INSERTKEY_NEEDED;
78 keyingflag |= INSERTKEY_MATRIX;
80 /* call the API func, and set the active keyingset index */
81 ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag);
84 sce->active_keyingset= BLI_countlist(&sce->keyingsets);
88 BKE_report(reports, RPT_ERROR, "Keying Set could not be added.");
93 static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name)
95 if(BKE_imtype_is_movie(rd->imtype))
96 BKE_makeanimstring(name, rd);
98 BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION);
103 void RNA_api_scene(StructRNA *srna)
108 func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
109 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
110 parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set.", MINAFRAME, MAXFRAME);
111 RNA_def_property_flag(parm, PROP_REQUIRED);
112 parm= RNA_def_float(func, "subframe", 0.0, 0.0, 1.0, "", "Sub-frame time, between 0.0 and 1.0", 0.0, 1.0);
114 func= RNA_def_function(srna, "update", "rna_Scene_update_tagged");
115 RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators.");
118 func= RNA_def_function(srna, "add_keying_set", "rna_Scene_add_keying_set");
119 RNA_def_function_ui_description(func, "Add a new Keying Set to Scene.");
120 RNA_def_function_flag(func, FUNC_USE_REPORTS);
121 /* returns the new KeyingSet */
122 parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set.");
123 RNA_def_function_return(func, parm);
125 RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
127 RNA_def_boolean(func, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
129 RNA_def_boolean(func, "use_insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves.");
130 RNA_def_boolean(func, "use_insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
133 void RNA_api_scene_render(StructRNA *srna)
138 func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path");
139 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
140 parm= 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);
141 parm= RNA_def_string(func, "name", "", FILE_MAX, "File Name", "the resulting filename from the scenes render settings.");
142 RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
143 RNA_def_function_output(func, parm);