protected override void CheckScene(FbxScene scene) { FbxScene origScene = CreateScene(FbxManager); FbxNode origAnimNode = origScene.GetRootNode().GetChild(0); FbxNode importAnimNode = scene.GetRootNode().GetChild(0); Assert.AreEqual(origScene.GetRootNode().GetChildCount(), scene.GetRootNode().GetChildCount()); Assert.IsNotNull(origAnimNode); Assert.IsNotNull(importAnimNode); Assert.AreEqual(origAnimNode.GetName(), importAnimNode.GetName()); FbxAnimStack origStack = origScene.GetCurrentAnimationStack(); FbxAnimStack importStack = scene.GetCurrentAnimationStack(); CheckAnimStack(origStack, importStack); FbxAnimLayer origLayer = origStack.GetAnimLayerMember(); FbxAnimLayer importLayer = importStack.GetAnimLayerMember(); Assert.IsNotNull(origLayer); Assert.IsNotNull(importLayer); Assert.AreEqual(FbxTime.EMode.eFrames30, scene.GetGlobalSettings().GetTimeMode()); CheckAnimCurve(origAnimNode, importAnimNode, origLayer, importLayer, PropertyComponentList); }
protected override FbxScene CreateScene(FbxManager manager) { FbxScene scene = base.CreateScene(manager); FbxNode lightNode = scene.GetRootNode().GetChild(0); FbxLight light = FbxLight.Create(scene, "light"); light.LightType.Set(FbxLight.EType.eSpot); light.InnerAngle.Set(20); light.OuterAngle.Set(95); // Export bounceIntensity as custom property ExportFloatProperty(lightNode, 3, "bounceIntensity"); light.Color.Set(new FbxDouble3(0.3, 0.1, 0.75)); // Export colorTemperature as custom property ExportFloatProperty(lightNode, 6, "colorTemperature"); light.FileName.Set("/path/to/texture.png"); light.DrawGroundProjection.Set(true); light.DrawVolumetricLight.Set(true); light.DrawFrontFacingVolumetricLight.Set(false); ExportFloatProperty(lightNode, 4.2f, "cookieSize"); light.Intensity.Set(120); light.FarAttenuationStart.Set(0.01f /* none zero start */); light.FarAttenuationEnd.Set(9.8f); light.CastShadows.Set(true); FbxAnimStack animStack = scene.GetCurrentAnimationStack(); FbxAnimLayer animLayer = animStack.GetAnimLayerMember(); // TODO: (UNI-19438) figure out why trying to add anim curves to FbxNodeAttribute.sColor, // Intensity and InnerAngle fails // add animation CreateAnimCurves(lightNode, animLayer, new List <PropertyComponentPair> () { new PropertyComponentPair("colorTemperature", new string[] { null }), new PropertyComponentPair("cookieSize", new string[] { null }) }, (index) => { return((index + 1) / 2.0); }, (index) => { return(index % 2); }); // set ambient lighting scene.GetGlobalSettings().SetAmbientColor(new FbxColor(0.1, 0.2, 0.3)); lightNode.SetNodeAttribute(light); scene.GetRootNode().AddChild(lightNode); return(scene); }
protected override void CheckScene(FbxScene scene) { base.CheckScene(scene); FbxScene origScene = CreateScene(FbxManager); FbxNode origLightNode = origScene.GetRootNode().GetChild(0); FbxNode importLightNode = scene.GetRootNode().GetChild(0); Assert.IsNotNull(origLightNode); Assert.IsNotNull(importLightNode); FbxLight origLight = origLightNode.GetLight(); FbxLight importLight = importLightNode.GetLight(); Assert.IsNotNull(origLight); Assert.IsNotNull(importLight); Assert.AreEqual(origLight.GetName(), importLight.GetName()); // Check properties CheckProperties( origLightNode, importLightNode, origLight, importLight, new string[] { "bounceIntensity", "colorTemperature", "cookieSize" } ); // Check anim FbxAnimStack origAnimStack = origScene.GetCurrentAnimationStack(); FbxAnimLayer origAnimLayer = origAnimStack.GetAnimLayerMember(); Assert.IsNotNull(origAnimStack); Assert.IsNotNull(origAnimLayer); FbxAnimStack importAnimStack = scene.GetCurrentAnimationStack(); FbxAnimLayer importAnimLayer = importAnimStack.GetAnimLayerMember(); Assert.IsNotNull(importAnimStack); Assert.IsNotNull(importAnimLayer); // TODO: (UNI-19438) figure out why trying to add anim curves to FbxNodeAttribute.sColor, // Intensity and InnerAngle fails CheckAnimCurve(origLightNode, importLightNode, origAnimLayer, importAnimLayer, new List <PropertyComponentPair>() { new PropertyComponentPair("colorTemperature", new string[] { null }), new PropertyComponentPair("cookieSize", new string[] { null }) }, origLight, importLight); }
protected override void CheckScene(FbxScene scene) { base.CheckScene(scene); FbxScene origScene = CreateScene(FbxManager); FbxNode origCameraNode = origScene.GetRootNode().GetChild(0); FbxNode importCameraNode = scene.GetRootNode().GetChild(0); Assert.IsNotNull(origCameraNode); Assert.IsNotNull(importCameraNode); Assert.AreEqual(origScene.GetGlobalSettings().GetDefaultCamera(), scene.GetGlobalSettings().GetDefaultCamera()); FbxCamera origCamera = origCameraNode.GetCamera(); FbxCamera importCamera = importCameraNode.GetCamera(); Assert.IsNotNull(origCamera); Assert.IsNotNull(importCamera); CheckCameraSettings(origCamera, importCamera, origCameraNode, importCameraNode); // check anim FbxAnimStack origAnimStack = origScene.GetCurrentAnimationStack(); FbxAnimLayer origAnimLayer = origAnimStack.GetAnimLayerMember(); Assert.IsNotNull(origAnimStack); Assert.IsNotNull(origAnimLayer); FbxAnimStack importAnimStack = scene.GetCurrentAnimationStack(); FbxAnimLayer importAnimLayer = importAnimStack.GetAnimLayerMember(); Assert.IsNotNull(importAnimStack); Assert.IsNotNull(importAnimLayer); CheckAnimCurve(origCameraNode, importCameraNode, origAnimLayer, importAnimLayer, new List <PropertyComponentPair>() { new PropertyComponentPair("backgroundColor", new string[] { Globals.FBXSDK_CURVENODE_COLOR_RED, Globals.FBXSDK_CURVENODE_COLOR_GREEN, Globals.FBXSDK_CURVENODE_COLOR_BLUE, "W" }), new PropertyComponentPair("FocalLength", new string[] { null }), new PropertyComponentPair("clearFlags", new string[] { null }) }, origCamera, importCamera); }
protected override void CheckScene(FbxScene scene) { FbxScene origScene = CreateScene(FbxManager); Assert.That(origScene.GetRootNode().GetChildCount(), Is.EqualTo(scene.GetRootNode().GetChildCount())); // check nodes match FbxNode origSourceNode = origScene.GetRootNode().GetChild(0); FbxNode origConstrainedNode = origScene.GetRootNode().GetChild(1); FbxNode importSourceNode = scene.GetRootNode().GetChild(0); FbxNode importConstrainedNode = scene.GetRootNode().GetChild(1); Assert.That(origSourceNode, Is.Not.Null); Assert.That(importSourceNode, Is.Not.Null); Assert.That(origConstrainedNode, Is.Not.Null); Assert.That(importConstrainedNode, Is.Not.Null); Assert.That(importSourceNode.GetName(), Is.EqualTo(origSourceNode.GetName())); Assert.That(importConstrainedNode.GetName(), Is.EqualTo(origConstrainedNode.GetName())); // check constraints match // TODO: find a way to cast to FbxConstraint Assert.That(scene.GetSrcObjectCount(), Is.EqualTo(origScene.GetSrcObjectCount())); FbxObject origPosConstraint = origScene.FindSrcObject(ConstraintName); FbxObject importPosConstraint = scene.FindSrcObject(ConstraintName); Assert.That(origPosConstraint, Is.Not.Null); Assert.That(importPosConstraint, Is.Not.Null); Assert.That(importPosConstraint.GetName(), Is.EqualTo(origPosConstraint.GetName())); // check animation matches FbxAnimStack origStack = origScene.GetCurrentAnimationStack(); FbxAnimStack importStack = scene.GetCurrentAnimationStack(); CheckAnimStack(origStack, importStack); FbxAnimLayer origLayer = origStack.GetAnimLayerMember(); FbxAnimLayer importLayer = importStack.GetAnimLayerMember(); Assert.That(origLayer, Is.Not.Null); Assert.That(importLayer, Is.Not.Null); Assert.That(scene.GetGlobalSettings().GetTimeMode(), Is.EqualTo(FbxTime.EMode.eFrames30)); CheckAnimCurve(origPosConstraint, importPosConstraint, origLayer, importLayer, PropertyComponentList); }
protected override FbxScene CreateScene(FbxManager manager) { FbxScene scene = base.CreateScene(manager); FbxNode cameraNode = scene.GetRootNode().GetChild(0); FbxCamera camera = FbxCamera.Create(scene, "camera"); camera.ProjectionType.Set(FbxCamera.EProjectionType.ePerspective); camera.SetAspect(FbxCamera.EAspectRatioMode.eFixedRatio, 300, 400); camera.FilmAspectRatio.Set(240); camera.SetApertureWidth(4); camera.SetApertureHeight(2); camera.SetApertureMode(FbxCamera.EApertureMode.eFocalLength); camera.FocalLength.Set(32); camera.SetNearPlane(1); camera.SetFarPlane(100); // create custom property (background color) var bgColorProperty = FbxProperty.Create(cameraNode, Globals.FbxColor4DT, "backgroundColor"); Assert.IsTrue(bgColorProperty.IsValid()); bgColorProperty.Set(new FbxColor(0.5, 0.4, 0.1, 1)); // Must be marked user-defined or it won't be shown in most DCCs bgColorProperty.ModifyFlag(FbxPropertyFlags.EFlags.eUserDefined, true); bgColorProperty.ModifyFlag(FbxPropertyFlags.EFlags.eAnimatable, true); Assert.IsTrue(bgColorProperty.GetFlag(FbxPropertyFlags.EFlags.eUserDefined)); Assert.IsTrue(bgColorProperty.GetFlag(FbxPropertyFlags.EFlags.eAnimatable)); // create custom property (clear flags) var clearFlagsProperty = FbxProperty.Create(cameraNode, Globals.FbxIntDT, "clearFlags"); Assert.IsTrue(clearFlagsProperty.IsValid()); clearFlagsProperty.Set(4); // Must be marked user-defined or it won't be shown in most DCCs clearFlagsProperty.ModifyFlag(FbxPropertyFlags.EFlags.eUserDefined, true); clearFlagsProperty.ModifyFlag(FbxPropertyFlags.EFlags.eAnimatable, true); Assert.IsTrue(clearFlagsProperty.GetFlag(FbxPropertyFlags.EFlags.eUserDefined)); Assert.IsTrue(clearFlagsProperty.GetFlag(FbxPropertyFlags.EFlags.eAnimatable)); // Add camera properties to animation clip FbxAnimStack animStack = scene.GetCurrentAnimationStack(); FbxAnimLayer animLayer = animStack.GetAnimLayerMember(); // TODO: (UNI-19438) Figure out why trying to do GetCurve for NearPlane always returns null CreateAnimCurves(cameraNode, animLayer, new List <PropertyComponentPair> () { new PropertyComponentPair("backgroundColor", new string[] { Globals.FBXSDK_CURVENODE_COLOR_RED, Globals.FBXSDK_CURVENODE_COLOR_GREEN, Globals.FBXSDK_CURVENODE_COLOR_BLUE, "W" }), new PropertyComponentPair("FocalLength", new string[] { null }), new PropertyComponentPair("clearFlags", new string[] { null }) }, (index) => { return(index); }, (index) => { return(index / 5.0f); }, camera); cameraNode.SetNodeAttribute(camera); // set the default camera scene.GetGlobalSettings().SetDefaultCamera(cameraNode.GetName()); return(scene); }