예제 #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();
        }
예제 #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;
        }
예제 #3
0
        public override GameModel.Model GetModel()
        {
            Color PrimaryColour   = this.PrimaryMaterial == null ? Color.Gray : this.PrimaryMaterial.Colour;
            Color SecondaryColour = this.SecondaryMaterial == null ? PrimaryColour : this.SecondaryMaterial.Colour;
            Color GlowColour      = this.Enchant == null ? PrimaryColour : this.Enchant.LineColour;
            Dictionary <string, string> matcolor = new Dictionary <string, string>
            {
                { "$handle", GameModel.ModelGeometryCompiler.ColourToCode(SecondaryColour) },
                { "$blade", GameModel.ModelGeometryCompiler.ColourToCode(PrimaryColour) },
                { "$enchant", GameModel.ModelGeometryCompiler.ColourToCode(GlowColour) }
            };
            string modelname = "sword1"; //will get edited to select specific model

            return(ModelGeometryCompiler.LoadModel(modelname, matcolor));
            // return base.GetModel();
        }