RE: Change quaternion FCurve interpolation?
| Date : Fri, 29 Sep 2006 08:58:36 -0400 |
| To : <XSI(at)Softimage.COM> |
| From : "Brent McPherson" <brentmc(at)Softimage.COM> |
| Subject : RE: Change quaternion FCurve interpolation? |
|
Agedito,
You should be able to go the scripted operator route as XSI has the math
support built in.
A
few years ago I did a similar operator as a proof-of-concept. The only problem
is all I have is some (incomplete?) VB code I found on my disk but maybe it will
give you some ideas. Unfortunately I don't remember too much else about how I
set things up but I seem to remember I copied the original fcurves to parameters
on the scripted operator and removed the original fcurves. I know at some point
I switched from a scripted operator to a compiled operator but that may have
been for performance and other reasons.
Anyway, here is the code I found. It might gives you some ideas on where
to start if nothing else...
Cheers!
--
Brent
if In_UpdateContext.Mute.Value then
out.value.rotx.value = input.value.rotx.value out.value.roty.value = input.value.roty.value out.value.rotz.value = input.value.rotz.value else ' Get rotation fcurve info dim kine, rotx, roty, rotz, fcx, fcy, fcz ' set kine = input.value ' set rotx = kine.parameters("rotx") ' set roty = kine.parameters("roty") ' set rotz = kine.parameters("rotz") set rotx = In_UpdateContext.rotx set roty = In_UpdateContext.roty set rotz = In_UpdateContext.rotz set fcx = getsource(rotx.fullname)(0) set fcy = getsource(roty.fullname)(0) set fcz = getsource(rotz.fullname)(0) ' Get number of keyframes
dim xkeys, ykeys, zkeys GetFCurveInfo fcx,,, xkeys GetFCurveInfo fcy,,, ykeys GetFCurveInfo fcz,,, zkeys ' Make sure fcurves have the same number of keyframes
if xkeys < 2 or xkeys <> ykeys or xkeys <> zkeys then out.value.rotx.value = input.value.rotx.value out.value.roty.value = input.value.roty.value out.value.rotz.value = input.value.rotz.value LogMessage "not enough keyframes" else dim current ' TODO: handle different frame
rates
current = In_UpdateContext.currentframe / 29.97 dim i, t, t1, t2, x1, y1, z1, x2, y2,
z2
for i = 0 to xkeys -
1
GetKeyInfo fcx, i, t2, x2 if current < t2
then
if i = 0 then out.value.rotx.value = rotx.value out.value.roty.value = roty.value out.value.rotz.value = rotz.value else ' TODO: handle rotorder GetKeyInfo fcy, i, , y2 GetKeyInfo fcz, i, , z2 GetKeyInfo fcy, i-1,, y1 GetKeyInfo fcz, i-1,, z1 x1 =
XSIMath.DegreesToRadians(x1)
y1 = XSIMath.DegreesToRadians(y1) z1 = XSIMath.DegreesToRadians(z1) x2 = XSIMath.DegreesToRadians(x2) y2 = XSIMath.DegreesToRadians(y2) z2 = XSIMath.DegreesToRadians(z2) '
Interpolate r1.SetFromXYZAnglesValues x1, y1, z1 r1.GetQuaternion q1 r1.SetFromXYZAnglesValues x2, y2, z2 r1.GetQuaternion q2 t = (current - t1) / (t2 - t1) q3.SLerp q1, q2, t Out.value.quatw.value = q3.w Out.value.quatx.value = q3.x Out.value.quaty.value = q3.y Out.value.quatz.value = q3.z end if i = xkeys - 1 elseif i = xkeys - 1 then out.value.rotx.value = rotx.value out.value.roty.value = roty.value out.value.rotz.value = rotz.value else t1 = t2 x1 = x2 end if next end if end if From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Agedito Sent: Thursday, September 28, 2006 11:14 PM To: XSI(at)Softimage.COM Subject: RE: Change quaternion FCurve interpolation? Thanks Brent.
It’ bad new that it’s
impossible to access it L I need to change it to lineal. L Thanks
again De:
Sorry, I do not believe it is
possible to do this in scripting. The quaternion fcurve is a
completely different type of curve in XSI and it has not been exposed through
scripting. Also, you need to be careful when using quaternion fcurves since they
cannot be exported to different file formats. If you want something like simple
spherical linear interpolation might be better to roll you own using a custom
operator attached to the rotation parameters. (e.g. grab the fcurves, read the
key values, and then do your own slerp) -- Brent From: Thanks Brent, but I
need do it by scripting. Any
idea? De:
Agedito, Open the animation editor, select
all three curves (but don't select any keys on the curves) and hit the linear
interpolation button in the toolbar. Cheers! -- Brent From: Hello Ok, the quaternions FCurve are
spline interpolated and I need to change the interpolation to lineal. I dont
found how do it, I'd tryed all the methods but If the FCurve is euler runs but
if it's quaternion don't run. |
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: RE: Hair pre-processing
- Next by Date: RE: Hair pre-processing
- Previous by Thread: RE: Hair pre-processing
- Next by Thread: RE: Hair pre-processing
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |