public Face(Vector3 normal, Vector3 center) { this.normal = normal; this.center = center; blocks = new List<Block>(); Block b = new Block(); Vector3 xDir = Vector3.UnitX; if(Vector3.Cross(xDir, normal).Equals(Vector3.Zero)) xDir = Vector3.UnitZ; Vector3 yDir = Vector3.Cross(normal, xDir); yDir.Normalize(); xDir.Normalize(); b.edges.Add(new Edge(center,center+xDir*2)); b.edges.Add(new Edge(center+xDir*2,center+xDir*2+yDir*2)); b.edges.Add(new Edge(center+xDir*2+yDir*2,center+yDir*2)); b.edges.Add(new Edge(center + yDir * 2, center)); b.Init(); blocks.Add(b); doodads = new List<Doodad>(); monsters = new List<Monster>(); }
public void AddBlock(Vector3 position) { Block b = new Block(); Vector3 xDir = Vector3.UnitX; if (Vector3.Cross(xDir, normal).Equals(Vector3.Zero)) xDir = Vector3.UnitZ; Vector3 yDir = Vector3.Cross(normal, xDir); yDir.Normalize(); xDir.Normalize(); xDir = 2f * xDir; yDir = 2f * yDir; b.edges.Add(new Edge(position, position + xDir)); b.edges.Add(new Edge(position + xDir, position + xDir + yDir)); b.edges.Add(new Edge(position + xDir + yDir, position + yDir)); b.edges.Add(new Edge(position + yDir, position)); bool blockOK = IsBlockValid(b); if (blockOK) { b.Init(); blocks.Add(b); } }