Exemplo n.º 1
0
        public static void loadlindenmeshes2(string LODfilename)
        {
            // Already have mashes loaded?
            if (lindenMeshesLoaded) return;

            attachment_points.Clear();

            string basedir = Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "character" + System.IO.Path.DirectorySeparatorChar;

            XmlDocument lad = new XmlDocument();
            lad.Load(basedir + LODfilename);

            //Firstly read the skeleton section this contains attachment point info and the bone deform info for visual params
            // And load the skeleton file in to the bones class

            XmlNodeList skeleton = lad.GetElementsByTagName("skeleton");
            string skeletonfilename = skeleton[0].Attributes.GetNamedItem("file_name").Value;
            Bone.loadbones(skeletonfilename);

            // Next read all the skeleton child nodes, we have attachment points and bone deform params
            // attachment points are an offset and rotation from a bone location
            // the name of the bone they reference is the joint paramater
            // params in the skeleton nodes are bone deforms, eg leg length changes the scale of the leg bones

            foreach (XmlNode skeletonnode in skeleton[0].ChildNodes)
            {
                if (skeletonnode.Name == "attachment_point")
                {
                    attachment_point point = new attachment_point(skeletonnode);
                    attachment_points.Add(point.id, point);
                }
            }

            // Parse all visual paramaters in one go
            // we can dedue type on the fly
            XmlNodeList paramss = lad.GetElementsByTagName("param");
            foreach (XmlNode paramNode in paramss)
            {
                VisualParamEx vp = new VisualParamEx(paramNode);
            }

            //Now we parse the mesh nodes, mesh nodes reference a particular LLM file with a LOD

            XmlNodeList meshes = lad.GetElementsByTagName("mesh");
            foreach (XmlNode meshNode in meshes)
            {
                string type = meshNode.Attributes.GetNamedItem("type").Value;
                int lod = Int32.Parse(meshNode.Attributes.GetNamedItem("lod").Value);
                string fileName = meshNode.Attributes.GetNamedItem("file_name").Value;

                GLMesh mesh = null;
                lock (_defaultmeshes)
                    mesh = (_defaultmeshes.ContainsKey(type) ? _defaultmeshes[type] : new GLMesh(type));

                // Set up the texture elemenets for each mesh
                // And hack the eyeball position
                switch (mesh.Name)
                {
                    case "lowerBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.LowerBaked;
                        break;

                    case "upperBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.UpperBaked;
                        break;

                    case "headMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "hairMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HairBaked;
                        break;

                    case "eyelashMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "eyeBallRightMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "eyeBallLeftMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "skirtMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.SkirtBaked;
                        break;

                    default:
                        mesh.teFaceID = 0;
                        break;
                }

                if (lod == 0)
                    mesh.LoadMesh(basedir + fileName);
                else
                    mesh.LoadLODMesh(lod, basedir + fileName);

                if (lod == 0)
                {
                    switch (mesh.Name)
                    {
                        case "eyeBallLeftMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeLeft"].getTotalOffset());
                            break;

                        case "eyeBallRightMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeRight"].getTotalOffset());
                            break;

                        case "eyelashMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        case "hairMesh":
                            //mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        default:
                            break;
                    }
                }

                lock (_defaultmeshes) _defaultmeshes[type] = mesh;

            }

            lindenMeshesLoaded = true;
        }
Exemplo n.º 2
0
        public static void loadlindenmeshes2(string LODfilename)
        {
            // Already have mashes loaded?
            if (lindenMeshesLoaded) return;

            attachment_points.Clear();

            //on android, Directory.GetCurrentDirectory() returns "/" which means root folder of the system. no folder or file can be added into "/"
            //I change character folder path as follow
            string basedir = Utility.GetCharacterDir();
            UnityEngine.Debug.Log("avatar_lad.xml is in " + basedir);
            XmlDocument lad = new XmlDocument();
            string path = basedir + LODfilename;

            if (!File.Exists(path))
            {
                UnityEngine.Debug.Log(path + " doesn't exist! So we quit");
                UnityEngine.Application.Quit();
            }

            if (path.Contains("://"))
            {
                UnityEngine.WWW www = new UnityEngine.WWW(path);
                while(!www.isDone)
                    ;

                lad.LoadXml(www.text);
            }
            else
                lad.Load(path);
            UnityEngine.Debug.Log("Successfully loaded avatar_lad.xml");
            //Firstly read the skeleton section this contains attachment point info and the bone deform info for visual params
            // And load the skeleton file in to the bones class

            XmlNodeList skeleton = lad.GetElementsByTagName("skeleton");
            string skeletonfilename = skeleton[0].Attributes.GetNamedItem("file_name").Value;
            Bone.loadbones(skeletonfilename);

            // Next read all the skeleton child nodes, we have attachment points and bone deform params
            // attachment points are an offset and rotation from a bone location
            // the name of the bone they reference is the joint paramater
            // params in the skeleton nodes are bone deforms, eg leg length changes the scale of the leg bones

            foreach (XmlNode skeletonnode in skeleton[0].ChildNodes)
            {
                if (skeletonnode.Name == "attachment_point")
                {
                    attachment_point point = new attachment_point(skeletonnode);
                    attachment_points.Add(point.id, point);
                }
            }

            // Parse all visual paramaters in one go
            // we can dedue type on the fly
            XmlNodeList paramss = lad.GetElementsByTagName("param");
            foreach (XmlNode paramNode in paramss)
            {
                VisualParamEx vp = new VisualParamEx(paramNode);
            }

            //Now we parse the mesh nodes, mesh nodes reference a particular LLM file with a LOD

            XmlNodeList meshes = lad.GetElementsByTagName("mesh");
            foreach (XmlNode meshNode in meshes)
            {
                string type = meshNode.Attributes.GetNamedItem("type").Value;
                int lod = Int32.Parse(meshNode.Attributes.GetNamedItem("lod").Value);
                string fileName = meshNode.Attributes.GetNamedItem("file_name").Value;

                GLMesh mesh = null;
                lock (_defaultmeshes)
                    mesh = (_defaultmeshes.ContainsKey(type) ? _defaultmeshes[type] : new GLMesh(type));

                // Set up the texture elemenets for each mesh
                // And hack the eyeball position
                switch (mesh.Name)
                {
                    case "lowerBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.LowerBaked;
                        break;

                    case "upperBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.UpperBaked;
                        break;

                    case "headMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "hairMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HairBaked;
                        break;

                    case "eyelashMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "eyeBallRightMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "eyeBallLeftMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "skirtMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.SkirtBaked;
                        break;

                    default:
                        mesh.teFaceID = 0;
                        break;
                }

                if (lod == 0)
                    mesh.LoadMesh(basedir + fileName);
                else
                    mesh.LoadLODMesh(lod, basedir + fileName);

                if (lod == 0)
                {
                    switch (mesh.Name)
                    {
                        case "eyeBallLeftMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeLeft"].getTotalOffset());
                            break;

                        case "eyeBallRightMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mEyeRight"].getTotalOffset());
                            break;

                        case "eyelashMesh":
                            lock (Bone.mBones) mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        case "hairMesh":
                            //mesh.setMeshPos(Bone.mBones["mHead"].getTotalOffset());
                            break;

                        default:
                            break;
                    }
                }

                lock (_defaultmeshes) _defaultmeshes[type] = mesh;

            }

            lindenMeshesLoaded = true;
        }
Exemplo n.º 3
0
        public static void loadlindenmeshes2(string LODfilename)
        {
            // Already have mashes loaded?
            if (lindenMeshesLoaded) return;

            attachment_points.Clear();

            string basedir = Directory.GetCurrentDirectory() + System.IO.Path.DirectorySeparatorChar + "character" + System.IO.Path.DirectorySeparatorChar;

            XmlDocument lad = new XmlDocument();
            lad.Load(basedir + LODfilename);

            //Firstly read the skeleton section this contains attachment point info and the bone deform info for visual params
            // And load the skeleton file in to the bones class

            XmlNodeList skeleton = lad.GetElementsByTagName("skeleton");
            string skeletonfilename = skeleton[0].Attributes.GetNamedItem("file_name").Value;
            Bone.loadbones(skeletonfilename);

            // Next read all the skeleton child nodes, we have attachment points and bone deform params
            // attachment points are an offset and rotation from a bone location
            // the name of the bone they reference is the joint paramater
            // params in the skeleton nodes are bone deforms, eg leg length changes the scale of the leg bones

            foreach (XmlNode skeletonnode in skeleton[0].ChildNodes)
            {
                if (skeletonnode.Name == "attachment_point")
                {
                    attachment_point point = new attachment_point(skeletonnode);
                    attachment_points.Add(point.id, point);
                }

                if (skeletonnode.Name == "param")
                {
                    //Bone deform param
                    VisualParamEx vp = new VisualParamEx(skeletonnode, VisualParamEx.ParamType.TYPE_BONEDEFORM);
                }
            }

            //Now we parse the mesh nodes, mesh nodes reference a particular LLM file with a LOD
            //and also list VisualParams for the various mesh morphs that can be applied

            XmlNodeList meshes = lad.GetElementsByTagName("mesh");
            foreach (XmlNode meshNode in meshes)
            {
                string type = meshNode.Attributes.GetNamedItem("type").Value;
                int lod = Int32.Parse(meshNode.Attributes.GetNamedItem("lod").Value);
                string fileName = meshNode.Attributes.GetNamedItem("file_name").Value;

                GLMesh mesh = (_defaultmeshes.ContainsKey(type) ? _defaultmeshes[type] : new GLMesh(type));

                if (meshNode.HasChildNodes)
                {
                    foreach (XmlNode paramnode in meshNode.ChildNodes)
                    {
                        if (paramnode.Name == "param")
                        {
                            VisualParamEx vp = new VisualParamEx(paramnode, VisualParamEx.ParamType.TYPE_MORPH);

                            mesh._evp.Add(vp.ParamID, vp); //Not sure we really need this may optimise out later
                            vp.morphmesh = mesh.Name;
                        }
                    }
                }

                // Set up the texture elemenets for each mesh
                // And hack the eyeball position
                switch (mesh.Name)
                {
                    case "lowerBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.LowerBaked;
                        break;

                    case "upperBodyMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.UpperBaked;
                        break;

                    case "headMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "hairMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HairBaked;
                        break;

                    case "eyelashMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.HeadBaked;
                        break;

                    case "eyeBallRightMesh":
                        mesh.setMeshPos(Bone.mBones["mEyeLeft"].getTotalOffset());
                        //mesh.setMeshRot(Bone.getRotation("mEyeLeft"));
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "eyeBallLeftMesh":
                        mesh.setMeshPos(Bone.mBones["mEyeRight"].getTotalOffset());
                        //mesh.setMeshRot(Bone.getRotation("mEyeRight"));
                        mesh.teFaceID = (int)AvatarTextureIndex.EyesBaked;
                        break;

                    case "skirtMesh":
                        mesh.teFaceID = (int)AvatarTextureIndex.SkirtBaked;
                        break;

                    default:
                        mesh.teFaceID = 0;
                        break;
                }

                if (lod == 0)
                    mesh.LoadMesh(basedir + fileName);
                else
                    mesh.LoadLODMesh(lod, basedir + fileName);

                _defaultmeshes[type] = mesh;

            }

            // Next are the textureing params, skipping for the moment

            XmlNodeList colors = lad.GetElementsByTagName("global_color");
            {
                foreach (XmlNode globalcolornode in colors)
                {
                    foreach (XmlNode node in globalcolornode.ChildNodes)
                    {
                        if (node.Name == "param")
                        {
                            VisualParamEx vp = new VisualParamEx(node, VisualParamEx.ParamType.TYPE_COLOR);
                        }
                    }
                }
            }

            // Get layer paramaters, a bit of a verbose way to do it but we probably want to get access
            // to some of the other data not just the <param> tag

            XmlNodeList layer_sets = lad.GetElementsByTagName("layer_set");
            {
                foreach (XmlNode layer_set in layer_sets)
                {
                    foreach (XmlNode layer in layer_set.ChildNodes)
                    {
                        foreach (XmlNode layernode in layer.ChildNodes)
                        {
                            if (layernode.Name == "param")
                            {
                                VisualParamEx vp = new VisualParamEx(layernode, VisualParamEx.ParamType.TYPE_COLOR);
                            }
                        }
                    }
                }
            }

            // Next are the driver parameters, these are parameters that change multiple real parameters

            XmlNodeList drivers = lad.GetElementsByTagName("driver_parameters");

            foreach (XmlNode node in drivers[0].ChildNodes) //lazy
            {
                if (node.Name == "param")
                {
                    VisualParamEx vp = new VisualParamEx(node, VisualParamEx.ParamType.TYPE_DRIVER);
                }
            }

            lindenMeshesLoaded = true;
        }