Exemple #1
0
        void PrintAttribute(FbxNodeAttribute attri)
        {
            Log.Info("attri " + attri.GetName());
            Log.Info("attri type " + Enum.GetName(typeof(FbxNodeAttribute.EType), attri.GetAttributeType()));
            //attri.is

            if (attri.GetAttributeType() == FbxNodeAttribute.EType.eMesh)
            {
                Type t = attri.GetType();
                Log.Info("type name " + t.Name);

                FbxMesh mesh = attri.GetNode().GetMesh();
                //FbxMesh mesh = attri as FbxMesh;
                if (mesh == null)
                {
                    Log.Error("convert mesh failed!");
                    return;
                }

                //FbxMesh mesh;
                //FbxLayerElementUV uv = mesh.GetElementUV();

                //uv.GetDirectArray()

                FbxLayerElementNormal normal = mesh.GetElementNormal();
                DirectArrayFbxVector4 array  = normal.GetDirectArray();

                Log.Info("normal count " + array.GetCount());
                for (int i = 0; i < array.GetCount(); i++)
                {
                    FbxVector4        v    = array.GetAt(i);
                    SWIGTYPE_p_double data = v.mData;
                    DoubleArray       d    = DoubleArray.frompointer(data);
                    PrintDoubleArray(d, 4);
                }
            }
        }
Exemple #2
0
        void PrintAttribute(FbxManager manager, FbxNodeAttribute attri)
        {
            FbxLayerElementVertexColor pp;


            Log.Info("attri " + attri.GetName());
            Log.Info("attri type " + Enum.GetName(typeof(FbxNodeAttribute.EType), attri.GetAttributeType()));
            //attri.is

            if (attri.GetAttributeType() == FbxNodeAttribute.EType.eMesh)
            {
                Type t = attri.GetType();
                Log.Info("type name " + t.Name);

                FbxMesh mesh = attri.GetNode().GetMesh();


                //FbxMesh mesh = attri as FbxMesh;
                if (mesh == null)
                {
                    Log.Error("convert mesh failed!");
                    return;
                }


                Console.WriteLine($"mesh.GetMeshEdgeCount() = {mesh.GetMeshEdgeCount()}; mesh.GetPolygonCount() = {mesh.GetPolygonCount()}; mesh.GetPolygonVertexCount()={mesh.GetPolygonVertexCount()}; " +
                                  $"mesh.GetTextureUVCount() {mesh.GetTextureUVCount()}; mesh.GetControlPointsCount()={mesh.GetControlPointsCount()}; mesh.GetElementTangentCount()={mesh.GetElementTangentCount()};" +
                                  $" mesh.GetElementNormalCount()={mesh.GetElementNormalCount()}; mesh.GetElementVertexColorCount()={mesh.GetElementVertexColorCount()};" +
                                  $"mesh.GetUVLayerCount() = {mesh.GetUVLayerCount()}; mesh.GetLayerCount() = {mesh.GetLayerCount()}");
                var pts = mesh.GetControlPoints();
                var ar  = FbxVector4Array.frompointer(pts);

                for (int i = 0; i < mesh.GetLayerCount(); i++)
                {
                    var layer = mesh.GetLayer(i);
                }

                try
                {
                    var v2 = new FbxVector2();

                    IntPtr mem = Marshal.AllocHGlobal(4);

                    FbxStringList lst = new FbxStringList();
                    //int nameCount = lst.GetCount();
                    mesh.GetUVSetNames(lst); //ToDo : что за List, расширяется ли он сам?
                    var name = lst.GetItemAt(0).mString.Buffer();

                    //var myBool = new _MyBool(mem);
                    //var res = mesh.GetPolygonVertexUV(0, 0, name, v2, myBool);
                    //            var c0 = v2.at(0);
                    //            var c2 = v2.at(1);

                    var    fbxArV2 = new FbxArrayFbxVector2();
                    var    fbxArI  = new FbxArrayInt();
                    var    res     = mesh.GetPolygonVertexUVs(name, fbxArV2, fbxArI);
                    var    ptr     = fbxArV2.GetAt(2).mData;
                    double coord1  = FbxWrapperNative.DoubleArrayFunc_getitem(ptr, 0);
                    double coord2  = FbxWrapperNative.DoubleArrayFunc_getitem(ptr, 1);
                    var    param   = FbxWrapperNative.new_FbxLayerElementArrayTemplateIntPtrFunc();
                    res = mesh.GetMaterialIndices(param);
                    var param2 = FbxWrapperNative.FbxLayerElementArrayTemplateIntPtrFunc_value(param);
                    int count  = param2.GetCount();

                    List <int> mind = new List <int>();
                    for (int i = 0; i < count; i++)
                    {
                        mind.Add(param2.GetAt(i));
                    }



                    //var vec = new FbxVector4Array(5);
                    //var res2 = mesh.GetPolygonVertexUVs("", , null);

                    bool res1 = mesh.GenerateTangentsData(0);
                    //bool res2 = mesh.GenerateTangentsDataForAllUVSets( );
                    var tCount = mesh.GetElementTangentCount();
                    var tang   = mesh.GetElementTangent(  );
                    var tangAr = tang.GetDirectArray();
                    int tC     = tangAr.GetCount();

                    //int binCount = mesh.GetElementBinormalCount();
                    //var bin = mesh.GetElementBinormal().GetDirectArray().GetCount();
                }
                catch (Exception ex)
                {
                }


                //var vertices =  mesh.GetPolygonVertices();

                //FbxMesh mesh;
                //FbxLayerElementUV uv = mesh.GetElementUV();

                //uv.GetDirectArray()


                FbxLayerElementNormal normal = mesh.GetElementNormal();

                //ToDo

                //DirectArrayFbxVector4 array = normal.GetDirectArray();
                var array = normal.GetDirectArray();

                Log.Info("normal count " + array.GetCount());
                //for (int i = 0; i < array.GetCount(); i++)
                //{
                //    FbxVector4 v = array.GetAt(i);
                //    SWIGTYPE_p_double data = v.mData;
                //    DoubleArray d = DoubleArray.frompointer(data);
                //    PrintDoubleArray(d, 4);
                //}
            }
        }