2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-08-25 04:05:37 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2012-03-18 09:27:36 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2009-08-25 04:05:37 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-08-25 04:05:37 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2012-03-18 09:27:36 +00:00
|
|
|
*
|
2009-09-22 16:35:07 +00:00
|
|
|
* Contributor(s): Joshua Leung, Arystanbek Dyussenov
|
2009-08-25 04:05:37 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:20:01 +00:00
|
|
|
/** \file blender/makesrna/intern/rna_scene_api.c
|
|
|
|
* \ingroup RNA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2009-08-25 04:05:37 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
|
|
|
#include "DNA_anim_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
2010-01-08 13:52:38 +00:00
|
|
|
#include "BKE_utildefines.h"
|
2009-08-25 04:05:37 +00:00
|
|
|
|
2012-06-16 23:35:53 +00:00
|
|
|
|
2009-08-25 04:05:37 +00:00
|
|
|
#ifdef RNA_RUNTIME
|
|
|
|
|
|
|
|
#include "BKE_animsys.h"
|
2009-08-19 09:52:13 +00:00
|
|
|
#include "BKE_depsgraph.h"
|
2010-08-01 12:47:49 +00:00
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_scene.h"
|
2010-01-08 13:52:38 +00:00
|
|
|
#include "BKE_writeavi.h"
|
2009-08-25 04:05:37 +00:00
|
|
|
|
|
|
|
|
2009-08-19 09:52:13 +00:00
|
|
|
|
2012-04-30 12:49:26 +00:00
|
|
|
void rna_Scene_frame_set(Scene *scene, int frame, float subframe)
|
2009-07-11 11:58:50 +00:00
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
scene->r.cfra = frame;
|
|
|
|
scene->r.subframe = subframe;
|
2010-08-10 03:28:06 +00:00
|
|
|
|
2009-11-24 09:24:32 +00:00
|
|
|
CLAMP(scene->r.cfra, MINAFRAME, MAXFRAME);
|
2012-05-12 11:01:29 +00:00
|
|
|
BKE_scene_update_for_newframe(G.main, scene, (1 << 20) - 1);
|
2012-05-05 14:33:36 +00:00
|
|
|
BKE_scene_camera_switch_update(scene);
|
2009-07-11 11:58:50 +00:00
|
|
|
|
2012-03-18 09:27:36 +00:00
|
|
|
/* cant use NC_SCENE|ND_FRAME because this casues wm_event_do_notifiers to call
|
2012-05-05 14:33:36 +00:00
|
|
|
* BKE_scene_update_for_newframe which will loose any un-keyed changes [#24690] */
|
2010-11-17 17:38:56 +00:00
|
|
|
/* WM_main_add_notifier(NC_SCENE|ND_FRAME, scene); */
|
|
|
|
|
|
|
|
/* instead just redraw the views */
|
|
|
|
WM_main_add_notifier(NC_WINDOW, NULL);
|
2009-11-24 09:24:32 +00:00
|
|
|
}
|
|
|
|
|
2010-08-01 12:47:49 +00:00
|
|
|
static void rna_Scene_update_tagged(Scene *scene)
|
|
|
|
{
|
2012-05-05 14:33:36 +00:00
|
|
|
BKE_scene_update_tagged(G.main, scene);
|
2010-08-01 12:47:49 +00:00
|
|
|
}
|
|
|
|
|
2010-01-08 13:52:38 +00:00
|
|
|
static void rna_SceneRender_get_frame_path(RenderData *rd, int frame, char *name)
|
|
|
|
{
|
2012-03-05 23:30:41 +00:00
|
|
|
if (BKE_imtype_is_movie(rd->im_format.imtype))
|
2012-05-07 09:30:15 +00:00
|
|
|
BKE_movie_filepath_get(name, rd);
|
2010-01-08 13:52:38 +00:00
|
|
|
else
|
2012-03-18 09:27:36 +00:00
|
|
|
BKE_makepicstring(name, rd->pic, G.main->name, (frame == INT_MIN) ? rd->cfra : frame, rd->im_format.imtype,
|
|
|
|
rd->scemode & R_EXTENSION, TRUE);
|
2010-01-08 13:52:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-27 22:02:54 +00:00
|
|
|
#ifdef WITH_COLLADA
|
|
|
|
/* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
|
|
|
|
#include "../../collada/collada.h"
|
|
|
|
|
2012-05-24 14:56:09 +00:00
|
|
|
static void rna_Scene_collada_export(
|
|
|
|
Scene *scene,
|
2012-06-12 22:05:33 +00:00
|
|
|
const char *filepath,
|
|
|
|
int apply_modifiers,
|
2012-06-16 23:35:53 +00:00
|
|
|
int export_mesh_type,
|
2012-06-22 16:16:58 +00:00
|
|
|
|
|
|
|
int selected,
|
2012-06-12 22:05:33 +00:00
|
|
|
int include_children,
|
2012-06-15 22:00:25 +00:00
|
|
|
int include_armatures,
|
2012-06-16 09:18:00 +00:00
|
|
|
int deform_bones_only,
|
2012-06-22 16:16:58 +00:00
|
|
|
|
|
|
|
int active_uv_only,
|
|
|
|
int include_textures,
|
|
|
|
int use_texture_copies,
|
|
|
|
|
2012-06-12 22:05:33 +00:00
|
|
|
int use_object_instantiation,
|
2012-06-16 09:18:00 +00:00
|
|
|
int sort_by_name,
|
2012-06-12 22:05:33 +00:00
|
|
|
int second_life)
|
2011-03-27 22:02:54 +00:00
|
|
|
{
|
2012-06-16 23:35:53 +00:00
|
|
|
collada_export(scene, filepath, apply_modifiers, export_mesh_type, selected,
|
2012-06-22 16:16:58 +00:00
|
|
|
include_children, include_armatures, deform_bones_only,
|
|
|
|
active_uv_only, include_textures, use_texture_copies,
|
2012-06-14 10:38:39 +00:00
|
|
|
use_object_instantiation, sort_by_name, second_life);
|
2011-03-27 22:02:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2009-08-25 04:05:37 +00:00
|
|
|
#else
|
|
|
|
|
|
|
|
void RNA_api_scene(StructRNA *srna)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyRNA *parm;
|
2009-06-24 19:23:34 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "frame_set", "rna_Scene_frame_set");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Set scene frame updating all objects immediately");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_int(func, "frame", 0, MINAFRAME, MAXFRAME, "", "Frame number to set", MINAFRAME, MAXFRAME);
|
2009-07-11 11:58:50 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
2011-01-10 03:58:07 +00:00
|
|
|
RNA_def_float(func, "subframe", 0.0, 0.0, 1.0, "", "Sub-frame time, between 0.0 and 1.0", 0.0, 1.0);
|
2009-09-22 16:35:07 +00:00
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "update", "rna_Scene_update_tagged");
|
2012-03-18 09:27:36 +00:00
|
|
|
RNA_def_function_ui_description(func,
|
|
|
|
"Update data tagged to be updated from previous access to data or operators");
|
2011-03-27 22:02:54 +00:00
|
|
|
|
|
|
|
#ifdef WITH_COLLADA
|
|
|
|
/* don't remove this, as COLLADA exporting cannot be done through operators in render() callback. */
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "collada_export", "rna_Scene_collada_export");
|
|
|
|
parm = RNA_def_string(func, "filepath", "", FILE_MAX, "File Path", "File path to write Collada file");
|
2011-03-27 22:02:54 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_REQUIRED);
|
|
|
|
RNA_def_property_subtype(parm, PROP_FILEPATH); /* allow non utf8 */
|
2012-06-16 23:35:53 +00:00
|
|
|
parm = RNA_def_boolean(func, "apply_modifiers", 0, "Apply Modifiers", "Apply modifiers");
|
|
|
|
parm = RNA_def_int(func, "export_mesh_type", 0, INT_MIN, INT_MAX,
|
|
|
|
"Resolution", "Modifier resolution for export", INT_MIN, INT_MAX);
|
2012-06-15 22:00:25 +00:00
|
|
|
parm = RNA_def_boolean(func, "selected", 0, "Selection Only", "Export only selected elements");
|
|
|
|
parm = RNA_def_boolean(func, "include_children", 0, "Include Children", "Export all children of selected objects (even if not selected)");
|
|
|
|
parm = RNA_def_boolean(func, "include_armatures", 0, "Include Armatures", "Export related armatures (even if not selected)");
|
|
|
|
parm = RNA_def_boolean(func, "deform_bones_only", 0, "Deform Bones only", "Only export deforming bones with armatures");
|
2012-06-22 16:16:58 +00:00
|
|
|
|
|
|
|
parm = RNA_def_boolean(func, "active_uv_only", 0, "Active UV Layer only", "Export only the active UV Layer");
|
|
|
|
parm = RNA_def_boolean(func, "include_textures", 0, "Include Textures", "Export related textures");
|
|
|
|
parm = RNA_def_boolean(func, "use_texture_copies", 0, "copy", "Copy textures to same folder where the .dae file is exported");
|
|
|
|
|
2012-06-15 22:00:25 +00:00
|
|
|
parm = RNA_def_boolean(func, "use_object_instantiation", 1, "Use Object Instances", "Instantiate multiple Objects from same Data");
|
2012-06-14 10:38:39 +00:00
|
|
|
parm = RNA_def_boolean(func, "sort_by_name", 0, "Sort by Object name", "Sort exported data by Object name");
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_boolean(func, "second_life", 0, "Export for Second Life", "Compatibility mode for Second Life");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Export to collada file");
|
2011-03-27 22:02:54 +00:00
|
|
|
#endif
|
2009-08-25 04:05:37 +00:00
|
|
|
}
|
|
|
|
|
2011-03-27 22:02:54 +00:00
|
|
|
|
2010-01-08 13:52:38 +00:00
|
|
|
void RNA_api_scene_render(StructRNA *srna)
|
|
|
|
{
|
|
|
|
FunctionRNA *func;
|
|
|
|
PropertyRNA *parm;
|
|
|
|
|
2012-03-05 23:30:41 +00:00
|
|
|
func = RNA_def_function(srna, "frame_path", "rna_SceneRender_get_frame_path");
|
2011-09-19 13:23:58 +00:00
|
|
|
RNA_def_function_ui_description(func, "Return the absolute path to the filename to be written for a given frame");
|
|
|
|
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);
|
2012-03-05 23:30:41 +00:00
|
|
|
parm = RNA_def_string_file_path(func, "filepath", "", FILE_MAX, "File Path",
|
2012-05-12 11:01:29 +00:00
|
|
|
"The resulting filepath from the scenes render settings");
|
2010-01-08 13:52:38 +00:00
|
|
|
RNA_def_property_flag(parm, PROP_THICK_WRAP); /* needed for string return value */
|
2010-01-24 10:51:59 +00:00
|
|
|
RNA_def_function_output(func, parm);
|
2010-01-08 13:52:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-25 04:05:37 +00:00
|
|
|
#endif
|