public void ConstructPieces() { Random r = new Random(); GroundPieces = new TestGroundPiece[NPieces.Height, NPieces.Width]; float xstep = Size.Width / NPieces.Width; float ystep = Size.Height / NPieces.Height; for (int y = 0; y < NPieces.Height; y++) { for (int x = 0; x < NPieces.Width; x++) { var piece = new TestGroundPiece { Translation = new Vector3(xstep * x, ystep * y, 0), Ground = this, HeightmapSelection = new RectangleF( x / (float)NPieces.Width, y / (float)NPieces.Height, 1 / (float)NPieces.Width, 1 / (float)NPieces.Height), Size = new Vector2(xstep, ystep), Color = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)) }; piece.EnsureConstructed(); var xMesh = ((MetaModel)piece.MainGraphic).XMesh; piece.MotionObject = new Common.Motion.Static { LocalBounding = new Common.Bounding.Chain { Shallow = true, Boundings = new object[] { new MetaBoundingBox { Mesh = xMesh }, new BoundingMetaMesh { Mesh = xMesh, Transformation = Matrix.Identity } } }, Position = piece.Translation, }; Scene.Add(GroundPieces[y, x] = piece); } } }
public void ConstructPieces() { Random r = new Random(); GroundPieces = new TestGroundPiece[NPieces.Height, NPieces.Width]; float xstep = Size.Width / NPieces.Width; float ystep = Size.Height / NPieces.Height; for (int y = 0; y < NPieces.Height; y++) for (int x = 0; x < NPieces.Width; x++) { var piece = new TestGroundPiece { Translation = new Vector3(xstep * x, ystep * y, 0), Ground = this, HeightmapSelection = new RectangleF( x / (float)NPieces.Width, y / (float)NPieces.Height, 1 / (float)NPieces.Width, 1 / (float)NPieces.Height), Size = new Vector2(xstep, ystep), Color = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)) }; piece.EnsureConstructed(); var xMesh = ((MetaModel)piece.MainGraphic).XMesh; piece.MotionObject = new Common.Motion.Static { LocalBounding = new Common.Bounding.Chain { Shallow = true, Boundings = new object[] { new MetaBoundingBox { Mesh = xMesh }, new BoundingMetaMesh { Mesh = xMesh, Transformation = Matrix.Identity } } }, Position = piece.Translation, }; Scene.Add(GroundPieces[y, x] = piece); } }