Pondering Keyframe Animation
Posted: Tue Dec 15, 2009 4:28 pm
Okay, folks. I've never programmed anything like this before, so I'd like to make sure that I'm on a sensible track before I get too many lines of useless code written.
I'm trying to set up a keyframe animation system. I already have a class set up for characters that will be using this system, and each character on the screen can and usually will have a different animation playing, so I have already come to the conclusion that the table of keyframes is going to need to be stored somewhere within the character class (my character class is called "yarnie").
And so, I have added the following to the "yarnie" table:
Now, my animation editor is basically an array of sliders. Adjusting each slider should create a new key inside the keylist table, but since the keyframe data contains both a frame number and a rotation amount, the new key must also be a table. So, if I were to go to frame 30 and adjust the head by 45 degrees and then go to frame 50 and adjust the front bicep by 90 degrees, I would end up with something like this:
After a couple of additional keyframes, it might look more like this:
Since I'm planning to keep the animation system at a smooth 30 fps, the above represents a short but strange three-second animation.
However, there's no way for the character to keep up with which keyframe he's on at any given moment, so I add:
Now... having a table with numerical indexes (which are equal to tables) and named keys (which are equal to integers) is okay, right?
If this system works, it would allow me to have the character work toward the next keyframe by calling the body part's index using the index key inside the same table. Does that make sense? Does that work? Can that many tables be nested within one another, or should I go back to the drawing board and start over?
Does anybody have any suggestions on how I'd go about getting the indexes containing tables for frame and position to arrange themselves in order from smallest frame value to largest?
Any questions, comments, criticisms and concerns will be deeply appreciated.
I'm trying to set up a keyframe animation system. I already have a class set up for characters that will be using this system, and each character on the screen can and usually will have a different animation playing, so I have already come to the conclusion that the table of keyframes is going to need to be stored somewhere within the character class (my character class is called "yarnie").
And so, I have added the following to the "yarnie" table:
Code: Select all
yarnie.keylist={}
Code: Select all
yarnie.keylist= {
fbicep= {
1 {
frame=50
position=90
}
}
head= {
1= {
frame=30
position=45
}
}
}
Code: Select all
yarnie.keylist= {
fbicep= {
1= {
frame=50
position=90
}
2= {
frame=60
position=80
}
}
head= {
1= {
frame=30
position=45
}
2= {
frame=90
position=90
}
}
}
However, there's no way for the character to keep up with which keyframe he's on at any given moment, so I add:
Code: Select all
yarnie.keylist= {
fbicep= {
1= {
frame=50
position=90
}
2= {
frame=60
position=80
}
index=1
}
head= {
1= {
frame=30
position=45
}
2= {
frame=90
position=90
}
index=1
}
}
If this system works, it would allow me to have the character work toward the next keyframe by calling the body part's index using the index key inside the same table. Does that make sense? Does that work? Can that many tables be nested within one another, or should I go back to the drawing board and start over?
Does anybody have any suggestions on how I'd go about getting the indexes containing tables for frame and position to arrange themselves in order from smallest frame value to largest?
Any questions, comments, criticisms and concerns will be deeply appreciated.