Blender  V2.59
BIF_retarget.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BIF_retarget.h 35242 2011-02-27 20:29:51Z jesterking $
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  * ***** END GPL LICENSE BLOCK *****
00021  */
00022 
00028 #ifndef BIF_RETARGET_H
00029 #define BIF_RETARGET_H
00030 
00031 #include "DNA_listBase.h"
00032 
00033 #include "BLI_graph.h"
00034 #include "BLI_ghash.h"
00035 #include "BLI_threads.h"
00036 
00037 #include "reeb.h"
00038 
00039 struct Object;
00040 struct bArmature;
00041 struct bContext;
00042 
00043 struct EditBone;
00044 
00045 struct RigJoint;
00046 struct RigGraph;
00047 struct RigNode;
00048 struct RigArc;
00049 struct RigEdge;
00050 
00051 #define USE_THREADS
00052 
00053 typedef struct RigGraph {
00054         ListBase        arcs;
00055         ListBase        nodes;
00056 
00057         float length;
00058         
00059         FreeArc                 free_arc;
00060         FreeNode                free_node;
00061         RadialSymmetry  radial_symmetry;
00062         AxialSymmetry   axial_symmetry;
00063         /*********************************/
00064         
00065         int                     flag;
00066 
00067         ListBase        controls;
00068         ListBase*       editbones;
00069         
00070         struct RigNode *head;
00071         ReebGraph *link_mesh;
00072         
00073         
00074         struct ThreadedWorker *worker;
00075         
00076         GHash *bones_map;       /* map of editbones by name */
00077         GHash *controls_map;    /* map of rigcontrols by bone pointer */
00078         
00079         struct Object *ob;
00080 } RigGraph;
00081 
00082 typedef struct RigNode {
00083         void *next, *prev;
00084         float p[3];
00085         int flag;
00086 
00087         int degree;
00088         struct BArc **arcs;
00089 
00090         int subgraph_index;
00091 
00092         int symmetry_level;
00093         int symmetry_flag;
00094         float symmetry_axis[3];
00095         /*********************************/
00096 
00097         ReebNode *link_mesh;
00098 } RigNode;
00099 
00100 typedef struct RigArc {
00101         void *next, *prev;
00102         RigNode *head, *tail;
00103         int flag;
00104 
00105         float length;
00106 
00107         int symmetry_level;
00108         int symmetry_group;
00109         int symmetry_flag;
00110         /*********************************/
00111         
00112         ListBase edges;
00113         int count;
00114         ReebArc *link_mesh;
00115 } RigArc;
00116 
00117 typedef struct RigEdge {
00118         struct RigEdge *next, *prev;
00119         float head[3], tail[3];
00120         float length;
00121         float angle; /* angle to next edge */
00122         float up_angle; /* angle between up_axis and the joint normal (defined as Previous edge CrossProduct Current edge */
00123         struct EditBone *bone;
00124         float up_axis[3];
00125 } RigEdge;
00126 
00127 /* Graph flags */
00128 #define RIG_FREE_BONELIST               1
00129 
00130 /* Control flags */
00131 #define RIG_CTRL_HEAD_DONE              1
00132 #define RIG_CTRL_TAIL_DONE              2
00133 #define RIG_CTRL_PARENT_DEFORM  4
00134 #define RIG_CTRL_FIT_ROOT               8
00135 #define RIG_CTRL_FIT_BONE               16
00136 
00137 #define RIG_CTRL_DONE   (RIG_CTRL_HEAD_DONE|RIG_CTRL_TAIL_DONE)
00138 
00139 /* Control tail flags */
00140 typedef enum {
00141         TL_NONE = 0,
00142         TL_TAIL,
00143         TL_HEAD
00144 } LinkTailMode;
00145 
00146 typedef struct RigControl {
00147         struct RigControl *next, *prev;
00148         float head[3], tail[3];
00149         struct EditBone *bone;
00150         struct EditBone *link;
00151         struct EditBone *link_tail;
00152         float   up_axis[3];
00153         float   offset[3];
00154         float   qrot[4]; /* for dual linked bones, store the rotation of the linked bone for the finalization */
00155         int             flag;
00156         LinkTailMode tail_mode;
00157 } RigControl;
00158 
00159 void BIF_retargetArc(struct bContext *C, ReebArc *earc, RigGraph *template_rigg);
00160 RigGraph *RIG_graphFromArmature(const struct bContext *C, struct Object *ob, struct bArmature *arm);
00161 int RIG_nbJoints(RigGraph *rg);
00162 const char *RIG_nameBone(RigGraph *rg, int arc_index, int bone_index);
00163 void RIG_freeRigGraph(BGraph *rg);
00164 
00165 /* UNUSED */
00166 void BIF_retargetArmature(bContext *C);
00167 void BIF_adjustRetarget(bContext *C);
00168 /* UNUSED / print funcs */
00169 void RIG_printArc(struct RigGraph *rg, struct RigArc *arc);
00170 void RIG_printGraph(struct RigGraph *rg);
00171 void RIG_printArcBones(struct RigArc *arc);
00172 
00173 #endif /* BIF_RETARGET_H */