示例#1
0
 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);
     }
 }
示例#2
0
        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
        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);
        }
示例#4
0
        public bool loadSceneGraph(string path, PrefabStore prefabs)
        {
            string          binName          = mapNameToPath(path);
            SceneGraph_Data serialized_graph = new SceneGraph_Data();

            m_renamer.basename = buildBaseName(path);
            binName            = binName.Replace("Chunks.bin", "CHUNKS.bin");
            if (!serialized_graph.LoadSceneData(binName))
            {
                return(false);
            }

            serialized_graph.serializeIn(this, prefabs, binName);
            return(true);
        }
示例#5
0
        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);
                }
            }
        }
示例#6
0
        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);
        }
示例#7
0
 private bool read_prefab_definitions(string directory_path)
 {
     //if(null==m_prefab_mapping)
     m_prefab_mapping = new PrefabStore(directory_path);
     return(m_prefab_mapping.prepareGeoLookupArray(directory_path));
 }