2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2003-04-26 11:56:44 +00:00
|
|
|
* lattice.c
|
|
|
|
|
*
|
|
|
|
|
*
|
2002-10-12 11:37:38 +00:00
|
|
|
* $Id$
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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
|
2008-01-07 19:13:47 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
2008-01-07 19:13:47 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:40:57 +00:00
|
|
|
/** \file blender/blenkernel/intern/lattice.c
|
|
|
|
|
* \ingroup bke
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2009-01-06 12:30:44 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <math.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
#include "DNA_mesh_types.h"
|
2004-03-20 22:55:42 +00:00
|
|
|
#include "DNA_meshdata_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_scene_types.h"
|
2010-08-04 04:01:27 +00:00
|
|
|
#include "DNA_object_types.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "DNA_lattice_types.h"
|
|
|
|
|
#include "DNA_curve_types.h"
|
|
|
|
|
#include "DNA_key_types.h"
|
|
|
|
|
|
2010-12-13 06:31:49 +00:00
|
|
|
#include "BKE_animsys.h"
|
2004-09-14 19:03:11 +00:00
|
|
|
#include "BKE_anim.h"
|
2006-08-28 01:12:36 +00:00
|
|
|
#include "BKE_cdderivedmesh.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_displist.h"
|
2004-09-14 19:03:11 +00:00
|
|
|
#include "BKE_global.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "BKE_key.h"
|
2004-09-14 19:03:11 +00:00
|
|
|
#include "BKE_lattice.h"
|
|
|
|
|
#include "BKE_library.h"
|
|
|
|
|
#include "BKE_main.h"
|
2006-09-03 12:16:14 +00:00
|
|
|
#include "BKE_mesh.h"
|
2005-08-15 10:30:53 +00:00
|
|
|
#include "BKE_modifier.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2010-04-20 21:38:55 +00:00
|
|
|
#include "BKE_deform.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-01-01 18:16:10 +00:00
|
|
|
//XXX #include "BIF_editdeform.h"
|
2005-07-21 21:19:38 +00:00
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
void calc_lat_fudu(int flag, int res, float *fu, float *du)
|
|
|
|
|
{
|
|
|
|
|
if(res==1) {
|
|
|
|
|
*fu= 0.0;
|
|
|
|
|
*du= 0.0;
|
|
|
|
|
}
|
|
|
|
|
else if(flag & LT_GRID) {
|
|
|
|
|
*fu= -0.5f*(res-1);
|
|
|
|
|
*du= 1.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*fu= -1.0f;
|
|
|
|
|
*du= 2.0f/(res-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void resizelattice(Lattice *lt, int uNew, int vNew, int wNew, Object *ltOb)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
BPoint *bp;
|
2005-08-15 10:30:53 +00:00
|
|
|
int i, u, v, w;
|
|
|
|
|
float fu, fv, fw, uc, vc, wc, du=0.0, dv=0.0, dw=0.0;
|
|
|
|
|
float *co, (*vertexCos)[3] = NULL;
|
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
/* vertex weight groups are just freed all for now */
|
|
|
|
|
if(lt->dvert) {
|
|
|
|
|
free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
|
|
|
|
|
lt->dvert= NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
while(uNew*vNew*wNew > 32000) {
|
|
|
|
|
if( uNew>=vNew && uNew>=wNew) uNew--;
|
|
|
|
|
else if( vNew>=uNew && vNew>=wNew) vNew--;
|
|
|
|
|
else wNew--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vertexCos = MEM_mallocN(sizeof(*vertexCos)*uNew*vNew*wNew, "tmp_vcos");
|
|
|
|
|
|
|
|
|
|
calc_lat_fudu(lt->flag, uNew, &fu, &du);
|
|
|
|
|
calc_lat_fudu(lt->flag, vNew, &fv, &dv);
|
|
|
|
|
calc_lat_fudu(lt->flag, wNew, &fw, &dw);
|
|
|
|
|
|
|
|
|
|
/* If old size is different then resolution changed in interface,
|
|
|
|
|
* try to do clever reinit of points. Pretty simply idea, we just
|
|
|
|
|
* deform new verts by old lattice, but scaling them to match old
|
|
|
|
|
* size first.
|
|
|
|
|
*/
|
|
|
|
|
if (ltOb) {
|
|
|
|
|
if (uNew!=1 && lt->pntsu!=1) {
|
|
|
|
|
fu = lt->fu;
|
|
|
|
|
du = (lt->pntsu-1)*lt->du/(uNew-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (vNew!=1 && lt->pntsv!=1) {
|
|
|
|
|
fv = lt->fv;
|
|
|
|
|
dv = (lt->pntsv-1)*lt->dv/(vNew-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (wNew!=1 && lt->pntsw!=1) {
|
|
|
|
|
fw = lt->fw;
|
|
|
|
|
dw = (lt->pntsw-1)*lt->dw/(wNew-1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
co = vertexCos[0];
|
|
|
|
|
for(w=0,wc=fw; w<wNew; w++,wc+=dw) {
|
|
|
|
|
for(v=0,vc=fv; v<vNew; v++,vc+=dv) {
|
|
|
|
|
for(u=0,uc=fu; u<uNew; u++,co+=3,uc+=du) {
|
|
|
|
|
co[0] = uc;
|
|
|
|
|
co[1] = vc;
|
|
|
|
|
co[2] = wc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
if (ltOb) {
|
|
|
|
|
float mat[4][4];
|
|
|
|
|
int typeu = lt->typeu, typev = lt->typev, typew = lt->typew;
|
|
|
|
|
|
|
|
|
|
/* works best if we force to linear type (endpoints match) */
|
|
|
|
|
lt->typeu = lt->typev = lt->typew = KEY_LINEAR;
|
|
|
|
|
|
|
|
|
|
/* prevent using deformed locations */
|
|
|
|
|
freedisplist(<Ob->disp);
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(mat, ltOb->obmat);
|
|
|
|
|
unit_m4(ltOb->obmat);
|
2006-08-28 01:12:36 +00:00
|
|
|
lattice_deform_verts(ltOb, NULL, NULL, vertexCos, uNew*vNew*wNew, NULL);
|
2009-11-10 20:43:45 +00:00
|
|
|
copy_m4_m4(ltOb->obmat, mat);
|
2005-08-15 10:30:53 +00:00
|
|
|
|
|
|
|
|
lt->typeu = typeu;
|
|
|
|
|
lt->typev = typev;
|
|
|
|
|
lt->typew = typew;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lt->fu = fu;
|
|
|
|
|
lt->fv = fv;
|
|
|
|
|
lt->fw = fw;
|
|
|
|
|
lt->du = du;
|
|
|
|
|
lt->dv = dv;
|
|
|
|
|
lt->dw = dw;
|
|
|
|
|
|
|
|
|
|
lt->pntsu = uNew;
|
|
|
|
|
lt->pntsv = vNew;
|
|
|
|
|
lt->pntsw = wNew;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(lt->def);
|
|
|
|
|
lt->def= MEM_callocN(lt->pntsu*lt->pntsv*lt->pntsw*sizeof(BPoint), "lattice bp");
|
|
|
|
|
|
|
|
|
|
bp= lt->def;
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
for (i=0; i<lt->pntsu*lt->pntsv*lt->pntsw; i++,bp++) {
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_v3_v3(bp->vec, vertexCos[i]);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-08-15 10:30:53 +00:00
|
|
|
|
|
|
|
|
MEM_freeN(vertexCos);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2010-11-17 09:45:45 +00:00
|
|
|
Lattice *add_lattice(const char *name)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
Lattice *lt;
|
|
|
|
|
|
2007-03-11 16:25:17 +00:00
|
|
|
lt= alloc_libblock(&G.main->latt, ID_LT, name);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
lt->flag= LT_GRID;
|
|
|
|
|
|
|
|
|
|
lt->typeu= lt->typev= lt->typew= KEY_BSPLINE;
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
lt->def= MEM_callocN(sizeof(BPoint), "lattvert"); /* temporary */
|
|
|
|
|
resizelattice(lt, 2, 2, 2, NULL); /* creates a uniform lattice */
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
return lt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Lattice *copy_lattice(Lattice *lt)
|
|
|
|
|
{
|
|
|
|
|
Lattice *ltn;
|
|
|
|
|
|
|
|
|
|
ltn= copy_libblock(lt);
|
|
|
|
|
ltn->def= MEM_dupallocN(lt->def);
|
|
|
|
|
|
|
|
|
|
ltn->key= copy_key(ltn->key);
|
|
|
|
|
if(ltn->key) ltn->key->from= (ID *)ltn;
|
|
|
|
|
|
2006-09-03 12:16:14 +00:00
|
|
|
if(lt->dvert) {
|
|
|
|
|
int tot= lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
ltn->dvert = MEM_mallocN (sizeof (MDeformVert)*tot, "Lattice MDeformVert");
|
|
|
|
|
copy_dverts(ltn->dvert, lt->dvert, tot);
|
|
|
|
|
}
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return ltn;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void free_lattice(Lattice *lt)
|
|
|
|
|
{
|
|
|
|
|
if(lt->def) MEM_freeN(lt->def);
|
2006-09-03 12:16:14 +00:00
|
|
|
if(lt->dvert) free_dverts(lt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
|
2009-01-13 15:18:41 +00:00
|
|
|
if(lt->editlatt) {
|
2010-08-10 06:36:42 +00:00
|
|
|
Lattice *editlt= lt->editlatt->latt;
|
|
|
|
|
|
|
|
|
|
if(editlt->def) MEM_freeN(editlt->def);
|
|
|
|
|
if(editlt->dvert) free_dverts(editlt->dvert, lt->pntsu*lt->pntsv*lt->pntsw);
|
|
|
|
|
|
|
|
|
|
MEM_freeN(editlt);
|
2009-01-13 15:18:41 +00:00
|
|
|
MEM_freeN(lt->editlatt);
|
|
|
|
|
}
|
2010-12-13 06:31:49 +00:00
|
|
|
|
|
|
|
|
/* free animation data */
|
|
|
|
|
if (lt->adt) {
|
|
|
|
|
BKE_free_animdata(<->id);
|
|
|
|
|
lt->adt= NULL;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void make_local_lattice(Lattice *lt)
|
|
|
|
|
{
|
|
|
|
|
Object *ob;
|
|
|
|
|
Lattice *ltn;
|
|
|
|
|
int local=0, lib=0;
|
2003-04-26 11:56:44 +00:00
|
|
|
|
|
|
|
|
/* - only lib users: do nothing
|
|
|
|
|
* - only local users: set flag
|
|
|
|
|
* - mixed: make copy
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if(lt->id.lib==NULL) return;
|
2002-10-12 11:37:38 +00:00
|
|
|
if(lt->id.us==1) {
|
2011-02-13 10:52:18 +00:00
|
|
|
lt->id.lib= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
lt->id.flag= LIB_LOCAL;
|
2011-02-13 10:52:18 +00:00
|
|
|
new_id(NULL, (ID *)lt, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ob= G.main->object.first;
|
|
|
|
|
while(ob) {
|
|
|
|
|
if(ob->data==lt) {
|
|
|
|
|
if(ob->id.lib) lib= 1;
|
|
|
|
|
else local= 1;
|
|
|
|
|
}
|
|
|
|
|
ob= ob->id.next;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(local && lib==0) {
|
2011-02-13 10:52:18 +00:00
|
|
|
lt->id.lib= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
lt->id.flag= LIB_LOCAL;
|
2011-02-13 10:52:18 +00:00
|
|
|
new_id(NULL, (ID *)lt, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else if(local && lib) {
|
|
|
|
|
ltn= copy_lattice(lt);
|
|
|
|
|
ltn->id.us= 0;
|
|
|
|
|
|
|
|
|
|
ob= G.main->object.first;
|
|
|
|
|
while(ob) {
|
|
|
|
|
if(ob->data==lt) {
|
|
|
|
|
|
2011-02-13 10:52:18 +00:00
|
|
|
if(ob->id.lib==NULL) {
|
2002-10-12 11:37:38 +00:00
|
|
|
ob->data= ltn;
|
|
|
|
|
ltn->id.us++;
|
|
|
|
|
lt->id.us--;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ob= ob->id.next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void init_latt_deform(Object *oblatt, Object *ob)
|
|
|
|
|
{
|
2005-08-15 10:30:53 +00:00
|
|
|
/* we make an array with all differences */
|
2009-01-02 19:10:35 +00:00
|
|
|
Lattice *lt= oblatt->data;
|
|
|
|
|
BPoint *bp;
|
2005-08-15 10:30:53 +00:00
|
|
|
DispList *dl = find_displist(&oblatt->disp, DL_VERTS);
|
|
|
|
|
float *co = dl?dl->verts:NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
float *fp, imat[4][4];
|
2005-08-15 10:30:53 +00:00
|
|
|
float fu, fv, fw;
|
2002-10-12 11:37:38 +00:00
|
|
|
int u, v, w;
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2010-08-10 06:36:42 +00:00
|
|
|
if(lt->editlatt) lt= lt->editlatt->latt;
|
2009-01-02 19:10:35 +00:00
|
|
|
bp = lt->def;
|
|
|
|
|
|
2009-01-07 16:05:55 +00:00
|
|
|
fp= lt->latticedata= MEM_mallocN(sizeof(float)*3*lt->pntsu*lt->pntsv*lt->pntsw, "latticedata");
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
/* for example with a particle system: ob==0 */
|
2009-01-07 16:05:55 +00:00
|
|
|
if(ob==NULL) {
|
2003-04-26 11:56:44 +00:00
|
|
|
/* in deformspace, calc matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(lt->latmat, oblatt->obmat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* back: put in deform array */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, lt->latmat);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2003-04-26 11:56:44 +00:00
|
|
|
/* in deformspace, calc matrix */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, oblatt->obmat);
|
|
|
|
|
mul_m4_m4m4(lt->latmat, ob->obmat, imat);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* back: put in deform array */
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(imat, lt->latmat);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
for(w=0,fw=lt->fw; w<lt->pntsw; w++,fw+=lt->dw) {
|
|
|
|
|
for(v=0,fv=lt->fv; v<lt->pntsv; v++, fv+=lt->dv) {
|
|
|
|
|
for(u=0,fu=lt->fu; u<lt->pntsu; u++, bp++, co+=3, fp+=3, fu+=lt->du) {
|
|
|
|
|
if (dl) {
|
|
|
|
|
fp[0] = co[0] - fu;
|
|
|
|
|
fp[1] = co[1] - fv;
|
|
|
|
|
fp[2] = co[2] - fw;
|
|
|
|
|
} else {
|
|
|
|
|
fp[0] = bp->vec[0] - fu;
|
|
|
|
|
fp[1] = bp->vec[1] - fv;
|
|
|
|
|
fp[2] = bp->vec[2] - fw;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_mat3_m4_v3(imat, fp);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-07 16:05:55 +00:00
|
|
|
void calc_latt_deform(Object *ob, float *co, float weight)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-01-07 16:05:55 +00:00
|
|
|
Lattice *lt= ob->data;
|
2005-08-15 10:30:53 +00:00
|
|
|
float u, v, w, tu[4], tv[4], tw[4];
|
2010-04-20 21:38:55 +00:00
|
|
|
float vec[3];
|
|
|
|
|
int idx_w, idx_v, idx_u;
|
2003-02-13 16:56:42 +00:00
|
|
|
int ui, vi, wi, uu, vv, ww;
|
2010-04-20 21:38:55 +00:00
|
|
|
|
|
|
|
|
/* vgroup influence */
|
|
|
|
|
int defgroup_nr= -1;
|
|
|
|
|
float co_prev[3], weight_blend= 0.0f;
|
|
|
|
|
MDeformVert *dvert= lattice_get_deform_verts(ob);
|
|
|
|
|
|
|
|
|
|
|
2010-08-10 06:36:42 +00:00
|
|
|
if(lt->editlatt) lt= lt->editlatt->latt;
|
2009-01-07 16:05:55 +00:00
|
|
|
if(lt->latticedata==NULL) return;
|
2010-04-20 21:38:55 +00:00
|
|
|
|
|
|
|
|
if(lt->vgroup[0] && dvert) {
|
|
|
|
|
defgroup_nr= defgroup_name_index(ob, lt->vgroup);
|
|
|
|
|
copy_v3_v3(co_prev, co);
|
|
|
|
|
}
|
|
|
|
|
|
2003-04-26 11:56:44 +00:00
|
|
|
/* co is in local coords, treat with latmat */
|
2010-04-20 21:38:55 +00:00
|
|
|
mul_v3_m4v3(vec, lt->latmat, co);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/* u v w coords */
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(lt->pntsu>1) {
|
2005-08-15 10:30:53 +00:00
|
|
|
u= (vec[0]-lt->fu)/lt->du;
|
2002-10-12 11:37:38 +00:00
|
|
|
ui= (int)floor(u);
|
|
|
|
|
u -= ui;
|
2009-09-09 18:09:03 +00:00
|
|
|
key_curve_position_weights(u, tu, lt->typeu);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tu[0]= tu[2]= tu[3]= 0.0; tu[1]= 1.0;
|
|
|
|
|
ui= 0;
|
|
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(lt->pntsv>1) {
|
2005-08-15 10:30:53 +00:00
|
|
|
v= (vec[1]-lt->fv)/lt->dv;
|
2002-10-12 11:37:38 +00:00
|
|
|
vi= (int)floor(v);
|
|
|
|
|
v -= vi;
|
2009-09-09 18:09:03 +00:00
|
|
|
key_curve_position_weights(v, tv, lt->typev);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tv[0]= tv[2]= tv[3]= 0.0; tv[1]= 1.0;
|
|
|
|
|
vi= 0;
|
|
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
if(lt->pntsw>1) {
|
2005-08-15 10:30:53 +00:00
|
|
|
w= (vec[2]-lt->fw)/lt->dw;
|
2002-10-12 11:37:38 +00:00
|
|
|
wi= (int)floor(w);
|
|
|
|
|
w -= wi;
|
2009-09-09 18:09:03 +00:00
|
|
|
key_curve_position_weights(w, tw, lt->typew);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
tw[0]= tw[2]= tw[3]= 0.0; tw[1]= 1.0;
|
|
|
|
|
wi= 0;
|
|
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2003-02-13 16:56:42 +00:00
|
|
|
for(ww= wi-1; ww<=wi+2; ww++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
w= tw[ww-wi+1];
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2011-03-27 17:22:04 +00:00
|
|
|
if(w != 0.0f) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(ww>0) {
|
2010-04-20 21:38:55 +00:00
|
|
|
if(ww<lt->pntsw) idx_w= ww*lt->pntsu*lt->pntsv;
|
|
|
|
|
else idx_w= (lt->pntsw-1)*lt->pntsu*lt->pntsv;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
else idx_w= 0;
|
|
|
|
|
|
2003-02-13 16:56:42 +00:00
|
|
|
for(vv= vi-1; vv<=vi+2; vv++) {
|
2002-10-12 11:37:38 +00:00
|
|
|
v= w*tv[vv-vi+1];
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2011-03-27 17:22:04 +00:00
|
|
|
if(v != 0.0f) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(vv>0) {
|
2010-04-20 21:38:55 +00:00
|
|
|
if(vv<lt->pntsv) idx_v= idx_w + vv*lt->pntsu;
|
|
|
|
|
else idx_v= idx_w + (lt->pntsv-1)*lt->pntsu;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
else idx_v= idx_w;
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
for(uu= ui-1; uu<=ui+2; uu++) {
|
2005-10-20 18:52:29 +00:00
|
|
|
u= weight*v*tu[uu-ui+1];
|
2010-04-20 21:38:55 +00:00
|
|
|
|
2011-03-27 17:22:04 +00:00
|
|
|
if(u != 0.0f) {
|
2002-10-12 11:37:38 +00:00
|
|
|
if(uu>0) {
|
2010-04-20 21:38:55 +00:00
|
|
|
if(uu<lt->pntsu) idx_u= idx_v + uu;
|
|
|
|
|
else idx_u= idx_v + (lt->pntsu-1);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
else idx_u= idx_v;
|
|
|
|
|
|
|
|
|
|
madd_v3_v3fl(co, <->latticedata[idx_u * 3], u);
|
|
|
|
|
|
|
|
|
|
if(defgroup_nr != -1)
|
|
|
|
|
weight_blend += (u * defvert_find_weight(dvert + idx_u, defgroup_nr));
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-04-20 21:38:55 +00:00
|
|
|
|
|
|
|
|
if(defgroup_nr != -1)
|
|
|
|
|
interp_v3_v3v3(co, co_prev, co, weight_blend);
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-07 16:05:55 +00:00
|
|
|
void end_latt_deform(Object *ob)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2009-01-07 16:05:55 +00:00
|
|
|
Lattice *lt= ob->data;
|
|
|
|
|
|
2010-08-10 06:36:42 +00:00
|
|
|
if(lt->editlatt) lt= lt->editlatt->latt;
|
2009-01-07 16:05:55 +00:00
|
|
|
|
|
|
|
|
if(lt->latticedata)
|
|
|
|
|
MEM_freeN(lt->latticedata);
|
|
|
|
|
lt->latticedata= NULL;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
2004-09-14 19:03:11 +00:00
|
|
|
/* calculations is in local space of deformed object
|
|
|
|
|
so we store in latmat transform from path coord inside object
|
|
|
|
|
*/
|
|
|
|
|
typedef struct {
|
|
|
|
|
float dmin[3], dmax[3], dsize, dloc[3];
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
float curvespace[4][4], objectspace[4][4], objectspace3[3][3];
|
|
|
|
|
int no_rot_axis;
|
2004-09-14 19:03:11 +00:00
|
|
|
} CurveDeform;
|
|
|
|
|
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
static void init_curve_deform(Object *par, Object *ob, CurveDeform *cd, int dloc)
|
2004-09-14 19:03:11 +00:00
|
|
|
{
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(ob->imat, ob->obmat);
|
|
|
|
|
mul_m4_m4m4(cd->objectspace, par->obmat, ob->imat);
|
|
|
|
|
invert_m4_m4(cd->curvespace, cd->objectspace);
|
|
|
|
|
copy_m3_m4(cd->objectspace3, cd->objectspace);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2004-09-14 19:03:11 +00:00
|
|
|
// offset vector for 'no smear'
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
if(dloc) {
|
2009-11-10 20:43:45 +00:00
|
|
|
invert_m4_m4(par->imat, par->obmat);
|
|
|
|
|
mul_v3_m4v3(cd->dloc, par->imat, ob->obmat[3]);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
}
|
2010-08-06 05:19:00 +00:00
|
|
|
else {
|
|
|
|
|
cd->dloc[0]=cd->dloc[1]=cd->dloc[2]= 0.0f;
|
|
|
|
|
}
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
|
|
|
|
cd->no_rot_axis= 0;
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
2004-11-21 10:42:42 +00:00
|
|
|
/* this makes sure we can extend for non-cyclic. *vec needs 4 items! */
|
2009-09-12 14:12:37 +00:00
|
|
|
static int where_on_path_deform(Object *ob, float ctime, float *vec, float *dir, float *quat, float *radius) /* returns OK */
|
2004-09-14 19:03:11 +00:00
|
|
|
{
|
|
|
|
|
Curve *cu= ob->data;
|
|
|
|
|
BevList *bl;
|
|
|
|
|
float ctime1;
|
|
|
|
|
int cycl=0;
|
|
|
|
|
|
|
|
|
|
/* test for cyclic */
|
|
|
|
|
bl= cu->bev.first;
|
2007-12-03 22:42:48 +00:00
|
|
|
if (!bl->nr) return 0;
|
2004-09-14 19:03:11 +00:00
|
|
|
if(bl && bl->poly> -1) cycl= 1;
|
|
|
|
|
|
|
|
|
|
if(cycl==0) {
|
2011-03-27 17:22:04 +00:00
|
|
|
ctime1= CLAMPIS(ctime, 0.0f, 1.0f);
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
|
|
|
|
else ctime1= ctime;
|
2004-11-21 10:42:42 +00:00
|
|
|
|
|
|
|
|
/* vec needs 4 items */
|
2010-04-21 11:59:47 +00:00
|
|
|
if(where_on_path(ob, ctime1, vec, dir, quat, radius, NULL)) {
|
2004-09-14 19:03:11 +00:00
|
|
|
|
|
|
|
|
if(cycl==0) {
|
|
|
|
|
Path *path= cu->path;
|
|
|
|
|
float dvec[3];
|
|
|
|
|
|
2011-03-27 17:22:04 +00:00
|
|
|
if(ctime < 0.0f) {
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(dvec, path->data[1].vec, path->data[0].vec);
|
|
|
|
|
mul_v3_fl(dvec, ctime*(float)path->len);
|
2010-08-06 05:19:00 +00:00
|
|
|
add_v3_v3(vec, dvec);
|
|
|
|
|
if(quat) copy_qt_qt(quat, path->data[0].quat);
|
2009-09-12 14:12:37 +00:00
|
|
|
if(radius) *radius= path->data[0].radius;
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
2011-03-27 17:22:04 +00:00
|
|
|
else if(ctime > 1.0f) {
|
2009-11-10 20:43:45 +00:00
|
|
|
sub_v3_v3v3(dvec, path->data[path->len-1].vec, path->data[path->len-2].vec);
|
2011-03-27 17:22:04 +00:00
|
|
|
mul_v3_fl(dvec, (ctime-1.0f)*(float)path->len);
|
2010-08-06 05:19:00 +00:00
|
|
|
add_v3_v3(vec, dvec);
|
|
|
|
|
if(quat) copy_qt_qt(quat, path->data[path->len-1].quat);
|
2009-09-12 14:12:37 +00:00
|
|
|
if(radius) *radius= path->data[path->len-1].radius;
|
2010-04-21 11:59:47 +00:00
|
|
|
/* weight - not used but could be added */
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* for each point, rotate & translate to curve */
|
|
|
|
|
/* use path, since it has constant distances */
|
|
|
|
|
/* co: local coord, result local too */
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
/* returns quaternion for rotation, using cd->no_rot_axis */
|
|
|
|
|
/* axis is using another define!!! */
|
2009-01-04 14:14:06 +00:00
|
|
|
static int calc_curve_deform(Scene *scene, Object *par, float *co, short axis, CurveDeform *cd, float *quatp)
|
2004-09-14 19:03:11 +00:00
|
|
|
{
|
|
|
|
|
Curve *cu= par->data;
|
2009-09-30 23:31:10 +00:00
|
|
|
float fac, loc[4], dir[3], new_quat[4], radius;
|
|
|
|
|
short /*upflag, */ index;
|
|
|
|
|
|
|
|
|
|
index= axis-1;
|
|
|
|
|
if(index>2)
|
|
|
|
|
index -= 3; /* negative */
|
|
|
|
|
|
2006-06-27 10:51:35 +00:00
|
|
|
/* to be sure, mostly after file load */
|
2004-09-27 10:39:18 +00:00
|
|
|
if(cu->path==NULL) {
|
2009-01-04 14:14:06 +00:00
|
|
|
makeDispListCurveTypes(scene, par, 0);
|
2008-02-27 17:43:23 +00:00
|
|
|
if(cu->path==NULL) return 0; // happens on append...
|
2004-09-27 10:39:18 +00:00
|
|
|
}
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2004-09-14 19:03:11 +00:00
|
|
|
/* options */
|
2009-09-30 23:31:10 +00:00
|
|
|
if(ELEM3(axis, OB_NEGX+1, OB_NEGY+1, OB_NEGZ+1)) { /* OB_NEG# 0-5, MOD_CURVE_POS# 1-6 */
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
if(cu->flag & CU_STRETCH)
|
|
|
|
|
fac= (-co[index]-cd->dmax[index])/(cd->dmax[index] - cd->dmin[index]);
|
|
|
|
|
else
|
|
|
|
|
fac= (cd->dloc[index])/(cu->path->totdist) - (co[index]-cd->dmax[index])/(cu->path->totdist);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(cu->flag & CU_STRETCH)
|
|
|
|
|
fac= (co[index]-cd->dmin[index])/(cd->dmax[index] - cd->dmin[index]);
|
|
|
|
|
else
|
|
|
|
|
fac= (cd->dloc[index])/(cu->path->totdist) + (co[index]-cd->dmin[index])/(cu->path->totdist);
|
|
|
|
|
}
|
|
|
|
|
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
#if 0 // XXX old animation system
|
2006-11-08 10:51:27 +00:00
|
|
|
/* we want the ipo to work on the default 100 frame range, because there's no
|
|
|
|
|
actual time involved in path position */
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
// huh? by WHY!!!!???? - Aligorith
|
2006-11-08 10:51:27 +00:00
|
|
|
if(cu->ipo) {
|
|
|
|
|
fac*= 100.0f;
|
|
|
|
|
if(calc_ipo_spec(cu->ipo, CU_SPEED, &fac)==0)
|
|
|
|
|
fac/= 100.0;
|
|
|
|
|
}
|
2.5: Blender "Animato" - New Animation System
Finally, here is the basic (functional) prototype of the new animation system which will allow for the infamous "everything is animatable", and which also addresses several of the more serious shortcomings of the old system. Unfortunately, this will break old animation files (especially right now, as I haven't written the version patching code yet), however, this is for the future.
Highlights of the new system:
* Scrapped IPO-Curves/IPO/(Action+Constraint-Channels)/Action system, and replaced it with F-Curve/Action.
- F-Curves (animators from other packages will feel at home with this name) replace IPO-Curves.
- The 'new' Actions, act as the containers for F-Curves, so that they can be reused. They are therefore more akin to the old 'IPO' blocks, except they do not have the blocktype restriction, so you can store materials/texture/geometry F-Curves in the same Action as Object transforms, etc.
* F-Curves use RNA-paths for Data Access, hence allowing "every" (where sensible/editable that is) user-accessible setting from RNA to be animated.
* Drivers are no longer mixed with Animation Data, so rigs will not be that easily broken and several dependency problems can be eliminated. (NOTE: drivers haven't been hooked up yet, but the code is in place)
* F-Curve modifier system allows useful 'large-scale' manipulation of F-Curve values, including (I've only included implemented ones here): envelope deform (similar to lattices to allow broad-scale reshaping of curves), curve generator (polynomial or py-expression), cycles (replacing the old cyclic extrapolation modes, giving more control over this). (NOTE: currently this cannot be tested, as there's not access to them, but the code is all in place)
* NLA system with 'tracks' (i.e. layers), and multiple strips per track. (NOTE: NLA system is not yet functional, as it's only partially coded still)
There are more nice things that I will be preparing some nice docs for soon, but for now, check for more details:
http://lists.blender.org/pipermail/bf-taskforce25/2009-January/000260.html
So, what currently works:
* I've implemented two basic operators for the 3D-view only to Insert and Delete Keyframes. These are tempolary ones only that will be replaced in due course with 'proper' code.
* Object Loc/Rot/Scale can be keyframed. Also, the colour of the 'active' material (Note: this should really be for nth material instead, but that doesn't work yet in RNA) can also be keyframed into the same datablock.
* Standard animation refresh (i.e. animation resulting from NLA and Action evaluation) is now done completely separate from drivers before anything else is done after a frame change. Drivers are handled after this in a separate pass, as dictated by depsgraph flags, etc.
Notes:
* Drivers haven't been hooked up yet
* Only objects and data directly linked to objects can be animated.
* Depsgraph will need further tweaks. Currently, I've only made sure that it will update some things in the most basic cases (i.e. frame change).
* Animation Editors are currently broken (in terms of editing stuff). This will be my next target (priority to get Dopesheet working first, then F-Curve editor - i.e. old IPO Editor)
* I've had to put in large chunks of XXX sandboxing for old animation system code all around the place. This will be cleaned up in due course, as some places need special review.
In particular, the particles and sequencer code have far too many manual calls to calculate + flush animation info, which is really bad (this is a 'please explain yourselves' call to Physics coders!).
2009-01-17 03:12:50 +00:00
|
|
|
#endif // XXX old animation system
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2009-09-30 23:31:10 +00:00
|
|
|
if( where_on_path_deform(par, fac, loc, dir, new_quat, &radius)) { /* returns OK */
|
|
|
|
|
float quat[4], cent[3];
|
|
|
|
|
|
|
|
|
|
#if 0 // XXX - 2.4x Z-Up, Now use bevel tilt.
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
if(cd->no_rot_axis) /* set by caller */
|
|
|
|
|
dir[cd->no_rot_axis-1]= 0.0f;
|
|
|
|
|
|
|
|
|
|
/* -1 for compatibility with old track defines */
|
2009-11-10 20:43:45 +00:00
|
|
|
vec_to_quat( quat,dir, axis-1, upflag);
|
2005-05-13 13:06:20 +00:00
|
|
|
|
|
|
|
|
/* the tilt */
|
|
|
|
|
if(loc[3]!=0.0) {
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(dir);
|
2005-05-13 13:06:20 +00:00
|
|
|
q[0]= (float)cos(0.5*loc[3]);
|
|
|
|
|
fac= (float)sin(0.5*loc[3]);
|
|
|
|
|
q[1]= -fac*dir[0];
|
|
|
|
|
q[2]= -fac*dir[1];
|
|
|
|
|
q[3]= -fac*dir[2];
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(quat, q, quat);
|
2009-09-12 16:25:49 +00:00
|
|
|
}
|
2009-09-30 23:31:10 +00:00
|
|
|
#endif
|
2009-09-12 16:25:49 +00:00
|
|
|
|
2009-09-30 23:31:10 +00:00
|
|
|
if(cd->no_rot_axis) { /* set by caller */
|
|
|
|
|
|
|
|
|
|
/* this is not exactly the same as 2.4x, since the axis is having rotation removed rather then
|
|
|
|
|
* changing the axis before calculating the tilt but serves much the same purpose */
|
|
|
|
|
float dir_flat[3]={0,0,0}, q[4];
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_v3_v3(dir_flat, dir);
|
2009-09-30 23:31:10 +00:00
|
|
|
dir_flat[cd->no_rot_axis-1]= 0.0f;
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(dir);
|
|
|
|
|
normalize_v3(dir_flat);
|
2009-09-30 23:31:10 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
rotation_between_vecs_to_quat(q, dir, dir_flat); /* Could this be done faster? */
|
2009-09-30 23:31:10 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_qt_qtqt(new_quat, q, new_quat);
|
2009-09-30 23:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Logic for 'cent' orientation *
|
|
|
|
|
*
|
|
|
|
|
* The way 'co' is copied to 'cent' may seem to have no meaning, but it does.
|
|
|
|
|
*
|
|
|
|
|
* Use a curve modifier to stretch a cube out, color each side RGB, positive side light, negative dark.
|
|
|
|
|
* view with X up (default), from the angle that you can see 3 faces RGB colors (light), anti-clockwise
|
|
|
|
|
* Notice X,Y,Z Up all have light colors and each ordered CCW.
|
|
|
|
|
*
|
|
|
|
|
* Now for Neg Up XYZ, the colors are all dark, and ordered clockwise - Campbell
|
2010-10-08 02:08:11 +00:00
|
|
|
*
|
|
|
|
|
* note: moved functions into quat_apply_track/vec_apply_track
|
2009-09-30 23:31:10 +00:00
|
|
|
* */
|
2010-10-08 02:08:11 +00:00
|
|
|
copy_qt_qt(quat, new_quat);
|
|
|
|
|
copy_v3_v3(cent, co);
|
|
|
|
|
|
|
|
|
|
/* zero the axis which is not used,
|
|
|
|
|
* the big block of text above now applies to these 3 lines */
|
2010-10-08 07:29:08 +00:00
|
|
|
quat_apply_track(quat, axis-1, (axis==1 || axis==3) ? 1:0); /* up flag is a dummy, set so no rotation is done */
|
2010-10-08 02:08:11 +00:00
|
|
|
vec_apply_track(cent, axis-1);
|
|
|
|
|
cent[axis < 4 ? axis-1 : axis-4]= 0.0f;
|
2009-09-30 23:31:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* scale if enabled */
|
|
|
|
|
if(cu->flag & CU_PATH_RADIUS)
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(cent, radius);
|
2004-09-14 19:03:11 +00:00
|
|
|
|
2009-09-30 23:31:10 +00:00
|
|
|
/* local rotation */
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_qt(quat);
|
|
|
|
|
mul_qt_v3(quat, cent);
|
2009-09-30 23:31:10 +00:00
|
|
|
|
2004-09-14 19:03:11 +00:00
|
|
|
/* translation */
|
2010-08-06 05:19:00 +00:00
|
|
|
add_v3_v3v3(co, cent, loc);
|
2009-09-30 23:31:10 +00:00
|
|
|
|
2008-02-27 17:43:23 +00:00
|
|
|
if(quatp)
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_qt_qt(quatp, quat);
|
|
|
|
|
|
2008-02-27 17:43:23 +00:00
|
|
|
return 1;
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
2008-02-27 17:43:23 +00:00
|
|
|
return 0;
|
2004-09-14 19:03:11 +00:00
|
|
|
}
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
void curve_deform_verts(Scene *scene, Object *cuOb, Object *target, DerivedMesh *dm, float (*vertexCos)[3], int numVerts, char *vgroup, short defaxis)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2008-04-04 12:33:01 +00:00
|
|
|
Curve *cu;
|
|
|
|
|
int a, flag;
|
2005-07-19 20:14:17 +00:00
|
|
|
CurveDeform cd;
|
2006-08-28 01:12:36 +00:00
|
|
|
int use_vgroups;
|
2008-04-04 12:33:01 +00:00
|
|
|
|
|
|
|
|
if(cuOb->type != OB_CURVE)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
cu = cuOb->data;
|
|
|
|
|
flag = cu->flag;
|
2005-07-19 20:14:17 +00:00
|
|
|
cu->flag |= (CU_PATH|CU_FOLLOW); // needed for path & bevlist
|
|
|
|
|
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
init_curve_deform(cuOb, target, &cd, (cu->flag & CU_STRETCH)==0);
|
2010-08-06 08:27:07 +00:00
|
|
|
|
|
|
|
|
/* dummy bounds, keep if CU_DEFORM_BOUNDS_OFF is set */
|
|
|
|
|
if(defaxis < 3) {
|
|
|
|
|
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
|
|
|
|
|
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* negative, these bounds give a good rest position */
|
|
|
|
|
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= -1.0f;
|
|
|
|
|
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
/* check whether to use vertex groups (only possible if target is a Mesh)
|
|
|
|
|
* we want either a Mesh with no derived data, or derived data with
|
|
|
|
|
* deformverts
|
|
|
|
|
*/
|
|
|
|
|
if(target && target->type==OB_MESH) {
|
|
|
|
|
/* if there's derived data without deformverts, don't use vgroups */
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
if(dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
|
2006-08-28 01:12:36 +00:00
|
|
|
use_vgroups = 0;
|
|
|
|
|
else
|
|
|
|
|
use_vgroups = 1;
|
|
|
|
|
} else
|
|
|
|
|
use_vgroups = 0;
|
|
|
|
|
|
|
|
|
|
if(vgroup && vgroup[0] && use_vgroups) {
|
2005-10-20 18:52:29 +00:00
|
|
|
Mesh *me= target->data;
|
2010-08-06 05:19:00 +00:00
|
|
|
int index= defgroup_name_index(target, vgroup);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2010-08-06 05:19:00 +00:00
|
|
|
if(index != -1 && (me->dvert || dm)) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *dvert = me->dvert;
|
2005-10-20 18:52:29 +00:00
|
|
|
float vec[3];
|
2010-08-06 05:19:00 +00:00
|
|
|
float weight;
|
2010-08-06 08:27:07 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2010-08-06 08:27:07 +00:00
|
|
|
if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
|
|
|
|
|
/* dummy bounds */
|
|
|
|
|
cd.dmin[0]= cd.dmin[1]= cd.dmin[2]= 0.0f;
|
|
|
|
|
cd.dmax[0]= cd.dmax[1]= cd.dmax[2]= 1.0f;
|
2010-08-06 05:19:00 +00:00
|
|
|
|
2010-08-06 08:27:07 +00:00
|
|
|
dvert = me->dvert;
|
|
|
|
|
for(a = 0; a < numVerts; a++, dvert++) {
|
|
|
|
|
if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
|
|
|
|
|
weight= defvert_find_weight(dvert, index);
|
|
|
|
|
|
|
|
|
|
if(weight > 0.0f) {
|
|
|
|
|
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
|
|
|
|
copy_v3_v3(vec, vertexCos[a]);
|
|
|
|
|
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
|
|
|
|
|
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
|
|
|
|
|
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-08-06 08:27:07 +00:00
|
|
|
else {
|
|
|
|
|
/* set mesh min/max bounds */
|
|
|
|
|
INIT_MINMAX(cd.dmin, cd.dmax);
|
|
|
|
|
|
|
|
|
|
for(a = 0; a < numVerts; a++, dvert++) {
|
|
|
|
|
if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
if(defvert_find_weight(dvert, index) > 0.0f) {
|
|
|
|
|
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
|
|
|
|
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dvert = me->dvert;
|
|
|
|
|
for(a = 0; a < numVerts; a++, dvert++) {
|
|
|
|
|
if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
|
|
|
|
|
|
|
|
|
|
weight= defvert_find_weight(dvert, index);
|
|
|
|
|
|
|
|
|
|
if(weight > 0.0f) {
|
|
|
|
|
copy_v3_v3(vec, vertexCos[a]);
|
|
|
|
|
calc_curve_deform(scene, cuOb, vec, defaxis, &cd, NULL);
|
|
|
|
|
interp_v3_v3v3(vertexCos[a], vertexCos[a], vec, weight);
|
|
|
|
|
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
|
|
|
|
}
|
2005-10-20 18:52:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-08-06 08:27:07 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(cu->flag & CU_DEFORM_BOUNDS_OFF) {
|
|
|
|
|
for(a = 0; a < numVerts; a++) {
|
|
|
|
|
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
|
|
|
|
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
|
|
|
|
|
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
}
|
2010-08-06 08:27:07 +00:00
|
|
|
else {
|
|
|
|
|
/* set mesh min max bounds */
|
|
|
|
|
INIT_MINMAX(cd.dmin, cd.dmax);
|
|
|
|
|
|
|
|
|
|
for(a = 0; a < numVerts; a++) {
|
|
|
|
|
mul_m4_v3(cd.curvespace, vertexCos[a]);
|
|
|
|
|
DO_MINMAX(vertexCos[a], cd.dmin, cd.dmax);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(a = 0; a < numVerts; a++) {
|
|
|
|
|
calc_curve_deform(scene, cuOb, vertexCos[a], defaxis, &cd, NULL);
|
|
|
|
|
mul_m4_v3(cd.objectspace, vertexCos[a]);
|
|
|
|
|
}
|
2005-10-20 18:52:29 +00:00
|
|
|
}
|
2005-07-19 20:14:17 +00:00
|
|
|
}
|
|
|
|
|
cu->flag = flag;
|
|
|
|
|
}
|
2005-07-19 02:36:21 +00:00
|
|
|
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
/* input vec and orco = local coord in armature space */
|
|
|
|
|
/* orco is original not-animated or deformed reference point */
|
|
|
|
|
/* result written in vec and mat */
|
2009-01-04 14:14:06 +00:00
|
|
|
void curve_deform_vector(Scene *scene, Object *cuOb, Object *target, float *orco, float *vec, float mat[][3], int no_rot_axis)
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
{
|
|
|
|
|
CurveDeform cd;
|
2008-02-27 17:43:23 +00:00
|
|
|
float quat[4];
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2008-04-04 12:33:01 +00:00
|
|
|
if(cuOb->type != OB_CURVE) {
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m3(mat);
|
2008-04-04 12:33:01 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
init_curve_deform(cuOb, target, &cd, 0); /* 0 no dloc */
|
|
|
|
|
cd.no_rot_axis= no_rot_axis; /* option to only rotate for XY, for example */
|
|
|
|
|
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_v3_v3(cd.dmin, orco);
|
|
|
|
|
copy_v3_v3(cd.dmax, orco);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(cd.curvespace, vec);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
if(calc_curve_deform(scene, cuOb, vec, target->trackflag+1, &cd, quat)) {
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
float qmat[3][3];
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
quat_to_mat3( qmat,quat);
|
|
|
|
|
mul_m3_m3m3(mat, qmat, cd.objectspace3);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
}
|
|
|
|
|
else
|
2009-11-10 20:43:45 +00:00
|
|
|
unit_m3(mat);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_m4_v3(cd.objectspace, vec);
|
Two wonderful new NLA & Armature editing features!
- FORWARD CYCLING & MATCHING
Up to no now, adding multiple actions in NLA with walkcycles required to
animate them standing still, as if walking on a conveyor belt. The stride
option then makes the object itself move forward, trying to keep the foot
stuck on the floor (with poor results!).
This option now allows to make walk cycles moving forward. By
indicating a reference Offset Bone, the NLA system will use that bone to
detect the correct offset for the Armature Pose to make it seamlessly going
forward.
Best of all, this option works as for cyclic Action Strips as well as for
individual Action Strips. Note that for individual strips, you have to set
the strip on "Hold". (Might become automatic detected later).
Here's an example edit image for NLA:
http://www.blender.org/bf/nla_match-cycle.jpg
And the animation for it:
http://download.blender.org/demo/test/2.43/0001_0150_match.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_matching.blend
Using this kind of cycling works pretty straightforward, and is a lot
easier to setup than Stride Bones.
To be further tested:
- Blending cycles
- matching rotation for the bones as well.
- ACTION MODIFIERS (motion deformors)
The above option was actually required for this feature. Typically walk
cycles are constructed with certain Bones to be the handles, controlling
for example the torso or feet.
An Action Modifier allows you to use a Curve Path to deform the motion of
these controlling bones. This uses the existing Curve Deformation option.
Modifiers can be added per Action Strip, each controlling a channel (bone)
by choice, and even allows to layer multiple modifiers on top of each other
(several paths deforming motion). This option is using the dependency graph,
so editing the Curve will give realtime changes in the Armature.
The previous walkcycle, controlled by two curves:
http://download.blender.org/demo/test/2.43/0001_0150_deform.avi
Blender file:
http://download.blender.org/demo/test/2.43/mancandy_actiondeform.blend
Action Modifiers can be added in the NLA Properties Panel. Per Modifier you
have to indicate the channel and a Curve Object. You can copy modifiers from
one strip to another using CTRL+C (only copies to active Object strips).
Setting up a correct Curve Path has to be carefully done:
- Use SHIFT+A "Curve Path" in top view, or ensure the path is not rotated.
- make sure the center point of the Curve Object is at the center of the
Armature (or above)
- move the first point of the curve to the center point as well.
- check if the path starts from this first point, you can change it using
(in Curve EditMode) the option Wkey -> "Switch Direction"
- Make sure alignment uses the correct axis; if the Armature walks into
the negative Y direction, you have to set in Object Buttons, "Anim settings"
Panel, the correct Track option. (Note; option will probably move to the
Modifier later).
This is a good reason to make such paths automatic (on a command). Is on the
todo list.
Also note this:
- the Curve Path extends in beginning and ending, that's (for now) the default,
and allows to use multiple paths. Make sure paths begin and end horizontal.
- Moving the Curve in Object Mode will change the "mapping" (as if the landscape
a character walks over moves). Moving the Curve in Edit Mode will change the
actual position of the deformation.
- Speed (Ipos) on paths is not supported yet, will be done.
- The Curve "Stretch" deform option doesn't work.
- Modifiers are executed *after* all actions in NLA are evaluated, there's no
support yet for blending multiple strips with Modifiers.
- This doesn't work yet for time-mapping...
This commit is mostly for review by character animators... some details or
working methods might change.
This feature can also be used for other modifiers, such as noise (Perlin) or
the mythical "Oomph" (frequency control) and of course Python.
Special thanks to Bassam & Matt for research & design help. Have fun!
2006-10-31 15:51:57 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
void lattice_deform_verts(Object *laOb, Object *target, DerivedMesh *dm,
|
2010-03-22 09:30:00 +00:00
|
|
|
float (*vertexCos)[3], int numVerts, char *vgroup)
|
2005-07-19 20:14:17 +00:00
|
|
|
{
|
|
|
|
|
int a;
|
2006-08-28 01:12:36 +00:00
|
|
|
int use_vgroups;
|
2005-07-19 02:36:21 +00:00
|
|
|
|
2008-04-04 12:33:01 +00:00
|
|
|
if(laOb->type != OB_LATTICE)
|
|
|
|
|
return;
|
|
|
|
|
|
2005-07-19 20:14:17 +00:00
|
|
|
init_latt_deform(laOb, target);
|
2006-08-28 01:12:36 +00:00
|
|
|
|
|
|
|
|
/* check whether to use vertex groups (only possible if target is a Mesh)
|
|
|
|
|
* we want either a Mesh with no derived data, or derived data with
|
|
|
|
|
* deformverts
|
|
|
|
|
*/
|
|
|
|
|
if(target && target->type==OB_MESH) {
|
|
|
|
|
/* if there's derived data without deformverts, don't use vgroups */
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
if(dm && !dm->getVertData(dm, 0, CD_MDEFORMVERT))
|
2006-08-28 01:12:36 +00:00
|
|
|
use_vgroups = 0;
|
|
|
|
|
else
|
|
|
|
|
use_vgroups = 1;
|
|
|
|
|
} else
|
|
|
|
|
use_vgroups = 0;
|
|
|
|
|
|
|
|
|
|
if(vgroup && vgroup[0] && use_vgroups) {
|
|
|
|
|
Mesh *me = target->data;
|
2010-06-13 00:11:42 +00:00
|
|
|
int index = defgroup_name_index(target, vgroup);
|
|
|
|
|
float weight;
|
2006-08-28 01:12:36 +00:00
|
|
|
|
2010-06-13 00:11:42 +00:00
|
|
|
if(index >= 0 && (me->dvert || dm)) {
|
2006-08-28 01:12:36 +00:00
|
|
|
MDeformVert *dvert = me->dvert;
|
2005-10-20 18:52:29 +00:00
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
for(a = 0; a < numVerts; a++, dvert++) {
|
Added custom vertex/edge/face data for meshes:
All data layers, including MVert/MEdge/MFace, are now managed as custom
data layers. The pointers like Mesh.mvert, Mesh.dvert or Mesh.mcol are
still used of course, but allocating, copying or freeing these arrays
should be done through the CustomData API.
Work in progress documentation on this is here:
http://mediawiki.blender.org/index.php/BlenderDev/BlenderArchitecture/CustomData
Replaced TFace by MTFace:
This is the same struct, except that it does not contain color, that now
always stays separated in MCol. This was not a good design decision to
begin with, and it is needed for adding multiple color layers later. Note
that this does mean older Blender versions will not be able to read UV
coordinates from the next release, due to an SDNA limitation.
Removed DispListMesh:
This now fully replaced by DerivedMesh. To provide access to arrays of
vertices, edges and faces, like DispListMesh does. The semantics of the
DerivedMesh.getVertArray() and similar functions were changed to return
a pointer to an array if one exists, or otherwise allocate a temporary
one. On releasing the DerivedMesh, this temporary array will be removed
automatically.
Removed ssDM and meshDM DerivedMesh backends:
The ssDM backend was for DispListMesh, so that became obsolete automatically.
The meshDM backend was replaced by the custom data backend, that now figures
out which layers need to be modified, and only duplicates those.
This changes code in many places, and overall removes 2514 lines of code.
So, there's a good chance this might break some stuff, although I've been
testing it for a few days now. The good news is, adding multiple color and
uv layers should now become easy.
2006-11-20 04:28:02 +00:00
|
|
|
if(dm) dvert = dm->getVertData(dm, a, CD_MDEFORMVERT);
|
2010-06-13 00:11:42 +00:00
|
|
|
|
|
|
|
|
weight= defvert_find_weight(dvert, index);
|
|
|
|
|
|
|
|
|
|
if(weight > 0.0f)
|
|
|
|
|
calc_latt_deform(laOb, vertexCos[a], weight);
|
2005-10-20 18:52:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
2006-08-28 01:12:36 +00:00
|
|
|
} else {
|
|
|
|
|
for(a = 0; a < numVerts; a++) {
|
2009-01-07 16:05:55 +00:00
|
|
|
calc_latt_deform(laOb, vertexCos[a], 1.0f);
|
2005-10-20 18:52:29 +00:00
|
|
|
}
|
2005-07-19 02:36:21 +00:00
|
|
|
}
|
2009-01-07 16:05:55 +00:00
|
|
|
end_latt_deform(laOb);
|
2005-07-19 20:14:17 +00:00
|
|
|
}
|
|
|
|
|
|
2010-06-28 11:07:02 +00:00
|
|
|
int object_deform_mball(Object *ob, ListBase *dispbase)
|
2005-07-19 02:36:21 +00:00
|
|
|
{
|
2005-08-14 06:08:41 +00:00
|
|
|
if(ob->parent && ob->parent->type==OB_LATTICE && ob->partype==PARSKEL) {
|
|
|
|
|
DispList *dl;
|
2005-07-19 02:36:21 +00:00
|
|
|
|
2010-06-28 11:07:02 +00:00
|
|
|
for (dl=dispbase->first; dl; dl=dl->next) {
|
2006-08-28 01:12:36 +00:00
|
|
|
lattice_deform_verts(ob->parent, ob, NULL,
|
2010-03-22 09:30:00 +00:00
|
|
|
(float(*)[3]) dl->verts, dl->nr, NULL);
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-08-14 06:08:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
return 1;
|
2005-08-14 06:08:41 +00:00
|
|
|
} else {
|
|
|
|
|
return 0;
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-08-14 06:08:41 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
static BPoint *latt_bp(Lattice *lt, int u, int v, int w)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
|
return lt->def+ u + v*lt->pntsu + w*lt->pntsu*lt->pntsv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void outside_lattice(Lattice *lt)
|
|
|
|
|
{
|
|
|
|
|
BPoint *bp, *bp1, *bp2;
|
|
|
|
|
int u, v, w;
|
|
|
|
|
float fac1, du=0.0, dv=0.0, dw=0.0;
|
|
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
if(lt->flag & LT_OUTSIDE) {
|
|
|
|
|
bp= lt->def;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
if(lt->pntsu>1) du= 1.0f/((float)lt->pntsu-1);
|
|
|
|
|
if(lt->pntsv>1) dv= 1.0f/((float)lt->pntsv-1);
|
|
|
|
|
if(lt->pntsw>1) dw= 1.0f/((float)lt->pntsw-1);
|
|
|
|
|
|
|
|
|
|
for(w=0; w<lt->pntsw; w++) {
|
|
|
|
|
|
|
|
|
|
for(v=0; v<lt->pntsv; v++) {
|
|
|
|
|
|
|
|
|
|
for(u=0; u<lt->pntsu; u++, bp++) {
|
|
|
|
|
if(u==0 || v==0 || w==0 || u==lt->pntsu-1 || v==lt->pntsv-1 || w==lt->pntsw-1);
|
|
|
|
|
else {
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2009-07-03 15:23:33 +00:00
|
|
|
bp->hide= 1;
|
|
|
|
|
bp->f1 &= ~SELECT;
|
|
|
|
|
|
|
|
|
|
/* u extrema */
|
|
|
|
|
bp1= latt_bp(lt, 0, v, w);
|
|
|
|
|
bp2= latt_bp(lt, lt->pntsu-1, v, w);
|
|
|
|
|
|
|
|
|
|
fac1= du*u;
|
|
|
|
|
bp->vec[0]= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
|
|
|
|
|
bp->vec[1]= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
|
|
|
|
|
bp->vec[2]= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
|
|
|
|
|
|
|
|
|
|
/* v extrema */
|
|
|
|
|
bp1= latt_bp(lt, u, 0, w);
|
|
|
|
|
bp2= latt_bp(lt, u, lt->pntsv-1, w);
|
|
|
|
|
|
|
|
|
|
fac1= dv*v;
|
|
|
|
|
bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
|
|
|
|
|
bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
|
|
|
|
|
bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
|
|
|
|
|
|
|
|
|
|
/* w extrema */
|
|
|
|
|
bp1= latt_bp(lt, u, v, 0);
|
|
|
|
|
bp2= latt_bp(lt, u, v, lt->pntsw-1);
|
|
|
|
|
|
|
|
|
|
fac1= dw*w;
|
|
|
|
|
bp->vec[0]+= (1.0f-fac1)*bp1->vec[0] + fac1*bp2->vec[0];
|
|
|
|
|
bp->vec[1]+= (1.0f-fac1)*bp1->vec[1] + fac1*bp2->vec[1];
|
|
|
|
|
bp->vec[2]+= (1.0f-fac1)*bp1->vec[2] + fac1*bp2->vec[2];
|
|
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
mul_v3_fl(bp->vec, 0.3333333f);
|
2009-07-03 15:23:33 +00:00
|
|
|
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2009-07-03 15:23:33 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-07-03 15:23:33 +00:00
|
|
|
else {
|
|
|
|
|
bp= lt->def;
|
|
|
|
|
|
|
|
|
|
for(w=0; w<lt->pntsw; w++)
|
|
|
|
|
for(v=0; v<lt->pntsv; v++)
|
|
|
|
|
for(u=0; u<lt->pntsu; u++, bp++)
|
|
|
|
|
bp->hide= 0;
|
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
}
|
2005-08-15 10:30:53 +00:00
|
|
|
|
|
|
|
|
float (*lattice_getVertexCos(struct Object *ob, int *numVerts_r))[3]
|
|
|
|
|
{
|
2009-01-02 19:10:35 +00:00
|
|
|
Lattice *lt = ob->data;
|
|
|
|
|
int i, numVerts;
|
2009-01-06 12:30:44 +00:00
|
|
|
float (*vertexCos)[3];
|
2005-08-15 10:30:53 +00:00
|
|
|
|
2010-08-10 06:36:42 +00:00
|
|
|
if(lt->editlatt) lt= lt->editlatt->latt;
|
2009-01-02 19:10:35 +00:00
|
|
|
numVerts = *numVerts_r = lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
|
2009-01-06 12:30:44 +00:00
|
|
|
vertexCos = MEM_mallocN(sizeof(*vertexCos)*numVerts,"lt_vcos");
|
|
|
|
|
|
2005-08-15 10:30:53 +00:00
|
|
|
for (i=0; i<numVerts; i++) {
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_v3_v3(vertexCos[i], lt->def[i].vec);
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return vertexCos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lattice_applyVertexCos(struct Object *ob, float (*vertexCos)[3])
|
|
|
|
|
{
|
|
|
|
|
Lattice *lt = ob->data;
|
|
|
|
|
int i, numVerts = lt->pntsu*lt->pntsv*lt->pntsw;
|
|
|
|
|
|
|
|
|
|
for (i=0; i<numVerts; i++) {
|
2010-08-06 05:19:00 +00:00
|
|
|
copy_v3_v3(lt->def[i].vec, vertexCos[i]);
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
void lattice_calc_modifiers(Scene *scene, Object *ob)
|
2005-08-15 10:30:53 +00:00
|
|
|
{
|
2009-01-02 19:10:35 +00:00
|
|
|
Lattice *lt= ob->data;
|
2005-08-15 10:30:53 +00:00
|
|
|
ModifierData *md = modifiers_getVirtualModifierList(ob);
|
2009-01-02 19:10:35 +00:00
|
|
|
float (*vertexCos)[3] = NULL;
|
|
|
|
|
int numVerts, editmode = (lt->editlatt!=NULL);
|
2005-08-15 10:30:53 +00:00
|
|
|
|
|
|
|
|
freedisplist(&ob->disp);
|
|
|
|
|
|
|
|
|
|
for (; md; md=md->next) {
|
|
|
|
|
ModifierTypeInfo *mti = modifierType_getInfo(md->type);
|
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
md->scene= scene;
|
|
|
|
|
|
2006-08-28 01:12:36 +00:00
|
|
|
if (!(md->mode&eModifierMode_Realtime)) continue;
|
2005-08-15 10:30:53 +00:00
|
|
|
if (editmode && !(md->mode&eModifierMode_Editmode)) continue;
|
2009-11-25 14:07:12 +00:00
|
|
|
if (mti->isDisabled && mti->isDisabled(md, 0)) continue;
|
2005-08-15 10:30:53 +00:00
|
|
|
if (mti->type!=eModifierTypeType_OnlyDeform) continue;
|
|
|
|
|
|
|
|
|
|
if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
|
2009-05-31 17:20:57 +00:00
|
|
|
mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0);
|
2005-08-15 10:30:53 +00:00
|
|
|
}
|
|
|
|
|
|
2008-07-20 16:06:40 +00:00
|
|
|
/* always displist to make this work like derivedmesh */
|
|
|
|
|
if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
|
|
|
|
|
|
|
|
|
|
{
|
2005-08-15 10:30:53 +00:00
|
|
|
DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
|
|
|
|
|
dl->type = DL_VERTS;
|
|
|
|
|
dl->parts = 1;
|
|
|
|
|
dl->nr = numVerts;
|
|
|
|
|
dl->verts = (float*) vertexCos;
|
|
|
|
|
|
|
|
|
|
BLI_addtail(&ob->disp, dl);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-11-03 23:17:36 +00:00
|
|
|
|
2008-11-04 01:05:44 +00:00
|
|
|
struct MDeformVert* lattice_get_deform_verts(struct Object *oblatt)
|
2008-11-03 23:17:36 +00:00
|
|
|
{
|
2011-03-30 02:59:32 +00:00
|
|
|
Lattice *lt = (Lattice*)oblatt->data;
|
|
|
|
|
BLI_assert(oblatt->type == OB_LATTICE);
|
|
|
|
|
if(lt->editlatt) lt= lt->editlatt->latt;
|
|
|
|
|
return lt->dvert;
|
2008-11-03 23:17:36 +00:00
|
|
|
}
|