12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- // ***********************************************************************
- // Copyright (c) 2017 Unity Technologies. All rights reserved.
- //
- // Licensed under the ##LICENSENAME##.
- // See LICENSE.md file in the project root for full license information.
- // ***********************************************************************
- using NUnit.Framework;
- using System.Collections;
- using Autodesk.Fbx;
- namespace Autodesk.Fbx.UnitTests
- {
- public class FbxCameraTest : FbxNodeAttributeBase<FbxCamera>
- {
- [Test]
- public void TestBasics()
- {
- using (var fbxCamera = CreateObject ("camera")) {
- base.TestBasics(fbxCamera, FbxNodeAttribute.EType.eCamera);
- // test SetAspect
- fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, 100, 200);
- Assert.AreEqual (FbxCamera.EAspectRatioMode.eFixedResolution, fbxCamera.GetAspectRatioMode ());
- // test SetAspect with invalid width/height (make sure it doesn't crash)
- fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, -100, 200);
- fbxCamera.SetAspect (FbxCamera.EAspectRatioMode.eFixedResolution, 100, -200);
- // Test SetApertureWidth
- fbxCamera.SetApertureWidth(100.0);
- Assert.AreEqual (100, (int)fbxCamera.GetApertureWidth ());
- // test with negative width
- fbxCamera.SetApertureWidth(-100.0);
- // Test SetApertureHeight
- fbxCamera.SetApertureHeight(100.0);
- Assert.AreEqual (100, (int)fbxCamera.GetApertureHeight ());
- // test with negative height
- fbxCamera.SetApertureHeight(-100.0);
- // Test SetApertureMode
- fbxCamera.SetApertureMode(FbxCamera.EApertureMode.eFocalLength);
- Assert.AreEqual (FbxCamera.EApertureMode.eFocalLength, fbxCamera.GetApertureMode ());
- // Test SetNearPlane
- fbxCamera.SetNearPlane(10.0);
- Assert.AreEqual (10, (int)fbxCamera.GetNearPlane ());
- // test with negative value
- fbxCamera.SetNearPlane(-10.0);
- // Test SetFarPlane
- fbxCamera.SetFarPlane(10.0);
- Assert.AreEqual (10, (int)fbxCamera.GetFarPlane ());
- // test with negative value
- fbxCamera.SetFarPlane(-10.0);
- // Test ComputeFocalLength
- double result = fbxCamera.ComputeFocalLength(90);
- Assert.GreaterOrEqual (result, 0);
- // test with negative value
- result = fbxCamera.ComputeFocalLength(-90);
- Assert.LessOrEqual (result, 0);
- }
- }
- [Test]
- public void TestProperties(){
- using (var fbxCamera = CreateObject ("camera")) {
- // test getting the properties
- TestGetter (fbxCamera.ProjectionType);
- TestGetter (fbxCamera.FilmAspectRatio);
- TestGetter (fbxCamera.FocalLength);
- TestGetter (fbxCamera.AspectHeight);
- TestGetter (fbxCamera.AspectWidth);
- TestGetter (fbxCamera.NearPlane);
- TestGetter (fbxCamera.FieldOfView);
- TestGetter (fbxCamera.GateFit);
- TestGetter (fbxCamera.FilmOffsetX);
- TestGetter (fbxCamera.FilmOffsetY);
- }
- }
- }
- }
|