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_scene.h"
43 #include "BKE_image.h"
44 #include "BKE_depsgraph.h"
45 #include "BKE_writeavi.h"
49 static void rna_Scene_set_frame(Scene *scene, int frame)
52 CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
53 scene_update_for_newframe(scene, (1<<20) - 1);
55 WM_main_add_notifier(NC_SCENE|ND_FRAME, scene);
58 static KeyingSet *rna_Scene_add_keying_set(Scene *sce, ReportList *reports,
59 char name[], int absolute, int insertkey_needed, int insertkey_visual)
62 short flag=0, keyingflag=0;
66 flag |= KEYINGSET_ABSOLUTE;
68 keyingflag |= INSERTKEY_NEEDED;
70 keyingflag |= INSERTKEY_MATRIX;
72 /* call the API func, and set the active keyingset index */
73 ks= BKE_keyingset_add(&sce->keyingsets, name, flag, keyingflag);
76 sce->active_keyingset= BLI_countlist(&sce->keyingsets);
80 BKE_report(reports, RPT_ERROR, "Keying Set could not be added.");
85 static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name)
87 if(BKE_imtype_is_movie(rd->imtype))
88 BKE_makeanimstring(name, rd);
90 BKE_makepicstring(name, rd->pic, (frame==INT_MIN) ? rd->cfra : frame, rd->imtype, rd->scemode & R_EXTENSION);
95 void RNA_api_scene(StructRNA *srna)
100 func= RNA_def_function(srna, "set_frame", "rna_Scene_set_frame");
101 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
102 parm= RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set.", MINAFRAME, MAXFRAME);
103 RNA_def_property_flag(parm, PROP_REQUIRED);
105 func= RNA_def_function(srna, "update", "scene_update_tagged");
106 RNA_def_function_ui_description(func, "Update data tagged to be updated from previous access to data or operators.");
109 func= RNA_def_function(srna, "add_keying_set", "rna_Scene_add_keying_set");
110 RNA_def_function_ui_description(func, "Add a new Keying Set to Scene.");
111 RNA_def_function_flag(func, FUNC_USE_REPORTS);
112 /* returns the new KeyingSet */
113 parm= RNA_def_pointer(func, "keyingset", "KeyingSet", "", "Newly created Keying Set.");
114 RNA_def_function_return(func, parm);
116 RNA_def_string(func, "name", "KeyingSet", 64, "Name", "Name of Keying Set");
118 RNA_def_boolean(func, "absolute", 1, "Absolute", "Keying Set defines specific paths/settings to be keyframed (i.e. is not reliant on context info)");
120 RNA_def_boolean(func, "insertkey_needed", 0, "Insert Keyframes - Only Needed", "Only insert keyframes where they're needed in the relevant F-Curves.");
121 RNA_def_boolean(func, "insertkey_visual", 0, "Insert Keyframes - Visual", "Insert keyframes based on 'visual transforms'.");
124 void RNA_api_scene_render(StructRNA *srna)
129 func= RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path");
130 RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately.");
131 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);
132 parm= RNA_def_string(func, "name", "", FILE_MAX, "File Name", "the resulting filename from the scenes render settings.");
133 RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
134 RNA_def_function_output(func, parm);