コード例 #1
0
ファイル: SceneGraph.cs プロジェクト: nemerle/Seccu
        public static SceneGraph loadWholeMap(string filename)
        {
            RuntimeData rd = RuntimeData.get();

            SceneGraph     m_scene_graph = new SceneGraph();
            LoadingContext ctx           = new LoadingContext(0);

            ctx.m_target = m_scene_graph;
            int geobin_idx = filename.IndexOf("geobin");
            int maps_idx   = filename.IndexOf("maps");

            ctx.m_base_path = filename.Substring(0, geobin_idx);
            Debug.Assert(rd.m_prefab_mapping != null);
            string upcase_city = filename;

            upcase_city = upcase_city.Replace("city_", "City_");
            upcase_city = upcase_city.Replace("hazard_", "Hazard_");
            upcase_city = upcase_city.Replace("/trial_", "/Trial_");
            if (upcase_city.StartsWith("trial_"))
            {
                upcase_city = "Trial_" + upcase_city.Substring(6);
            }
            upcase_city = upcase_city.Replace("zones_", "Zones_");
            rd.m_prefab_mapping.sceneGraphWasReset();
            bool res = ctx.loadSceneGraph(maps_idx == -1 ? upcase_city : upcase_city.Substring(maps_idx), rd.m_prefab_mapping);

            if (!res)
            {
                return(null);
            }

            return(m_scene_graph);
        }
コード例 #2
0
ファイル: SceneGraphNode_Data.cs プロジェクト: nemerle/Seccu
        public bool addNode(LoadingContext ctx, PrefabStore prefabs, string path)
        {
            if (this.p_Grp.Count == 0 && String.IsNullOrEmpty(this.p_Obj))
            {
                return(false);
            }

            string    obj_path = ctx.groupRename(this.name, true);
            SceneNode node     = ctx.m_target.getNodeByName(obj_path);

            if (null == node)
            {
                node           = ctx.m_target.newDef(ctx.nesting_level);
                node.m_src_bin = path;
                if (0 != this.p_Property.Count)
                {
                    node.m_properties = new List <GroupProperty_Data2>(this.p_Property);
                }
            }

            if (this.p_Obj.Length != 0)
            {
                node.m_model = prefabs.groupModelFind(this.p_Obj);
                if (null == node.m_model)
                {
                    Debug.LogError("Cannot find root geometry in " + this.p_Obj);
                }

                node.groupApplyModifiers();
            }

            node.setNodeNameAndPath(ctx.m_target, obj_path);
            node.addChildNodes(this, ctx, prefabs);

            if (node.m_children.Count == 0 && null == node.m_model)
            {
                Debug.LogFormat("Should delete def {0} after conversion it has no children, nor models", name);
                return(false);
            }

            postprocessNodeFlags(node);
            postprocessLOD(node);
            postprocessTextureReplacers(node);
            postprocessTintColor(node);
            postprocessAmbient(node);
            postprocessFog(node);
            postprocessEditorBeacon(node);
            postprocessSound(node);
            postprocessLight(node);

            node.nodeCalculateBounds();
            node.nodeSetVisBounds();
            return(true);
        }
コード例 #3
0
ファイル: SceneGraph.cs プロジェクト: nemerle/Seccu
 public void serializeIn(LoadingContext ctx, PrefabStore prefabs, string binpath)
 {
     foreach (SceneGraphNode_Data node_dat in Def)
     {
         node_dat.addNode(ctx, prefabs, binpath);
     }
     foreach (SceneRootNode_Data root_dat in Ref)
     {
         root_dat.addRoot(ctx, prefabs);
     }
 }
コード例 #4
0
ファイル: LoadingContext.cs プロジェクト: nemerle/Seccu
        public void loadSubgraph(string geopath, PrefabStore prefabs)
        {
            var            fi  = new FileInfo(geopath);
            LoadingContext tmp = new LoadingContext(nesting_level + 1);

            tmp.m_renamer    = DeepClone <NameList>(m_renamer);
            tmp.m_target     = m_target;
            tmp.last_node_id = last_node_id;
            tmp.m_base_path  = m_base_path;
            string complete_base_name = Path.GetFileNameWithoutExtension(fi.Name);

            tmp.loadSceneGraph(fi.DirectoryName + "/" + complete_base_name + ".txt", prefabs);
        }
コード例 #5
0
ファイル: PrefabStore.cs プロジェクト: nemerle/Seccu
        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));
        }
コード例 #6
0
ファイル: SceneNode.cs プロジェクト: nemerle/Seccu
        public void addChildNodes(SceneGraphNode_Data inp_data, LoadingContext ctx, PrefabStore store)
        {
            if (inp_data.p_Grp == null || inp_data.p_Grp.Count == 0)
            {
                return;
            }

            foreach (GroupLoc_Data dat in inp_data.p_Grp)
            {
                string new_name = ctx.groupRename(dat.name, false);
                SceneNodeChildTransform child = new SceneNodeChildTransform();
                child.node = ctx.m_target.getNodeByName(new_name);
                if (null == child.node)
                {
                    bool loaded = store.loadNamedPrefab(new_name, ctx);
                    if (!loaded)
                    {
                        Debug.LogError("Cannot load named prefab " + new_name + " result is " + loaded);
                    }
                    child.node = ctx.m_target.getNodeByName(new_name);
                }

                // construct from euler angles
                Quaternion qPitch  = UnityEngine.Quaternion.AngleAxis(Mathf.Rad2Deg * dat.rot.x, new Vector3(-1, 0, 0));
                Quaternion qYaw    = UnityEngine.Quaternion.AngleAxis(Mathf.Rad2Deg * dat.rot.y, new Vector3(0, 1, 0));
                Quaternion qRoll   = UnityEngine.Quaternion.AngleAxis(Mathf.Rad2Deg * dat.rot.z, new Vector3(0, 0, -1));
                Quaternion rotQuat = qYaw * qPitch * qRoll;
                child.m_matrix2 = Matrix4x4.TRS(dat.pos, rotQuat, new Vector3(1, 1, 1));
                if (null != child.node)
                {
                    m_children.Add(child);
                }
                else
                {
                    Debug.LogError("Node " + m_name + "\ncan't find member " + dat.name);
                }
            }
        }
コード例 #7
0
ファイル: PrefabStore.cs プロジェクト: nemerle/Seccu
        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);
        }
コード例 #8
0
ファイル: SceneGraph.cs プロジェクト: nemerle/Seccu
        public void addRoot(LoadingContext ctx, PrefabStore store)
        {
            string newname = ctx.groupRename(name, false);
            var    def     = ctx.m_target.getNodeByName(newname);

            if (null == def)
            {
                if (store.loadNamedPrefab(newname, ctx))
                {
                    def = ctx.m_target.getNodeByName(newname);
                }
            }

            if (null == def)
            {
                Debug.LogErrorFormat("{0}: Missing reference:{1}=>{2}", ctx.m_renamer.basename, name, newname);
                return;
            }

            var ref_entr = ctx.m_target.newRef();

            ref_entr.node = def;
            ref_entr.mat  = Tools.transformFromYPRandTranslation(rot, pos);
        }