コード例 #1
0
        public override void AbcSetup(aiObject abcObj, aiSchema abcSchema)
        {
            base.AbcSetup(abcObj, abcSchema);
            m_abcSchema = (aiPolyMesh)abcSchema;

            m_abcSchema.GetSummary(ref m_summary);
        }
コード例 #2
0
        public override void AbcSetup(aiObject abcObj, aiSchema abcSchema)
        {
            base.AbcSetup(abcObj, abcSchema);
            m_abcSchema = (aiCamera)abcSchema;

            m_camera = GetOrAddComponent <Camera>();
        }
コード例 #3
0
        public override void AbcSetup(aiObject abcObj, aiSchema abcSchema)
        {
            base.AbcSetup(abcObj, abcSchema);
            m_abcSchema = (aiCamera)abcSchema;

            m_camera = GetOrAddComponent <Camera>();

            // flip forward direction (camera in Alembic has inverted forward direction)
            abcTreeNode.gameObject.transform.localEulerAngles = new Vector3(0, 180, 0);
        }
コード例 #4
0
        public override void AbcSetup(aiObject abcObj, aiSchema abcSchema)
        {
            base.AbcSetup(abcObj, abcSchema);
            m_abcSchema = abcSchema;

            Light light = GetOrAddComponent <Light>();

            // Disable component for now
            light.enabled = false;
        }
コード例 #5
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
        /*
         *  public static GameObject ImportAbc(string path)
         *  {
         *      var relPath = MakeRelativePath(path);
         *      ImportParams p = new ImportParams();
         *      return ImportImpl(relPath, p);
         *  }
         *
         *  private static GameObject ImportImpl(string path, ImportParams p)
         *  {
         *      if (path == null || path == "")
         *      {
         *          return null;
         *      }
         *
         *      string baseName = System.IO.Path.GetFileNameWithoutExtension(path);
         *      string name = baseName;
         *      int index = 1;
         *
         *      while (GameObject.Find("/" + name) != null)
         *      {
         *          name = baseName + index;
         ++index;
         *      }
         *
         *      var root = new GameObject {name = name};
         *      var abcStream = new AlembicStream( root )
         *      {
         *          m_pathToAbc = path,
         *          m_swapHandedness = p.swapHandedness,
         *          m_swapFaceWinding = p.swapFaceWinding
         *      };
         *      abcStream.AbcLoad(true);
         *
         *      return root;
         *  }
         */
    #endif

        public static void UpdateAbcTree(aiContext ctx, AlembicTreeNode node, float time, bool createMissingNodes = false)
        {
            var ic = new ImportContext
            {
                alembicTreeNode = node,
                ss = aiTimeToSampleSelector(time),
                createMissingNodes = createMissingNodes,
                objectsToDelete    = new List <aiObject>()
            };

            GCHandle hdl = GCHandle.Alloc(ic);

            aiObject top = aiGetTopObject(ctx);

            if (top.ptr != (IntPtr)0)
            {
                aiEnumerateChild(top, ImportEnumerator, GCHandle.ToIntPtr(hdl));

                foreach (aiObject obj in ic.objectsToDelete)
                {
                    aiDestroyObject(ctx, obj);
                }
            }
        }
コード例 #6
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 [DllImport("abci")] private static extern IntPtr    aiGetFullNameS(aiObject obj);
コード例 #7
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.enabled = false;
                        return;
                    }
                    else
                    {
                        obj.enabled = 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.enabled = false;
            }

            ic.alembicTreeNode = childTreeNode;
            obj.EachChild(ImportCallback);
            ic.alembicTreeNode = treeNode;
        }
コード例 #8
0
 public virtual void AbcSetup(aiObject abcObj, aiSchema abcSchema)
 {
     m_abcObj = abcObj;
 }
コード例 #9
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
        static void ImportEnumerator(aiObject obj, IntPtr userData)
        {
            var             ic       = GCHandle.FromIntPtr(userData).Target as ImportContext;
            AlembicTreeNode treeNode = ic.alembicTreeNode;

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

            // Find targetted child GameObj
            AlembicTreeNode childTreeNode = null;
            GameObject      childGO       = null;
            var             childTransf   = treeNode.linkedGameObj.transform.Find(childName);

            if (childTransf == null)
            {
                if (!ic.createMissingNodes)
                {
                    ic.objectsToDelete.Add(obj);
                    return;
                }

                childGO = new GameObject {
                    name = childName
                };
                var trans = childGO.GetComponent <Transform>();
                trans.parent           = treeNode.linkedGameObj.transform;
                trans.localPosition    = Vector3.zero;
                trans.localEulerAngles = Vector3.zero;
                trans.localScale       = Vector3.one;
            }
            else
            {
                childGO = childTransf.gameObject;
            }

            if (childTreeNode == null)
            {
                childTreeNode = new AlembicTreeNode()
                {
                    linkedGameObj = childGO, stream = treeNode.stream
                };
                treeNode.children.Add(childTreeNode);
            }

            // Update
            AlembicElement elem   = null;
            aiSchema       schema = default(aiSchema);

            if (aiGetXForm(obj))
            {
                elem   = childTreeNode.GetOrAddAlembicObj <AlembicXForm>();
                schema = aiGetXForm(obj);
            }
            else if (aiGetPolyMesh(obj))
            {
                elem   = childTreeNode.GetOrAddAlembicObj <AlembicMesh>();
                schema = aiGetPolyMesh(obj);
            }
            else if (aiGetCamera(obj))
            {
                elem   = childTreeNode.GetOrAddAlembicObj <AlembicCamera>();
                schema = aiGetCamera(obj);
            }
            else if (aiGetPoints(obj))
            {
                elem   = childTreeNode.GetOrAddAlembicObj <AlembicPoints>();
                schema = aiGetPoints(obj);
            }

            if (elem != null)
            {
                elem.AbcSetup(obj, schema);
                elem.AbcUpdateConfig();
                aiSchemaUpdateSample(schema, ref ic.ss);
                elem.AbcUpdate();
            }

            ic.alembicTreeNode = childTreeNode;
            aiEnumerateChild(obj, ImportEnumerator, userData);
            ic.alembicTreeNode = treeNode;
        }
コード例 #10
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 [DllImport("abci")] public static extern aiSchema   aiGetPoints(aiObject obj);
コード例 #11
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.linkedGameObj == null ? null : treeNode.linkedGameObj.transform.Find(childName);
                if (childTransf == null)
                {
                    if (!ic.createMissingNodes)
                    {
                        obj.enabled = false;
                        return;
                    }

                    childGO = new GameObject {
                        name = childName
                    };
                    var trans = childGO.GetComponent <Transform>();
                    trans.parent           = treeNode.linkedGameObj.transform;
                    trans.localPosition    = Vector3.zero;
                    trans.localEulerAngles = Vector3.zero;
                    trans.localScale       = Vector3.one;
                }
                else
                {
                    childGO = childTransf.gameObject;
                }

                childTreeNode = new AlembicTreeNode()
                {
                    linkedGameObj = childGO, streamDescriptor = treeNode.streamDescriptor
                };
                treeNode.children.Add(childTreeNode);

                // Update
                AlembicElement elem = null;

                if (obj.AsXform())
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicXform>();
                }
                else if (obj.AsPolyMesh())
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicMesh>();
                }
                else if (obj.AsCamera())
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicCamera>();
                }
                else if (obj.AsPoints())
                {
                    elem = childTreeNode.GetOrAddAlembicObj <AlembicPoints>();
                }

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

            ic.alembicTreeNode = childTreeNode;
            obj.EachChild(ImportCallback);
            ic.alembicTreeNode = treeNode;
        }
コード例 #12
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 [DllImport("abci")] public static extern aiSchema   aiGetCamera(aiObject obj);
コード例 #13
0
 [DllImport("AlembicImporter")] public static extern void       aiDestroyObject(aiContext ctx, aiObject obj);
コード例 #14
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 [DllImport("abci")] public static extern void       aiEnumerateChild(aiObject obj, aiNodeEnumerator e, IntPtr userData);
コード例 #15
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 [DllImport("abci")] public static extern void       aiDestroyObject(aiContext ctx, aiObject obj);
コード例 #16
0
 [DllImport("AlembicImporter")] public static extern aiSchema    aiGetPoints(aiObject obj);
コード例 #17
0
 [DllImport("AlembicImporter")] private static extern IntPtr    aiGetFullNameS(aiObject obj);
コード例 #18
0
        public override void AbcSetup(aiObject abcObj, aiSchema abcSchema)
        {
            base.AbcSetup(abcObj, abcSchema);

            m_abcSchema = (aiXform)abcSchema;
        }
コード例 #19
0
ファイル: AbcAPI.cs プロジェクト: superowner/AlembicImporter
 public static string aiGetFullName(aiObject obj)
 {
     return(Marshal.PtrToStringAnsi(aiGetFullNameS(obj)));
 }