예제 #1
0
        /// <summary>
        /// Initializes instance.
        /// </summary>
        /// <param name="moc">Moc.</param>
        private CubismUnmanagedModel(CubismUnmanagedMoc moc)
        {
            // Allocate and initialize memory (returning on fail).
            var size   = CubismCoreDll.GetSizeofModel(moc.Ptr);
            var memory = CubismUnmanagedMemory.Allocate((int)size, CubismCoreDll.AlignofModel);


            if (memory == IntPtr.Zero)
            {
                return;
            }


            // Initialize native model (cleaning up and returning on fail).
            Ptr = CubismCoreDll.InitializeModelInPlace(moc.Ptr, memory, size);


            if (Ptr == IntPtr.Zero)
            {
                CubismUnmanagedMemory.Deallocate(memory);


                return;
            }


            // Initialize 'components'.
            Parameters = new CubismUnmanagedParameters(Ptr);
            Parts      = new CubismUnmanagedParts(Ptr);
            Drawables  = new CubismUnmanagedDrawables(Ptr);
        }