-
Notifications
You must be signed in to change notification settings - Fork 72
Expand file tree
/
Copy pathPrimitiveDataTests.cs
More file actions
106 lines (101 loc) · 4.05 KB
/
PrimitiveDataTests.cs
File metadata and controls
106 lines (101 loc) · 4.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// Visual Pinball Engine
// Copyright (C) 2023 freezy and VPE Team
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
using FluentAssertions;
using NUnit.Framework;
using VisualPinball.Engine.Test.Test;
using VisualPinball.Engine.VPT.Primitive;
using VisualPinball.Engine.VPT.Table;
namespace VisualPinball.Engine.Test.VPT.Primitive
{
public class PrimitiveDataTests
{
[Test]
public void ShouldReadPrimitiveData()
{
var table = FileTableContainer.Load(VpxPath.Primitive);
ValidatePrimitiveData(table.Primitive("Cube").Data);
}
[Test]
public void ShouldWritePrimitiveData()
{
const string tmpFileName = "ShouldWritePrimitiveData.vpx";
var table = FileTableContainer.Load(VpxPath.Primitive);
new TableWriter(table).WriteTable(tmpFileName);
var writtenTable = FileTableContainer.Load(tmpFileName);
ValidatePrimitiveData(writtenTable.Primitive("Cube").Data);
}
public static void ValidatePrimitiveData(PrimitiveData data)
{
data.BackfacesEnabled.Should().Be(false);
data.CollisionReductionFactor.Should().Be(0.6119f);
data.CompressedIndices.Should().Be(53);
data.CompressedVertices.Should().Be(135);
data.DepthBias.Should().Be(0.1665f);
data.DisableLightingBelow.Should().Be(0.0012f);
data.DisableLightingTop.Should().BeInRange(0.019f, 0.02f);
data.DisplayTexture.Should().Be(false);
data.DrawTexturesInside.Should().Be(false);
data.EdgeFactorUi.Should().Be(0.267f);
data.Elasticity.Should().Be(0.3163f);
data.ElasticityFalloff.Should().Be(0.53219f);
data.Friction.Should().Be(0.36189f);
data.HitEvent.Should().Be(false);
data.Image.Should().Be("p1-beachwood");
data.IsCollidable.Should().Be(true);
data.IsReflectionEnabled.Should().Be(true);
data.IsToy.Should().Be(false);
data.IsVisible.Should().Be(true);
data.Material.Should().Be("Playfield");
data.MeshFileName.Should().Be("cube.obj");
data.NormalMap.Should().Be("");
data.NumIndices.Should().Be(36);
data.NumVertices.Should().Be(24);
data.OverwritePhysics.Should().Be(true);
data.PhysicsMaterial.Should().Be("");
data.Position.X.Should().Be(500.1f);
data.Position.Y.Should().Be(500.2f);
data.Position.Z.Should().Be(0.123f);
data.RotAndTra[0].Should().Be(0.12f);
data.RotAndTra[1].Should().Be(0.98f);
data.RotAndTra[2].Should().Be(0.69f);
data.RotAndTra[3].Should().Be(0.45f);
data.RotAndTra[4].Should().Be(0.47f);
data.RotAndTra[5].Should().Be(0.24f);
data.RotAndTra[6].Should().Be(0.19f);
data.RotAndTra[7].Should().Be(0.59f);
data.RotAndTra[8].Should().Be(0.13f);
data.Scatter.Should().Be(0.9815f);
data.SideColor.Red.Should().Be(150);
data.SideColor.Green.Should().Be(150);
data.SideColor.Blue.Should().Be(150);
data.Sides.Should().Be(4);
data.Size.X.Should().Be(100.11f);
data.Size.Y.Should().Be(100.22f);
data.Size.Z.Should().Be(100.33f);
data.StaticRendering.Should().Be(true);
data.Threshold.Should().Be(2f);
data.Use3DMesh.Should().Be(true);
data.Mesh.Vertices[0].X.Should().Be(1f);
data.Mesh.Vertices[0].Y.Should().Be(1f);
data.Mesh.Vertices[0].Z.Should().Be(-1f);
// data.Mesh.Vertices[0].Nx.Should().BeApproximately(0f, 0.0001f);
// data.Mesh.Vertices[0].Ny.Should().BeApproximately(1f, 0.0001f);
// data.Mesh.Vertices[0].Nz.Should().BeApproximately(0f, 0.0001f);
data.Mesh.Vertices[0].Tu.Should().Be(0.375f);
data.Mesh.Vertices[0].Tv.Should().Be(0f);
}
}
}