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); }
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); }
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); } }
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); } }
public virtual void usdiOnUnload() { usdiSync(); m_schema = default(usdi.Xform); }
public abstract void CreateUSDObject(usdi.Context ctx, usdi.Schema parent);
public UsdSchema usdiFindSchema(usdi.Schema s) { return(usdiFindSchema(usdi.usdiPrimGetPathS(s))); }
public RootCapturer(UsdExporter exporter, usdi.Schema usd) : base(exporter, null) { m_usd = usd; }
public void usdiOnLoad(UsdMesh parent, int nth) { m_schema = parent.nativeSchemaPtr; m_nth = nth; }