|
30 | 30 | using Orts.Viewer3D.Processes;
|
31 | 31 | using ORTS.Common;
|
32 | 32 | using glTFLoader.Schema;
|
| 33 | +using Orts.Simulation.AIs; |
33 | 34 |
|
34 | 35 | namespace Orts.Viewer3D
|
35 | 36 | {
|
@@ -168,6 +169,11 @@ public override Matrix SetRenderMatrices(ShapePrimitive baseShapePrimitive, Matr
|
168 | 169 | hi = shapePrimitive.Hierarchy[hi];
|
169 | 170 | }
|
170 | 171 | Matrix.Multiply(ref bones[j], ref PlusZToForward, out bones[j]);
|
| 172 | + |
| 173 | + // The ConsistGenerator is used to show all the Khronos sample models for testing purposes. However they need adjustments to show them all at once. |
| 174 | + if (ConsistGenerator.GeneratedRun && SampleModelsAdjustments.TryGetValue(Path.GetFileNameWithoutExtension(FilePath), out var adjustment)) |
| 175 | + Matrix.Multiply(ref bones[j], ref adjustment, out bones[j]); |
| 176 | + |
171 | 177 | Matrix.Multiply(ref bones[j], ref tileTranslation, out bones[j]);
|
172 | 178 | }
|
173 | 179 |
|
@@ -525,7 +531,7 @@ public GltfDistanceLevel(GltfShape shape, int lodId, Gltf gltfFile, string gltfF
|
525 | 531 | }
|
526 | 532 | }
|
527 | 533 |
|
528 |
| -if (shape.GltfAnimations.Count > 0) { shape.GltfAnimations.Add(shape.GltfAnimations[0]); shape.MatrixNames[shape.GltfAnimations.Count - 1] = "ORTSITEM1CONTINUOUS"; } |
| 534 | +//if (shape.GltfAnimations.Count > 0) { shape.GltfAnimations.Add(shape.GltfAnimations[0]); shape.MatrixNames[shape.GltfAnimations.Count - 1] = "ORTSITEM1CONTINUOUS"; } |
529 | 535 | }
|
530 | 536 | }
|
531 | 537 |
|
@@ -1781,6 +1787,63 @@ public void Animate(int animationNumber, float time, Matrix[] animatedMatrices)
|
1781 | 1787 | static readonly Func<float, float> D = (t) => t*t*t - t*t;
|
1782 | 1788 | static readonly Func<Quaternion, Quaternion, Quaternion, Quaternion, float, Quaternion> CsInterp = (v1, b1, v2, a2, t) =>
|
1783 | 1789 | Quaternion.Normalize(Quaternion.Multiply(v1, A(t)) + Quaternion.Multiply(b1, B(t)) + Quaternion.Multiply(v2, C(t)) + Quaternion.Multiply(a2, D(t)));
|
| 1790 | + |
| 1791 | + /// <summary> |
| 1792 | + /// It is used to store the adjustments needed for the Khronos sample models for being able to show them all at once in a single consist. |
| 1793 | + /// For this to work 'git clone https://github.com/KhronosGroup/glTF-Sample-Models.git' to the MSTS/TRAINS/TRAINSET folder, so that the |
| 1794 | + /// models will be available in e.g. MSTS/TRAINS/TRAINSET/glTF-Sample-Models/2.0/... folder. Then start like: |
| 1795 | + /// RunActivity.exe -start -explorer "C:\Devel\MSTS\ROUTES\USA2\PATHS\tut6path.pat" "glTF-Sample-Models" 12:00 1 0 |
| 1796 | + /// </summary> |
| 1797 | + static readonly Dictionary<string, Matrix> SampleModelsAdjustments = new Dictionary<string, Matrix> |
| 1798 | + { |
| 1799 | + { "2CylinderEngine".ToLower(), Matrix.CreateScale(0.01f) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1800 | + { "ABeautifulGame".ToLower(), Matrix.CreateScale(10) }, |
| 1801 | + { "AnimatedCube".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1802 | + { "AnimatedMorphCube".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1803 | + { "AnimatedMorphSphere".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1804 | + { "AntiqueCamera".ToLower(), Matrix.CreateScale(0.5f) }, |
| 1805 | + { "AttenuationTest".ToLower(), Matrix.CreateScale(0.3f) * Matrix.CreateTranslation(0, 4, 0) }, |
| 1806 | + { "Avocado".ToLower(), Matrix.CreateScale(50) }, |
| 1807 | + { "BarramundiFish".ToLower(), Matrix.CreateScale(10) }, |
| 1808 | + { "BoomBox".ToLower(), Matrix.CreateScale(100) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1809 | + { "BoomBoxWithAxes".ToLower(), Matrix.CreateScale(100) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1810 | + { "Box".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1811 | + { "Box With Spaces".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1812 | + { "BoxAnimated".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1813 | + { "BoxInterleaved".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1814 | + { "BoxTextured".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1815 | + { "BoxTexturedNonPowerOfTwo".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1816 | + { "BoxVertexColors".ToLower(), Matrix.CreateTranslation(0, 1, 0) }, |
| 1817 | + { "Buggy".ToLower(), Matrix.CreateScale(0.02f) * Matrix.CreateTranslation(0, 1, 0) }, |
| 1818 | + { "ClearCoatTest".ToLower(), Matrix.CreateScale(0.5f) * Matrix.CreateTranslation(0, 3, 0) }, |
| 1819 | + { "Corset".ToLower(), Matrix.CreateScale(40) * Matrix.CreateTranslation(0, 1, 0) }, |
| 1820 | + { "Cube".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1821 | + { "DamagedHelmet".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1822 | + { "DragonAttenuation".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1823 | + { "EmissiveStrengthTest".ToLower(), Matrix.CreateScale(0.5f) * Matrix.CreateTranslation(0, 3, 0) }, |
| 1824 | + { "FlightHelmet".ToLower(), Matrix.CreateScale(5) }, |
| 1825 | + { "Fox".ToLower(), Matrix.CreateScale(0.02f) }, |
| 1826 | + { "GearboxAssy".ToLower(), Matrix.CreateTranslation(100, 0, 0) }, |
| 1827 | + { "GlamVelvetSofa".ToLower(), Matrix.CreateScale(2) }, |
| 1828 | + { "InterpolationTest".ToLower(), Matrix.CreateScale(0.5f) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1829 | + { "IridescenceDielectricSpheres".ToLower(), Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(0, 4, 0) }, |
| 1830 | + { "IridescenceLamp".ToLower(), Matrix.CreateScale(5) }, |
| 1831 | + { "IridescenceMetallicSpheres".ToLower(), Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(0, 4, 0) }, |
| 1832 | + { "IridescenceSuzanne".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1833 | + { "IridescentDishWithOlives".ToLower(), Matrix.CreateScale(10) }, |
| 1834 | + { "Lantern".ToLower(), Matrix.CreateScale(0.2f) }, |
| 1835 | + { "MaterialsVariantsShoe".ToLower(), Matrix.CreateScale(5) }, |
| 1836 | + { "MetalRoughSpheres".ToLower(), Matrix.CreateTranslation(0, 5, 0) }, |
| 1837 | + { "MetalRoughSpheresNoTextures".ToLower(), Matrix.CreateTranslation(0, 5, 0) }, |
| 1838 | + { "MorphPrimitivesTest".ToLower(), Matrix.CreateScale(2) * Matrix.CreateTranslation(0, 1, 0) }, |
| 1839 | + { "MosquitoInAmber".ToLower(), Matrix.CreateScale(25) * Matrix.CreateTranslation(0, 1, 0) }, |
| 1840 | + { "MultiUVTest".ToLower(), Matrix.CreateTranslation(0, 2, 0) }, |
| 1841 | + { "NormalTangentMirrorTest".ToLower(), Matrix.CreateScale(2) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1842 | + { "NormalTangentTest".ToLower(), Matrix.CreateScale(2) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1843 | + { "OrientationTest".ToLower(), Matrix.CreateScale(0.2f) * Matrix.CreateTranslation(0, 2, 0) }, |
| 1844 | + { "ReciprocatingSaw".ToLower(), Matrix.CreateScale(0.02f) * Matrix.CreateTranslation(0, 3, 0) }, |
| 1845 | + { "RecursiveSkeletons".ToLower(), Matrix.CreateScale(0.02f) }, |
| 1846 | + }; |
1784 | 1847 | }
|
1785 | 1848 |
|
1786 | 1849 | class GltfAnimation
|
|
0 commit comments