Пример #1
0
        public FbxLayerElementMaterial GetElementMaterial()
        {
            global::System.IntPtr   cPtr = fbx_wrapperPINVOKE.FbxGeometryBase_GetElementMaterial__SWIG_1(swigCPtr);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            return(ret);
        }
Пример #2
0
        public static FbxLayerElementMaterial Create(FbxLayerContainer pOwner, string pName)
        {
            global::System.IntPtr   cPtr = FbxWrapperNativePINVOKE.FbxLayerElementMaterial_Create(FbxLayerContainer.getCPtr(pOwner), pName);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            return(ret);
        }
Пример #3
0
        public FbxLayerElementMaterial GetElementMaterial(int pIndex)
        {
            global::System.IntPtr   cPtr = FbxWrapperNativePINVOKE.FbxGeometryBase_GetElementMaterial__SWIG_0(swigCPtr, pIndex);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            return(ret);
        }
Пример #4
0
        public FbxLayerElementMaterial CreateElementMaterial()
        {
            global::System.IntPtr   cPtr = FbxWrapperNativePINVOKE.FbxGeometryBase_CreateElementMaterial(swigCPtr);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            return(ret);
        }
Пример #5
0
        public FbxLayerElementMaterial GetMaterials()
        {
            global::System.IntPtr   cPtr = FbxWrapperNativePINVOKE.FbxLayer_GetMaterials__SWIG_0(swigCPtr);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            return(ret);
        }
Пример #6
0
 public void SetMaterials(FbxLayerElementMaterial pMaterials)
 {
     NativeMethods.FbxLayer_SetMaterials(swigCPtr, FbxLayerElementMaterial.getCPtr(pMaterials));
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
Пример #7
0
        public FbxLayerElementMaterial GetMaterials()
        {
            global::System.IntPtr   cPtr = NativeMethods.FbxLayer_GetMaterials(swigCPtr);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #8
0
        public static FbxLayerElementMaterial Create(FbxLayerContainer pOwner, string pName)
        {
            global::System.IntPtr   cPtr = NativeMethods.FbxLayerElementMaterial_Create(FbxLayerContainer.getCPtr(pOwner), pName);
            FbxLayerElementMaterial ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxLayerElementMaterial(cPtr, false);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #9
0
        public void TestSetMaterials()
        {
            // make sure nothing crashes

            m_fbxLayer.SetMaterials(FbxLayerElementMaterial.Create(m_fbxMesh, ""));
            Assert.IsNotNull(m_fbxLayer.GetMaterials());

            // test null
            m_fbxLayer.SetMaterials(null);
            Assert.IsNull(m_fbxLayer.GetMaterials());

            // test destroyed
            FbxLayerElementMaterial material = FbxLayerElementMaterial.Create(m_fbxMesh, "");

            material.Dispose();
            m_fbxLayer.SetMaterials(material);
        }
Пример #10
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxLayerElementMaterial obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Пример #11
0
        public bool RemoveElementMaterial(FbxLayerElementMaterial pElementMaterial)
        {
            bool ret = fbx_wrapperPINVOKE.FbxGeometryBase_RemoveElementMaterial(swigCPtr, FbxLayerElementMaterial.getCPtr(pElementMaterial));

            return(ret);
        }
Пример #12
0
        // For use only by FbxExportGlobals.
        internal static FbxMesh CreateFbxMesh(FbxExportGlobals G, GeometryPool pool, string poolName)
        {
            FbxMesh fbxMesh = FbxMesh.Create(G.m_manager, poolName);

            ExportMesh mesh   = new ExportMesh(pool);
            int        nVerts = mesh.m_pool.m_Vertices.Count;

            fbxMesh.InitControlPoints(nVerts);

            unsafe
            {
                fixed(Vector3 *f = mesh.m_pool.m_Vertices.GetBackingArray())
                {
                    Globals.SetControlPoints(fbxMesh, (IntPtr)f);
                }
            }

            List <int> triangles = mesh.m_pool.m_Tris;

            // Not available in Unity's wrappers
            // fbxMesh.ReservePolygonCount(triangles.Count / 3);
            // fbxMesh.ReservePolygonVertexCount(triangles.Count);
            for (int i = 0; i < triangles.Count; i += 3)
            {
                fbxMesh.BeginPolygon(-1 /* Material */, -1 /* Texture */, -1 /* Group */, false /* Legacy */);
                fbxMesh.AddPolygon(triangles[i]);
                fbxMesh.AddPolygon(triangles[i + 1]);
                fbxMesh.AddPolygon(triangles[i + 2]);
                fbxMesh.EndPolygon();
            }

            FbxLayer layer0 = fbxMesh.GetLayer(0);

            if (layer0 == null)
            {
                fbxMesh.CreateLayer();
                layer0 = fbxMesh.GetLayer(0);
            }

            var layerElementNormal = FbxLayerElementNormal.Create(fbxMesh, "normals");

            layerElementNormal.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
            layerElementNormal.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);
            CopyToFbx(layerElementNormal.GetDirectArray(), mesh.m_pool.m_Normals);
            layer0.SetNormals(layerElementNormal);

            var layerElementColor = FbxLayerElementVertexColor.Create(fbxMesh, "color");

            layerElementColor.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
            layerElementColor.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);
            CopyToFbx(layerElementColor.GetDirectArray(), mesh.m_linearColor);
            layer0.SetVertexColors(layerElementColor);

            var layerElementTangent = FbxLayerElementTangent.Create(fbxMesh, "tangents");

            layerElementTangent.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
            layerElementTangent.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);
            CopyToFbx(layerElementTangent.GetDirectArray(), mesh.m_pool.m_Tangents);
            layer0.SetTangents(layerElementTangent);

            // Compute and export binormals since Unity's FBX importer won't import the tangents without
            // them, even though they're not used.
            var layerElementBinormal = FbxLayerElementBinormal.Create(fbxMesh, "binormals");

            layerElementBinormal.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
            layerElementBinormal.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);
            var binormals = mesh.m_pool.m_Tangents
                            .Select((tan, idx) => {
                var b3 = Vector3.Cross(tan, mesh.m_pool.m_Normals[idx]) * tan.w;
                return(new Vector4(b3.x, b3.y, b3.z, 1));
            })
                            .ToList();

            CopyToFbx(layerElementBinormal.GetDirectArray(), binormals);
            layer0.SetBinormals(layerElementBinormal);

            var layerElementMaterial = FbxLayerElementMaterial.Create(fbxMesh, "materials");

            layerElementMaterial.SetMappingMode(FbxLayerElement.EMappingMode.eAllSame);
            layer0.SetMaterials(layerElementMaterial);

            // Export everything up to the last uvset containing data
            // even if some intermediate uvsets have no data.
            // Otherwise Unity will get the uvset numbering wrong on import

            List <List <Vector2> > uvSets = DemuxTexcoords(mesh.m_pool);

            for (int i = 0; i < uvSets.Count; i++)
            {
                FbxLayer layerN = fbxMesh.GetLayer(i);
                while (layerN == null)
                {
                    fbxMesh.CreateLayer();
                    layerN = fbxMesh.GetLayer(i);
                }
                var layerElementUV = FbxLayerElementUV.Create(fbxMesh, String.Format("uv{0}", i));
                layerElementUV.SetMappingMode(FbxLayerElement.EMappingMode.eByControlPoint);
                layerElementUV.SetReferenceMode(FbxLayerElement.EReferenceMode.eDirect);

                List <Vector2> uvSet = uvSets[i];
                if (uvSet == null)
                {
                    // Do nothing
                    // Replicates what the old fbx export code did; seems to work fine
                }
                else
                {
                    Debug.Assert(uvSet.Count == nVerts);
                    CopyToFbx(layerElementUV.GetDirectArray(), uvSet);
                }

                layerN.SetUVs(layerElementUV, FbxLayerElement.EType.eTextureDiffuse);
            }
            return(fbxMesh);
        }
Пример #13
0
 public void SetMaterials(FbxLayerElementMaterial pMaterials)
 {
     fbx_wrapperPINVOKE.FbxLayer_SetMaterials(swigCPtr, FbxLayerElementMaterial.getCPtr(pMaterials));
 }
Пример #14
0
 public void SetMaterials(FbxLayerElementMaterial pMaterials)
 {
     FbxWrapperNativePINVOKE.FbxLayer_SetMaterials(swigCPtr, FbxLayerElementMaterial.getCPtr(pMaterials));
 }