示例#1
0
        public new static FbxLight Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxLight_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxLight ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLight(cPtr, false);

            return(ret);
        }
示例#2
0
        public void FbxObject_TypedGetSrcObjectCount_GetsCountOfObjectsOfThatType()
        {
            // given:
            var obj   = new FbxObject("asdf");
            var mesh1 = new FbxMesh("mesh1");
            var mesh2 = new FbxMesh("mesh2");
            var node  = new FbxNode("node");
            var mesh3 = new FbxMesh("mesh3");
            var light = new FbxLight("light");

            obj.ConnectSrcObject(mesh1);
            obj.ConnectSrcObject(mesh2);
            obj.ConnectSrcObject(node);
            obj.ConnectSrcObject(mesh3);
            obj.ConnectSrcObject(light);

            // require:
            Assert.AreEqual(5, obj.GetSrcObjectCount());
            Assert.AreSame(mesh1, obj.GetSrcObject(0));
            Assert.AreSame(mesh2, obj.GetSrcObject(1));
            Assert.AreSame(node, obj.GetSrcObject(2));
            Assert.AreSame(mesh3, obj.GetSrcObject(3));
            Assert.AreSame(light, obj.GetSrcObject(4));

            // then:
            Assert.AreEqual(3, obj.GetSrcObjectCount <FbxMesh>());
            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxNode>());
            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxLight>());
            Assert.AreEqual(4, obj.GetSrcObjectCount <FbxNodeAttribute>());
        }
示例#3
0
        protected void CheckProperties(
            FbxNode origLightNode, FbxNode importLightNode,
            FbxLight origLight, FbxLight importLight, string[] customProperties)
        {
            Assert.AreEqual(origLight.LightType.Get(), importLight.LightType.Get());
            Assert.AreEqual(origLight.InnerAngle.Get(), importLight.InnerAngle.Get());
            Assert.AreEqual(origLight.OuterAngle.Get(), importLight.OuterAngle.Get());
            Assert.AreEqual(origLight.Color.Get(), importLight.Color.Get());
            Assert.AreEqual(origLight.FileName.Get(), importLight.FileName.Get());
            Assert.AreEqual(origLight.DrawGroundProjection.Get(), importLight.DrawGroundProjection.Get());
            Assert.AreEqual(origLight.DrawVolumetricLight.Get(), importLight.DrawVolumetricLight.Get());
            Assert.AreEqual(origLight.DrawFrontFacingVolumetricLight.Get(), importLight.DrawFrontFacingVolumetricLight.Get());
            Assert.AreEqual(origLight.Intensity.Get(), importLight.Intensity.Get());
            Assert.AreEqual(origLight.FarAttenuationStart.Get(), importLight.FarAttenuationStart.Get());
            Assert.AreEqual(origLight.FarAttenuationEnd.Get(), importLight.FarAttenuationEnd.Get());
            Assert.AreEqual(origLight.CastShadows.Get(), importLight.CastShadows.Get());

            foreach (var customProp in customProperties)
            {
                var origProperty   = origLightNode.FindProperty(customProp);
                var importProperty = importLightNode.FindProperty(customProp);
                Assert.IsNotNull(origProperty);
                Assert.IsNotNull(importProperty);
                Assert.AreEqual(origProperty.GetFloat(), importProperty.GetFloat());
            }
        }
示例#4
0
        public new static FbxLight Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxLight_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxLight ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLight(cPtr, false);

            return(ret);
        }
示例#5
0
        public void Light_Create_HasNamespacePrefix()
        {
            // given:
            var obj = new FbxLight("asdf");

            // then:
            Assert.AreEqual("NodeAttribute::", obj.GetNameSpacePrefix());
        }
示例#6
0
 public bool Equals(FbxLight other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }
 public void TestGetLight()
 {
     // make sure it doesn't crash
     using (FbxNode node = CreateObject("root")) {
         FbxLight light = FbxLight.Create(Manager, "light");
         node.SetNodeAttribute(light);
         Assert.AreEqual(light, node.GetLight());
     }
 }
示例#8
0
        public new static FbxLight Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxLight_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxLight ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLight(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#9
0
        public FbxLight GetLight()
        {
            global::System.IntPtr cPtr = NativeMethods.FbxNode_GetLight(swigCPtr);
            FbxLight ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLight(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
示例#10
0
        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);
        }
示例#11
0
        public void FbxObject_TypedDisconnectAllSrcObjectWithInheritance_DisconnectsAllSrcObjectOfThatType()
        {
            // given:
            var obj   = new FbxObject("asdf");
            var mesh1 = new FbxMesh("mesh1");
            var node  = new FbxNode("node");
            var light = new FbxLight("light");

            obj.ConnectSrcObject(mesh1);
            obj.ConnectSrcObject(node);
            obj.ConnectSrcObject(light);

            // require:
            Assert.AreEqual(3, obj.GetSrcObjectCount());
            Assert.AreSame(mesh1, obj.GetSrcObject(0));
            Assert.AreSame(node, obj.GetSrcObject(1));
            Assert.AreSame(light, obj.GetSrcObject(2));

            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxMesh>());
            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxNode>());
            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxLight>());
            Assert.AreEqual(2, obj.GetSrcObjectCount <FbxNodeAttribute>());

            Assert.AreEqual(1, mesh1.GetDstObjectCount());
            Assert.AreEqual(1, node.GetDstObjectCount());
            Assert.AreEqual(1, light.GetDstObjectCount());

            // when:
            var ret = obj.DisconnectAllSrcObject <FbxNodeAttribute>();

            // then:
            Assert.True(ret);
            Assert.AreEqual(1, obj.GetSrcObjectCount());
            Assert.AreSame(node, obj.GetSrcObject());
            Assert.AreSame(node, obj.GetSrcObject(0));

            Assert.AreEqual(0, obj.GetSrcObjectCount <FbxMesh>());
            Assert.AreEqual(0, obj.GetSrcObjectCount <FbxLight>());
            Assert.AreEqual(0, obj.GetSrcObjectCount <FbxNodeAttribute>());

            Assert.AreEqual(1, obj.GetSrcObjectCount <FbxNode>());
            Assert.AreSame(node, obj.GetSrcObject <FbxNode>());
            Assert.AreSame(node, obj.GetSrcObject <FbxNode>(0));

            Assert.AreEqual(0, mesh1.GetDstObjectCount());
            Assert.AreEqual(1, node.GetDstObjectCount());
            Assert.AreEqual(0, light.GetDstObjectCount());
        }
示例#12
0
        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);
        }
示例#13
0
            /// <summary>
            /// Exports the game object has a light component
            /// </summary>
            protected void ExportComponents(GameObject unityGo, FbxScene fbxScene, FbxNode fbxNodeParent)
            {
                // create an node and add it as a child of parent
                FbxNode fbxNode = FbxNode.Create(fbxScene, unityGo.name);

                NumNodes++;

                ExportTransform(unityGo.transform, fbxNode);

                var fbxMesh = ExportMesh(unityGo, fbxScene);

                if (fbxMesh != null)
                {
                    // set the fbxNode containing the mesh
                    fbxNode.SetNodeAttribute(fbxMesh);
                    fbxNode.SetShadingMode(FbxNode.EShadingMode.eWireFrame);
                }

                FbxLight fbxLight = ExportLight(unityGo, fbxScene, fbxNode);

                if (fbxLight != null)
                {
                    fbxNode.SetNodeAttribute(fbxLight);
                }

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting {0}", fbxNode.GetName()));
                }

                fbxNodeParent.AddChild(fbxNode);

                // add mapping between fbxnode for light
                // and unity game object for animation export
                MapUnityObjectToFbxNode [unityGo] = fbxNode;

                // now  unityGo  through our children and recurse
                foreach (Transform childT in  unityGo.transform)
                {
                    ExportComponents(childT.gameObject, fbxScene, fbxNode);
                }

                return;
            }
示例#14
0
        public void Light_Create_HasProperties()
        {
            // given:
            var         light = new FbxLight("light");
            FbxProperty prop;

            // then:
            Assert.AreEqual(27, CountProperties(light));
            Assert.AreEqual(0, light.GetSrcPropertyCount());
            Assert.AreEqual(0, light.GetDstPropertyCount());

            prop = light.FindProperty("LightType");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.LightType);
            Assert.True(light.LightType.IsValid());
            Assert.AreEqual("LightType", light.LightType.GetName());
            Assert.AreSame(prop, light.LightType);

            prop = light.FindProperty("CastLightOnObject");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.CastLight);
            Assert.True(light.CastLight.IsValid());
            Assert.AreEqual("CastLightOnObject", light.CastLight.GetName());
            Assert.AreSame(prop, light.CastLight);

            prop = light.FindProperty("DrawVolumetricLight");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.DrawVolumetricLight);
            Assert.True(light.DrawVolumetricLight.IsValid());
            Assert.AreEqual("DrawVolumetricLight", light.DrawVolumetricLight.GetName());
            Assert.AreSame(prop, light.DrawVolumetricLight);

            prop = light.FindProperty("DrawGroundProjection");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.DrawGroundProjection);
            Assert.True(light.DrawGroundProjection.IsValid());
            Assert.AreEqual("DrawGroundProjection", light.DrawGroundProjection.GetName());
            Assert.AreSame(prop, light.DrawGroundProjection);

            prop = light.FindProperty("DrawFrontFacingVolumetricLight");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.DrawFrontFacingVolumetricLight);
            Assert.True(light.DrawFrontFacingVolumetricLight.IsValid());
            Assert.AreEqual("DrawFrontFacingVolumetricLight", light.DrawFrontFacingVolumetricLight.GetName());
            Assert.AreSame(prop, light.DrawFrontFacingVolumetricLight);

            prop = light.FindProperty("Color");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.Color);
            Assert.True(light.Color.IsValid());
            Assert.AreEqual("Color", light.Color.GetName());
            Assert.AreSame(prop, light.Color);

            prop = light.FindProperty("Intensity");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.Intensity);
            Assert.True(light.Intensity.IsValid());
            Assert.AreEqual("Intensity", light.Intensity.GetName());
            Assert.AreSame(prop, light.Intensity);

            prop = light.FindProperty("InnerAngle");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.InnerAngle);
            Assert.True(light.InnerAngle.IsValid());
            Assert.AreEqual("InnerAngle", light.InnerAngle.GetName());
            Assert.AreSame(prop, light.InnerAngle);

            prop = light.FindProperty("OuterAngle");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.OuterAngle);
            Assert.True(light.OuterAngle.IsValid());
            Assert.AreEqual("OuterAngle", light.OuterAngle.GetName());
            Assert.AreSame(prop, light.OuterAngle);

            prop = light.FindProperty("Fog");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.Fog);
            Assert.True(light.Fog.IsValid());
            Assert.AreEqual("Fog", light.Fog.GetName());
            Assert.AreSame(prop, light.Fog);

            prop = light.FindProperty("DecayType");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.DecayType);
            Assert.True(light.DecayType.IsValid());
            Assert.AreEqual("DecayType", light.DecayType.GetName());
            Assert.AreSame(prop, light.DecayType);

            prop = light.FindProperty("DecayStart");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.DecayStart);
            Assert.True(light.DecayStart.IsValid());
            Assert.AreEqual("DecayStart", light.DecayStart.GetName());
            Assert.AreSame(prop, light.DecayStart);

            prop = light.FindProperty("FileName");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.FileName);
            Assert.True(light.FileName.IsValid());
            Assert.AreEqual("FileName", light.FileName.GetName());
            Assert.AreSame(prop, light.FileName);

            prop = light.FindProperty("EnableNearAttenuation");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.EnableNearAttenuation);
            Assert.True(light.EnableNearAttenuation.IsValid());
            Assert.AreEqual("EnableNearAttenuation", light.EnableNearAttenuation.GetName());
            Assert.AreSame(prop, light.EnableNearAttenuation);

            prop = light.FindProperty("NearAttenuationStart");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.NearAttenuationStart);
            Assert.True(light.NearAttenuationStart.IsValid());
            Assert.AreEqual("NearAttenuationStart", light.NearAttenuationStart.GetName());
            Assert.AreSame(prop, light.NearAttenuationStart);

            prop = light.FindProperty("NearAttenuationEnd");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.NearAttenuationEnd);
            Assert.True(light.NearAttenuationEnd.IsValid());
            Assert.AreEqual("NearAttenuationEnd", light.NearAttenuationEnd.GetName());
            Assert.AreSame(prop, light.NearAttenuationEnd);

            prop = light.FindProperty("EnableFarAttenuation");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.EnableFarAttenuation);
            Assert.True(light.EnableFarAttenuation.IsValid());
            Assert.AreEqual("EnableFarAttenuation", light.EnableFarAttenuation.GetName());
            Assert.AreSame(prop, light.EnableFarAttenuation);

            prop = light.FindProperty("FarAttenuationStart");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.FarAttenuationStart);
            Assert.True(light.FarAttenuationStart.IsValid());
            Assert.AreEqual("FarAttenuationStart", light.FarAttenuationStart.GetName());
            Assert.AreSame(prop, light.FarAttenuationStart);

            prop = light.FindProperty("FarAttenuationEnd");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.FarAttenuationEnd);
            Assert.True(light.FarAttenuationEnd.IsValid());
            Assert.AreEqual("FarAttenuationEnd", light.FarAttenuationEnd.GetName());
            Assert.AreSame(prop, light.FarAttenuationEnd);

            prop = light.FindProperty("CastShadows");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.CastShadows);
            Assert.True(light.CastShadows.IsValid());
            Assert.AreEqual("CastShadows", light.CastShadows.GetName());
            Assert.AreSame(prop, light.CastShadows);

            prop = light.FindProperty("ShadowColor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.ShadowColor);
            Assert.True(light.ShadowColor.IsValid());
            Assert.AreEqual("ShadowColor", light.ShadowColor.GetName());
            Assert.AreSame(prop, light.ShadowColor);

            prop = light.FindProperty("AreaLightShape");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.AreaLightShape);
            Assert.True(light.AreaLightShape.IsValid());
            Assert.AreEqual("AreaLightShape", light.AreaLightShape.GetName());
            Assert.AreSame(prop, light.AreaLightShape);

            prop = light.FindProperty("LeftBarnDoor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.LeftBarnDoor);
            Assert.True(light.LeftBarnDoor.IsValid());
            Assert.AreEqual("LeftBarnDoor", light.LeftBarnDoor.GetName());
            Assert.AreSame(prop, light.LeftBarnDoor);

            prop = light.FindProperty("RightBarnDoor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.RightBarnDoor);
            Assert.True(light.RightBarnDoor.IsValid());
            Assert.AreEqual("RightBarnDoor", light.RightBarnDoor.GetName());
            Assert.AreSame(prop, light.RightBarnDoor);

            prop = light.FindProperty("TopBarnDoor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.TopBarnDoor);
            Assert.True(light.TopBarnDoor.IsValid());
            Assert.AreEqual("TopBarnDoor", light.TopBarnDoor.GetName());
            Assert.AreSame(prop, light.TopBarnDoor);

            prop = light.FindProperty("BottomBarnDoor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.BottomBarnDoor);
            Assert.True(light.BottomBarnDoor.IsValid());
            Assert.AreEqual("BottomBarnDoor", light.BottomBarnDoor.GetName());
            Assert.AreSame(prop, light.BottomBarnDoor);

            prop = light.FindProperty("EnableBarnDoor");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(light.EnableBarnDoor);
            Assert.True(light.EnableBarnDoor.IsValid());
            Assert.AreEqual("EnableBarnDoor", light.EnableBarnDoor.GetName());
            Assert.AreSame(prop, light.EnableBarnDoor);
        }
        public void TestEquality()
        {
            using (var manager = FbxManager.Create()) {
                // FbxProperty
                var node      = FbxNode.Create(manager, "node");
                var prop1     = FbxProperty.Create(node, Globals.FbxBoolDT, "bool1");
                var prop2     = FbxProperty.Create(node, Globals.FbxBoolDT, "bool2");
                var prop1copy = node.FindProperty("bool1");
                EqualityTester <FbxProperty> .TestEquality(prop1, prop2, prop1copy);

                // FbxPropertyT<bool>
                var vis1     = node.VisibilityInheritance;
                var vis2     = FbxNode.Create(manager, "node2").VisibilityInheritance;
                var vis1copy = vis1; // TODO: node.FindProperty("Visibility Inheritance"); -- but that has a different proxy type
                EqualityTester <FbxPropertyBool> .TestEquality(vis1, vis2, vis1copy);

                // FbxPropertyT<EInheritType>
                var inhType1     = node.InheritType;
                var inhType2     = FbxNode.Create(manager, "node3").InheritType;
                var inhType1Copy = inhType1; // TODO: node.FindProperty("InheritType");
                EqualityTester <FbxPropertyEInheritType> .TestEquality(inhType1, inhType2, inhType1Copy);

                // FbxPropertyT<double>
                var lambert      = FbxSurfaceLambert.Create(manager, "lambert");
                var emissiveCopy = lambert.EmissiveFactor; // TODO: lambert.FindProperty("EmissiveFactor");
                EqualityTester <FbxPropertyDouble> .TestEquality(lambert.EmissiveFactor, lambert.AmbientFactor, emissiveCopy);

                // FbxPropertyT<FbxDouble3>
                var lclTranslationCopy = node.LclTranslation; // TODO: node.FindProperty("Lcl Translation");
                EqualityTester <FbxPropertyDouble3> .TestEquality(node.LclTranslation, node.LclRotation, lclTranslationCopy);

                // FbxPropertyT<float>
                var light = FbxLight.Create(manager, "light");
                EqualityTester <FbxPropertyFloat> .TestEquality(light.LeftBarnDoor, light.RightBarnDoor, light.LeftBarnDoor);

                // FbxPropertyT<int>
                var constraint      = FbxConstraintAim.Create(manager, "constraint");
                var constraint2     = FbxConstraintAim.Create(manager, "constraint2");
                var worldUpTypeCopy = constraint.WorldUpType; // TODO: constraint.FindProperty("WorldUpType");
                EqualityTester <FbxPropertyInt> .TestEquality(constraint.WorldUpType, constraint2.WorldUpType, worldUpTypeCopy);

                // FbxPropertyT<> for FbxTexture enums
                var tex1      = FbxTexture.Create(manager, "tex1");
                var tex2      = FbxTexture.Create(manager, "tex2");
                var blendCopy = tex1.CurrentTextureBlendMode; // TODO: tex1.FindProperty(...)
                EqualityTester <FbxPropertyEBlendMode> .TestEquality(tex1.CurrentTextureBlendMode, tex2.CurrentTextureBlendMode, blendCopy);

                var wrapCopy = tex1.WrapModeU; // TODO: tex1.FindProperty(...)
                EqualityTester <FbxPropertyEWrapMode> .TestEquality(tex1.WrapModeU, tex2.WrapModeU, wrapCopy);

                // FbxPropertyT<FbxNull.ELook>
                var null1 = FbxNull.Create(manager, "null1");
                var null2 = FbxNull.Create(manager, "null2");
                EqualityTester <FbxPropertyNullELook> .TestEquality(null1.Look, null2.Look, null1.Look);

                // FbxPropertyT<FbxMarker.ELook>
                var marker1 = FbxMarker.Create(manager, "marker1");
                var marker2 = FbxMarker.Create(manager, "marker2");
                EqualityTester <FbxPropertyMarkerELook> .TestEquality(marker1.Look, marker2.Look, marker1.Look);

                // FbxPropertyT<string>
                var impl          = FbxImplementation.Create(manager, "impl");
                var renderAPIcopy = impl.RenderAPI; // TODO: impl.FindProperty("RenderAPI");
                EqualityTester <FbxPropertyString> .TestEquality(impl.RenderAPI, impl.RenderAPIVersion, renderAPIcopy);

                // FbxPropertyT<> for FbxCamera enum EProjectionType
                var cam1           = FbxCamera.Create(manager, "cam1");
                var cam2           = FbxCamera.Create(manager, "cam2");
                var projectionCopy = cam1.ProjectionType;
                EqualityTester <FbxPropertyEProjectionType> .TestEquality(cam1.ProjectionType, cam2.ProjectionType, projectionCopy);

                // FbxPropertyT<> for FbxLight enum EType
                var light1   = FbxLight.Create(manager, "light1");
                var light2   = FbxLight.Create(manager, "light2");
                var typeCopy = light1.LightType;
                EqualityTester <FbxPropertyELightType> .TestEquality(light1.LightType, light2.LightType, typeCopy);

                var lightShapeCopy = light1.AreaLightShape;
                EqualityTester <FbxPropertyEAreaLightShape> .TestEquality(light1.AreaLightShape, light2.AreaLightShape, lightShapeCopy);

                var decayCopy = light1.DecayType;
                EqualityTester <FbxPropertyEDecayType> .TestEquality(light1.DecayType, light2.DecayType, decayCopy);

                var floatCopy = light1.LeftBarnDoor;
                EqualityTester <FbxPropertyFloat> .TestEquality(light1.LeftBarnDoor, light2.LeftBarnDoor, floatCopy);
            }
        }
        public void BasicTests()
        {
            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<FbxBool> example: VisibilityInheritance on a node
                var node = FbxNode.Create(manager, "node");
                GenericPropertyTests <FbxPropertyBool> (node.VisibilityInheritance, node, "Visibility Inheritance", Globals.FbxVisibilityInheritanceDT);

                var property = node.VisibilityInheritance;
                property.Set(false);
                Assert.AreEqual(false, property.Get());
                Assert.AreEqual(false, property.EvaluateValue());
                Assert.AreEqual(false, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(false, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<FbxDouble> example: several of them on a Lambert shader
                var obj = FbxSurfaceLambert.Create(manager, "lambert");
                GenericPropertyTests <FbxPropertyDouble> (obj.EmissiveFactor, obj, "EmissiveFactor", Globals.FbxDoubleDT);

                var property = obj.EmissiveFactor;
                property.Set(5.0); // bool Set<float> is not accessible here!
                Assert.AreEqual(5.0, property.Get());
                Assert.AreEqual(5.0, property.EvaluateValue());
                Assert.AreEqual(5.0, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(5.0, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<Double3> example: the LclTranslation on a node
                var node = FbxNode.Create(manager, "node");
                GenericPropertyTests <FbxPropertyDouble3> (node.LclTranslation, node, "Lcl Translation", Globals.FbxLocalTranslationDT);

                var property = node.LclTranslation;
                property.Set(new FbxDouble3(1, 2, 3));
                Assert.AreEqual(new FbxDouble3(1, 2, 3), property.Get());
                Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue());
                Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(new FbxDouble3(1, 2, 3), property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<float> example: the LeftBarnDoor on a light
                var light = FbxLight.Create(manager, "light");
                GenericPropertyTests(light.LeftBarnDoor, light, "LeftBarnDoor", Globals.FbxFloatDT);

                var property = light.LeftBarnDoor;
                light.LeftBarnDoor.Set(5.0f);
                Assert.AreEqual(5.0f, light.LeftBarnDoor.Get());
                Assert.AreEqual(5.0f, property.EvaluateValue());
                Assert.AreEqual(5.0f, property.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(5.0f, property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<int> example: the WorldUpType on an aim constraint
                var constraint = FbxConstraintAim.Create(manager, "constraint");
                GenericPropertyTests(constraint.WorldUpType, constraint, "WorldUpType", Globals.FbxEnumDT);

                var property = constraint.WorldUpType;
                int value    = (int)FbxConstraintAim.EWorldUp.eAimAtObjectUp;
                constraint.WorldUpType.Set(value);
                Assert.That(constraint.WorldUpType.Get(), Is.EqualTo(value));
                Assert.That(property.EvaluateValue(), Is.EqualTo(value));
                Assert.That(property.EvaluateValue(FbxTime.FromSecondDouble(5)), Is.EqualTo(value));
                Assert.That(property.EvaluateValue(FbxTime.FromSecondDouble(5), true), Is.EqualTo(value));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<FbxString> example: the description of a shader implementation
                var impl = FbxImplementation.Create(manager, "name");
                GenericPropertyTests <FbxPropertyString> (impl.RenderAPI, impl, "RenderAPI", Globals.FbxStringDT);

                var property = impl.RenderAPI;
                property.Set("a value");
                Assert.AreEqual("a value", property.Get());

                // animated strings come out as empty-string
                Assert.AreEqual("", property.EvaluateValue());
                Assert.AreEqual("", property.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual("", property.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT for FbxTexture enums EBlendMode and EWrapMode
                var tex = FbxTexture.Create(manager, "tex");

                FbxPropertyTest.GenericPropertyTests(tex.CurrentTextureBlendMode, tex, "CurrentTextureBlendMode", Globals.FbxEnumDT);
                tex.CurrentTextureBlendMode.Set(FbxTexture.EBlendMode.eAdditive);
                Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.Get());
                Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue());
                Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxTexture.EBlendMode.eAdditive, tex.CurrentTextureBlendMode.EvaluateValue(FbxTime.FromSecondDouble(5), true));

                FbxPropertyTest.GenericPropertyTests(tex.WrapModeU, tex, "WrapModeU", Globals.FbxEnumDT);
                tex.WrapModeU.Set(FbxTexture.EWrapMode.eClamp);
                Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.Get());
                Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue());
                Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxTexture.EWrapMode.eClamp, tex.WrapModeU.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<FbxNull.ELook>
                var null1 = FbxNull.Create(manager, "null1");

                FbxPropertyTest.GenericPropertyTests(null1.Look, null1, "Look", Globals.FbxEnumDT);
                null1.Look.Set(FbxNull.ELook.eCross);
                Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.Get());
                Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue());
                Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxNull.ELook.eCross, null1.Look.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<FbxMarker.ELook>
                var marker1 = FbxMarker.Create(manager, "marker1");

                FbxPropertyTest.GenericPropertyTests(marker1.Look, marker1, "Look", Globals.FbxEnumDT);
                marker1.Look.Set(FbxMarker.ELook.eCapsule);
                Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.Get());
                Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue());
                Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxMarker.ELook.eCapsule, marker1.Look.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT for FbxCamera enum EProjectionType
                var camera = FbxCamera.Create(manager, "camera");

                FbxPropertyTest.GenericPropertyTests(camera.ProjectionType, camera, "CameraProjectionType", Globals.FbxEnumDT);
                camera.ProjectionType.Set(FbxCamera.EProjectionType.ePerspective);
                Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.Get());
                Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue());
                Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxCamera.EProjectionType.ePerspective, camera.ProjectionType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT for FbxCamera enum EGateFit
                var camera = FbxCamera.Create(manager, "camera");

                FbxPropertyTest.GenericPropertyTests(camera.GateFit, camera, "GateFit", Globals.FbxEnumDT);
                camera.GateFit.Set(FbxCamera.EGateFit.eFitHorizontal);
                Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.Get());
                Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue());
                Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxCamera.EGateFit.eFitHorizontal, camera.GateFit.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT<EInheritType>
                var node = FbxNode.Create(manager, "node");

                FbxPropertyTest.GenericPropertyTests(node.InheritType, node, "InheritType", Globals.FbxEnumDT);
                node.InheritType.Set(FbxTransform.EInheritType.eInheritRSrs);
                Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.Get());
                Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue());
                Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxTransform.EInheritType.eInheritRSrs, node.InheritType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // FbxPropertyT for FbxLight enums
                var light = FbxLight.Create(manager, "light");

                FbxPropertyTest.GenericPropertyTests(light.LightType, light, "LightType", Globals.FbxEnumDT);
                light.LightType.Set(FbxLight.EType.eSpot);
                Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.Get());
                Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue());
                Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxLight.EType.eSpot, light.LightType.EvaluateValue(FbxTime.FromSecondDouble(5), true));

                FbxPropertyTest.GenericPropertyTests(light.AreaLightShape, light, "AreaLightShape", Globals.FbxEnumDT);
                light.AreaLightShape.Set(FbxLight.EAreaLightShape.eSphere);
                Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.Get());
                Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue());
                Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxLight.EAreaLightShape.eSphere, light.AreaLightShape.EvaluateValue(FbxTime.FromSecondDouble(5), true));

                FbxPropertyTest.GenericPropertyTests(light.DecayType, light, "DecayType", Globals.FbxEnumDT);
                light.DecayType.Set(FbxLight.EDecayType.eCubic);
                Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.Get());
                Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue());
                Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue(FbxTime.FromSecondDouble(5)));
                Assert.AreEqual(FbxLight.EDecayType.eCubic, light.DecayType.EvaluateValue(FbxTime.FromSecondDouble(5), true));
            }

            using (var manager = FbxManager.Create()) {
                // Test all the create and destroy operations
                FbxProperty root, child;
                var         obj = FbxObject.Create(manager, "obj");

                Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "a"));
                Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "b", "label"));
                Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "c", "label", false));
                bool didFind;
                Assert.IsNotNull(FbxProperty.Create(obj, Globals.FbxStringDT, "c", "label", true, out didFind));
                Assert.IsTrue(didFind);

                root = FbxProperty.Create(obj, Globals.FbxCompoundDT, "root");

                child = FbxProperty.Create(root, Globals.FbxStringDT, "a");
                Assert.IsNotNull(child);
                Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "b", "label"));
                Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", false));
                Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", true, out didFind));
                Assert.IsTrue(didFind);

                child.Destroy();

                root.DestroyChildren();
                Assert.IsNotNull(FbxProperty.Create(root, Globals.FbxStringDT, "c", "label", true, out didFind));
                Assert.IsFalse(didFind);

                root.DestroyRecursively();
            }
        }
示例#17
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxLight obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
示例#18
0
            /// <summary>
            /// Exports light component.
            /// Supported types: point, spot and directional
            /// Cookie => Gobo
            /// </summary>
            protected FbxLight ExportLight(GameObject unityGo, FbxScene fbxScene, FbxNode fbxNode)
            {
                Light unityLight = unityGo.GetComponent <Light> ();

                if (unityLight == null)
                {
                    return(null);
                }

                FbxLight.EType fbxLightType;

                // Is light type supported?
                if (!MapLightType.TryGetValue(unityLight.type, out fbxLightType))
                {
                    return(null);
                }

                // add to the list of lights
                Lights.Add(unityLight);

                FbxLight fbxLight = FbxLight.Create(fbxScene.GetFbxManager(), unityLight.name);

                // Set the type of the light.
                fbxLight.LightType.Set(fbxLightType);

                switch (unityLight.type)
                {
                case LightType.Directional: {
                    break;
                }

                case LightType.Spot: {
                    // Set the angle of the light's spotlight cone in degrees.
                    fbxLight.InnerAngle.Set(unityLight.spotAngle);
                    fbxLight.OuterAngle.Set(unityLight.spotAngle);
                    break;
                }

                case LightType.Point: {
                    break;
                }

                case LightType.Area: {
                    // TODO: areaSize          The size of the area light by scaling the node XY

                    break;
                }
                }

                // Export bounceIntensity as custom property
                // NOTE: export on fbxNode so that it will show up in Maya
                ExportFloatProperty(fbxNode, unityLight.bounceIntensity,
                                    MakeName("bounceIntensity"),
                                    "The multiplier that defines the strength of the bounce lighting.");

                // color             The color of the light.
                var unityLightColor = unityLight.color;

                fbxLight.Color.Set(new FbxDouble3(unityLightColor.r, unityLightColor.g, unityLightColor.b));

                // Export colorTemperature as custom property
                ExportFloatProperty(fbxNode, unityLight.colorTemperature,
                                    MakeName("colorTemperature"),
                                    "The color temperature of the light. Correlated Color Temperature (abbreviated as CCT) is multiplied with the color filter when calculating the final color of a light source.The color temperature of the electromagnetic radiation emitted from an ideal black body is defined as its surface temperature in Kelvin.White is 6500K according to the D65 standard. Candle light is 1800K.If you want to use lightsUseCCT, lightsUseLinearIntensity has to be enabled to ensure physically correct output. See Also: GraphicsSettings.lightsUseLinearIntensity, GraphicsSettings.lightsUseCCT.");

                // TODO: commandBufferCount Number of command buffers set up on this light (Read Only).

                // cookie            The cookie texture projected by the light.
                var unityCookieTexture = unityLight.cookie;

                if (unityCookieTexture != null)
                {
                    // Find its filename
                    var textureSourceFullPath = AssetDatabase.GetAssetPath(unityCookieTexture);
                    if (textureSourceFullPath != "")
                    {
                        // get absolute filepath to texture
                        textureSourceFullPath = Path.GetFullPath(textureSourceFullPath);

                        fbxLight.FileName.Set(textureSourceFullPath);
                        fbxLight.DrawGroundProjection.Set(true);
                        fbxLight.DrawVolumetricLight.Set(true);
                        fbxLight.DrawFrontFacingVolumetricLight.Set(false);
                    }
                }

                // Export cookieSize as custom property
                ExportFloatProperty(fbxNode, unityLight.cookieSize,
                                    MakeName("cookieSize"),
                                    "The size of a directional light's cookie.");

                // TODO: cullingMask       This is used to light certain objects in the scene selectively.
                // TODO: flare             The flare asset to use for this light.

                // Set the Intensity of a light is multiplied with the Light color.
                fbxLight.Intensity.Set(unityLight.intensity * 100.0f /*compensate for Maya scaling by system units*/);

                // TODO: isBaked           Is the light contribution already stored in lightmaps and/or lightprobes (Read Only).
                // TODO: lightmapBakeType  This property describes what part of a light's contribution can be baked.

                // Set the range of the light.
                // applies-to: Point & Spot
                // => FarAttenuationStart, FarAttenuationEnd
                fbxLight.FarAttenuationStart.Set(0.01f /* none zero start */);
                fbxLight.FarAttenuationEnd.Set(unityLight.range);

                // TODO: renderMode        How to render the light.

                // shadows           Set how this light casts shadows
                // applies-to: Point & Spot
                bool unityLightCastShadows = unityLight.shadows != LightShadows.None;

                fbxLight.CastShadows.Set(unityLightCastShadows);

                // TODO: shadowBias        Shadow mapping constant bias.
                // TODO: shadowCustomResolution The custom resolution of the shadow map.
                // TODO: shadowNearPlane   Near plane value to use for shadow frustums.
                // TODO: shadowNormalBias  Shadow mapping normal-based bias.
                // TODO: shadowResolution  The resolution of the shadow map.
                // TODO: shadowStrength    Strength of light's shadows.

                return(fbxLight);
            }