# Create a water mask we need to remove from the DDS later\r
if (self._tag == "natural" and self._value == "water") or (self._tag == "water" and self._value == "lake") or (self._tag == "water" and self._value == "pond") or (self._tag == "water" and self._value == "river") or (self._tag == "leisure" and self._value == "swimming_pool"):\r
mstr_msg("layergen", "Generating inland water mask")\r
- inl_mask = Image.new("RGBA", (self._imgsize, self._imgsize), (0,0,0,0))\r
+ water_file = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(self._lat_number) + "_" + str(self._lng_number) + "_water.png"\r
+ inl_mask = None\r
+ if os.path.isfile(water_file):\r
+ inl_mask = Image.open(water_file)\r
+ else:\r
+ inl_mask = Image.new("RGBA", (self._imgsize, self._imgsize), (255,255,255,255))\r
lyr_pix = layer_comp.load()\r
inl_pix = inl_mask.load()\r
for y in range(self._imgsize):\r
for x in range(self._imgsize):\r
l = lyr_pix[x,y]\r
- if l[3] > 65:\r
- b = 255 - l[3]\r
- inl_pix[x,y] = (255,0,255,255)\r
+ if l[3] > 50:\r
+ clr = 255-l[3]\r
+ c = (clr,clr,clr,255)\r
+ inl_pix[x,y] = c\r
+ inl_mask.save(water_file)\r
+ #if l[3] > 65:\r
+ # b = 255 - l[3]\r
+ # inl_pix[x,y] = (255,0,255,255)\r
#inl_mask.save(mstr_datafolder + "_cache/" + str(self._latitude) + "-" + str(self._lat_number) + "_" + str(self._longitude) + "-" + str(self._lng_number) + "_" + self._tag + "-" + self._value + "_layer_mask.png")\r
- layer_comp = inl_mask\r
+ #layer_comp = inl_mask\r
mstr_msg("layergen", "Inland water mask generated and saved")\r
\r
# Return the completed image\r
cnt_x = cur_lat + (self._vstep/2)
cnt_y = cur_lng + (mstr_zl_18/2)
+ ddsf_water = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png"
+
terstr = ""
terstr = terstr + "A\r\n"
terstr = terstr + "800\r\n"
if mstr_xp_scn_normalmaps == True:
terstr = terstr + "NORMAL_TEX 1.0 ../../normals/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".png\r\n"
+ if os.path.isfile(ddsf_water) == True:
+ terstr = terstr + "BORDER_TEX ../../orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png\r\n"
+
terfln = mstr_datafolder + "z_orthographic/terrain/" + self._latlngfld + "/" + str(lat)+"_"+str(lng)+".ter"
with open(terfln, 'w') as textfile:
dsf_str = dsf_str + "PROPERTY sim/east " + str((int(self._lng) + 1)) + "\r\n"
dsf_str = dsf_str + "PROPERTY sim/south " + str(int(self._lat)) + "\r\n"
dsf_str = dsf_str + "PROPERTY sim/north " + str((int(self._lat) + 1)) + "\r\n"
- dsf_str = dsf_str + "PROPERTY sim/require_object 6/0\r\n"
+ dsf_str = dsf_str + "PROPERTY sim/require_object 0/6\r\n"
dsf_str = dsf_str + "PROPERTY planet earth\r\n"
dsf_str = dsf_str + "PROPERTY sim/creation_agent Orthographic\r\n"
#dsf_str = dsf_str + "TERRAIN_DEF terrain_Water\r\n"
for lng in range(1, self._mlng+1):
# Write the line only if an ortho exists of course.
ddsf = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + ".dds"
+ ddsf_water = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png"
if os.path.isfile(ddsf) == True:
dsfstr = "TERRAIN_DEF terrain/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + ".ter\r\n"
# Let's check if this tile needs water beneath
- needs_water = False
- thistile = Image.open(ddsf)
- tile_pix = thistile.load()
- for y in range(thistile.height):
- for x in range(thistile.width):
- clr = tile_pix[x,y]
- if clr[3] == 0:
- needs_water = True
- break
-
- if needs_water == True:
+ if os.path.isfile(ddsf_water) == True:
dsfstr = dsfstr + "TERRAIN_DEF terrain_Water\r\n"
with open(meshtxt, 'a') as textfile:
#ddsf = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/1_1.dds"
ddsf = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + ".dds"
+ ddsf_water = mstr_datafolder + "z_orthographic/orthos/" + self._latlngfld + "/" + str(lat) + "_" + str(lng) + "_water.png"
if os.path.isfile(ddsf) == True:
scangrid = self.find_height_scan_start_end_points([ self._lat+((lat-1)*self._vstep), self._lng+((lng-1)*mstr_zl_18) ])
# Let's check if this tile needs water beneath
needs_water = False
- thistile = Image.open(ddsf)
- tile_pix = thistile.load()
- for y in range(thistile.height):
- for x in range(thistile.width):
- clr = tile_pix[x,y]
- if clr[3] == 0:
- needs_water = True
- break
+ if os.path.isfile(ddsf_water) == True: needs_water = True
if needs_water == True: