Ejemplo n.º 1
0
        void usdiCreateNodeRecursive(Transform parent, usdi.Schema schema, Action <usdiElement, usdi.Schema> node_handler)
        {
            if (!schema)
            {
                return;
            }

            var elem = usdiCreateNode(parent, schema);

            if (elem != null)
            {
                elem.stream = this;
                elem.usdiOnLoad(schema);
                node_handler(elem, schema);
            }

            var trans        = elem == null ? parent : elem.GetComponent <Transform>();
            int num_children = usdi.usdiGetNumChildren(schema);

            for (int ci = 0; ci < num_children; ++ci)
            {
                var child = usdi.usdiGetChild(schema, ci);
                usdiCreateNodeRecursive(trans, child, node_handler);
            }
        }
Ejemplo n.º 2
0
        UsdSchema usdiFindOrCreateNode(Transform parent, usdi.Schema schema, ref bool created)
        {
            GameObject go = null;

            // find existing GameObject or create new one
            var name  = usdi.usdiPrimGetNameS(schema);
            var child = parent.FindChild(name);

            if (child != null)
            {
                go      = child.gameObject;
                created = false;
            }
            else if (go == null)
            {
                go      = new GameObject();
                go.name = name;
                go.GetComponent <Transform>().SetParent(parent, false);
                created = true;
            }

            // create USD node
            UsdSchema ret = usdiCreateNode(schema);

            ret.gameObject = go;

            return(ret);
        }
Ejemplo n.º 3
0
        static usdiElement usdiCreateNode(Transform parent, usdi.Schema schema)
        {
            {
                var name  = usdi.S(usdi.usdiGetName(schema));
                var child = parent.FindChild(name);
                if (child != null)
                {
                    return(child.GetComponent <usdiElement>());
                }
            }

            GameObject  go   = null;
            usdiElement elem = null;

            if (go == null)
            {
                var points = usdi.usdiAsPoints(schema);
                if (points)
                {
                    go   = new GameObject();
                    elem = go.AddComponent <usdiPoints>();
                }
            }
            if (go == null)
            {
                var mesh = usdi.usdiAsMesh(schema);
                if (mesh)
                {
                    go   = new GameObject();
                    elem = go.AddComponent <usdiMesh>();
                }
            }
            if (go == null)
            {
                var cam = usdi.usdiAsCamera(schema);
                if (cam)
                {
                    go   = new GameObject();
                    elem = go.AddComponent <usdiCamera>();
                }
            }
            if (go == null)
            {
                var xf = usdi.usdiAsXform(schema);
                if (xf)
                {
                    go   = new GameObject();
                    elem = go.AddComponent <usdiXform>();
                }
            }

            if (go != null)
            {
                go.GetComponent <Transform>().SetParent(parent);
                go.name = usdi.S(usdi.usdiGetName(schema));
            }

            return(elem);
        }
Ejemplo n.º 4
0
        public override void usdiOnLoad(usdi.Schema schema)
        {
            base.usdiOnLoad(schema);

            m_camera = usdi.usdiAsCamera(schema);
            if (!m_camera)
            {
                Debug.LogWarning("schema is not Xform!");
            }

            m_ucam = GetOrAddComponent <Camera>();
        }
Ejemplo n.º 5
0
        public override void usdiOnLoad(usdi.Schema schema)
        {
            base.usdiOnLoad(schema);

            m_points = usdi.usdiAsPoints(schema);
            if (!m_points)
            {
                Debug.LogWarning("schema is not Points!");
                return;
            }
            usdi.usdiPointsGetSummary(m_points, ref m_summary);
            m_attrRot = usdi.usdiFindAttribute(m_points, "rotations");
        }
Ejemplo n.º 6
0
        UsdSchema usdiCreateNode(usdi.Schema schema)
        {
            UsdSchema ret = null;

            if (ret == null)
            {
                var s = usdi.usdiAsPoints(schema);
                if (s)
                {
                    ret = new UsdPoints();
                }
            }
            if (ret == null)
            {
                var s = usdi.usdiAsMesh(schema);
                if (s)
                {
                    ret = new UsdMesh();
                }
            }
            if (ret == null)
            {
                var s = usdi.usdiAsCamera(schema);
                if (s)
                {
                    ret = new UsdCamera();
                }
            }
            if (ret == null)
            {
                // Xform must be latter because some schemas are subclass of Xform
                var s = usdi.usdiAsXform(schema);
                if (s)
                {
                    ret = new UsdXform();
                }
            }
            if (ret == null)
            {
                ret = new UsdSchema();
            }
            ret.nativeSchemaPtr = schema;
            ret.stream          = this;
            return(ret);
        }
Ejemplo n.º 7
0
        void usdiConstructMasterTree(usdi.Schema schema, Action <UsdSchema> node_handler)
        {
            if (!schema)
            {
                return;
            }

            var elem = usdiCreateNode(schema);

            node_handler(elem);

            int num_children = usdi.usdiPrimGetNumChildren(schema);

            for (int ci = 0; ci < num_children; ++ci)
            {
                var child = usdi.usdiPrimGetChild(schema, ci);
                usdiConstructMasterTree(child, node_handler);
            }
        }
Ejemplo n.º 8
0
        public override void usdiOnLoad(usdi.Schema schema)
        {
            base.usdiOnLoad(schema);

            m_mesh = usdi.usdiAsMesh(schema);
            if (!m_mesh)
            {
                Debug.LogWarning("schema is not Mesh!");
                return;
            }

            usdi.usdiMeshGetSummary(m_mesh, ref m_meshSummary);
            m_umesh           = usdiGetOrAddMeshComponents();
            m_meshVertexCount = m_umesh.vertexCount;

            m_renderer = GetComponent <MeshRenderer>();

            usdiGatherExistingSplits();
            for (int i = 0; i < m_children.Count; ++i)
            {
                m_children[i].usdiOnLoad(this, m_children.Count);
            }
        }
Ejemplo n.º 9
0
        void usdiConstructTree(Transform parent, usdi.Schema schema, Action <UsdSchema> node_handler)
        {
            if (!schema)
            {
                return;
            }

            bool created = false;
            var  elem    = usdiFindOrCreateNode(parent, schema, ref created);

            if (elem != null)
            {
                node_handler(elem);
            }

            var trans        = elem == null ? parent : elem.GetComponent <Transform>();
            int num_children = usdi.usdiPrimGetNumChildren(schema);

            for (int ci = 0; ci < num_children; ++ci)
            {
                var child = usdi.usdiPrimGetChild(schema, ci);
                usdiConstructTree(trans, child, node_handler);
            }
        }
Ejemplo n.º 10
0
 public UsdSchema usdiFindSchema(usdi.Schema s)
 {
     return(usdiFindSchema(usdi.usdiPrimGetPathS(s)));
 }
 public abstract void CreateUSDObject(usdi.Context ctx, usdi.Schema parent);
Ejemplo n.º 12
0
 public override void usdiOnLoad(usdi.Schema schema)
 {
     base.usdiOnLoad(schema);
     m_xf    = usdi.usdiAsXform(schema);
     m_trans = GetComponent <Transform>();
 }
Ejemplo n.º 13
0
 public RootCapturer(usdiExporter exporter, usdi.Schema usd)
     : base(exporter, null)
 {
     m_usd = usd;
 }
Ejemplo n.º 14
0
 public virtual void usdiOnLoad(usdi.Schema schema)
 {
     m_schema = schema;
 }
Ejemplo n.º 15
0
 public virtual void usdiOnUnload()
 {
     usdiSync();
     m_schema = default(usdi.Xform);
 }
Ejemplo n.º 16
0
 public void usdiOnLoad(UsdMesh parent, int nth)
 {
     m_schema = parent.nativeSchemaPtr;
     m_nth    = nth;
 }
Ejemplo n.º 17
0
 public void usdiOnLoad(usdiMesh parent, int nth)
 {
     m_stream = parent.stream;
     m_schema = parent.nativeSchemaPtr;
     m_nth    = nth;
 }