2
2
// This file is subject to the terms and conditions defined in
3
3
// file 'LICENSE.txt', which is part of this source code package.
4
4
5
- using System ;
6
5
using Microsoft . Xna . Framework ;
7
6
using Microsoft . Xna . Framework . Content . Pipeline ;
8
7
using Microsoft . Xna . Framework . Content . Pipeline . Graphics ;
9
- using Microsoft . Xna . Framework . Graphics ;
10
- using NUnit . Framework ;
11
8
using Microsoft . Xna . Framework . Content . Pipeline . Processors ;
9
+ using NUnit . Framework ;
10
+ using System ;
12
11
13
12
namespace MonoGame . Tests . ContentPipeline
14
13
{
@@ -281,5 +280,51 @@ public void DefaultEffectTest()
281
280
282
281
//Assert.IsInstanceOf(typeof(SkinnedMaterialContent), output.Meshes[0].MeshParts[0].Material);
283
282
}
283
+
284
+ [ Test ]
285
+ /// <summary>
286
+ /// Test to validate a model with missing normals does not throw an exception using the default ModelProcessor.
287
+ /// </summary>
288
+ public void MissingNormalsTestDefault ( )
289
+ {
290
+ string level1fbx = "Assets/Models/level1.fbx" ;
291
+ var importer = new FbxImporter ( ) ;
292
+ var context = new TestImporterContext ( "TestObj" , "TestBin" ) ;
293
+ var nodeContent = importer . Import ( level1fbx , context ) ;
294
+
295
+ ModelProcessor processor = new ModelProcessor ( ) ;
296
+ var processorContext = new TestProcessorContext ( TargetPlatform . Windows , "level1.xnb" ) ;
297
+
298
+ ModelContent output = null ;
299
+ // Validate that the processor does not throw an exception when normals are missing from the mesh
300
+ Assert . DoesNotThrow ( ( ) => output = processor . Process ( nodeContent , processorContext ) ) ;
301
+
302
+ // Test some basics.
303
+ Assert . NotNull ( output ) ;
304
+ Assert . NotNull ( output . Meshes ) ;
305
+ }
306
+
307
+ [ Test ]
308
+ /// <summary>
309
+ /// Test to validate a model with missing normals does not throw an exception using a custom ModelProcessor using MeshHelper.CalculateTangentFrames directly.
310
+ /// </summary>
311
+ public void MissingNormalsTestCustom ( )
312
+ {
313
+ string level1fbx = "Assets/Models/level1.fbx" ;
314
+ var importer = new FbxImporter ( ) ;
315
+ var context = new TestImporterContext ( "TestObj" , "TestBin" ) ;
316
+ var nodeContent = importer . Import ( level1fbx , context ) ;
317
+
318
+ NormalMappingModelProcessor processor = new NormalMappingModelProcessor ( ) ;
319
+ var processorContext = new TestProcessorContext ( TargetPlatform . Windows , "level1_costum.xnb" ) ;
320
+
321
+ ModelContent output = null ;
322
+ // Validate that the custom processor does not throw an exception when normals are missing from the mesh
323
+ Assert . DoesNotThrow ( ( ) => output = processor . Process ( nodeContent , processorContext ) ) ;
324
+
325
+ // Test some basics.
326
+ Assert . NotNull ( output ) ;
327
+ Assert . NotNull ( output . Meshes ) ;
328
+ }
284
329
}
285
- }
330
+ }
0 commit comments