|
Blender
V2.59
|
00001 /* 00002 * $Id: ED_keyframing.h 36924 2011-05-26 13:38:16Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2008, Blender Foundation 00021 * This is a new part of Blender (with some old code) 00022 * 00023 * Contributor(s): Joshua Leung 00024 * 00025 * ***** END GPL LICENSE BLOCK ***** 00026 */ 00027 00032 #ifndef ED_KEYFRAMING_H 00033 #define ED_KEYFRAMING_H 00034 00035 #ifdef __cplusplus 00036 extern "C" { 00037 #endif 00038 00039 struct Main; 00040 struct ListBase; 00041 struct ID; 00042 struct Scene; 00043 00044 struct KeyingSet; 00045 00046 struct bAction; 00047 struct FCurve; 00048 struct BezTriple; 00049 00050 struct bPoseChannel; 00051 struct bConstraint; 00052 00053 struct bContext; 00054 struct wmOperatorType; 00055 struct ReportList; 00056 00057 struct PointerRNA; 00058 struct PropertyRNA; 00059 struct EnumPropertyItem; 00060 00061 #include "RNA_types.h" 00062 00063 /* ************ Keyframing Management **************** */ 00064 00065 /* Get the active settings for keyframing settings from context (specifically the given scene) 00066 * - incl_mode: include settings from keyframing mode in the result (i.e. replace only) 00067 */ 00068 short ANIM_get_keyframing_flags(struct Scene *scene, short incl_mode); 00069 00070 /* -------- */ 00071 00072 /* Get (or add relevant data to be able to do so) the Active Action for the given 00073 * Animation Data block, given an ID block where the Animation Data should reside. 00074 */ 00075 struct bAction *verify_adt_action(struct ID *id, short add); 00076 00077 /* Get (or add relevant data to be able to do so) F-Curve from the given Action. 00078 * This assumes that all the destinations are valid. 00079 */ 00080 struct FCurve *verify_fcurve(struct bAction *act, const char group[], const char rna_path[], const int array_index, short add); 00081 00082 /* -------- */ 00083 00084 /* Lesser Keyframing API call: 00085 * Use this when validation of necessary animation data isn't necessary as it already 00086 * exists, and there is a beztriple that can be directly copied into the array. 00087 */ 00088 int insert_bezt_fcurve(struct FCurve *fcu, struct BezTriple *bezt, short flag); 00089 00090 /* Main Keyframing API call: 00091 * Use this when validation of necessary animation data isn't necessary as it 00092 * already exists. It will insert a keyframe using the current value being keyframed. 00093 * Returns the index at which a keyframe was added (or -1 if failed) 00094 */ 00095 int insert_vert_fcurve(struct FCurve *fcu, float x, float y, short flag); 00096 00097 /* -------- */ 00098 00099 /* Secondary Keyframing API calls: 00100 * Use this to insert a keyframe using the current value being keyframed, in the 00101 * nominated F-Curve (no creation of animation data performed). Returns success. 00102 */ 00103 short insert_keyframe_direct(struct ReportList *reports, struct PointerRNA ptr, struct PropertyRNA *prop, struct FCurve *fcu, float cfra, short flag); 00104 00105 /* -------- */ 00106 00107 /* Main Keyframing API calls: 00108 * Use this to create any necessary animation data, and then insert a keyframe 00109 * using the current value being keyframed, in the relevant place. Returns success. 00110 */ 00111 short insert_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); 00112 00113 /* Main Keyframing API call: 00114 * Use this to delete keyframe on current frame for relevant channel. Will perform checks just in case. 00115 */ 00116 short delete_keyframe(struct ReportList *reports, struct ID *id, struct bAction *act, const char group[], const char rna_path[], int array_index, float cfra, short flag); 00117 00118 /* ************ Keying Sets ********************** */ 00119 00120 /* forward decl. for this struct which is declared a bit later... */ 00121 struct KeyingSetInfo; 00122 struct ExtensionRNA; 00123 00124 /* Polling Callback for KeyingSets */ 00125 typedef int (*cbKeyingSet_Poll)(struct KeyingSetInfo *ksi, struct bContext *C); 00126 /* Context Iterator Callback for KeyingSets */ 00127 typedef void (*cbKeyingSet_Iterator)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks); 00128 /* Property Specifier Callback for KeyingSets (called from iterators) */ 00129 typedef void (*cbKeyingSet_Generate)(struct KeyingSetInfo *ksi, struct bContext *C, struct KeyingSet *ks, struct PointerRNA *ptr); 00130 00131 00132 /* Callback info for 'Procedural' KeyingSets to use */ 00133 typedef struct KeyingSetInfo { 00134 struct KeyingSetInfo *next, *prev; 00135 00136 /* info */ 00137 /* identifier so that user can hook this up to a KeyingSet */ 00138 char name[64]; 00139 /* identifier used for class name, which KeyingSet instances reference as "Typeinfo Name" */ 00140 char idname[64]; 00141 /* keying settings */ 00142 short keyingflag; 00143 00144 /* polling callbacks */ 00145 /* callback for polling the context for whether the right data is available */ 00146 cbKeyingSet_Poll poll; 00147 00148 /* generate callbacks */ 00149 /* iterator to use to go through collections of data in context 00150 * - this callback is separate from the 'adding' stage, allowing 00151 * BuiltIn KeyingSets to be manually specified to use 00152 */ 00153 cbKeyingSet_Iterator iter; 00154 /* generator to use to add properties based on the data found by iterator */ 00155 cbKeyingSet_Generate generate; 00156 00157 /* RNA integration */ 00158 struct ExtensionRNA ext; 00159 } KeyingSetInfo; 00160 00161 /* -------- */ 00162 00163 /* Add another data source for Relative Keying Sets to be evaluated with */ 00164 void ANIM_relative_keyingset_add_source(ListBase *dsources, struct ID *id, struct StructRNA *srna, void *data); 00165 00166 00167 /* mode for modify_keyframes */ 00168 typedef enum eModifyKey_Modes { 00169 MODIFYKEY_MODE_INSERT = 0, 00170 MODIFYKEY_MODE_DELETE, 00171 } eModifyKey_Modes; 00172 00173 /* return codes for errors (with Relative KeyingSets) */ 00174 typedef enum eModifyKey_Returns { 00175 /* context info was invalid for using the Keying Set */ 00176 MODIFYKEY_INVALID_CONTEXT = -1, 00177 /* there isn't any typeinfo for generating paths from context */ 00178 MODIFYKEY_MISSING_TYPEINFO = -2, 00179 } eModifyKey_Returns; 00180 00181 /* use the specified KeyingSet to add/remove various Keyframes on the specified frame */ 00182 int ANIM_apply_keyingset(struct bContext *C, ListBase *dsources, struct bAction *act, struct KeyingSet *ks, short mode, float cfra); 00183 00184 /* -------- */ 00185 00186 /* Get the first builtin KeyingSet with the given name, which occurs after the given one (or start of list if none given) */ 00187 struct KeyingSet *ANIM_builtin_keyingset_get_named(struct KeyingSet *prevKS, const char name[]); 00188 00189 /* Find KeyingSet type info given a name */ 00190 KeyingSetInfo *ANIM_keyingset_info_find_named(const char name[]); 00191 00192 /* for RNA type registrations... */ 00193 void ANIM_keyingset_info_register(KeyingSetInfo *ksi); 00194 void ANIM_keyingset_info_unregister(struct Main *bmain, KeyingSetInfo *ksi); 00195 00196 /* cleanup on exit */ 00197 void ANIM_keyingset_infos_exit(void); 00198 00199 /* -------- */ 00200 00201 /* Get the active KeyingSet for the given scene */ 00202 struct KeyingSet *ANIM_scene_get_active_keyingset(struct Scene *scene); 00203 00204 /* Get the index of the Keying Set provided, for the given Scene */ 00205 int ANIM_scene_get_keyingset_index(struct Scene *scene, struct KeyingSet *ks); 00206 00207 /* Get Keying Set to use for Auto-Keyframing some transforms */ 00208 struct KeyingSet *ANIM_get_keyingset_for_autokeying(struct Scene *scene, const char *tranformKSName); 00209 00210 /* Create (and show) a menu containing all the Keying Sets which can be used in the current context */ 00211 void ANIM_keying_sets_menu_setup(struct bContext *C, const char title[], const char op_name[]); 00212 00213 /* Dynamically populate an enum of Keying Sets */ 00214 struct EnumPropertyItem *ANIM_keying_sets_enum_itemf(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int *free); 00215 00216 /* Check if KeyingSet can be used in the current context */ 00217 short ANIM_keyingset_context_ok_poll(struct bContext *C, struct KeyingSet *ks); 00218 00219 /* ************ Drivers ********************** */ 00220 00221 /* Flags for use by driver creation calls */ 00222 typedef enum eCreateDriverFlags { 00223 CREATEDRIVER_WITH_DEFAULT_DVAR = (1<<0), /* create drivers with a default variable for nicer UI */ 00224 } eCreateDriverFlags; 00225 00226 /* -------- */ 00227 00228 /* Returns whether there is a driver in the copy/paste buffer to paste */ 00229 short ANIM_driver_can_paste(void); 00230 00231 /* Main Driver Management API calls: 00232 * Add a new driver for the specified property on the given ID block 00233 */ 00234 short ANIM_add_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag, int type); 00235 00236 /* Main Driver Management API calls: 00237 * Remove the driver for the specified property on the given ID block (if available) 00238 */ 00239 short ANIM_remove_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag); 00240 00241 /* Main Driver Management API calls: 00242 * Make a copy of the driver for the specified property on the given ID block 00243 */ 00244 short ANIM_copy_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag); 00245 00246 /* Main Driver Management API calls: 00247 * Add a new driver for the specified property on the given ID block or replace an existing one 00248 * with the driver + driver-curve data from the buffer 00249 */ 00250 short ANIM_paste_driver(struct ReportList *reports, struct ID *id, const char rna_path[], int array_index, short flag); 00251 00252 /* ************ Auto-Keyframing ********************** */ 00253 /* Notes: 00254 * - All the defines for this (User-Pref settings and Per-Scene settings) 00255 * are defined in DNA_userdef_types.h 00256 * - Scene settings take presidence over those for userprefs, with old files 00257 * inheriting userpref settings for the scene settings 00258 * - "On/Off + Mode" are stored per Scene, but "settings" are currently stored 00259 * as userprefs 00260 */ 00261 00262 /* Auto-Keying macros for use by various tools */ 00263 /* check if auto-keyframing is enabled (per scene takes presidence) */ 00264 #define IS_AUTOKEY_ON(scene) ((scene) ? (scene->toolsettings->autokey_mode & AUTOKEY_ON) : (U.autokey_mode & AUTOKEY_ON)) 00265 /* check the mode for auto-keyframing (per scene takes presidence) */ 00266 #define IS_AUTOKEY_MODE(scene, mode) ((scene) ? (scene->toolsettings->autokey_mode == AUTOKEY_MODE_##mode) : (U.autokey_mode == AUTOKEY_MODE_##mode)) 00267 /* check if a flag is set for auto-keyframing (per scene takes presidence) */ 00268 #define IS_AUTOKEY_FLAG(scene, flag) \ 00269 ((scene)? \ 00270 ((scene->toolsettings->autokey_flag & AUTOKEY_FLAG_##flag) || (U.autokey_flag & AUTOKEY_FLAG_##flag)) \ 00271 : \ 00272 (U.autokey_flag & AUTOKEY_FLAG_##flag)) 00273 00274 /* auto-keyframing feature - checks for whether anything should be done for the current frame */ 00275 int autokeyframe_cfra_can_key(struct Scene *scene, struct ID *id); 00276 00277 /* ************ Keyframe Checking ******************** */ 00278 00279 /* Lesser Keyframe Checking API call: 00280 * - Used for the buttons to check for keyframes... 00281 */ 00282 short fcurve_frame_has_keyframe(struct FCurve *fcu, float frame, short filter); 00283 00284 /* Main Keyframe Checking API call: 00285 * Checks whether a keyframe exists for the given ID-block one the given frame. 00286 * - It is recommended to call this method over the other keyframe-checkers directly, 00287 * in case some detail of the implementation changes... 00288 * - frame: the value of this is quite often result of BKE_curframe() 00289 */ 00290 short id_frame_has_keyframe(struct ID *id, float frame, short filter); 00291 00292 /* filter flags for id_cfra_has_keyframe 00293 * 00294 * WARNING: do not alter order of these, as also stored in files 00295 * (for v3d->keyflags) 00296 */ 00297 typedef enum eAnimFilterFlags { 00298 /* general */ 00299 ANIMFILTER_KEYS_LOCAL = (1<<0), /* only include locally available anim data */ 00300 ANIMFILTER_KEYS_MUTED = (1<<1), /* include muted elements */ 00301 ANIMFILTER_KEYS_ACTIVE = (1<<2), /* only include active-subelements */ 00302 00303 /* object specific */ 00304 ANIMFILTER_KEYS_NOMAT = (1<<9), /* don't include material keyframes */ 00305 ANIMFILTER_KEYS_NOSKEY = (1<<10), /* don't include shape keys (for geometry) */ 00306 } eAnimFilterFlags; 00307 00308 #ifdef __cplusplus 00309 } 00310 #endif 00311 00312 #endif /* ED_KEYFRAMING_H */