Example #1
0
        public FbxSurfaceMaterial GetAt(int pIndex)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_GetAt(swigCPtr, pIndex);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #2
0
        public new static FbxSurfaceMaterial Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxSurfaceMaterial_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #3
0
        public FbxSurfaceMaterial GetMaterial(string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxScene_GetMaterial__SWIG_1(swigCPtr, pName);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #4
0
 public FbxMaterialConverter(FbxManager mManager, FbxSurfaceMaterial pDefaultMaterial) : this(FbxWrapperNativePINVOKE.new_FbxMaterialConverter__SWIG_0(FbxManager.getCPtr(mManager), FbxSurfaceMaterial.getCPtr(pDefaultMaterial)), true)
 {
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Example #5
0
        public FbxSurfaceMaterial GetMaterial(int pIndex)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxScene_GetMaterial__SWIG_0(swigCPtr, pIndex);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #6
0
        public new static FbxSurfaceMaterial Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxSurfaceMaterial_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #7
0
        public FbxSurfaceMaterial GetLast()
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_GetLast(swigCPtr);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #8
0
        public FbxSurfaceMaterial GetAt(int pIndex)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_GetAt(swigCPtr, pIndex);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
Example #9
0
        protected override FbxScene CreateScene(FbxManager manager)
        {
            FbxScene scene = base.CreateScene(manager);

            // mesh shared by all instances
            FbxMesh            sharedMesh     = FbxMesh.Create(scene, m_meshName);
            FbxSurfaceMaterial sharedMaterial = FbxSurfacePhong.Create(scene, m_materialName);

            // add mesh to all nodes
            Queue <FbxNode> nodes = new Queue <FbxNode>();

            for (int i = 0; i < scene.GetRootNode().GetChildCount(); i++)
            {
                nodes.Enqueue(scene.GetRootNode().GetChild(i));
            }

            while (nodes.Count > 0)
            {
                FbxNode node = nodes.Dequeue();
                node.SetNodeAttribute(sharedMesh);
                node.AddMaterial(sharedMaterial);
                for (int i = 0; i < node.GetChildCount(); i++)
                {
                    nodes.Enqueue(node.GetChild(i));
                }
            }

            return(scene);
        }
Example #10
0
        public FbxSurfaceMaterial RemoveLast()
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_RemoveLast(swigCPtr);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            return(ret);
        }
 public bool Equals(FbxSurfaceMaterial other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }
Example #12
0
        public int AddMaterial(FbxSurfaceMaterial pMaterial)
        {
            int ret = NativeMethods.FbxNode_AddMaterial(swigCPtr, FbxSurfaceMaterial.getCPtr(pMaterial));

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #13
0
            /// <summary>
            /// Export an Unity Texture
            /// </summary>
            public void ExportTexture(Material unityMaterial, string unityPropName,
                                      FbxSurfaceMaterial fbxMaterial, string fbxPropName)
            {
                if (!unityMaterial)
                {
                    return;
                }

                // Get the texture on this property, if any.
                if (!unityMaterial.HasProperty(unityPropName))
                {
                    return;
                }
                var unityTexture = unityMaterial.GetTexture(unityPropName);

                if (!unityTexture)
                {
                    return;
                }

                // Find its filename
                var textureSourceFullPath = AssetDatabase.GetAssetPath(unityTexture);

                if (textureSourceFullPath == "")
                {
                    return;
                }

                // get absolute filepath to texture
                textureSourceFullPath = Path.GetFullPath(textureSourceFullPath);

                if (Verbose)
                {
                    Debug.Log(string.Format("{2}.{1} setting texture path {0}", textureSourceFullPath, fbxPropName, fbxMaterial.GetName()));
                }

                // Find the corresponding property on the fbx material.
                var fbxMaterialProperty = fbxMaterial.FindProperty(fbxPropName);

                if (fbxMaterialProperty == null || !fbxMaterialProperty.IsValid())
                {
                    Debug.Log("property not found"); return;
                }

                // Find or create an fbx texture and link it up to the fbx material.
                if (!TextureMap.ContainsKey(textureSourceFullPath))
                {
                    var fbxTexture = FbxFileTexture.Create(fbxMaterial, fbxPropName + "_Texture");
                    fbxTexture.SetFileName(textureSourceFullPath);
                    fbxTexture.SetTextureUse(FbxTexture.ETextureUse.eStandard);
                    fbxTexture.SetMappingType(FbxTexture.EMappingType.eUV);
                    TextureMap.Add(textureSourceFullPath, fbxTexture);
                }
                TextureMap[textureSourceFullPath].ConnectDstProperty(fbxMaterialProperty);
            }
        public new static FbxSurfaceMaterial Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxSurfaceMaterial_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #15
0
        private FbxSurfaceMaterial GetAtUnchecked(int pIndex)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxLayerElementArrayTemplateFbxSurfaceMaterial_GetAtUnchecked(swigCPtr, pIndex);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #16
0
        public static FbxSurfaceLambert fromMaterial(FbxSurfaceMaterial m)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxSurfaceLambert_fromMaterial(FbxSurfaceMaterial.getCPtr(m));
            FbxSurfaceLambert     ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceLambert(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #17
0
        public FbxSurfaceMaterial GetMaterial(int pIndex)
        {
            global::System.IntPtr cPtr = NativeMethods.FbxNode_GetMaterial(swigCPtr, pIndex);
            FbxSurfaceMaterial    ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxSurfaceMaterial(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Example #18
0
        private void CheckSceneHelper(FbxNode node, FbxMesh mesh, FbxSurfaceMaterial material)
        {
            if (node == null)
            {
                return;
            }

            Assert.AreEqual(mesh, node.GetMesh());

            int matIndex = node.GetMaterialIndex(m_materialName);

            Assert.GreaterOrEqual(matIndex, 0);
            Assert.AreEqual(material, node.GetMaterial(matIndex));

            for (int i = 0; i < node.GetChildCount(); i++)
            {
                // recurse through the hierarchy
                CheckSceneHelper(node.GetChild(i), mesh, material);
            }
        }
Example #19
0
        protected override void CheckScene(FbxScene scene)
        {
            base.CheckScene(scene);

            FbxNode rootNode = scene.GetRootNode().GetChild(0);

            Assert.IsNotNull(rootNode);

            FbxMesh sharedMesh = rootNode.GetMesh();

            Assert.IsNotNull(sharedMesh);
            Assert.AreEqual(m_meshName, sharedMesh.GetName());

            int matIndex = rootNode.GetMaterialIndex(m_materialName);

            Assert.GreaterOrEqual(matIndex, 0);
            FbxSurfaceMaterial sharedMat = rootNode.GetMaterial(matIndex);

            Assert.IsNotNull(sharedMat);

            // check that the mesh is the same for all children
            CheckSceneHelper(rootNode, sharedMesh, sharedMat);
        }
Example #20
0
 /// Memoized version of CreateFbxMaterial
 /// Guarantees 1:1 correspondence between IEM, FbxMaterial, and FbxMaterial.name
 public FbxSurfaceMaterial GetOrCreateFbxMaterial(
     string meshNamespace,
     IExportableMaterial exportableMaterial)
 {
     // Unity's able to ensure a 1:1 correspondence between FBX materials and generated Unity
     // materials. However, users like TBT who go through the OnAssignMaterialModel interface cannot
     // distinguish between "two unique materials with the same name" and "one material being
     // used multiple times".
     //
     // Since TBT can't detect reference-equality of FbxMaterial, we have to help it by
     // making name-equality the same as reference-equality. IOW distinct materials need
     // distinct names.
     if (m_createdMaterials.TryGetValue(exportableMaterial, out FbxSurfaceMaterial mtl))
     {
         return(mtl);
     }
     else
     {
         FbxSurfaceMaterial newMtl = ExportFbx.CreateFbxMaterial(
             this, meshNamespace, exportableMaterial, m_createdMaterialNames);
         m_createdMaterials[exportableMaterial] = newMtl;
         return(newMtl);
     }
 }
Example #21
0
        public bool RemoveIt(FbxSurfaceMaterial pItem)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_RemoveIt(swigCPtr, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }
Example #22
0
 public void SetLast(FbxSurfaceMaterial pItem)
 {
     FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_SetLast(swigCPtr, FbxSurfaceMaterial.getCPtr(pItem));
 }
Example #23
0
        public int InsertAt(int pIndex, FbxSurfaceMaterial pItem)
        {
            int ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_InsertAt(swigCPtr, pIndex, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }
Example #24
0
        public int Add(FbxSurfaceMaterial pItem)
        {
            int ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_Add(swigCPtr, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }
Example #25
0
        public int FindBefore(int pBeforeIndex, FbxSurfaceMaterial pItem)
        {
            int ret = FbxWrapperNativePINVOKE.FbxLayerElementArrayTemplateFbxSurfaceMaterialPtr_FindBefore(swigCPtr, pBeforeIndex, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }
Example #26
0
        public int InsertAt(int pIndex, FbxSurfaceMaterial pItem)
        {
            int ret = fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_InsertAt(swigCPtr, pIndex, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }
Example #27
0
 public void SetLast(FbxSurfaceMaterial pItem)
 {
     fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_SetLast(swigCPtr, FbxSurfaceMaterial.getCPtr(pItem));
 }
Example #28
0
 public void SetAt(int pIndex, FbxSurfaceMaterial pItem)
 {
     fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_SetAt(swigCPtr, pIndex, FbxSurfaceMaterial.getCPtr(pItem));
 }
        public void TestBasics()
        {
            bool    ok;
            FbxNode found;

            // Call every function once in a non-corner-case way
            var root = CreateObject("root");

            Assert.AreEqual(0, root.GetChildCount());     // non-recursive
            Assert.AreEqual(0, root.GetChildCount(true)); // recursive

            var t = root.LclTranslation;

            Assert.AreEqual(new FbxDouble3(0, 0, 0), t.Get());
            var s = root.LclScaling;

            Assert.AreEqual(new FbxDouble3(1, 1, 1), s.Get());
            var r = root.LclRotation;

            Assert.AreEqual(new FbxDouble3(0, 0, 0), r.Get());
            var vi = root.VisibilityInheritance;

            Assert.AreEqual(true, vi.Get());

            var child = CreateObject("child");

            ok = root.AddChild(child);
            Assert.IsTrue(ok);
            Assert.AreEqual(0, child.GetChildCount());     // non-recursive
            Assert.AreEqual(0, child.GetChildCount(true)); // recursive
            Assert.AreEqual(1, root.GetChildCount());      // non-recursive
            Assert.AreEqual(1, root.GetChildCount(true));  // recursive
            found = child.GetParent();
            Assert.AreEqual(root, found);
            found = root.GetChild(0);
            Assert.AreEqual(child, found);

            var grandchild = CreateObject("grandchild");

            ok = child.AddChild(grandchild);
            Assert.IsTrue(ok);
            Assert.AreEqual(0, grandchild.GetChildCount());     // non-recursive
            Assert.AreEqual(0, grandchild.GetChildCount(true)); // recursive
            Assert.AreEqual(1, child.GetChildCount());          // non-recursive
            Assert.AreEqual(1, child.GetChildCount(true));      // recursive
            Assert.AreEqual(1, root.GetChildCount());           // non-recursive
            Assert.AreEqual(2, root.GetChildCount(true));       // recursive
            found = root.GetChild(0);
            Assert.AreEqual(child, found);
            found = child.GetChild(0);
            Assert.AreEqual(grandchild, found);

            // Create a node from the grandchild. That's a child.
            var greatgrandchild = FbxNode.Create(grandchild, "greatgrandchild");

            Assert.AreEqual(1, grandchild.GetChildCount());

            found = root.FindChild("child");      // recursive
            Assert.AreEqual(child, found);
            found = root.FindChild("grandchild"); // recursive
            Assert.AreEqual(grandchild, found);
            found = root.FindChild("grandchild", pRecursive: false);
            Assert.IsNull(found);
            greatgrandchild.SetName("greatest");
            found = root.FindChild("greatgrandchild", pRecursive: true, pInitial: false);
            Assert.AreEqual(null, found);
            found = root.FindChild("greatgrandchild", pRecursive: true, pInitial: true);
            Assert.AreEqual(greatgrandchild, found);

            // Destroying the grandchild recursively nukes the great-grandchild and unparents from child.
            grandchild.Destroy(pRecursive: true);
            Assert.That(() => { greatgrandchild.GetName(); }, Throws.Exception.TypeOf <System.ArgumentNullException>());
            Assert.AreEqual(0, child.GetChildCount());

            // Destroying the child non-recursively (after adding a new
            // grandchild) doesn't destroy the grandchild.
            grandchild = CreateObject("grandchild2");
            child.AddChild(grandchild);
            child.Destroy();
            Assert.AreEqual("grandchild2", grandchild.GetName()); // actually compare by name => check it doesn't throw

            // That unparents the grandchild.
            Assert.IsNull(grandchild.GetParent());

            // Recursively destroying the root does not destroy the grandchild.
            root.Destroy(pRecursive: true);
            Assert.AreEqual("grandchild2", grandchild.GetName()); // actually compare by name => check it doesn't throw

            // Test we can remove a child.
            var fooNode = FbxNode.Create(grandchild, "foo");

            grandchild.RemoveChild(fooNode);
            Assert.IsNull(fooNode.GetParent());
            Assert.AreEqual(0, grandchild.GetChildCount());

            // Add a material.
            var mat = FbxSurfaceMaterial.Create(Manager, "mat");

            Assert.AreEqual(0, fooNode.AddMaterial(mat));
            Assert.That(() => { fooNode.AddMaterial(null); }, Throws.Exception.TypeOf <System.ArgumentNullException>());

            int matIndex = fooNode.GetMaterialIndex("mat");

            Assert.GreaterOrEqual(matIndex, 0);
            Assert.AreEqual(fooNode.GetMaterial(matIndex), mat);

            // test that invalid material index doesnt crash
            fooNode.GetMaterial(int.MinValue);
            fooNode.GetMaterial(int.MaxValue);

            Assert.Less(fooNode.GetMaterialIndex("not a mat"), 0);
            // TODO: Find a way to do a null arg check without breaking Create function
            //       (as they both us pName as a param)
            //Assert.That(() => { fooNode.GetMaterialIndex (null); }, Throws.Exception.TypeOf<System.ArgumentNullException>());

            // Test whether it's a skeleton, camera, etc. It isn't.
            Assert.IsNull(fooNode.GetCamera());
            Assert.IsNull(fooNode.GetGeometry());
            Assert.IsNull(fooNode.GetMesh());
            Assert.IsNull(fooNode.GetNodeAttribute());
            Assert.IsNull(fooNode.GetSkeleton());
            Assert.IsNull(fooNode.GetLight());

            // Test that we can get at the limits by reference.
            Assert.IsNotNull(fooNode.GetTranslationLimits());
            Assert.IsNotNull(fooNode.GetRotationLimits());
            Assert.IsNotNull(fooNode.GetScalingLimits());

            var limits = fooNode.GetTranslationLimits();

            Assert.IsFalse(limits.GetActive());
            limits.SetActive(true);
            Assert.IsTrue(fooNode.GetTranslationLimits().GetActive());
        }
Example #30
0
        public bool RemoveIt(FbxSurfaceMaterial pItem)
        {
            bool ret = fbx_wrapperPINVOKE.DirectArrayFbxSurfaceMaterialPtr_RemoveIt(swigCPtr, FbxSurfaceMaterial.getCPtr(pItem));

            return(ret);
        }