Beispiel #1
0
        public Model()
        {
            this.Children = new List <ModelPart>();
            ModelPart Root = new ModelPart();

            ModelVertex[] vertices = new ModelVertex[8];
            vertices[0] = new ModelVertex(new Vector3(-1.5f, 0.5f, -0.5f), Color.DarkGray);
            vertices[1] = new ModelVertex(new Vector3(0.5f, 0.2f, 0.2f), Color.DarkGray);
            vertices[2] = new ModelVertex(new Vector3(-1.5f, 0.5f, 0.5f), Color.DarkGray);
            vertices[3] = new ModelVertex(new Vector3(0.5f, 0.2f, -0.2f), Color.DarkGray);

            vertices[4] = new ModelVertex(new Vector3(-1.5f, -0.5f, -0.5f), Color.DarkGray);
            vertices[5] = new ModelVertex(new Vector3(0.5f, -0.2f, 0.2f), Color.DarkGray);
            vertices[6] = new ModelVertex(new Vector3(-1.5f, -0.5f, 0.5f), Color.DarkGray);
            vertices[7] = new ModelVertex(new Vector3(0.5f, -0.2f, -0.2f), Color.DarkGray);
            Root.SetVertices(vertices);
            Root.SetIndices(new int[] { //--,++,-+/--,+-,++
                0, 1, 2, 0, 3, 1
                , 4, 6, 5, 4, 5, 7
                , 4, 2, 6, 4, 0, 2
                , 7, 5, 1, 7, 1, 3
                , 6, 2, 1, 6, 1, 5
                , 4, 3, 0, 4, 7, 3
            });

            ModelPart leg;
            ModelPart eye;

            leg            = new TestParts.PartBugLeg();
            eye            = new TestParts.PartLight(Color.Blue);
            eye.BoneFactor = 0.33f;

            leg.Append(eye, Matrix.CreateTranslation(new Vector3(0.2f, 0.8f, 0.0f)));
            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 0.3f) * Matrix.CreateTranslation(new Vector3(0.4f, 0, -0.5f)));
            leg = new TestParts.PartBugLeg();
            leg.Animation.SetPhase(0.5f);
            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 0.5f) * Matrix.CreateTranslation(new Vector3(0, 0, -0.5f)));
            leg = new TestParts.PartBugLeg();
            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 0.8f) * Matrix.CreateTranslation(new Vector3(-0.4f, 0, -0.5f)));

            leg = new TestParts.PartBugLeg(true);
            leg.Animation.SetPhase(0.5f);
            eye            = new TestParts.PartLight(Color.Blue);
            eye.BoneFactor = 0.33f;
            leg.Append(eye, Matrix.CreateTranslation(new Vector3(0.2f, 0.8f, 0.0f)));

            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 1.8f) * Matrix.CreateTranslation(new Vector3(0.4f, 0, 0.5f)));
            leg = new TestParts.PartBugLeg(true);
            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 1.5f) * Matrix.CreateTranslation(new Vector3(0, 0, 0.5f)));
            leg = new TestParts.PartBugLeg(true);
            leg.Animation.SetPhase(0.5f);
            Root.Append(leg, Matrix.CreateRotationY((float)Math.PI * 1.3f) * Matrix.CreateTranslation(new Vector3(-0.4f, 0, 0.5f)));

            this.Children.Add(Root);
        }
Beispiel #2
0
        ModelPart ReadBB(LineSplitter ls)
        {
            ModelPart result = new ModelPart();

            string type = ls.Next();
            int    H    = ls.NextInt();
            int    W    = ls.NextInt();
            Color  c;

            string[] rgb;
            rgb = ls.Next().Split(':');
            c   = new Microsoft.Xna.Framework.Color(int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2]));
            TestParts.PartLight p = new TestParts.PartLight(c);
            p.Width  = W;
            p.Height = H;
            result   = p;

            return(result);
        }