|
Revision 10853, 2.0 kB
(checked in by robert, 3 years ago)
|
|
From Sukender,
"Here is our freshly baked 3DS reader/writer (named 'v0.5' to differentiate from previous one). Changes are against trunk rev. 10819.
Short changelog (from rev 10819):
- Added 3DS writer
- Sync'd with latest lib3DS
- Added options, especially "flattenMatrixTransforms" to get the "old" behaviour (else the reader correctly maps to OSG the transforms from the 3DS file).
What should be done:
- Check with pivot points, with and without "flattenMatrixTransforms" option.
- We ran tests on it, but we can never be 100% sure there is no bug. Testing from the community would of course be helpful."
|
| Line | |
|---|
| 1 | |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | |
|---|
| 11 | |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | #include "lib3ds_impl.h" |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | float |
|---|
| 22 | lib3ds_math_ease(float fp, float fc, float fn, float ease_from, float ease_to) { |
|---|
| 23 | double s, step; |
|---|
| 24 | double tofrom; |
|---|
| 25 | double a; |
|---|
| 26 | |
|---|
| 27 | s = step = (float)(fc - fp) / (fn - fp); |
|---|
| 28 | tofrom = ease_to + ease_from; |
|---|
| 29 | if (tofrom != 0.0) { |
|---|
| 30 | if (tofrom > 1.0) { |
|---|
| 31 | ease_to = (float)(ease_to / tofrom); |
|---|
| 32 | ease_from = (float)(ease_from / tofrom); |
|---|
| 33 | } |
|---|
| 34 | a = 1.0 / (2.0 - (ease_to + ease_from)); |
|---|
| 35 | |
|---|
| 36 | if (step < ease_from) s = a / ease_from * step * step; |
|---|
| 37 | else { |
|---|
| 38 | if ((1.0 - ease_to) <= step) { |
|---|
| 39 | step = 1.0 - step; |
|---|
| 40 | s = 1.0 - a / ease_to * step * step; |
|---|
| 41 | } else { |
|---|
| 42 | s = ((2.0 * step) - ease_from) * a; |
|---|
| 43 | } |
|---|
| 44 | } |
|---|
| 45 | } |
|---|
| 46 | return((float)s); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | void |
|---|
| 51 | lib3ds_math_cubic_interp(float *v, float *a, float *p, float *q, float *b, int n, float t) { |
|---|
| 52 | float x, y, z, w; |
|---|
| 53 | int i; |
|---|
| 54 | |
|---|
| 55 | x = 2 * t * t * t - 3 * t * t + 1; |
|---|
| 56 | y = -2 * t * t * t + 3 * t * t; |
|---|
| 57 | z = t * t * t - 2 * t * t + t; |
|---|
| 58 | w = t * t * t - t * t; |
|---|
| 59 | for (i = 0; i < n; ++i) { |
|---|
| 60 | v[i] = x * a[i] + y * b[i] + z * p[i] + w * q[i]; |
|---|
| 61 | } |
|---|
| 62 | } |
|---|