function RoomPackager.RegionsFromBasePlate(I,Q)local Z=I:TopCornersOfBasePlate(Q)local O=Z[1]local R=O.X local r=O.Z local v=O.X local f=O.Z for Q,I in pairs(Z)do R=math.min(R,I.X)r=math.min(r,I.Z)v=math.max(v,I.X)f=math.max(f,I.Z)end local t=Z[1].Y local c=Vector3.new(R,t,r)local D=t+70 local Y=Vector3.new(v,D,f)local N=math.floor(100000/(math.abs(v-R)*math.abs(f-r)))local C={}local q=t while q-t<70 do q=q+N c=Vector3.new(c.x,q-N,c.z)Y=Vector3.new(Y.x,q,Y.z)table.insert(C,Region3.new(c,Y))end return C end
--this returns a region3 that lines up on top of the baseplate to capture
--whatever room has been constructed on top of it, it is smart enough
--to capture a room that has been less-than-ideally set up
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
