FbxCameraTest.cs 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 FbxCameraTest : FbxNodeAttributeBase<FbxCamera>
  13. {
  14. [Test]
  15. public void TestBasics()
  16. {
  17. using (var fbxCamera = CreateObject ("camera")) {
  18. base.TestBasics(fbxCamera, FbxNodeAttribute.EType.eCamera);
  19. // test SetAspect
  20. fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, 100, 200);
  21. Assert.AreEqual (FbxCamera.EAspectRatioMode.eFixedResolution, fbxCamera.GetAspectRatioMode ());
  22. // test SetAspect with invalid width/height (make sure it doesn't crash)
  23. fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, -100, 200);
  24. fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, 100, -200);
  25. // Test SetApertureWidth
  26. fbxCamera.SetApertureWidth(100.0);
  27. Assert.AreEqual (100, (int)fbxCamera.GetApertureWidth ());
  28. // test with negative width
  29. fbxCamera.SetApertureWidth(-100.0);
  30. // Test SetApertureHeight
  31. fbxCamera.SetApertureHeight(100.0);
  32. Assert.AreEqual (100, (int)fbxCamera.GetApertureHeight ());
  33. // test with negative height
  34. fbxCamera.SetApertureHeight(-100.0);
  35. // Test SetApertureMode
  36. fbxCamera.SetApertureMode(FbxCamera.EApertureMode.eFocalLength);
  37. Assert.AreEqual (FbxCamera.EApertureMode.eFocalLength, fbxCamera.GetApertureMode ());
  38. // Test SetNearPlane
  39. fbxCamera.SetNearPlane(10.0);
  40. Assert.AreEqual (10, (int)fbxCamera.GetNearPlane ());
  41. // test with negative value
  42. fbxCamera.SetNearPlane(-10.0);
  43. // Test SetFarPlane
  44. fbxCamera.SetFarPlane(10.0);
  45. Assert.AreEqual (10, (int)fbxCamera.GetFarPlane ());
  46. // test with negative value
  47. fbxCamera.SetFarPlane(-10.0);
  48. // Test ComputeFocalLength
  49. double result = fbxCamera.ComputeFocalLength(90);
  50. Assert.GreaterOrEqual (result, 0);
  51. // test with negative value
  52. result = fbxCamera.ComputeFocalLength(-90);
  53. Assert.LessOrEqual (result, 0);
  54. }
  55. }
  56. [Test]
  57. public void TestProperties(){
  58. using (var fbxCamera = CreateObject ("camera")) {
  59. // test getting the properties
  60. TestGetter (fbxCamera.ProjectionType);
  61. TestGetter (fbxCamera.FilmAspectRatio);
  62. TestGetter (fbxCamera.FocalLength);
  63. TestGetter (fbxCamera.AspectHeight);
  64. TestGetter (fbxCamera.AspectWidth);
  65. TestGetter (fbxCamera.NearPlane);
  66. TestGetter (fbxCamera.FieldOfView);
  67. TestGetter (fbxCamera.GateFit);
  68. TestGetter (fbxCamera.FilmOffsetX);
  69. TestGetter (fbxCamera.FilmOffsetY);
  70. }
  71. }
  72. }
  73. }