Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 21 December 2012 - 12:07 AM
Posted 21 December 2012 - 09:57 AM
This can be a bit tricky. You can't just say "two vectors are almost the same so they should be deleted" because if you apply this same rule to all your vectors one after the other, then you will end up with no vectors!...cause they will all be close to the one that precedes it.
So instead I would suggest adding each vector together, from start to end, till the angle between the last direction and the resulting direction have deviated enough to warrant a new key frame. Basically, if the last vector plus the new vector point in the same direction, then merge the points.
Posted 21 December 2012 - 05:01 PM
Thanks for your response, Nyssa!
I understand the issue you point out but what you are proposing appears to suffer from the same issue. You say 'if they have deviated enough to warrant a new keyframe' which is exactly the same as what I am doing. The only difference (if I understand your method properly) is you are measuring the direction of (A+B) relative to A, and I am measuring the components of A vs. the components of B. The difference in direction of A from (A+B) is just as likely to be too small and incorrectly eliminate a keyframe. I think its just a question of how strict you are with the comparisons. i.e. how much is 'enough' to warrant a new keyframe.
Moreover, your method only takes direction into account and would incorrectly merge the vectors (1,1,1) and (2,2,2) since their sum (3,3,3) is in the same direction as (1,1,1). Unless I misunderstand your approach, that is.
Posted 21 December 2012 - 05:49 PM
Moreover, your method only takes direction into account and would incorrectly merge the vectors (1,1,1) and (2,2,2) since their sum (3,3,3) is in the same direction as (1,1,1).
That's correct. Sorry, I shouldn't have been talking about adding vectors together. Lets say you have 4 points (1,1,1), (2,2,2), (3,3,3), (4,4,4). If you place these points on a graph then the resulting line would be straight. Therefore there is no need for points (2,2,2) and (3,3,3) so you would just keep keys (1,1,1) and (4,4,4).
If however we have the points (1,1,1), (2,2,2), (3,-20,3), (4,4,4) you would need to keep all the points otherwise your animations won't follow the correct paths.
You would always store the first keyframe and the last keyframe anyway so that your animation runs from the first position to the end position correctly. Then you would make the direction from A to B the first comparison direction. Then test the direction from A to C. If the direction is about the same as the first comparison direction then throw away B. The next test would be from A to D and so on....
If the direction from A to C wasn't in the same direction as A to B then you would need to keep B. Because without this point your animations wouldn't follow the correct path. The direction from B to C would become your new comparison direction and you would repeat the above test for B to D and so on...
Edited by Nyssa, 21 December 2012 - 05:54 PM.
Posted 22 December 2012 - 09:38 AM
Yes! This is part of what I was planning after the next step. After coming up with a suitable comparison function, the next step is to use it to A. eliminate duplicate key frames, and B. eliminate key frames that are equivalent to interpolation. I had essentially the same algorithm in mind, except I would do the following:
For a key-frame B at time t, between key-frames A and C: interpolate A and C and evaluate it at t. Now call Compare ( B, interpolate(A,C,t)) and eliminate B if they are close enough.
Posted 22 December 2012 - 02:09 PM
They would only be straight if they were timed equally far apart.
That's correct. Sorry, I shouldn't have been talking about adding vectors together. Lets say you have 4 points (1,1,1), (2,2,2), (3,3,3), (4,4,4). If you place these points on a graph then the resulting line would be straight. Therefore there is no need for points (2,2,2) and (3,3,3) so you would just keep keys (1,1,1) and (4,4,4).
Posted 22 December 2012 - 07:30 PM
They would only be straight if they were timed equally far apart.
That's true Daaark.
mv, are the errors you're talking about also occurring in a frames time stamp? If you have multiple frames with the same time stamp you could simply remove any duplicates?
Posted 22 December 2012 - 08:25 PM
Posted 24 December 2012 - 08:00 AM
bool canRemoveMiddleFrame(vec3 v0, vec3 v1, vec3 v2, float diff) { vec3 va = v1 - v0; vec3 vb = v2 - v1; vec3 vc = va - vb; return (abs(vc.x) < diff) && (abs(vc.y) < diff) && (abs(vc.z) < diff); } bool canRemoveMiddleFrame(quat v0, quat v1, quat v2, float diff) { quat va = v1 * invert(v0); quat vb = v2 * invert(v1); float difference = dot(va, vb); return abs( difference - 1 ) < diff; }
Edited by RobTheBloke, 24 December 2012 - 08:01 AM.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.