FbxPropertyTest.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 Autodesk.Fbx;
  9. namespace Autodesk.Fbx.UnitTests
  10. {
  11. public class FbxPropertyTest : TestBase<FbxProperty>
  12. {
  13. #if ENABLE_COVERAGE_TEST
  14. [Test]
  15. public override void TestCoverage() {
  16. // Alphabetical list, with FbxProperty at the top.
  17. base.TestCoverage();
  18. CoverageTester.TestCoverage(typeof(FbxPropertyBool), this.GetType());
  19. CoverageTester.TestCoverage(typeof(FbxPropertyDouble), this.GetType());
  20. CoverageTester.TestCoverage(typeof(FbxPropertyDouble3), this.GetType());
  21. CoverageTester.TestCoverage(typeof(FbxPropertyEBlendMode), this.GetType());
  22. CoverageTester.TestCoverage(typeof(FbxPropertyEGateFit), this.GetType());
  23. CoverageTester.TestCoverage(typeof(FbxPropertyEWrapMode), this.GetType());
  24. CoverageTester.TestCoverage(typeof(FbxPropertyEProjectionType), this.GetType());
  25. CoverageTester.TestCoverage(typeof(FbxPropertyMarkerELook), this.GetType());
  26. CoverageTester.TestCoverage(typeof(FbxPropertyNullELook), this.GetType());
  27. CoverageTester.TestCoverage(typeof(FbxPropertyString), this.GetType());
  28. CoverageTester.TestCoverage(typeof(FbxPropertyELightType), this.GetType ());
  29. CoverageTester.TestCoverage(typeof(FbxPropertyEAreaLightShape), this.GetType ());
  30. CoverageTester.TestCoverage(typeof(FbxPropertyEDecayType), this.GetType ());
  31. CoverageTester.TestCoverage(typeof(FbxPropertyFloat), this.GetType ());
  32. CoverageTester.TestCoverage(typeof(FbxPropertyEInheritType), this.GetType ());
  33. CoverageTester.TestCoverage(typeof(FbxPropertyInt), this.GetType ());
  34. }
  35. #endif
  36. [Test]
  37. public void TestEquality() {
  38. using(var manager = FbxManager.Create()) {
  39. // FbxProperty
  40. var node = FbxNode.Create(manager, "node");
  41. var prop1 = FbxProperty.Create(node, Globals.FbxBoolDT, "bool1");
  42. var prop2 = FbxProperty.Create(node, Globals.FbxBoolDT, "bool2");
  43. var prop1copy = node.FindProperty("bool1");
  44. EqualityTester<FbxProperty>.TestEquality(prop1, prop2, prop1copy);
  45. // FbxPropertyT<bool>
  46. var vis1 = node.VisibilityInheritance;
  47. var vis2 = FbxNode.Create(manager, "node2").VisibilityInheritance;
  48. var vis1copy = vis1; // TODO: node.FindProperty("Visibility Inheritance"); -- but that has a different proxy type
  49. EqualityTester<FbxPropertyBool>.TestEquality(vis1, vis2, vis1copy);
  50. // FbxPropertyT<EInheritType>
  51. var inhType1 = node.InheritType;
  52. var inhType2 = FbxNode.Create (manager, "node3").InheritType;
  53. var inhType1Copy = inhType1; // TODO: node.FindProperty("InheritType");
  54. EqualityTester<FbxPropertyEInheritType>.TestEquality (inhType1, inhType2, inhType1Copy);
  55. // FbxPropertyT<double>
  56. var lambert = FbxSurfaceLambert.Create(manager, "lambert");
  57. var emissiveCopy = lambert.EmissiveFactor; // TODO: lambert.FindProperty("EmissiveFactor");
  58. EqualityTester<FbxPropertyDouble>.TestEquality(lambert.EmissiveFactor, lambert.AmbientFactor, emissiveCopy);
  59. // FbxPropertyT<FbxDouble3>
  60. var lclTranslationCopy = node.LclTranslation; // TODO: node.FindProperty("Lcl Translation");
  61. EqualityTester<FbxPropertyDouble3>.TestEquality(node.LclTranslation, node.LclRotation, lclTranslationCopy);
  62. // FbxPropertyT<float>
  63. var light = FbxLight.Create(manager, "light");
  64. EqualityTester<FbxPropertyFloat>.TestEquality(light.LeftBarnDoor, light.RightBarnDoor, light.LeftBarnDoor);
  65. // FbxPropertyT<int>
  66. var constraint = FbxConstraintAim.Create (manager, "constraint");
  67. var constraint2 = FbxConstraintAim.Create (manager, "constraint2");
  68. var worldUpTypeCopy = constraint.WorldUpType; // TODO: constraint.FindProperty("WorldUpType");
  69. EqualityTester<FbxPropertyInt>.TestEquality (constraint.WorldUpType, constraint2.WorldUpType, worldUpTypeCopy);
  70. // FbxPropertyT<> for FbxTexture enums
  71. var tex1 = FbxTexture.Create(manager, "tex1");
  72. var tex2 = FbxTexture.Create(manager, "tex2");
  73. var blendCopy = tex1.CurrentTextureBlendMode; // TODO: tex1.FindProperty(...)
  74. EqualityTester<FbxPropertyEBlendMode>.TestEquality(tex1.CurrentTextureBlendMode, tex2.CurrentTextureBlendMode, blendCopy);
  75. var wrapCopy = tex1.WrapModeU; // TODO: tex1.FindProperty(...)
  76. EqualityTester<FbxPropertyEWrapMode>.TestEquality(tex1.WrapModeU, tex2.WrapModeU, wrapCopy);
  77. // FbxPropertyT<FbxNull.ELook>
  78. var null1 = FbxNull.Create(manager, "null1");
  79. var null2 = FbxNull.Create(manager, "null2");
  80. EqualityTester<FbxPropertyNullELook>.TestEquality(null1.Look, null2.Look, null1.Look);
  81. // FbxPropertyT<FbxMarker.ELook>
  82. var marker1 = FbxMarker.Create(manager, "marker1");
  83. var marker2 = FbxMarker.Create(manager, "marker2");
  84. EqualityTester<FbxPropertyMarkerELook>.TestEquality(marker1.Look, marker2.Look, marker1.Look);
  85. // FbxPropertyT<string>
  86. var impl = FbxImplementation.Create(manager, "impl");
  87. var renderAPIcopy = impl.RenderAPI; // TODO: impl.FindProperty("RenderAPI");
  88. EqualityTester<FbxPropertyString>.TestEquality(impl.RenderAPI, impl.RenderAPIVersion, renderAPIcopy);
  89. // FbxPropertyT<> for FbxCamera enum EProjectionType
  90. var cam1 = FbxCamera.Create(manager, "cam1");
  91. var cam2 = FbxCamera.Create(manager, "cam2");
  92. var projectionCopy = cam1.ProjectionType;
  93. EqualityTester<FbxPropertyEProjectionType>.TestEquality(cam1.ProjectionType, cam2.ProjectionType, projectionCopy);
  94. // FbxPropertyT<> for FbxLight enum EType
  95. var light1 = FbxLight.Create(manager, "light1");
  96. var light2 = FbxLight.Create(manager, "light2");
  97. var typeCopy = light1.LightType;
  98. EqualityTester<FbxPropertyELightType>.TestEquality(light1.LightType, light2.LightType, typeCopy);
  99. var lightShapeCopy = light1.AreaLightShape;
  100. EqualityTester<FbxPropertyEAreaLightShape>.TestEquality(light1.AreaLightShape, light2.AreaLightShape, lightShapeCopy);
  101. var decayCopy = light1.DecayType;
  102. EqualityTester<FbxPropertyEDecayType>.TestEquality(light1.DecayType, light2.DecayType, decayCopy);
  103. var floatCopy = light1.LeftBarnDoor;
  104. EqualityTester<FbxPropertyFloat>.TestEquality(light1.LeftBarnDoor, light2.LeftBarnDoor, floatCopy);
  105. }
  106. }
  107. // tests that should work for any subclass of FbxProperty
  108. public static void GenericPropertyTests<T>(T property, FbxObject parent, string propertyName, FbxDataType dataType) where T:FbxProperty{
  109. Assert.IsTrue(property.IsValid());
  110. Assert.AreEqual(dataType, property.GetPropertyDataType());
  111. Assert.AreEqual(propertyName, property.GetName());
  112. Assert.AreEqual(propertyName, property.ToString());
  113. Assert.AreEqual(propertyName, property.GetHierarchicalName());
  114. Assert.AreEqual(propertyName, property.GetLabel(true));
  115. property.SetLabel("label");
  116. Assert.AreEqual("label", property.GetLabel());
  117. Assert.AreEqual(parent, property.GetFbxObject());
  118. Assert.AreEqual(property.GetFbxObject(), parent); // test it both ways just in case equals is busted
  119. // test the flags using the animatable flag
  120. property.ModifyFlag(FbxPropertyFlags.EFlags.eAnimatable, true);
  121. Assert.IsTrue(property.GetFlag(FbxPropertyFlags.EFlags.eAnimatable));
  122. Assert.AreNotEqual(0, property.GetFlags() | FbxPropertyFlags.EFlags.eAnimatable);
  123. property.SetFlagInheritType(FbxPropertyFlags.EFlags.eAnimatable, FbxPropertyFlags.EInheritType.eInherit);
  124. Assert.AreEqual(FbxPropertyFlags.EInheritType.eInherit, property.GetFlagInheritType(FbxPropertyFlags.EFlags.eAnimatable));
  125. // not clear when this ever returns true: whether we set animatable
  126. // to true or false it says it has the default value.
  127. Assert.IsFalse(property.ModifiedFlag(FbxPropertyFlags.EFlags.eAnimatable));
  128. // Test setting the value with the generic float accessor.
  129. // The value may not round-trip: a bool property will go to 1.0
  130. property.Set(5.0f);
  131. TestGetter (property.GetFloat());
  132. TestGetter (property.GetBool ());
  133. TestGetter (property.GetDouble ());
  134. TestGetter (property.GetFbxColor ());
  135. TestGetter (property.GetFbxDouble3 ());
  136. TestGetter (property.GetString ());
  137. TestGetter (property.GetInt ());
  138. // Test setting the value with color accessor
  139. property.Set (new FbxColor ());
  140. // test GetCurve(). Just make sure it doesn't crash. We can't
  141. // generically test actually getting curves, because the details
  142. // (channel names etc) depend on the type of property and its
  143. // flags.
  144. FbxAnimLayer layer = FbxAnimLayer.Create(parent, "layer");
  145. property.GetCurve (layer);
  146. property.GetCurve (layer, true);
  147. property.GetCurve (layer, "asdf");
  148. property.GetCurve (layer, "asdf", true);
  149. property.GetCurve (layer, "asdf", "hjkl", true);
  150. Assert.That (() => { property.GetCurve(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  151. // test GetCurveNode() (make sure it doesn't crash)
  152. FbxAnimCurveNode curveNode = property.GetCurveNode();
  153. Assert.IsNull (curveNode); // didn't create one so should be null
  154. curveNode = property.GetCurveNode (true);
  155. // TODO: figure out why the curve node doesn't get created
  156. //Assert.IsNotNull (curveNode);
  157. property.GetCurveNode (FbxAnimStack.Create (parent, "anim stack"));
  158. property.GetCurveNode (FbxAnimStack.Create (parent, "anim stack"), true);
  159. property.GetCurveNode (FbxAnimLayer.Create (parent, "anim layer"));
  160. property.GetCurveNode (FbxAnimLayer.Create (parent, "anim layer"), true);
  161. Assert.That (() => { property.GetCurveNode((FbxAnimStack)null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  162. Assert.That (() => { property.GetCurveNode((FbxAnimLayer)null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  163. using (FbxManager manager = FbxManager.Create ()) {
  164. // Test ConnectSrcObject functions
  165. FbxObject obj = FbxObject.Create (manager, "obj");
  166. bool result = property.ConnectSrcObject (obj);
  167. Assert.IsTrue (result);
  168. Assert.IsTrue (property.IsConnectedSrcObject (obj));
  169. Assert.AreEqual (1, property.GetSrcObjectCount ());
  170. Assert.AreEqual (obj, property.GetSrcObject ());
  171. Assert.AreEqual (obj, property.GetSrcObject (0));
  172. Assert.AreEqual (obj, property.FindSrcObject ("obj"));
  173. Assert.IsNull (property.FindSrcObject ("obj", 1));
  174. Assert.That (() => { property.FindSrcObject(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  175. Assert.IsTrue (property.DisconnectSrcObject (obj));
  176. Assert.IsFalse (property.IsConnectedSrcObject (obj));
  177. Assert.That (() => { property.ConnectSrcObject(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  178. Assert.IsTrue (property.ConnectSrcObject (obj, FbxConnection.EType.eData));
  179. Assert.IsTrue(property.DisconnectAllSrcObject());
  180. // Test ConnectDstObject functions
  181. result = property.ConnectDstObject (obj);
  182. Assert.IsTrue (result);
  183. Assert.IsTrue (property.IsConnectedDstObject (obj));
  184. Assert.AreEqual (1, property.GetDstObjectCount ());
  185. Assert.AreEqual (obj, property.GetDstObject ());
  186. Assert.AreEqual (obj, property.GetDstObject (0));
  187. Assert.AreEqual (obj, property.FindDstObject ("obj"));
  188. Assert.IsNull (property.FindDstObject ("obj", 1));
  189. Assert.That (() => { property.FindDstObject(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  190. Assert.IsTrue (property.DisconnectDstObject (obj));
  191. Assert.IsFalse (property.IsConnectedDstObject (obj));
  192. Assert.That (() => { property.ConnectDstObject(null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());
  193. Assert.IsTrue (property.ConnectDstObject (obj, FbxConnection.EType.eData));
  194. Assert.IsTrue(property.DisconnectAllDstObject());
  195. }
  196. // verify this in the future: will dispose destroy?
  197. property.Dispose();
  198. }
  199. [Test]
  200. public void BasicTests ()
  201. {
  202. using (var manager = FbxManager.Create()) {
  203. // FbxPropertyT<FbxBool> example: VisibilityInheritance on a node
  204. var node = FbxNode.Create(manager, "node");
  205. GenericPropertyTests<FbxPropertyBool> (node.VisibilityInheritance, node, "Visibility Inheritance", Globals.FbxVisibilityInheritanceDT);
  206. var property = node.VisibilityInheritance;
  207. property.Set(false);
  208. Assert.AreEqual(false, property.Get());
  209. Assert.AreEqual(false, property.EvaluateValue());
  210. Assert.AreEqual(false, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
  211. Assert.AreEqual(false, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  212. }
  213. using(var manager = FbxManager.Create()) {
  214. // FbxPropertyT<FbxDouble> example: several of them on a Lambert shader
  215. var obj = FbxSurfaceLambert.Create(manager, "lambert");
  216. GenericPropertyTests<FbxPropertyDouble> (obj.EmissiveFactor, obj, "EmissiveFactor", Globals.FbxDoubleDT);
  217. var property = obj.EmissiveFactor;
  218. property.Set(5.0); // bool Set<float> is not accessible here!
  219. Assert.AreEqual(5.0, property.Get());
  220. Assert.AreEqual(5.0, property.EvaluateValue());
  221. Assert.AreEqual(5.0, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
  222. Assert.AreEqual(5.0, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  223. }
  224. using(var manager = FbxManager.Create()) {
  225. // FbxPropertyT<Double3> example: the LclTranslation on a node
  226. var node = FbxNode.Create(manager, "node");
  227. GenericPropertyTests<FbxPropertyDouble3> (node.LclTranslation, node, "Lcl Translation", Globals.FbxLocalTranslationDT);
  228. var property = node.LclTranslation;
  229. property.Set(new FbxDouble3(1,2,3));
  230. Assert.AreEqual(new FbxDouble3(1, 2, 3), property.Get());
  231. Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue());
  232. Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue(FbxTime.FromSecondDouble(5)));
  233. Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  234. }
  235. using(var manager = FbxManager.Create()) {
  236. // FbxPropertyT<float> example: the LeftBarnDoor on a light
  237. var light = FbxLight.Create(manager, "light");
  238. GenericPropertyTests(light.LeftBarnDoor, light, "LeftBarnDoor", Globals.FbxFloatDT);
  239. var property = light.LeftBarnDoor;
  240. light.LeftBarnDoor.Set(5.0f);
  241. Assert.AreEqual(5.0f, light.LeftBarnDoor.Get());
  242. Assert.AreEqual(5.0f, property.EvaluateValue());
  243. Assert.AreEqual(5.0f, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
  244. Assert.AreEqual(5.0f, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  245. }
  246. using (var manager = FbxManager.Create ()) {
  247. // FbxPropertyT<int> example: the WorldUpType on an aim constraint
  248. var constraint = FbxConstraintAim.Create (manager, "constraint");
  249. GenericPropertyTests (constraint.WorldUpType, constraint, "WorldUpType", Globals.FbxEnumDT);
  250. var property = constraint.WorldUpType;
  251. int value = (int)FbxConstraintAim.EWorldUp.eAimAtObjectUp;
  252. constraint.WorldUpType.Set (value);
  253. Assert.That (constraint.WorldUpType.Get (), Is.EqualTo (value));
  254. Assert.That (property.EvaluateValue (), Is.EqualTo (value));
  255. Assert.That (property.EvaluateValue (FbxTime.FromSecondDouble (5)), Is.EqualTo (value));
  256. Assert.That (property.EvaluateValue (FbxTime.FromSecondDouble (5), true), Is.EqualTo (value));
  257. }
  258. using (var manager = FbxManager.Create()) {
  259. // FbxPropertyT<FbxString> example: the description of a shader implementation
  260. var impl = FbxImplementation.Create(manager, "name");
  261. GenericPropertyTests<FbxPropertyString> (impl.RenderAPI, impl, "RenderAPI", Globals.FbxStringDT);
  262. var property = impl.RenderAPI;
  263. property.Set("a value");
  264. Assert.AreEqual("a value", property.Get());
  265. // animated strings come out as empty-string
  266. Assert.AreEqual("", property.EvaluateValue());
  267. Assert.AreEqual("", property.EvaluateValue(FbxTime.FromSecondDouble(5)));
  268. Assert.AreEqual("", property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  269. }
  270. using (var manager = FbxManager.Create()) {
  271. // FbxPropertyT for FbxTexture enums EBlendMode and EWrapMode
  272. var tex = FbxTexture.Create(manager, "tex");
  273. FbxPropertyTest.GenericPropertyTests(tex.CurrentTextureBlendMode, tex, "CurrentTextureBlendMode", Globals.FbxEnumDT);
  274. tex.CurrentTextureBlendMode.Set(FbxTexture.EBlendMode.eAdditive);
  275. Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.Get());
  276. Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue());
  277. Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue(FbxTime.FromSecondDouble(5)));
  278. Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  279. FbxPropertyTest.GenericPropertyTests(tex.WrapModeU, tex, "WrapModeU", Globals.FbxEnumDT);
  280. tex.WrapModeU.Set(FbxTexture.EWrapMode.eClamp);
  281. Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.Get());
  282. Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue());
  283. Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue(FbxTime.FromSecondDouble(5)));
  284. Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  285. }
  286. using (var manager = FbxManager.Create()) {
  287. // FbxPropertyT<FbxNull.ELook>
  288. var null1 = FbxNull.Create(manager, "null1");
  289. FbxPropertyTest.GenericPropertyTests(null1.Look, null1, "Look", Globals.FbxEnumDT);
  290. null1.Look.Set(FbxNull.ELook.eCross);
  291. Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.Get());
  292. Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue());
  293. Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue(FbxTime.FromSecondDouble(5)));
  294. Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  295. }
  296. using (var manager = FbxManager.Create()) {
  297. // FbxPropertyT<FbxMarker.ELook>
  298. var marker1 = FbxMarker.Create(manager, "marker1");
  299. FbxPropertyTest.GenericPropertyTests(marker1.Look, marker1, "Look", Globals.FbxEnumDT);
  300. marker1.Look.Set(FbxMarker.ELook.eCapsule);
  301. Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.Get());
  302. Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue());
  303. Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue(FbxTime.FromSecondDouble(5)));
  304. Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  305. }
  306. using (var manager = FbxManager.Create()) {
  307. // FbxPropertyT for FbxCamera enum EProjectionType
  308. var camera = FbxCamera.Create(manager, "camera");
  309. FbxPropertyTest.GenericPropertyTests(camera.ProjectionType, camera, "CameraProjectionType", Globals.FbxEnumDT);
  310. camera.ProjectionType.Set(FbxCamera.EProjectionType.ePerspective);
  311. Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.Get());
  312. Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue());
  313. Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue(FbxTime.FromSecondDouble(5)));
  314. Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  315. }
  316. using (var manager = FbxManager.Create()) {
  317. // FbxPropertyT for FbxCamera enum EGateFit
  318. var camera = FbxCamera.Create(manager, "camera");
  319. FbxPropertyTest.GenericPropertyTests(camera.GateFit, camera, "GateFit", Globals.FbxEnumDT);
  320. camera.GateFit.Set(FbxCamera.EGateFit.eFitHorizontal);
  321. Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.Get());
  322. Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue());
  323. Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue(FbxTime.FromSecondDouble(5)));
  324. Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  325. }
  326. using (var manager = FbxManager.Create()) {
  327. // FbxPropertyT<EInheritType>
  328. var node = FbxNode.Create(manager, "node");
  329. FbxPropertyTest.GenericPropertyTests(node.InheritType, node, "InheritType", Globals.FbxEnumDT);
  330. node.InheritType.Set(FbxTransform.EInheritType.eInheritRSrs);
  331. Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.Get());
  332. Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue());
  333. Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue(FbxTime.FromSecondDouble(5)));
  334. Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  335. }
  336. using (var manager = FbxManager.Create()) {
  337. // FbxPropertyT for FbxLight enums
  338. var light = FbxLight.Create(manager, "light");
  339. FbxPropertyTest.GenericPropertyTests(light.LightType, light, "LightType", Globals.FbxEnumDT);
  340. light.LightType.Set(FbxLight.EType.eSpot);
  341. Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.Get());
  342. Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue());
  343. Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue(FbxTime.FromSecondDouble(5)));
  344. Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  345. FbxPropertyTest.GenericPropertyTests(light.AreaLightShape, light, "AreaLightShape", Globals.FbxEnumDT);
  346. light.AreaLightShape.Set(FbxLight.EAreaLightShape.eSphere);
  347. Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.Get());
  348. Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue());
  349. Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue(FbxTime.FromSecondDouble(5)));
  350. Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  351. FbxPropertyTest.GenericPropertyTests(light.DecayType, light, "DecayType", Globals.FbxEnumDT);
  352. light.DecayType.Set(FbxLight.EDecayType.eCubic);
  353. Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.Get());
  354. Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue());
  355. Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue(FbxTime.FromSecondDouble(5)));
  356. Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
  357. }
  358. using (var manager = FbxManager.Create()) {
  359. // Test all the create and destroy operations
  360. FbxProperty root, child;
  361. var obj = FbxObject.Create(manager, "obj");
  362. Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "a"));
  363. Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "b", "label"));
  364. Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "c", "label", false));
  365. bool didFind;
  366. Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "c", "label", true, out didFind));
  367. Assert.IsTrue(didFind);
  368. root = FbxProperty.Create(obj, Globals.FbxCompoundDT, "root");
  369. child = FbxProperty.Create(root, Globals.FbxStringDT, "a");
  370. Assert.IsNotNull(child);
  371. Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "b", "label"));
  372. Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", false));
  373. Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", true, out didFind));
  374. Assert.IsTrue(didFind);
  375. child.Destroy();
  376. root.DestroyChildren();
  377. Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", true, out didFind));
  378. Assert.IsFalse(didFind);
  379. root.DestroyRecursively();
  380. }
  381. }
  382. }
  383. }