예제 #1
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);
        }
예제 #2
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);
                }
            }
        }
예제 #3
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);
        }