// --- public api ---

        public void AbcLoad(bool createMissingNodes = false)
        {
            if (m_playbackSettings == null || m_diagSettings == null || ImportSettings == null || ImportSettings.m_pathToAbc == null)
            {
                return;
            }

            m_time         = 0.0f;
            m_forceRefresh = true;

            m_abc    = AbcAPI.aiCreateContext(_alembicTreeRoot.linkedGameObj.GetInstanceID());
            m_loaded = AbcAPI.aiLoad(m_abc, ImportSettings.m_pathToAbc.GetFullPath());

            if (m_loaded)
            {
                m_forceRefresh = true;
                AbcSyncConfig();
                AbcAPI.UpdateAbcTree(m_abc, _alembicTreeRoot, AbcTime(m_time), createMissingNodes);
            }
            else
            {
                Debug.LogError("failed to load alembic: " + ImportSettings.m_pathToAbc);
            }
            AbcSetLastUpdateState(AbcTime(0.0f), AbcAPI.GetAspectRatio(ImportSettings.m_aspectRatioMode));
        }
示例#2
0
        public void Dispose()
        {
            AlembicStream.s_Streams.Remove(this);
            if (alembicTreeRoot != null)
            {
                alembicTreeRoot.Dispose();
                alembicTreeRoot = null;
            }

            if (AbcIsValid())
            {
                AbcAPI.aiDestroyContext(m_Context);
                m_Context = default(AbcAPI.aiContext);
            }
        }
        // --- method overrides ---

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_alembicTreeRoot != null)
                {
                    _alembicTreeRoot.Dispose();
                    _alembicTreeRoot = null;
                }
            }

            if (AbcIsValid())
            {
                if (m_updateBegan)
                {
                    AbcAPI.aiUpdateSamplesEnd(m_abc);
                }
                AbcAPI.aiDestroyContext(m_abc);
                m_abc = default(AbcAPI.aiContext);
            }

            base.Dispose(disposing);
        }
示例#4
0
        public void AbcLoad()
        {
            m_Time = 0.0f;

            m_Context = AbcAPI.aiCreateContext(alembicTreeRoot.linkedGameObj.GetInstanceID());

            var settings = m_StreamDesc.settings;

            m_Config.swapHandedness  = settings.swapHandedness;
            m_Config.shareVertices   = settings.shareVertices;
            m_Config.swapFaceWinding = settings.swapFaceWinding;
            m_Config.normalsMode     = settings.normalsMode;
            m_Config.tangentsMode    = settings.tangentsMode;
            m_Config.cacheSamples    = settings.cacheSamples;
            m_Config.treatVertexExtraDataAsStatics = settings.treatVertexExtraDataAsStatics;
            m_Config.turnQuadEdges       = settings.turnQuadEdges;
            m_Config.aspectRatio         = AbcAPI.GetAspectRatio(settings.aspectRatioMode);
            m_Config.cacheTangentsSplits = true;
#if UNITY_2017_3_OR_NEWER
            m_Config.use32BitsIndexBuffer = settings.use32BitsIndexBuffer;
#else
            m_Config.use32BitsIndexBuffer = false;
#endif
            AbcAPI.aiSetConfig(m_Context, ref m_Config);

            m_Loaded = AbcAPI.aiLoad(m_Context, Application.streamingAssetsPath + m_StreamDesc.pathToAbc);

            if (m_Loaded)
            {
                AbcAPI.UpdateAbcTree(m_Context, alembicTreeRoot, m_Time);
                AlembicStream.s_Streams.Add(this);
            }
            else
            {
                Debug.LogError("failed to load alembic at " + Application.streamingAssetsPath + m_StreamDesc.pathToAbc);
            }
        }
        private bool AbcRecoverContext()
        {
            if (!AbcIsValid())
            {
                if (m_diagSettings.m_verbose)
                {
                    Debug.Log("AlembicStream.AbcRecoverContext: Try to recover alembic context");
                }

                m_abc = AbcAPI.aiCreateContext(_alembicTreeRoot.linkedGameObj.GetInstanceID());

                if (AbcIsValid())
                {
                    m_forceRefresh = true;
                    _alembicTreeRoot.ResetTree();

                    AbcSyncConfig();

                    AbcAPI.UpdateAbcTree(m_abc, _alembicTreeRoot, AbcTime(m_time), false);

                    if (m_diagSettings.m_verbose)
                    {
                        Debug.Log("AlembicStream.AbcRecoverContext: Succeeded.");
                    }

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(true);
            }
        }