示例#1
0
        void UpdateAbcTree(aiContext ctx, AlembicTreeNode node, double time, bool createMissingNodes, bool initialImport)
        {
            var top = ctx.topObject;

            if (!top)
            {
                return;
            }

            m_importContext = new ImportContext
            {
                alembicTreeNode = node,
                ss = NativeMethods.aiTimeToSampleSelector(time),
                createMissingNodes = createMissingNodes,
            };
            top.EachChild(ImportCallback);

            if (!initialImport)
            {
                foreach (var meshFilter in node.gameObject.GetComponentsInChildren <MeshFilter>())
                {
                    meshFilter.sharedMesh.hideFlags |= HideFlags.DontSave;
                }
            }

            m_importContext = null;
        }
示例#2
0
 internal AlembicStream(GameObject rootGo, AlembicStreamDescriptor streamDesc)
 {
     m_config.SetDefaults();
     m_abcTreeRoot = new AlembicTreeNode()
     {
         stream = this, gameObject = rootGo
     };
     m_streamDesc = streamDesc;
 }
示例#3
0
 void AbcEndSyncData(AlembicTreeNode node)
 {
     if (node.abcObject != null && node.gameObject != null)
     {
         node.abcObject.AbcSyncDataEnd();
     }
     foreach (var child in node.Children)
     {
         AbcEndSyncData(child);
     }
 }
示例#4
0
 void AbcBeforeUpdateSamples(AlembicTreeNode node)
 {
     if (node.abcObject != null && node.gameObject != null)
     {
         node.abcObject.AbcPrepareSample();
     }
     foreach (var child in node.Children)
     {
         AbcBeforeUpdateSamples(child);
     }
 }
示例#5
0
        public void Dispose()
        {
            AlembicStream.s_streams.Remove(this);
            if (m_abcTreeRoot != null)
            {
                m_abcTreeRoot.Dispose();
                m_abcTreeRoot = null;
            }

            if (abcIsValid)
            {
                m_context.Destroy();
            }
        }
示例#6
0
        void ImportCallback(aiObject obj)
        {
            var             ic            = m_importContext;
            AlembicTreeNode treeNode      = ic.alembicTreeNode;
            AlembicTreeNode childTreeNode = null;

            aiSchema schema = obj.AsXform();

            if (!schema)
            {
                schema = obj.AsPolyMesh();
            }
            if (!schema)
            {
                schema = obj.AsCamera();
            }
            if (!schema)
            {
                schema = obj.AsPoints();
            }

            if (schema)
            {
                // Get child. create if needed and allowed.
                string childName = obj.name;

                // Find targetted child GameObj
                GameObject childGO = null;

                var childTransf = treeNode.gameObject == null ? null : treeNode.gameObject.transform.Find(childName);
                if (childTransf == null)
                {
                    if (!ic.createMissingNodes)
                    {
                        obj.SetEnabled(false);
                        return;
                    }
                    else
                    {
                        obj.SetEnabled(true);
                    }

                    childGO = new GameObject {
                        name = childName
                    };
                    childGO.GetComponent <Transform>().SetParent(treeNode.gameObject.transform, false);
                }
                else
                {
                    childGO = childTransf.gameObject;
                }

                childTreeNode = new AlembicTreeNode()
                {
                    stream = this, gameObject = childGO
                };
                treeNode.Children.Add(childTreeNode);

                // Update
                AlembicElement elem = null;

                if (obj.AsXform() && m_streamDesc.Settings.ImportXform)
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicXform>();
                }
                else if (obj.AsCamera() && m_streamDesc.Settings.ImportCameras)
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicCamera>();
                }
                else if (obj.AsPolyMesh() && m_streamDesc.Settings.ImportMeshes)
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicMesh>();
                }
                else if (obj.AsPoints() && m_streamDesc.Settings.ImportPoints)
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicPoints>();
                }

                if (elem != null)
                {
                    elem.AbcSetup(obj, schema);
                    elem.AbcPrepareSample();
                    schema.UpdateSample(ref ic.ss);
                    elem.AbcSyncDataBegin();
                    elem.AbcSyncDataEnd();
                }
            }
            else
            {
                obj.SetEnabled(false);
            }

            ic.alembicTreeNode = childTreeNode;
            obj.EachChild(ImportCallback);
            ic.alembicTreeNode = treeNode;
        }