Blender  V2.59
BKE_action.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BKE_action.h 37512 2011-06-15 14:06:25Z 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) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * Contributor(s): Full recode, Ton Roosendaal, Crete 2005
00024  *                               Full recode, Joshua Leung, 2009
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00029 #ifndef BKE_ACTION_H
00030 #define BKE_ACTION_H
00031 
00040 #include "DNA_listBase.h"
00041 
00042 /* The following structures are defined in DNA_action_types.h, and DNA_anim_types.h */
00043 struct bAction;
00044 struct bActionGroup;
00045 struct FCurve;
00046 struct bPose;
00047 struct bItasc;
00048 struct bPoseChannel;
00049 struct Object;
00050 struct Scene;
00051 struct ID;
00052 
00053 /* Kernel prototypes */
00054 #ifdef __cplusplus
00055 extern "C" {
00056 #endif
00057 
00058 /* Action Lib Stuff ----------------- */
00059 
00060 /* Allocate a new bAction with the given name */
00061 struct bAction *add_empty_action(const char name[]);
00062 
00063 /* Allocate a copy of the given Action and all its data */      
00064 struct bAction *copy_action(struct bAction *src);
00065 
00066 /* Deallocate all of the Action's data, but not the Action itself */
00067 void free_action(struct bAction *act);
00068 
00069 // XXX is this needed?
00070 void make_local_action(struct bAction *act);
00071 
00072 
00073 /* Action API ----------------- */
00074 
00075 /* types of transforms applied to the given item 
00076  *      - these are the return falgs for action_get_item_transforms()
00077  */
00078 typedef enum eAction_TransformFlags {
00079                 /* location */
00080         ACT_TRANS_LOC   = (1<<0),
00081                 /* rotation */
00082         ACT_TRANS_ROT   = (1<<1),
00083                 /* scaling */
00084         ACT_TRANS_SCALE = (1<<2),
00085         
00086                 /* strictly not a transform, but custom properties are also
00087                  * quite often used in modern rigs
00088                  */
00089         ACT_TRANS_PROP  = (1<<3),
00090                 
00091                 /* all flags */
00092         ACT_TRANS_ONLY  = (ACT_TRANS_LOC|ACT_TRANS_ROT|ACT_TRANS_SCALE),
00093         ACT_TRANS_ALL   = (ACT_TRANS_ONLY|ACT_TRANS_PROP)
00094 } eAction_TransformFlags;
00095 
00096 /* Return flags indicating which transforms the given object/posechannel has 
00097  *      - if 'curves' is provided, a list of links to these curves are also returned
00098  *        whose nodes WILL NEED FREEING
00099  */
00100 short action_get_item_transforms(struct bAction *act, struct Object *ob, struct bPoseChannel *pchan, ListBase *curves);
00101 
00102 
00103 /* Some kind of bounding box operation on the action */
00104 void calc_action_range(const struct bAction *act, float *start, float *end, short incl_modifiers);
00105 
00106 /* Does action have any motion data at all? */
00107 short action_has_motion(const struct bAction *act);
00108 
00109 /* Action Groups API ----------------- */
00110 
00111 /* Get the active action-group for an Action */
00112 struct bActionGroup *get_active_actiongroup(struct bAction *act);
00113 
00114 /* Make the given Action Group the active one */
00115 void set_active_action_group(struct bAction *act, struct bActionGroup *agrp, short select);
00116 
00117 /* Add a new action group with the given name to the action */
00118 struct bActionGroup *action_groups_add_new(struct bAction *act, const char name[]);
00119 
00120 /* Add given channel into (active) group  */
00121 void action_groups_add_channel(struct bAction *act, struct bActionGroup *agrp, struct FCurve *fcurve);
00122 
00123 /* Remove the given channel from all groups */
00124 void action_groups_remove_channel(struct bAction *act, struct FCurve *fcu);
00125 
00126 /* Find a group with the given name */
00127 struct bActionGroup *action_groups_find_named(struct bAction *act, const char name[]);
00128 
00129 /* Clear all 'temp' flags on all groups */
00130 void action_groups_clear_tempflags(struct bAction *act);
00131 
00132 /* Pose API ----------------- */        
00133         
00138 void free_pose_channel(struct bPoseChannel *pchan);
00139 
00144 void free_pose_channels(struct bPose *pose);
00145 
00150 void make_pose_channels_hash(struct bPose *pose);
00151 void free_pose_channels_hash(struct bPose *pose);
00152 
00156 void free_pose(struct bPose *pose);
00157 
00162 void copy_pose(struct bPose **dst, struct bPose *src, int copyconstraints);
00163 
00168 void duplicate_pose_channel_data(struct bPoseChannel *pchan, const struct bPoseChannel *pchan_from);
00169 
00174 struct bPoseChannel *get_pose_channel(const struct bPose *pose, const char *name);
00175 
00180 struct bPoseChannel *get_active_posechannel(struct Object *ob);
00181 
00187 struct bPoseChannel *verify_pose_channel(struct bPose* pose, const char* name);
00188 
00189 /* Copy the data from the action-pose (src) into the pose */
00190 void extract_pose_from_pose(struct bPose *pose, const struct bPose *src);
00191 
00192 /* sets constraint flags */
00193 void update_pose_constraint_flags(struct bPose *pose);
00194 
00195 /* return the name of structure pointed by pose->ikparam */
00196 const char *get_ikparam_name(struct bPose *pose);
00197 
00198 /* allocate and initialize pose->ikparam according to pose->iksolver */
00199 void init_pose_ikparam(struct bPose *pose);
00200 
00201 /* initialize a bItasc structure with default value */
00202 void init_pose_itasc(struct bItasc *itasc);
00203 
00204 /* clears BONE_UNKEYED flags for frame changing */
00205 // XXX to be depreceated for a more general solution in animsys...
00206 void framechange_poses_clear_unkeyed(void);
00207 
00208 /* Bone Groups API --------------------- */     
00209 
00210 /* Adds a new bone-group */
00211 void pose_add_group(struct Object *ob);
00212 
00213 /* Remove the active bone-group */
00214 void pose_remove_group(struct Object *ob);
00215 
00216 /* Assorted Evaluation ----------------- */     
00217 
00218 /* Used for the Action Constraint */
00219 void what_does_obaction(struct Object *ob, struct Object *workob, struct bPose *pose, struct bAction *act, char groupname[], float cframe);
00220 
00221 /* for proxy */
00222 void copy_pose_result(struct bPose *to, struct bPose *from);
00223 /* clear all transforms */
00224 void rest_pose(struct bPose *pose);
00225 
00226 #ifdef __cplusplus
00227 };
00228 #endif
00229 
00230 #endif
00231