forked from MonoGame/MonoGame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpenAssetImporterTests.cs
67 lines (58 loc) · 2.78 KB
/
OpenAssetImporterTests.cs
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
// MonoGame - Copyright (C) The MonoGame Team
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Graphics;
using NUnit.Framework;
using System.IO;
namespace MonoGame.Tests.ContentPipeline
{
class OpenAssetImporterTests
{
[Test]
public void Arguments()
{
var context = new TestImporterContext("TestObj", "TestBin");
var importer = new OpenAssetImporter();
Assert.Throws<ArgumentNullException>(() => importer.Import(null, context));
Assert.Throws<FileNotFoundException>(() => importer.Import("does_not_exist", context));
Assert.Throws<ArgumentNullException>(() => importer.Import("file", null));
}
[Test]
#if DESKTOPGL
[Ignore("This crashes inside Assimp on Mac!")]
#endif
public void BlenderTests()
{
var context = new TestImporterContext("TestObj", "TestBin");
var importer = new OpenAssetImporter();
var nodeContent = importer.Import("Assets/Models/Box.blend", context);
Assert.NotNull(nodeContent);
Assert.AreEqual("Cube", nodeContent.Name);
Assert.AreEqual(0, nodeContent.Children.Count);
Assert.AreEqual(Matrix.Identity, nodeContent.Transform);
Assert.AreEqual(Matrix.Identity, nodeContent.AbsoluteTransform);
Assert.NotNull(nodeContent.Parent);
Assert.AreEqual("<BlenderRoot>", nodeContent.Parent.Name);
var meshContent = nodeContent as MeshContent;
Assert.NotNull(meshContent);
Assert.AreEqual(1, meshContent.Geometry.Count);
Assert.AreEqual(0, meshContent.Animations.Count);
Assert.AreEqual(28, meshContent.Positions.Count);
var geometry = meshContent.Geometry[0];
Assert.IsNull(geometry.Name);
Assert.AreEqual(108, geometry.Indices.Count);
Assert.AreEqual(28, geometry.Vertices.VertexCount);
Assert.IsNotNull(geometry.Material);
Assert.AreEqual("Material", geometry.Material.Name);
Assert.AreEqual(5, geometry.Material.OpaqueData.Count);
Assert.AreEqual(new Vector3(1.65732033E-07f, 1, 0), geometry.Material.OpaqueData["DiffuseColor"]);
Assert.AreEqual(Vector3.Zero, geometry.Material.OpaqueData["AmbientColor"]);
Assert.AreEqual(Vector3.One, geometry.Material.OpaqueData["ReflectiveColor"]);
Assert.AreEqual(Vector3.One, geometry.Material.OpaqueData["SpecularColor"]);
Assert.AreEqual(50.0f, geometry.Material.OpaqueData["Shininess"]);
}
}
}