[Bf-committers] Animation project

Stephane SOPPERA stephane.soppera at wanadoo.fr
Sat Jan 15 19:37:25 CET 2005


Ton Roosendaal wrote:

> Hi,
>
> With all ideas being popping up in wiki and forums (a lot of good  
> suggestions btw!) it doesn't make it all easier to turn it into a 
> real  project with small feasible steps. And doing such evaluation 
> myself  (watching video demos and checking other packages) doesn't 
> make it  simple either.
> In many areas we're so much behind it's almost depressing to even 
> think  of starting to work on it. :)
>
> Nevertheless, here's an attempt to illustrate what could be worked on  
> first;
>
> http://wiki.blender.org/bin/view.pl/Blenderdev/AnimationUpdate
>
Ton,

I don't see in this list anything about ipo curve interpolation.
A problem I have with current ipo automatic interpolation, is that it 
overruns limits.
To illustrate my points let's have a look to an IPO:
http://perso.wanadoo.fr/stephane.soppera/blender/capture4_.png
I you can see on this picture, the second and third point have the same 
value. But between these two points the interpolated value is not constant.
If you take the fifth point, that should be a minimum, the interpolation 
of the ipo after it go smaller than its value.

These two situations can be problems while animating:
- if your character is walking up a stair for example (an animation I 
tried to do and  which raised this issue), for the foot that is on a 
step there will be at least two keys with the same position. Between 
those keys you certainly don't want the foot to move. (in my animation, 
the foot was rotating and going through the steps)
- If the fifth key is at the floor level, then after this key the 
character/object will go through the floor.

A correct interpolation should be:
http://perso.wanadoo.fr/stephane.soppera/blender/capture5_.png
http://perso.wanadoo.fr/stephane.soppera/blender/capture6_.png

This kind of interpolation is the default one in 3DSMax. I have a script 
that moves IPO handles to obtain this interpolation, see the attached file.

I don't think this is very complicated to implement in C, and it would 
be a good default interpolation for IPO curves. As far as I know, the 
default interpolation for IPO is the default interpolation for bezier 
curve. While this interpolation is correct for 2D/3D curves, it don't 
take into accout the specificity of an IPO (an IPO don't go back in time 
for example, for a given time t there is only one ipo point).

What do you think about it?

Thanks,

-- 
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera 

-------------- next part --------------
#!BPY

"""
Name: 'SmoothIpo'
Blender: 234
Group: 'Object'
Tooltip: 'Smmoooooth'
""" 


import Blender

def sign(x):
	if x < 0: return -1
	return 1

def computeBezTriple(pt0, pt1, pt2):
	tdx=(pt0[0]-pt1[0])/3.0
	udx=(pt2[0]-pt1[0])/3.0
	tx=pt1[0]+tdx
	ux=pt1[0]+udx
	max_udy=pt2[1]-pt1[1]
	max_tdy=pt0[1]-pt1[1]
	# compute slops
	slopu=(pt2[1]-pt1[1])/(pt2[0]-pt1[0])
	slopt=(pt0[1]-pt1[1])/(pt0[0]-pt1[0])
	if sign(slopu*slopt)<0:
		udy=0
		tdy=0
	else:
		# compute median slop
		medianSlop=(slopu+slopt)/2.0
		simpleudy=medianSlop*udx
		simpletdy=medianSlop*tdx
		if abs(simpleudy)<abs(max_udy) and abs(simpletdy)<abs(max_tdy):
			udy=simpleudy
			tdy=simpletdy
		else:
			# use the smallest slop
			slop=sign(slopu)*min(abs(slopu),abs(slopt))
			udy=slop*udx
			tdy=slop*tdx
	ty=pt1[1]+tdy
	uy=pt1[1]+udy
	return [tx, ty, 0, pt1[0], pt1[1], 0, ux, uy, 0]
		
	
	tdy=(pt1[1]-pt0[1])/3.0
	udy=(pt2[1]-pt1[1])/3.0
	if sign(tdy*udy)<0:
		dy=0
	else:
		absdy=min(abs(tdy),abs(udy))
		dy=sign(tdy)*absdy
	ty=pt1[1]+dy
		

def transformIpo(ipo):
	nbCurves=ipo.getNcurves()
	for i in range(nbCurves):
		nbPoints=ipo.getNBezPoints(i)
		triples=map(lambda x:ipo.getCurveBeztriple(i,x), range(nbPoints))
		for j in range(1, len(triples)-1):
			pt0=triples[j-1][3:5]
			pt1=triples[j][3:5]
			pt2=triples[j+1][3:5]
			triple=tuple(computeBezTriple(pt0, pt1, pt2))
			ipo.setCurveBeztriple(i, j, triple)

sel=Blender.Object.GetSelected()
for obj in sel:
	ipo=obj.getIpo()
	transformIpo(ipo)
	print dir(ipo)


More information about the Bf-committers mailing list