FAO: Mark, rendertweening

BlitzMax Forums/BlitzMax Programming/FAO: Mark, rendertweening

Tom(Posted 2005) [#1]
Hi,

edit: After re-reading what I just wrote below, I think my Q. could be boiled down to: Do you accumulate transforms and apply at renderworld, or apply transforms immediately? :)


Got syrup? Good, coz here's my waffle.... :P

I'd like to use render tweening in my engine, can you give a brief insight as to how Blitz3Ds tweening works? Not the math, but the system behind it.

i.e, If I do turnentity() then immediately call entitypitch() I get the new pitch.

So does turnentity just accumulate rotation and apply it all at renderworld (tweening the accumulated rotation with the capture world rotation), and entitypitch in the meantime would temporarily apply the accumilated rotation of all entitys in a parent chain, so you can get the pitch?

Or, do you apply transformations immediately (do you store b3d entity info as matrices?), entitypitch() gets the rotation from the current matrix state.........and rendertweening <>1.0 would have to interpolate the matrices of each parent > child chain .... with the capture world state?

I noticed render tweening > 1.0 doubles the transform effect, so I suspect you're accumulating and applying at renderworld?

Cheers
Tom


Bot Builder(Posted 2005) [#2]
I'm pretty sure he accumulates all the matrix transforms. As for tweening, I'm going to guess the best way would be to split the start/end matrices for each entity into start/end quaternions and translation vectors. Then the quaternions are interpolated with SLERP, and the translation vectors are intterpolated with linear interpolation. Finally, the quaternions and translation vectors are converted into matrices. Basically just convert the quat to a matrix, and do a raw memory copy from the vector to the proper location inside the matrix if you're using opengl matrices.


Tom(Posted 2005) [#3]
Mat to quat > slerp > quat to mat, done the trick, although I'm getting some weird scaling when the angles to be tweened from/to are wide apart, hard to describe... almost like the interpolation takes the shortest route through 2 spherical surface points, rather than go across the surface. Might be some normalization anomaly. Other than that, it's working pretty good, very much like Blitz3Ds.

Tom


marksibly(Posted 2005) [#4]
Hi,

Blitz3D's render tweening is pretty simple. It just interpolates between the last transform and the current transform (only if tween is non 0 (or 1: can't remember)).

It slerps the rot, and linear interpolates the pos/scale.


Tom(Posted 2005) [#5]
All sorted now, fredborg helped me with a missing quat normalize (doh!), and the scaling bug is fixed :)