Exemplo n.º 1
0
        public Model modelFind(string geoset_name, string model_name)
        {
            Model ptr_sub = null;

            if (string.IsNullOrEmpty(model_name) || string.IsNullOrEmpty(geoset_name))
            {
                Debug.LogError("Bad model/geometry set requested:");
                if (!string.IsNullOrEmpty(model_name))
                {
                    Debug.LogError("Model: " + model_name);
                }
                if (!string.IsNullOrEmpty(geoset_name))
                {
                    Debug.LogError("GeoFile: " + geoset_name);
                }
                return(null);
            }

            GeoSet geoset = GeoSet.Load(geoset_name, m_base_path);

            if (null == geoset) // failed to load the geometry set
            {
                Debug.LogErrorFormat("Geoset load failed {0},{1}", geoset_name, m_base_path);
                return(null);
            }

            int end_of_name_idx = model_name.IndexOf("__");

            if (end_of_name_idx == -1)
            {
                end_of_name_idx = model_name.Length;
            }

            string basename = model_name.Substring(0, end_of_name_idx);

            foreach (Model m in geoset.subs)
            {
                string modelname = m.name;
                if (modelname.Length == 0)
                {
                    continue;
                }

                bool subs_in_place = (modelname.Length <= end_of_name_idx ||
                                      modelname.Substring(end_of_name_idx).StartsWith("__"));
                if (subs_in_place && modelname.StartsWith(basename, StringComparison.OrdinalIgnoreCase))
                {
                    ptr_sub = m; // TODO: return immediately
                }
            }

            return(ptr_sub);
        }
Exemplo n.º 2
0
        public bool loadNamedPrefab(string name, LoadingContext ctx)
        {
            GeoStoreDef geo_store = groupGetFileEntryPtr(name);

            if (null == geo_store)
            {
                return(false);
            }
            if (geo_store.loaded)
            {
                return(true);
            }

            geo_store.loaded = true;
            // load given prefab's geoset
            GeoSet.Load(geo_store.geopath, m_base_path);
            ctx.loadSubgraph(geo_store.geopath, this);
            return(loadPrefabForNode(ctx.m_target.getNodeByName(name), ctx));
        }
Exemplo n.º 3
0
        internal bool loadPrefabForNode(SceneNode node, LoadingContext ctx) //groupLoadRequiredLibsForNode
        {
            GeoStoreDef gf;

            if (null == node || false == node.in_use)
            {
                return(false);
            }

            if (null != node.m_geoset_info)
            {
                gf = node.m_geoset_info;
            }
            else
            {
                gf = groupGetFileEntryPtr(node.m_name);
                node.m_geoset_info = gf;
                if (null == node.m_geoset_info)
                {
                    node.m_geoset_info = m_geostore_sentinel; // prevent future load attempts
                }
            }

            if (null == gf || gf == m_geostore_sentinel)
            {
                return(false);
            }

            if (!gf.loaded)
            {
                gf.loaded = true;
                GeoSet.Load(gf.geopath, m_base_path); // load given subgraph's root geoset
                ctx.loadSubgraph(gf.geopath, this);
            }

            return(true);
        }