Exemplo n.º 1
0
        /// <summary>
        /// Resets native handle.
        /// </summary>
        /// <param name="moc"></param>
        public static void ResetUnmanagedMoc(CubismMoc moc)
        {
            moc.UnmanagedMoc = null;


            moc.Revive();
        }
        /// <summary>
        /// Initializes instance.
        /// </summary>
        /// <param name="moc">Moc unmanaged model was instantiated from.</param>
        public CubismTaskableModel(CubismMoc moc)
        {
            Moc = moc;


            // Instantiate unmanaged model.
            var unmanagedMoc = moc.AcquireUnmanagedMoc();


            UnmanagedModel = CubismUnmanagedModel.FromMoc(unmanagedMoc);


            Lock  = new object();
            State = TaskState.Idle;
            DynamicDrawableData    = CubismDynamicDrawableData.CreateData(UnmanagedModel);
            ShouldReleaseUnmanaged = false;
        }
        /// <summary>
        /// Initializes instance.
        /// </summary>
        /// <param name="moc">Moc unmanaged model was instantiated from.</param>
        public CubismTaskableModel(CubismMoc moc)
        {
            Moc = moc;


            // Allocate unmanaged memory and instantiate unmanaged model.
            var unmanagedMoc = moc.AcquireUnmanagedMoc();
            var size         = csmGetSizeofModel(unmanagedMoc);
            var memory       = CubismMemory.AllocateUnmanaged((int)size, csmAlignofModel);


            UnmanagedModel = csmInitializeModelInPlace(unmanagedMoc, memory, size);


            Lock  = new object();
            State = TaskState.Idle;
            DynamicDrawableData    = CubismDynamicDrawableData.CreateData(UnmanagedModel);
            ShouldReleaseUnmanaged = false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Instantiates a <see cref="CubismMoc"/>.
        /// </summary>
        /// <param name="moc">Cubism moc to instantiate.</param>
        /// <returns>Instance.</returns>
        public static CubismModel InstantiateFrom(CubismMoc moc)
        {
            // Return if argument is invailed.
            if (moc == null)
            {
                return(null);
            }


            // Create model.
            var model = new GameObject(moc.name)
                        .AddComponent <CubismModel>();


            // Initialize it by resetting it.
            model.Reset(moc);


            return(model);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes instance for first use.
        /// </summary>
        /// <param name="moc">Moc to instantiate from.</param>
        private void Reset(CubismMoc moc)
        {
            Moc           = moc;
            name          = moc.name;
            TaskableModel = new CubismTaskableModel(moc);


            // Create and initialize proxies.
            var parameters = CubismParameter.CreateParameters(TaskableModel.UnmanagedModel);
            var parts      = CubismPart.CreateParts(TaskableModel.UnmanagedModel);
            var drawables  = CubismDrawable.CreateDrawables(TaskableModel.UnmanagedModel);


            parameters.transform.SetParent(transform);
            parts.transform.SetParent(transform);
            drawables.transform.SetParent(transform);


            Parameters = parameters.GetComponentsInChildren <CubismParameter>();
            Parts      = parts.GetComponentsInChildren <CubismPart>();
            Drawables  = drawables.GetComponentsInChildren <CubismDrawable>();
        }
 /// <summary>
 /// Creates a <see cref="CubismTaskableModel"/> from a <see cref="CubismMoc"/>.
 /// </summary>
 /// <param name="moc">Moc source.</param>
 /// <returns>Instance.</returns>
 public static CubismTaskableModel CreateTaskableModel(CubismMoc moc)
 {
     return(new CubismTaskableModel(moc));
 }
Exemplo n.º 7
0
 /// <summary>
 /// Resets a <see cref="CubismMoc"/> reference in <see cref="CubismModel"/>.
 /// </summary>
 /// <param name="model">Target Cubism model.</param>
 /// <param name="moc">Cubism moc to reset.</param>
 public static void ResetMocReference(CubismModel model, CubismMoc moc)
 {
     model.Moc = moc;
 }