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); }
ModelPart ReadPart() { ModelPart result = new ModelPart(); LineSplitter ls = new LineSplitter(lines[state.LineNumber]); List <ModelVertex> vertices = new List <ModelVertex>(); while (ls.Next() != "#endpart") { ls.Reset(); switch (ls.Next()) { case "#beginpoints": { state.LineNumber++; result.SetVertices(this.ReadPoints()); break; } case "#beginmesh": { state.LineNumber++; result.SetIndices(this.ReadMesh()); break; } case "#texture": //TODO: set part's tex { result.TextureName = ls.NextQuoted(); if (!Textures.Contains(result.TextureName)) { Textures.Add(result.TextureName); } break; } case "#billboard": //TODO: turn into PartLight, set tex and bb type { result = ReadBB(ls); break; } default: //throw an error or something lol { break; } } state.LineNumber++; ls = new LineSplitter(lines[state.LineNumber]); } return(result); }