Exemplo n.º 1
0
 public static void Save(string file, ImportInfo ii)
 {
     using (FileStream fs = File.OpenWrite(file))
     {
         fs.SetLength(0);
         new XmlSerializer(Type).Serialize(fs, ii);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 指定device上で開きます。
        /// </summary>
        /// <param name="device">device</param>
        /// <param name="effect">effect</param>
        public void Open(Device device, Effect effect)
        {
            this.device = device;
            this.effect = effect;

            ImportInfo info = ImportInfo.Load(Path.ChangeExtension(this.file, ".xml"));

            string dir = Path.GetDirectoryName(this.file);

            foreach (ImportTextureInfo tex_info in info.textures)
            {
                MqoTexture tex = new MqoTexture();
                tex.Name = tex_info.Name;
                string tex_path = Path.Combine(dir, tex_info.File);
                tex.Load(tex_path);
                tex.Open(device);

                textures.Add(tex);
            }

            texmap = new Dictionary <string, MqoTexture>();
            foreach (MqoTexture tex in textures)
            {
                texmap[tex.name] = tex;
            }

            foreach (MqoMaterial mtl in Materials)
            {
                string sub_script_path = Path.Combine(dir, mtl.name);
                mtl.Load(sub_script_path);
                mtl.GenerateShader();
            }

            handle_ShadeTex_texture = effect.GetParameter(null, "ShadeTex_texture");
            handle_ColorTex_texture = effect.GetParameter(null, "ColorTex_texture");

            handle_LightDir       = effect.GetParameter(null, "LightDir");
            handle_LightDirForced = effect.GetParameter(null, "LightDirForced");
            handle_UVSCR          = effect.GetParameter(null, "UVSCR");

            techmap = new Dictionary <string, EffectHandle>();

            int ntech = effect.Description.Techniques;

            techniques = new EffectHandle[ntech];

            //Console.WriteLine("Techniques:");

            for (int i = 0; i < ntech; i++)
            {
                techniques[i] = effect.GetTechnique(i);
                string tech_name = effect.GetTechniqueDescription(techniques[i]).Name;
                techmap[tech_name] = techniques[i];

                //Console.WriteLine(i + " " + tech_name);
            }

            foreach (MqoObject obj in Objects)
            {
                obj.WriteBuffer(device);
            }
        }