Last change
on this file since 2277 was
2096,
checked in by ldelgass, 14 years ago
|
Normalize line endings, set eol-style to native on *.cpp, *.h files
|
-
Property svn:eol-style set to
native
|
File size:
1.4 KB
|
Rev | Line | |
---|
[828] | 1 | #include <Vector3.h> |
---|
| 2 | |
---|
| 3 | void evaluate(float fraction, float* key, int count, Vector3* keyValue, Vector3* ret) |
---|
| 4 | { |
---|
| 5 | int limit = (int) count - 1; |
---|
| 6 | if (fraction <= key[0]) |
---|
| 7 | { |
---|
| 8 | *ret = keyValue[0]; |
---|
| 9 | } |
---|
| 10 | else if (fraction >= key[limit]) |
---|
| 11 | { |
---|
| 12 | *ret = keyValue[limit]; |
---|
| 13 | } |
---|
| 14 | else |
---|
| 15 | { |
---|
| 16 | int n; |
---|
| 17 | for (n = 0;n < limit; n++){ |
---|
| 18 | if (fraction >= key[n] && fraction < key[n+1]) break; |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | if (n >= limit){ |
---|
| 22 | *ret = keyValue[limit]; |
---|
| 23 | } |
---|
| 24 | else { |
---|
| 25 | float inter = (fraction - key[n]) / (key[n + 1] - key[n]); |
---|
| 26 | ret->set( |
---|
| 27 | inter * (keyValue[n + 1].x - keyValue[n].x) + keyValue[n].x, |
---|
| 28 | inter * (keyValue[n + 1].y - keyValue[n].y) + keyValue[n].y, |
---|
| 29 | inter * (keyValue[n + 1].z - keyValue[n].z) + keyValue[n].z); |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | void evaluate(float fraction, float* key, int count, float* keyValue, float* ret) |
---|
| 35 | { |
---|
| 36 | int limit = (int) count - 1; |
---|
| 37 | if (fraction <= key[0]) |
---|
| 38 | { |
---|
| 39 | *ret = keyValue[0]; |
---|
| 40 | } |
---|
| 41 | else if (fraction >= key[limit]) |
---|
| 42 | { |
---|
| 43 | *ret = keyValue[limit]; |
---|
| 44 | } |
---|
| 45 | else |
---|
| 46 | { |
---|
| 47 | int n; |
---|
| 48 | for (n = 0;n < limit; n++){ |
---|
| 49 | if (fraction >= key[n] && fraction < key[n+1]) break; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | if (n >= limit){ |
---|
| 53 | *ret = keyValue[limit]; |
---|
| 54 | } |
---|
| 55 | else { |
---|
| 56 | float inter = (fraction - key[n]) / (key[n + 1] - key[n]); |
---|
| 57 | *ret = inter * (keyValue[n + 1] - keyValue[n]) + keyValue[n]; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.