Sign in to follow this  
alessio55555

motion blending

Recommended Posts

Quote:
Original post by alessio55555
I don't know motion blur, but I need to motion blending.
I need a algorithm to interpolate between different animations?


Are you referring to morphing for sprites or meshes?

Share this post


Link to post
Share on other sites
Quote:
Original post by alessio55555
I don't know motion blur, but I need to motion blending.
I need a algorithm to interpolate between different animations?

Are you talking about keyframe animations involving skeletal models?

Share this post


Link to post
Share on other sites
I have a milkshape 3d model with several animations.It's a skeletal animation.
I would like a smooth transitions between several animations.For example, I want a smooth transition between walk and run.
I don't think that motion blur it's the solution.
Somebody suggest me motion blending, but I don't find a good tutorial.

Share this post


Link to post
Share on other sites


If your trying to blend between to animations sets its exactly the same as blending between two animation keyframes. You have a start position (or current position if switching animation sets), you have a destination position and X time allocated to get there. So blending from the current positions of the bones to the first keyframe of a different animation is simple.


Ex:

A---B---C---D---E

M---N---O---P---Q


Assume those are two differnt keyframe animations, the top being walk, and the bottom being run.

If you know how to blend between C and D whats different about blending between D and M? or even D.5 (as in halfway between D and E) and M (or P.5 in some cases)? If you have re written your milkshape class and fully understand what it is really doing you should have no trouble adapting it to do what you asked.

Share this post


Link to post
Share on other sites
check out "keyframed animation" and "linear interpolation" on google... then do following for each vertex:

Vertex[Current] = Lerp(Vertex[Target],CurrentAnimValue);

CurrentAnimValue = a number between 0 and 1, this is where animation is done...


Each update, add a value to CurrentAnimValue.
if CurrentAnimValue > 1, increase the currentframe & nextframe pointers.


The best way of learning is not to copy code from a tutorial or whatnot, but to figure out what needs to be done - and then find ways of doing it.

Cheers.

Share this post


Link to post
Share on other sites
Quote:
Original post by alessio55555
I know linear interpolation, but it take two point,start point and end point
while in your code I see only one parameter in the function Lerp.

I don't understand what do you tell.
Where is blend operation in your code?



You just explained the solution in your own words which is a good start.

When you running an animation you keep track of your last point, your next point, and how far you are in between

them as a value between 0 and 1 we'll call this Interp. When your Interp get's to 1 your last position becomes equal

to your next position and you increment your next position through the animation. (this is sounding confusing to me)

I dont know exactly how your doing your animations right now so if described your system it would be easier for us

to help you out. But your system should have a few featurs like this..



float animtime
flaot interpval
keyframe frames[numframes]
keyframe frameA, frameB
keyframe currentpositon
int curframe

ResetAnimation
{
frameA = frames[0]
frameB = frames[1]
animtime = 0
curframe = 0
}

IncrementAnimation (float T)
{
animtime += T

if animtime > frameB.start then
{
animtime -= frameB.start

curframe++
frameA[curframe]
frameB[curframe+1]

if curframe == numframes
{
ResetAnimation //reached the end
return
}
}

interpval = (animtime - frameA.startTime) / frameA.length

currentposition = LinInterpolate(frameA, frameB, interpval)
}







You need to modify it to handle an array of arrays of keyframes so

keyframe frames[numframes]

becomes..

keyframe frames[numtracks, numframes]

where numtracks are how many differnt animation tracks you have such as walk, run, jump, crawl would be 4

and you'll need to modify the soure to something like this..



float animtime
flaot interpval
keyframe frames[numtracks, numframes]
keyframe frameA, frameB
keyframe currentpositon

int curframe
int curtrack
bool switchingtracks //set true if we're not in normal animation
float switchlength //how much time to get to the next track

ResetAnimation
{
curtrack = 0
frameA = frames[curtrack, 0]
frameB = frames[curtrack, 1]
animtime = 0
curframe = 0
}

GoToStartOfTrack(int track, float time)
{
if track > numtracks
return whaaat?

frameA = currentposition

frameB = frames[track, 0] //start of next track

curtrack = track //prepare for when we finish blend
switchingtracks = true //tell increment function we're blending
switchlength = time //how long we have to blend

animtime = 0 //become how far through we are
curframe = 0 //prepare for when we finish blend
}

IncrementAnimation (float T)
{
animtime += T

if switchingtracks then //begining of blending code
{
if animtime > switchlength then //we're done blending
{
frameA = frames[curtrack, curframe] //basicaly do a reset animation with new track
frameB = frames[curtrack, curframe+1] //basicaly do a reset animation with new track
interpval = (animtime - frameA.startTime) / frameA.length //calculate interp
switchingtracks = false //done blending
}
else
{
interpval = (animtime) / switchlength //this is a quirk, we have to ignore the frames lengths
//becasue we're on special time here
} //end of blending code
}
else
{
if animtime > frameB.start then
{
animtime -= frameB.start

curframe++
frameA[curframe]
frameB[curframe+1]

if curframe == numframes
{
ResetAnimation //reached the end
return
}
}

interpval = (animtime - frameA.startTime) / frameA.length
}

currentposition = LinInterpolate(frameA, frameB, interpval)
}






Obviously that code is not run-able but it should give you some ideas. If anybody notices anything obviously wrong

please corrent me, its hard to catch bugs if you cant compile.

Hope that clears some things up.

Share this post


Link to post
Share on other sites
Doesn't Midnight Club 3 use pixel shaders to do motion blur?

Well, whatever it is, it is the best motion blur I have ever seen in any game. It really gives you a sense of speed. Anyway, I think I did see something about that NVidia's site. I wanted to find out how that worked but I never got too it.

Share this post


Link to post
Share on other sites
Quote:
Original post by T1Oracle
Doesn't Midnight Club 3 use pixel shaders to do motion blur?

Well, whatever it is, it is the best motion blur I have ever seen in any game. It really gives you a sense of speed. Anyway, I think I did see something about that NVidia's site. I wanted to find out how that worked but I never got too it.


Some people are confusing motion BLUR as in giving the appearance of motion, and motion BLENDING as in seamlessly tranfering between sets of skeletal animation data.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this