Example #1
0
        public static bool Load(string filePathString, out IntPtr context)
        {
            void *outContext;

            using (PinnedString path = new PinnedString(filePathString))
            {
                if (!Load(&outContext, path.Pointer, path.ByteSize))
                {
                    context = IntPtr.Zero;
                    return(false);
                }
            }
            context = new IntPtr(outContext);
            return(true);
        }
Example #2
0
        public static bool GetIndexes(IntPtr context, string meshNameString, out int[] indexes)
        {
            using (PinnedString meshName = new PinnedString(meshNameString))
            {
                int *ptr_native_indexesData;
                int  count;
                bool result = GetIndexes(context.ToPointer(), meshName.Pointer, &ptr_native_indexesData, &count);
                if (result)
                {
                    indexes = new int[count];
                    fixed(int *ptr_managed_Data = indexes)
                    {
                        ulong byteSize = (ulong)(Marshal.SizeOf(typeof(int)) * count);

                        Buffer.MemoryCopy(ptr_native_indexesData, ptr_managed_Data, byteSize, byteSize);
                    }

                    return(true);
                }
            }
            indexes = null;
            return(false);
        }
Example #3
0
        public static bool GetControlPoints(IntPtr context, string meshNameString, out double[] controlPoints)
        {
            using (PinnedString meshName = new PinnedString(meshNameString))
            {
                double *ptr_native_controlPointsData;
                int     count;
                bool    result = GetControlPoints(context.ToPointer(), meshName.Pointer, &ptr_native_controlPointsData, &count);
                if (result)
                {
                    controlPoints = new double[count * 3];
                    fixed(double *ptr_managed_controlPointsData = controlPoints)
                    {
                        ulong byteSize = (ulong)(Marshal.SizeOf(typeof(double)) * count * 3);

                        Buffer.MemoryCopy(ptr_native_controlPointsData, ptr_managed_controlPointsData, byteSize, byteSize);
                    }

                    return(true);
                }
            }
            controlPoints = null;
            return(false);
        }