Skip to content

Commit 0b72a7e

Browse files
authored
Merge pull request #46 from DomCR/glb-refactor
glb refactor
2 parents fa17b9d + efad305 commit 0b72a7e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4186
-3297
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ MeshIO allows to read or create 3D files using .Net and also extract or modify e
1919
FBX6000 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
2020
FBX7000 | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
2121
STL | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
22-
GLB | | :heavy_check_mark: | | :construction: |
23-
GLTF | :construction: | | :construction: | |
22+
GLB V1 | | :heavy_check_mark: | | :x: |
23+
GLB V2 | | :heavy_check_mark: | | :construction: |
24+
GLTF V1 | :construction: | | :x: | |
25+
GLTF V2 | :construction: | | :construction: | |
2426
OBJ | :heavy_check_mark: | | :construction: | |
2527

2628
The goal of this project is to give full support for all the formats in the table.

samples/in/glb/box_v1.glb

4.27 KB
Binary file not shown.

samples/in/glb/box_v2.glb

1.89 KB
Binary file not shown.
-1.79 KB
Binary file not shown.

src/MeshIO.Tests/Formats/Gltf/GltfReaderLocalTest.cs

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//Execute this test only if is in local and debug
2-
#if DEBUG
3-
using MeshIO.Formats.Gltf;
1+
using MeshIO.Formats.Gltf;
42
using MeshIO.Tests.Common;
3+
using MeshIO.Tests.TestModels;
54
using System;
65
using System.IO;
76
using Xunit;
@@ -11,60 +10,63 @@ namespace MeshIO.Tests.Formats.Gltf;
1110

1211
public class GltfReaderLocalTest : IOTestsBase
1312
{
14-
public static readonly TheoryData<string> V1Files = new();
13+
public static readonly TheoryData<FileModel> V1Files = new();
1514

16-
public static readonly TheoryData<string, string> V2Files = new();
15+
public static readonly TheoryData<FileModel> V2Files = new();
1716

1817
private const string _samplesFolder = "..\\..\\..\\..\\..\\..\\glTF-Sample-Models";
1918

2019
static GltfReaderLocalTest()
2120
{
2221
if (!Directory.Exists(_samplesFolder))
2322
{
24-
V1Files.Add(string.Empty);
25-
V2Files.Add(string.Empty, string.Empty);
23+
V1Files.Add(new FileModel());
24+
V2Files.Add(new FileModel());
2625
return;
2726
}
2827

2928
foreach (string file in Directory.GetFiles(Path.Combine(_samplesFolder, "1.0"), "*.glb", SearchOption.AllDirectories))
3029
{
31-
V1Files.Add(file);
30+
FileModel model = new FileModel(file);
31+
V1Files.Add(model);
3232
}
3333

3434
foreach (string file in Directory.GetFiles(Path.Combine(_samplesFolder, "2.0"), "*.glb", SearchOption.AllDirectories))
3535
{
36-
V2Files.Add(Path.GetFileName(file), file);
36+
V2Files.Add(new FileModel(file));
3737
}
3838
}
3939

4040
public GltfReaderLocalTest(ITestOutputHelper output) : base(output) { }
4141

4242
[Theory]
4343
[MemberData(nameof(V1Files))]
44-
public void ReadGlbV1(string path)
44+
public void ReadGlbV1(FileModel test)
4545
{
46-
if (string.IsNullOrEmpty(path))
46+
if (string.IsNullOrEmpty(test.Path))
4747
return;
4848

49-
using (GltfReader reader = new GltfReader(path))
49+
Scene scene = null;
50+
using (GlbReader reader = new GlbReader(test.Path))
5051
{
5152
reader.OnNotification += this.onNotification;
52-
Assert.Throws<NotSupportedException>(reader.Read);
53+
scene = reader.Read();
5354
}
55+
56+
Assert.NotNull(scene);
5457
}
5558

5659
[Theory]
5760
[MemberData(nameof(V2Files))]
58-
public void ReadGlbV2(string file, string path)
61+
public void ReadGlbV2(FileModel test)
5962
{
60-
if (string.IsNullOrEmpty(path))
63+
if (string.IsNullOrEmpty(test.Path))
6164
return;
6265

63-
using (GltfReader reader = new GltfReader(path))
66+
using (GlbReader reader = new GlbReader(test.Path))
6467
{
6568
reader.OnNotification += this.onNotification;
6669
reader.Read();
6770
}
6871
}
6972
}
70-
#endif

src/MeshIO.Tests/Formats/Gltf/GltfReaderTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ public class GltfReaderTests : IOTestsBase
1414

1515
static GltfReaderTests()
1616
{
17-
loadSamples("glb-gltf", "glb", GlbFiles);
18-
loadSamples("glb-gltf", "gltf", GltfFiles);
17+
loadSamples("glb", "glb", GlbFiles);
18+
loadSamples("gltf", "gltf", GltfFiles);
1919
}
2020

2121
public GltfReaderTests(ITestOutputHelper output) : base(output)
2222
{
2323
}
2424

25-
[Theory(Skip = "Gltf not implemented")]
25+
[Theory]
2626
[MemberData(nameof(GlbFiles))]
2727
public void ReadGlb(FileModel test)
2828
{
29-
using (GltfReader reader = new GltfReader(test.Path))
29+
using (GlbReader reader = new GlbReader(test.Path))
3030
{
3131
reader.OnNotification += this.onNotification;
3232
reader.Read();
@@ -37,7 +37,7 @@ public void ReadGlb(FileModel test)
3737
[MemberData(nameof(GltfFiles))]
3838
public void ReadGltf(FileModel test)
3939
{
40-
using (GltfReader reader = new GltfReader(test.Path))
40+
using (GlbReader reader = new GlbReader(test.Path))
4141
{
4242
reader.OnNotification += this.onNotification;
4343
reader.Read();

0 commit comments

Comments
 (0)