Exemple #1
0
        private void OpenModel(string filename)
        {
            FileName = filename;
            ProgramState.State.CurrentFilename = filename;
            GameModel.Model result;
            string          modeldata = System.IO.File.ReadAllText(filename);

            modelcode.Text = modeldata;
            ModelGeometryCompiler.ModelBaseDir = System.IO.Path.GetDirectoryName(filename);
            ModelGeometryCompiler compiler = new ModelGeometryCompiler(modeldata);

            result = compiler.ReturnOutput();
            result.RebuildSkeleton();
            //result.ApplyAnimation("Walk");
            ProgramState.State.CurrentModel = result;
            string choreofilename = ModelGeometryCompiler.ModelBaseDir + "\\" + result.ChoreoName + ".mcf";

            p.choreocode.Text = System.IO.File.ReadAllText(choreofilename);
            p.FileName        = choreofilename;
            p.movements.Items.Clear();
            p.movements.Items.Add("<none>");
            foreach (KeyValuePair <string, Dictionary <string, PartAnimation> > movement in result.Choreo)
            {
                p.movements.Items.Add(movement.Key);
            }
            p.movements.SelectedIndex = 0;
            Changes = false;
            CompileAndRun();
        }
Exemple #2
0
        public void CompileAndRun()
        {
            ModelGeometryCompiler compiler = new ModelGeometryCompiler(modelcode.Text);

            GameModel.Model result = compiler.ReturnOutput();
            GameModel.Model.TexturePool = new Dictionary <string, Texture2D>();
            if (compiler.Textures != null && compiler.Textures.Count > 0)
            {
                foreach (string texname in compiler.Textures)
                {
                    string path = ModelGeometryCompiler.ModelBaseDir + "\\textures\\" + texname + ".png";
                    if (!System.IO.File.Exists(path))
                    {
                        continue;
                    }
                    Texture2D            tex;
                    System.IO.FileStream s = new System.IO.FileStream(path, System.IO.FileMode.Open);
                    tex = Texture2D.FromStream(device, s);
                    s.Close();
                    GameModel.Model.TexturePool.Add(texname, tex);
                }
            }
            result.RebuildSkeleton();
            // result.ApplyAnimation("Walk");
            ProgramState.State.CurrentModel = result;
        }