Blender V2.61 - r43446

BKE_armature.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 #ifndef BKE_ARMATURE_H
00028 #define BKE_ARMATURE_H
00029 
00036 struct Bone;
00037 struct Main;
00038 struct bArmature;
00039 struct bPose;
00040 struct bPoseChannel;
00041 struct bConstraint;
00042 struct Scene;
00043 struct Object;
00044 struct MDeformVert;
00045 struct Mesh;
00046 struct PoseTree;
00047 struct ListBase;
00048 
00049 typedef struct PoseTarget
00050 {
00051     struct PoseTarget *next, *prev;
00052 
00053     struct bConstraint *con;        /* the constrait of this target */
00054     int tip;                        /* index of tip pchan in PoseTree */
00055 } PoseTarget;
00056 
00057 typedef struct PoseTree
00058 {
00059     struct PoseTree *next, *prev;
00060     
00061     int     type;                   /* type of IK that this serves (CONSTRAINT_TYPE_KINEMATIC or ..._SPLINEIK) */
00062     int     totchannel;             /* number of pose channels */
00063     
00064     struct ListBase targets;        /* list of targets of the tree */
00065     struct bPoseChannel **pchan;    /* array of pose channels */
00066     int     *parent;                /* and their parents */
00067     
00068     float   (*basis_change)[3][3];  /* basis change result from solver */
00069     int     iterations;             /* iterations from the constraint */
00070     int     stretch;                /* disable stretching */
00071 } PoseTree;
00072 
00073 /*  Core armature functionality */
00074 #ifdef __cplusplus
00075 extern "C" {
00076 #endif
00077 
00078 struct bArmature *add_armature(const char *name);
00079 struct bArmature *get_armature(struct Object *ob);
00080 void free_bonelist (struct ListBase *lb);
00081 void free_armature(struct bArmature *arm);
00082 void make_local_armature(struct bArmature *arm);
00083 struct bArmature *copy_armature(struct bArmature *arm);
00084 
00085 int bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail);
00086 
00087 struct Bone *get_named_bone (struct bArmature *arm, const char *name);
00088 
00089 float distfactor_to_bone (float vec[3], float b1[3], float b2[3], float rad1, float rad2, float rdist);
00090 
00091 void where_is_armature (struct bArmature *arm);
00092 void where_is_armature_bone(struct Bone *bone, struct Bone *prevbone);
00093 void armature_rebuild_pose(struct Object *ob, struct bArmature *arm);
00094 void where_is_pose (struct Scene *scene, struct Object *ob);
00095 void where_is_pose_bone(struct Scene *scene, struct Object *ob, struct bPoseChannel *pchan, float ctime, int do_extra);
00096 void where_is_pose_bone_tail(struct bPoseChannel *pchan);
00097 
00098 /* get_objectspace_bone_matrix has to be removed still */
00099 void get_objectspace_bone_matrix (struct Bone* bone, float M_accumulatedMatrix[][4], int root, int posed);
00100 void vec_roll_to_mat3(float *vec, float roll, float mat[][3]);
00101 void mat3_to_vec_roll(float mat[][3], float *vec, float *roll);
00102 
00103 int get_selected_defgroups(struct Object *ob, char *defbase_sel, int defbase_len);
00104 
00105 /* Common Conversions Between Co-ordinate Spaces */
00106 void armature_mat_world_to_pose(struct Object *ob, float inmat[][4], float outmat[][4]);
00107 void armature_loc_world_to_pose(struct Object *ob, float *inloc, float *outloc);
00108 void armature_mat_pose_to_bone(struct bPoseChannel *pchan, float inmat[][4], float outmat[][4]);
00109 void armature_loc_pose_to_bone(struct bPoseChannel *pchan, float *inloc, float *outloc);
00110 void armature_mat_pose_to_delta(float delta_mat[][4], float pose_mat[][4], float arm_mat[][4]);
00111 
00112 void pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[][3], short use_compat);
00113 void pchan_apply_mat4(struct bPoseChannel *pchan, float mat[][4], short use_comat);
00114 void pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]);
00115 void pchan_calc_mat(struct bPoseChannel *pchan);
00116 
00117 /* Rotation Mode Conversions - Used for PoseChannels + Objects... */
00118 void BKE_rotMode_change_values(float quat[4], float eul[3], float axis[3], float *angle, short oldMode, short newMode);
00119 
00120 /* B-Bone support */
00121 typedef struct Mat4 {
00122     float mat[4][4];
00123 } Mat4;
00124 
00125 Mat4 *b_bone_spline_setup(struct bPoseChannel *pchan, int rest);
00126 
00127 /* like EBONE_VISIBLE */
00128 #define PBONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
00129 #define _BONE_VISIBLE(arm, bone) (((bone)->layer & (arm)->layer) && !((bone)->flag & BONE_HIDDEN_P))
00130 
00131 #ifdef __cplusplus
00132 }
00133 #endif
00134 
00135 #endif
00136