예제 #1
0
        ModelVertex ReadPoint(LineSplitter ls)
        {
            ModelVertex v = new ModelVertex();
            //read format X Y Z Colour U V W
            float X, Y, Z, U, V, W;

            Microsoft.Xna.Framework.Color c = new Microsoft.Xna.Framework.Color();
            string[] rgb;

            X   = ls.NextFloat();
            Y   = ls.NextFloat();
            Z   = ls.NextFloat();
            rgb = ls.Next().Split(':');
            c   = new Microsoft.Xna.Framework.Color(int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2]));
            //c.A = 127;
            U = ls.NextFloat();
            V = ls.NextFloat();
            W = 1f;
            if (!ls.EOL)
            {
                W = ls.NextFloat();
            }
            W                  += 0;
            v.Position          = new Microsoft.Xna.Framework.Vector3(X, Y, Z);
            v.Color             = c;
            v.TextureCoordinate = new Microsoft.Xna.Framework.Vector2(U, V);
            v.BoneWeightData.X  = W;
            return(v);
        }
예제 #2
0
        public static Dictionary <string, Dictionary <string, PartAnimation> > LoadChoreo(string input)
        {
            Dictionary <string, Dictionary <string, PartAnimation> > result = new Dictionary <string, Dictionary <string, PartAnimation> >();

            string[] filelines = SplitLines(input);
            int      pointer   = 0;
            Dictionary <string, PartAnimation> CurrentMove = new Dictionary <string, PartAnimation>();
            string        CurrentMoveName = "";
            string        CurrentPartName = "";
            PartAnimation CurrentPart     = new PartAnimation();
            LineSplitter  ls;

            while (pointer < filelines.Length)
            {
                ls = new LineSplitter(filelines[pointer]);
                string cmd = ls.Next();
                switch (cmd)
                {
                case "#beginmove":
                {
                    CurrentMove     = new Dictionary <string, PartAnimation>();
                    CurrentMoveName = ls.NextQuoted();
                    break;
                }

                case "#endmove":
                {
                    if (result.ContainsKey(CurrentMoveName))
                    {
                        break;
                    }
                    result.Add(CurrentMoveName, CurrentMove);
                    break;
                }

                case "#beginpart":
                {
                    CurrentPart     = new PartAnimation();
                    CurrentPartName = ls.NextQuoted();
                    break;
                }

                case "#endpart":
                {
                    if (CurrentMove.ContainsKey(CurrentPartName))
                    {
                        break;
                    }
                    CurrentMove.Add(CurrentPartName, CurrentPart);
                    break;
                }

                case "#beginchoreo":
                {
                    break;
                }

                case "#endchoreo":
                {
                    break;
                }

                case "#moveparam":
                {
                    break;
                }

                default:
                {
                    ls.Reset();
                    float  duration  = ls.NextFloat();
                    Matrix transform = ls.NextTransform();
                    CurrentPart.Add(transform, duration);
                    break;
                }
                }

                pointer++;
            }

            return(result);
        }
예제 #3
0
        public ModelGeometryCompiler(string input)
        {
            this.lines = SplitLines(input);

            LineSplitter ls = new LineSplitter(lines[state.LineNumber]);
            Dictionary <string, ModelPart> parts = new Dictionary <string, ModelPart>();
            List <ModelPart> p          = new List <ModelPart>();
            string           choreoname = "";
            Vector3          offset     = Vector3.Zero;
            string           command    = ls.Next();

            while (command != "#endmodel")
            {
                switch (command)
                {
                case "#beginpart":
                {
                    state.LineNumber++;
                    parts.Add(ls.NextQuoted(), ReadPart());
                    break;
                }

                case "#beginassembly":
                {
                    AssembleModel(parts);
                    break;
                }

                case "#beginsymbols":
                {
                    state.LineNumber++;
                    BuildSymbolTable();
                    break;
                }

                case "#choreo":
                {
                    choreoname = ls.NextQuoted();

                    break;
                }

                case "#offset":
                {
                    float X, Y, Z;
                    X      = ls.NextFloat();
                    Y      = ls.NextFloat();
                    Z      = ls.NextFloat();
                    offset = new Vector3(X, Y, Z);
                    break;
                }

                default:
                {
                    //throw error here or something
                    break;
                }
                }
                state.LineNumber++;
                ls      = new LineSplitter(lines[state.LineNumber]);
                command = ls.Next();
            }
            string choreofname = ModelBaseDir + "\\" + choreoname + ".mcf";

            //create a dummy if doesn't exist. Dumb workaround but works for now
            if (!System.IO.File.Exists(choreofname))
            {
                System.IO.FileStream s = System.IO.File.Create(choreofname);
                s.Close();
            }
            Output.Choreo     = LoadChoreo(System.IO.File.ReadAllText(choreofname));
            Output.ChoreoName = choreoname;
            Output.Offset     = offset;
            ls = null;
        }