function RoomPackager.RegionsFromBasePlate(t,L)local q=t:TopCornersOfBasePlate(L)local d=q[1]local i=d.X local z=d.Z local E=d.X local H=d.Z for L,t in pairs(q)do i=math.min(i,t.X)z=math.min(z,t.Z)E=math.max(E,t.X)H=math.max(H,t.Z)end local b=q[1].Y local c=Vector3.new(i,b,z)local J=b+70 local l=Vector3.new(E,J,H)local O=math.floor(100000/(math.abs(E-i)*math.abs(H-z)))local o={}local T=b while T-b<70 do T=T+O c=Vector3.new(c.x,T-O,c.z)l=Vector3.new(l.x,T,l.z)table.insert(o,Region3.new(c,l))end return o end

function RoomPackager:RegionsFromBasePlate(basePlate)
	local topCorners = self:TopCornersOfBasePlate(basePlate)
	
	--we farm the min and max x's and z's from the top corners
	--to get x and z coordinates for the region3 that will contain the room
	--we choose an arbitrary corner so that the initial values are in the data set
	local arbitraryCorner = topCorners[1]
	local minX = arbitraryCorner.X
	local minZ = arbitraryCorner.Z
	local maxX = arbitraryCorner.X
	local maxZ = arbitraryCorner.Z
	for _, corner in pairs(topCorners) do
		minX = math.min(minX, corner.X)
		minZ = math.min(minZ, corner.Z)
		maxX = math.max(maxX, corner.X)
		maxZ = math.max(maxZ, corner.Z)
	end
	
	--construct the region using these new corners we have constructed
	--keeping in mind that all corners in topCorners *should* have the same y value
	local minY = topCorners[1].Y
	local lowerCorner = Vector3.new(minX, minY, minZ)
	local maxY = minY + 70
	local upperCorner = Vector3.new(maxX, maxY, maxZ)
	
	local segmentHeight = math.floor(100000/(math.abs(maxX-minX)*math.abs(maxZ-minZ))) 
	
	local regions = {}	
	
	local currentHeight = minY	
	while currentHeight - minY < 70 do
		currentHeight = currentHeight + segmentHeight
		lowerCorner = Vector3.new(lowerCorner.x, currentHeight - segmentHeight, lowerCorner.z)
		upperCorner = Vector3.new(upperCorner.x, currentHeight, upperCorner.z)
		table.insert(regions, Region3.new(lowerCorner, upperCorner))
	end
	
	return regions
end
