[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15007] branches/harmonic-skeleton/source/ blender: Skeleton retargetting - Preliminary commit.
Martin Poirier
theeth at yahoo.com
Tue May 27 15:33:25 CEST 2008
Revision: 15007
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15007
Author: theeth
Date: 2008-05-27 15:33:24 +0200 (Tue, 27 May 2008)
Log Message:
-----------
Skeleton retargetting - Preliminary commit. Results are encouraging but nothing *that* useful yet
Smarter heuristic noise arc filtering for Reeb graph
Modified Paths:
--------------
branches/harmonic-skeleton/source/blender/include/BIF_editarmature.h
branches/harmonic-skeleton/source/blender/include/butspace.h
branches/harmonic-skeleton/source/blender/include/reeb.h
branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h
branches/harmonic-skeleton/source/blender/src/buttons_editing.c
branches/harmonic-skeleton/source/blender/src/editarmature.c
branches/harmonic-skeleton/source/blender/src/reeb.c
Added Paths:
-----------
branches/harmonic-skeleton/source/blender/src/autoarmature.c
Modified: branches/harmonic-skeleton/source/blender/include/BIF_editarmature.h
===================================================================
--- branches/harmonic-skeleton/source/blender/include/BIF_editarmature.h 2008-05-27 13:32:10 UTC (rev 15006)
+++ branches/harmonic-skeleton/source/blender/include/BIF_editarmature.h 2008-05-27 13:33:24 UTC (rev 15007)
@@ -68,6 +68,8 @@
} EditBone;
+void make_boneList(struct ListBase *list, struct ListBase *bones, EditBone *parent);
+void editbones_to_armature (struct ListBase *list, struct Object *ob);
void adduplicate_armature(void);
void addvert_armature(void);
@@ -142,6 +144,9 @@
#define BONESEL_NOSEL 0x80000000 /* Indicates a negative number */
+/* from autoarmature */
+void BIF_retargetArmature();
+
#endif
Modified: branches/harmonic-skeleton/source/blender/include/butspace.h
===================================================================
--- branches/harmonic-skeleton/source/blender/include/butspace.h 2008-05-27 13:32:10 UTC (rev 15006)
+++ branches/harmonic-skeleton/source/blender/include/butspace.h 2008-05-27 13:33:24 UTC (rev 15007)
@@ -444,7 +444,8 @@
#define B_SETMCOL_RND 2083
#define B_DRAWBWEIGHTS 2084
-#define B_GEN_SKELETON 2090
+#define B_GEN_SKELETON 2085
+#define B_RETARGET_SKELETON 2086
/* *********************** */
#define B_VGROUPBUTS 2100
Modified: branches/harmonic-skeleton/source/blender/include/reeb.h
===================================================================
--- branches/harmonic-skeleton/source/blender/include/reeb.h 2008-05-27 13:32:10 UTC (rev 15006)
+++ branches/harmonic-skeleton/source/blender/include/reeb.h 2008-05-27 13:33:24 UTC (rev 15007)
@@ -30,6 +30,7 @@
#include "DNA_listBase.h"
+struct GHash;
struct EdgeHash;
struct ReebArc;
struct ReebEdge;
@@ -55,7 +56,11 @@
int degree;
float weight;
float p[3];
- int flags;
+ int flag;
+
+ int symmetry_level;
+ int symmetry_flag;
+ float symmetry_axis[3];
} ReebNode;
typedef struct ReebEdge {
@@ -63,6 +68,7 @@
struct ReebArc *arc;
struct ReebNode *v1, *v2;
struct ReebEdge *nextEdge;
+ int flag;
} ReebEdge;
typedef struct ReebArc {
@@ -71,7 +77,13 @@
struct ReebNode *v1, *v2;
struct EmbedBucket *buckets;
int bcount;
- int flags;
+ int flag;
+
+ int symmetry_level;
+ int symmetry_flag;
+
+ struct GHash *faces;
+ float angle;
} ReebArc;
typedef struct ReebArcIterator {
@@ -87,21 +99,28 @@
int weightToHarmonic(struct EditMesh *em);
int weightFromDistance(struct EditMesh *em);
int weightFromLoc(struct EditMesh *me, int axis);
-void weightToVCol(struct EditMesh *em);
+void weightToVCol(struct EditMesh *em, int index);
+void arcToVCol(struct ReebGraph *rg, struct EditMesh *em, int index);
+void angleToVCol(EditMesh *em, int index);
void renormalizeWeight(struct EditMesh *em, float newmax);
ReebGraph * generateReebGraph(struct EditMesh *me, int subdivisions);
-void freeGraph(ReebGraph *rg);
-void exportGraph(ReebGraph *rg, int count);
+ReebGraph * newReebGraph();
#define OTHER_NODE(arc, node) ((arc->v1 == node) ? arc->v2 : arc->v1)
void initArcIterator(struct ReebArcIterator *iter, struct ReebArc *arc, struct ReebNode *head);
void initArcIterator2(struct ReebArcIterator *iter, struct ReebArc *arc, int start, int end);
+void initArcIteratorStart(struct ReebArcIterator *iter, struct ReebArc *arc, struct ReebNode *head, int start);
struct EmbedBucket * nextBucket(struct ReebArcIterator *iter);
+struct EmbedBucket * nextNBucket(ReebArcIterator *iter, int n);
+struct EmbedBucket * currentBucket(struct ReebArcIterator *iter);
+struct EmbedBucket * previousBucket(struct ReebArcIterator *iter);
+int iteratorStopped(struct ReebArcIterator *iter);
/* Filtering */
void filterNullReebGraph(ReebGraph *rg);
+int filterSmartReebGraph(ReebGraph *rg, float threshold);
int filterExternalReebGraph(ReebGraph *rg, float threshold);
int filterInternalReebGraph(ReebGraph *rg, float threshold);
@@ -121,7 +140,32 @@
int hasAdjacencyList(ReebGraph *rg);
int isGraphCyclic(ReebGraph *rg);
-/* Sanity check */
+/*------------ Symmetry handling ------------*/
+void markdownSymmetry(ReebGraph *rg);
+
+/* ReebNode symmetry flags */
+#define SYM_TOPOLOGICAL 1
+#define SYM_PHYSICAL 2
+
+/* the following two are exclusive */
+#define SYM_AXIAL 4
+#define SYM_RADIAL 8
+
+/* ReebArc symmetry flags
+ *
+ * axial symetry sides */
+#define SYM_SIDE_POSITIVE 1
+#define SYM_SIDE_NEGATIVE 2
+
+
+
+/*------------ Sanity check ------------*/
void verifyBuckets(ReebGraph *rg);
+void verifyFaces(ReebGraph *rg);
+/*********************** PUBLIC *********************************/
+ReebGraph *BIF_ReebGraphFromEditMesh(void);
+void REEB_freeGraph(ReebGraph *rg);
+void REEB_exportGraph(ReebGraph *rg, int count);
+
#endif /*REEB_H_*/
Modified: branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-05-27 13:32:10 UTC (rev 15006)
+++ branches/harmonic-skeleton/source/blender/makesdna/DNA_scene_types.h 2008-05-27 13:33:24 UTC (rev 15007)
@@ -433,6 +433,8 @@
float skgen_angle_limit;
float skgen_correlation_limit;
float skgen_symmetry_limit;
+ float skgen_retarget_angle_weight;
+ float skgen_retarget_length_weight;
short skgen_options;
char skgen_postpro;
char skgen_postpro_passes;
@@ -831,6 +833,7 @@
#define SKGEN_CUT_LENGTH 8
#define SKGEN_CUT_ANGLE 16
#define SKGEN_CUT_CORRELATION 32
+#define SKGEN_HARMONIC 64
#define SKGEN_SUB_LENGTH 0
#define SKGEN_SUB_ANGLE 1
Added: branches/harmonic-skeleton/source/blender/src/autoarmature.c
===================================================================
--- branches/harmonic-skeleton/source/blender/src/autoarmature.c (rev 0)
+++ branches/harmonic-skeleton/source/blender/src/autoarmature.c 2008-05-27 13:33:24 UTC (rev 15007)
@@ -0,0 +1,1690 @@
+/**
+ * $Id: editarmature.c 14848 2008-05-15 08:05:56Z aligorith $
+ *
+ * ***** 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.
+ *
+ * Contributor(s): Martin Poirier
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * autoarmature.c: Interface for automagically manipulating armature (retarget, created, ...)
+ */
+
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_ID.h"
+#include "DNA_armature_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "BLI_editVert.h"
+#include "BLI_ghash.h"
+
+#include "BDR_editobject.h"
+
+#include "BKE_global.h"
+#include "BKE_utildefines.h"
+
+#include "BIF_editarmature.h"
+#include "BIF_space.h"
+
+#include "PIL_time.h"
+
+#include "mydevice.h"
+#include "reeb.h" // FIX ME
+#include "blendef.h"
+
+/************ RIG RETARGET DATA STRUCTURES ***************/
+
+struct RigJoint;
+struct RigGraph;
+struct RigNode;
+struct RigArc;
+struct RigEdge;
+
+typedef struct RigGraph {
+ ListBase arcs;
+ ListBase nodes;
+ struct RigNode *head;
+
+ ReebGraph *link;
+} RigGraph;
+
+typedef struct RigNode {
+ struct RigNode *next, *prev;
+ float p[3];
+ int degree;
+ struct RigArc **arcs;
+ int flag;
+
+ int symmetry_level;
+ int symmetry_flag;
+ float symmetry_axis[3];
+
+ ReebNode *link;
+} RigNode;
+
+typedef struct RigArc {
+ struct RigArc *next, *prev;
+ RigNode *head, *tail;
+ ListBase edges;
+ float length;
+ int flag;
+
+ int symmetry_level;
+ int symmetry_flag;
+
+ int count;
+ ReebArc *link;
+} RigArc;
+
+typedef struct RigEdge {
+ struct RigEdge *next, *prev;
+ float head[3], tail[3];
+ float length;
+ float angle;
+ EditBone *bone;
+} RigEdge;
+
+/*******************************************************************************************************/
+
+static void RIG_calculateEdgeAngle(RigEdge *edge_first, RigEdge *edge_second);
+void RIG_markdownSymmetry(RigGraph *rg);
+void RIG_markdownSymmetryArc(RigArc *arc, RigNode *node, int level);
+void RIG_markdownSecondarySymmetry(RigNode *node, int depth, int level);
+
+
+/*******************************************************************************************************/
+static RigNode *RIG_otherNode(RigArc *arc, RigNode *node)
+{
+ if (arc->head == node)
+ return arc->tail;
+ else
+ return arc->head;
+}
+
+static void RIG_flagNodes(RigGraph *rg, int flag)
+{
+ RigNode *node;
+
+ for(node = rg->nodes.first; node; node = node->next)
+ {
+ node->flag = flag;
+ }
+}
+
+static void RIG_flagArcs(RigGraph *rg, int flag)
+{
+ RigArc *arc;
+
+ for(arc = rg->arcs.first; arc; arc = arc->next)
+ {
+ arc->flag = flag;
+ }
+}
+
+static void RIG_addArcToNodeAdjacencyList(RigNode *node, RigArc *arc)
+{
+ node->arcs[node->degree] = arc;
+ node->degree++;
+}
+/*********************************** EDITBONE UTILS ****************************************************/
+
+int countEditBoneChildren(ListBase *list, EditBone *parent)
+{
+ EditBone *ebone;
+ int count = 0;
+
+ for (ebone = list->first; ebone; ebone = ebone->next)
+ {
+ if (ebone->parent == parent)
+ {
+ count++;
+ }
+ }
+
+ return count;
+}
+
+EditBone* nextEditBoneChild(ListBase *list, EditBone *parent, int n)
+{
+ EditBone *ebone;
+
+ for (ebone = list->first; ebone; ebone = ebone->next)
+ {
+ if (ebone->parent == parent)
+ {
+ if (n == 0)
+ {
+ return ebone;
+ }
+ n--;
+ }
+ }
+
+ return NULL;
+}
+
+/************************************* ALLOCATORS ******************************************************/
+
+static RigGraph *newRigGraph()
+{
+ RigGraph *rg;
+ rg = MEM_callocN(sizeof(RigGraph), "rig graph");
+
+ rg->head = NULL;
+
+ return rg;
+}
+
+static RigArc *newRigArc(RigGraph *rg)
+{
+ RigArc *arc;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list