Example #1
0
            //-------------------------------------------------------------------------------
            internal static void Face(int[] unity, MeshTopology topology, Interface.Array <aiFace> assimp)
            {
                uint nb_faces = 0;

                switch (topology)
                {
                case MeshTopology.Points:
                    nb_faces = 1;
                    break;

                case MeshTopology.Lines:
                    nb_faces = 2;
                    break;

                case MeshTopology.Triangles:
                    nb_faces = 3;
                    break;

                case MeshTopology.Quads:
                    nb_faces = 4;
                    break;

                default:
                    Debug.LogErrorFormat("Unsupported topology '{0}' in assimp export.", topology);
                    break;
                }

                assimp.Clear();

                if (nb_faces > 0)
                {
                    long size = unity.Length / nb_faces;

                    uint i = 0;
                    for (; i < size; i++)
                    {
                        using (aiFace face = new aiFace())
                        {
                            using (aiUIntArray indices = face.Indices)
                            {
                                for (uint j = 0; j < nb_faces; j++)
                                {
                                    indices.Set(j, (uint)unity[i * nb_faces + j]);
                                }

                                assimp.Set(i, face.Unmanaged());
                            }
                        }
                    }

                    if (i * nb_faces != unity.Length)
                    {
                        Debug.LogError("Invalid number of vertices to compose the faces.");
                    }
                }
            }
Example #2
0
            internal static void Array <T, U>(Conversion <T, U> conv, T[] unity, Interface.Array <U> assimp) where U : Interface.Unmanagable <U>, System.IDisposable
            {
                int size = unity.Length;

                assimp.Clear();

                for (uint i = 0; i < size; i++)
                {
                    using (U assimp_element = conv(unity[i]))
                    {
                        assimp.Set(i, assimp_element.Unmanaged());
                    }
                }
            }