FbxClusterTest.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // ***********************************************************************
  2. // Copyright (c) 2017 Unity Technologies. All rights reserved.
  3. //
  4. // Licensed under the ##LICENSENAME##.
  5. // See LICENSE.md file in the project root for full license information.
  6. // ***********************************************************************
  7. using NUnit.Framework;
  8. using System.Collections;
  9. using Autodesk.Fbx;
  10. namespace Autodesk.Fbx.UnitTests
  11. {
  12. public class FbxClusterTest : Base<FbxCluster>
  13. {
  14. [Test]
  15. public void TestBasics ()
  16. {
  17. using (var fbxCluster = FbxCluster.Create (Manager, "")) {
  18. // test set link mode
  19. fbxCluster.SetLinkMode (FbxCluster.ELinkMode.eAdditive);
  20. Assert.AreEqual (FbxCluster.ELinkMode.eAdditive, fbxCluster.GetLinkMode ());
  21. // test set link
  22. FbxNode node = FbxNode.Create(Manager, "node");
  23. fbxCluster.SetLink (node);
  24. Assert.AreEqual (node, fbxCluster.GetLink ());
  25. // test set null link
  26. Assert.That (() => { fbxCluster.SetLink(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  27. // test add control point index (make sure it doesn't crash)
  28. fbxCluster.AddControlPointIndex(0, 0);
  29. fbxCluster.AddControlPointIndex(-1, 0); // doesn't get added (probably because -1 is not a valid index)
  30. fbxCluster.AddControlPointIndex(0, -1.1);
  31. Assert.AreEqual (2, fbxCluster.GetControlPointIndicesCount ());
  32. fbxCluster.SetControlPointIWCount(-1); // test that setting invalid doesn't cause crash
  33. fbxCluster.SetControlPointIWCount (10);
  34. Assert.AreEqual (10, fbxCluster.GetControlPointIndicesCount ());
  35. Assert.AreEqual (0, fbxCluster.GetControlPointIndexAt (0));
  36. Assert.AreEqual (0, fbxCluster.GetControlPointWeightAt (0));
  37. Assert.AreEqual (0, fbxCluster.GetControlPointIndexAt (1));
  38. Assert.AreEqual (-1.1, fbxCluster.GetControlPointWeightAt (1));
  39. // test set transform matrix
  40. FbxAMatrix matrix = new FbxAMatrix();
  41. fbxCluster.SetTransformMatrix (matrix);
  42. FbxAMatrix returnMatrix = new FbxAMatrix();
  43. Assert.AreEqual (matrix, fbxCluster.GetTransformMatrix (returnMatrix));
  44. // test set null transform matrix
  45. Assert.That (() => { fbxCluster.SetTransformMatrix (null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  46. // test get null transform matrix
  47. Assert.That (() => { fbxCluster.GetTransformMatrix (null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  48. // test set transform link matrix
  49. matrix = new FbxAMatrix();
  50. fbxCluster.SetTransformLinkMatrix (matrix);
  51. FbxAMatrix returnMatrix2 = new FbxAMatrix();
  52. Assert.AreEqual (matrix, fbxCluster.GetTransformLinkMatrix (returnMatrix2));
  53. // test set null transform link matrix
  54. Assert.That (() => { fbxCluster.SetTransformLinkMatrix (null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  55. // test get null transform link matrix
  56. Assert.That (() => { fbxCluster.GetTransformLinkMatrix (null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  57. }
  58. }
  59. }
  60. }