コード例 #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);
        }
コード例 #2
0
        /// <summary>
        /// Releases instance.
        /// </summary>
        public void Release()
        {
            if (Ptr == IntPtr.Zero)
            {
                return;
            }


            CubismUnmanagedMemory.Deallocate(Ptr);


            Ptr = IntPtr.Zero;
        }
コード例 #3
0
        /// <summary>
        /// Initializes instance.
        /// </summary>
        /// <param name="bytes">Moc bytes.</param>
        private CubismUnmanagedMoc(byte[] bytes)
        {
            // Allocate and initialize memory (returning on fail).
            var memory = CubismUnmanagedMemory.Allocate(bytes.Length, CubismCoreDll.AlignofMoc);


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


            CubismUnmanagedMemory.Write(bytes, memory);


            // Revive native moc (cleaning up on fail).
            Ptr = CubismCoreDll.ReviveMocInPlace(memory, (uint)bytes.Length);


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