diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-08-25 08:05:37 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-08-25 08:05:37 +0400 |
commit | e80ac54a22214a8ecc499aa70f59bb61fcba4fa3 (patch) | |
tree | 5ac843114016951bdd8c44b404be35f67279c804 /source/blender/makesrna/intern/rna_animation_api.c | |
parent | e2eaf269350d972daec1f19ae5aa5ee7fbad4685 (diff) |
2.5 - Keying Sets API (now usable from Py-Scripts)
Wrapped the Keying Sets API with RNA Functions so that they can now be called from Py-Scripts. This will ultimately be useful for riggers to create Keying Sets which can get loaded up/created for animators to use after importing their rig.
I've created a demo for this, which can be found at:
http://www.pasteall.org/blend/552
Notes:
- Kazanbas, I've had to create a rna_scene_api.c here to hold some of the relevant functions. Hopefully this won't cause you too much pain when you do your next merge from 2.5 to your branch ;)
- I've noticed that there seem to be a few cases mentioned in the demo which don't totally work yet. I'll commit some fixes for those later.
Diffstat (limited to 'source/blender/makesrna/intern/rna_animation_api.c')
-rw-r--r-- | source/blender/makesrna/intern/rna_animation_api.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_animation_api.c b/source/blender/makesrna/intern/rna_animation_api.c new file mode 100644 index 00000000000..6af87335e02 --- /dev/null +++ b/source/blender/makesrna/intern/rna_animation_api.c @@ -0,0 +1,89 @@ +/** + * $Id: + * + * ***** 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 + * of the License, or (at your option) any later version. + * + * 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, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2009 Blender Foundation. + * All rights reserved. + * + * + * Contributor(s): Joshua Leung + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "RNA_define.h" +#include "RNA_enum_types.h" +#include "RNA_types.h" + +#include "DNA_anim_types.h" +#include "DNA_object_types.h" +#include "DNA_scene_types.h" + +#ifdef RNA_RUNTIME + +#include "BKE_animsys.h" + +static void rna_KeyingSet_add_destination(KeyingSet *keyingset, ReportList *reports, + ID *id, char rna_path[], int array_index, int entire_array, + int grouping_method, char group_name[]) +{ + short flag = 0; + + /* validate flags */ + if (entire_array) + flag |= KSP_FLAG_WHOLE_ARRAY; + + /* if data is valid, call the API function for this */ + if (keyingset) { + BKE_keyingset_add_destination(keyingset, id, group_name, rna_path, array_index, flag, grouping_method); + } + else { + BKE_report(reports, RPT_ERROR, "Keying Set Destination could not be added."); + } +} + +#else + +void RNA_api_keyingset(StructRNA *srna) +{ + FunctionRNA *func; + PropertyRNA *parm; + + /* Add Destination */ + func= RNA_def_function(srna, "add_destination", "rna_KeyingSet_add_destination"); + RNA_def_function_ui_description(func, "Add a new destination for the Keying Set."); + RNA_def_function_flag(func, FUNC_USE_REPORTS); + /* ID-block for target */ + parm= RNA_def_pointer(func, "target_id", "ID", "Target ID", "ID-Datablock for the destination."); + RNA_def_property_flag(parm, PROP_REQUIRED); + /* rna-path */ + parm= RNA_def_string(func, "rna_path", "", 256, "RNA-Path", "RNA-Path to destination property."); // xxx hopefully this is long enough + RNA_def_property_flag(parm, PROP_REQUIRED); + parm=RNA_def_int(func, "array_index", 0, 0, INT_MAX, "Array Index", "If applicable, the index ", 0, INT_MAX); + /* flags */ + parm=RNA_def_boolean(func, "entire_array", 1, "Entire Array", "When an 'array/vector' type is chosen (Location, Rotation, Color, etc.), entire array is to be used."); + /* grouping */ + parm=RNA_def_enum(func, "grouping_method", keyingset_path_grouping_items, KSP_GROUP_KSNAME, "Grouping Method", "Method used to define which Group-name to use."); + parm=RNA_def_string(func, "group_name", "", 64, "Group Name", "Name of Action Group to assign destination to (only if grouping mode is to use this name)."); +} + +#endif + |