# -*- coding: latin-1 -*-
#------------------------------
# Copie des mouvements imposés par le parent
# vers une ipo
# (c) jmsoler 25/12/2007
#------------------------------
import Blender
from Blender import Scene,Object, Ipo, BezTriple, Mathutils
endframe = Blender.Get('endframe')
staframe = Blender.Get('staframe')
SF = Blender.Draw.Create(staframe)
EF = Blender.Draw.Create(endframe)
block = []
block.append(("startFrame: ", SF, staframe, endframe))
block.append(("EndFrame: ", EF, staframe, endframe))
retval = Blender.Draw.PupBlock("Track 2 Ipo", block)
if retval :
POSLIST=[]
OBJ=Scene.getCurrent().getActiveObject()
IPO=Ipo.New('Object', 'ObIpo')
IPO.addCurve('RotX')
IPO.addCurve('RotY')
IPO.addCurve('RotZ')
IPO.addCurve('LocX')
IPO.addCurve('LocY')
IPO.addCurve('LocZ')
for f in range(SF.val,EF.val) :
Blender.Set('curframe',f)
time= Blender.Get('curtime')
MATRIX=OBJ.getMatrix()
EULER=MATRIX.toEuler()
POSLIST.append([time,EULER,MATRIX[3][:]])
print MATRIX[3]
if POSLIST :
for P in POSLIST :
ipoX = IPO[Ipo.OB_ROTX]
point=BezTriple.New()
point.pt=(P[0], P[1][0]/10.0)
point.handleTypes=[1,1]
ipoX.append(point)
ipoY = IPO[Ipo.OB_ROTY]
point=BezTriple.New()
point.pt=(P[0], P[1][1]/10.0)
point.handleTypes=[1,1]
ipoY.append(point)
ipoZ = IPO[Ipo.OB_ROTZ]
point=BezTriple.New()
point.pt=(P[0], P[1][2]/10.0)
point.handleTypes=[1,1]
ipoZ.append(point)
ipoLX = IPO[Ipo.OB_LOCX]
point=BezTriple.New()
point.pt=(P[0], P[2][0])
point.handleTypes=[1,1]
ipoLX.append(point)
ipoLY = IPO[Ipo.OB_LOCY]
point=BezTriple.New()
point.pt=(P[0], P[2][1])
point.handleTypes=[1,1]
ipoLY.append(point)
ipoLZ = IPO[Ipo.OB_LOCZ]
point=BezTriple.New()
point.pt=(P[0], P[2][2])
point.handleTypes=[1,1]
ipoLZ.append(point)
OBJ.setIpo(IPO)
|