From: Marcus Str. Date: Tue, 24 Sep 2024 21:22:27 +0000 (+0200) Subject: Possible initial public release. After extensive testing, code amended to incorporate... X-Git-Url: https://marstr.online/code/gitweb.cgi?a=commitdiff_plain;h=509cb359bd8d1557d59fb4a7991d4b6ac95a6e05;p=orthographic Possible initial public release. After extensive testing, code amended to incorporate Laminar Research tools to build usable meshes for X-Plane, along with the correct files needed for the scenery. Normal maps also generating correctly. New class xp_scenery which performs generation of the mesh. Structure of files unified so that multiple tiles can be held in one single folder. Dependency for wand removed. --- diff --git a/layergen.py b/layergen.py index e04bbce..4337fbf 100644 --- a/layergen.py +++ b/layergen.py @@ -430,7 +430,7 @@ class mstr_layergen: # Depending on if scenery for XP should be made, AND if normal maps should be made, we would # need to make them at this exact point if mstr_xp_genscenery == True: - if mstr_xp_scn_normalmaps == True: + if mstr_xp_scn_normalmaps == True and self._is_completion == False: nm = False for n in mstr_xp_normal_maps: if n[0] == self._tag and (n[1] == self._value or n[1] == "*"): @@ -788,7 +788,7 @@ class mstr_layergen: # Depending on if scenery for XP should be made, AND if normal maps should be made, we would # need to make them at this exact point if mstr_xp_genscenery == True: - if mstr_xp_scn_normalmaps == True: + if mstr_xp_scn_normalmaps == True and self._is_completion == False: nm = False for n in mstr_xp_normal_maps: if n[0] == self._tag and (n[1] == self._value or n[1] == "*"): diff --git a/orthographic.py b/orthographic.py index 3080ca7..0b4d695 100644 --- a/orthographic.py +++ b/orthographic.py @@ -100,7 +100,7 @@ class mstr_orthographic: os.makedirs(self._output + "/z_orthographic/orthos") mstr_msg("orthographic", "Created tile orthos folder") if not os.path.exists(self._output + "/z_orthographic/orthos" + self._latlngfld): - os.makedirs(self._output + "/z_orthographic/orthos/" + self._latlngfld) + os.makedirs(self._output + "/z_orthographic/orthos/" + self._latlngfld, exist_ok=True) # Generate the database folder if not os.path.exists(self._output + "/z_orthographic/data"): @@ -267,6 +267,7 @@ class mstr_orthographic: scn.acquire_xes_data() scn.build_mesh_script() scn.build_mesh() + scn.build_ter_files() mstr_msg("orthographic", "[X-Plane] Mesh built, and scenery completed") mstr_msg("orthographic", "Final step completed.") diff --git a/xp_scenery.py b/xp_scenery.py index 269b8aa..4c6e22d 100644 --- a/xp_scenery.py +++ b/xp_scenery.py @@ -161,6 +161,7 @@ class mstr_xp_scenery: # This builds the entire mesh in one go def build_mesh(self): + mstr_msg("xp_scenery", "[X-Plane] Building DSF mesh") end_bt = self.find_earthnavdata_number() btlfn = str(self.xplane_latlng_folder(end_bt)) xp_folder = self.xplane_latlng_folder([self._lat, self._lng]) @@ -174,9 +175,30 @@ class mstr_xp_scenery: os.system(cmd) + mstr_msg("xp_scenery", "[X-Plane] Mesh construction complete") + + + # This generates all .ter files + def build_ter_files(self): + mstr_msg("xp_scenery", "[X-Plane] Generating and writing terrain (.ter) files") + cur_lat = self._lat + cur_lng = self._lng + xp_folder = self.xplane_latlng_folder([self._lat, self._lng]) + for lat in range(1, self._mlat+1): + for lng in range(1, self._mlng+1): + terstr = "" + terstr = terstr + "A\n" + terstr = terstr + "800\n" + terstr = terstr + "TERRAIN\n" + terstr = terstr + "\n" + terstr = terstr + "BASE_TEX_NOWRAP ../orthos/"+xp_folder+"/"+str(lat)+"_"+str(lng)+".dds\n" + if mstr_xp_scn_normalmaps == True: + terstr = terstr + "TEXTURE_NORMAL ../normals/"+xp_folder+"/"+str(lat)+"_"+str(lng)+".dds\n" + + terfln = mstr_datafolder + "z_orthographic/terrain/"+xp_folder+"/"+str(lat)+"_"+str(lng)+".ter" + + with open(terfln, 'w') as textfile: + textfile.write(terstr) + + mstr_msg("xp_scenery", "[X-Plane] Terrain files written") -# Individual testing -#scn = mstr_xp_scenery(51, 7, 101, 64, 0.010102, "+51+007") -#scn.acquire_xes_data() -#scn.build_mesh_script() -#scn.build_mesh() \ No newline at end of file