Commit 1dacc725 authored by Rick Gruber-Riemer's avatar Rick Gruber-Riemer

New parameter FLAG_2017_2 for using new light effects only available in FG2017.2

parent b85f914b
......@@ -225,15 +225,15 @@ if __name__ == '__main__':
# At the very end copy static data stuff in one process
if exec_procedure is Procedures.all:
copy_data_stuff.process(False, "Buildings")
copy_data_stuff.process(False, "Roads")
copy_data_stuff.process(False, "Pylons")
copy_data_stuff.process("Buildings")
copy_data_stuff.process("Roads")
copy_data_stuff.process("Pylons")
elif exec_procedure is Procedures.pylons:
copy_data_stuff.process(False, "Pylons")
copy_data_stuff.process("Pylons")
elif exec_procedure is Procedures.roads:
copy_data_stuff.process(False, "Roads")
copy_data_stuff.process("Roads")
else:
copy_data_stuff.process(False, "Buildings")
copy_data_stuff.process("Buildings")
logging.info("Total time used {}".format(time.time() - start_time))
......
......@@ -8,12 +8,60 @@ import logging
import os
import shutil
import sys
import textwrap
import parameters
import utils.utilities as util
def process(copy_fg_data: bool, scenery_type: str) -> None:
def _write_roads_eff(path_to_dir: str) -> None:
eff = open(path_to_dir + 'roads.eff', 'w')
eff.write(textwrap.dedent("""<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>roadsLM</name>
<inherits-from>Effects/road</inherits-from>
<parameters>
<!-- Light Map -->
<lightmap-enabled type="int">1</lightmap-enabled>
<lightmap-multi type="int">0</lightmap-multi>
<lightmap-color type="vec3d" n="0"> 0.941 0.682 0.086 </lightmap-color>
<texture n="3">
<image>tex/roads_LM.png</image>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
</texture>
</parameters>
</PropertyList>
"""))
def _write_citylm_eff(path_to_dir: str) -> None:
eff = open(path_to_dir + 'cityLM.eff', 'w')
eff.write(textwrap.dedent("""<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
<name>cityLM</name>
<inherits-from>/Effects/model-combined-deferred</inherits-from>
<parameters>
<!-- Light Map -->
<lightmap-enabled type="int">1</lightmap-enabled>
<lightmap-multi type="int">1</lightmap-multi>
<texture n="3">
<image>tex/atlas_facades_LM.png</image>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
</texture>
<lightmap-factor type="float" n="0"><use>/environment/lightmap-factor</use></lightmap-factor>
<lightmap-color type="vec3d" n="0"> 1. 0.88 0.6 </lightmap-color>
<lightmap-factor type="float" n="1"><use>/environment/lightmap-factor</use></lightmap-factor>
<lightmap-color type="vec3d" n="1"> 0.564 0.409 0.172 </lightmap-color>
<lightmap-factor type="float" n="2">0</lightmap-factor>
<lightmap-factor type="float" n="3">0</lightmap-factor>
</parameters>
</PropertyList>
"""))
def process(scenery_type: str) -> None:
scenery_path = parameters.get_output_path()
scenery_path += os.sep + scenery_type
......@@ -45,18 +93,25 @@ def process(copy_fg_data: bool, scenery_type: str) -> None:
logging.info("Copying texture stuff to sub-directory %s", tex_dir)
for content in content_list:
shutil.copy(source_dir + os.sep + content, tex_dir)
# light-map effects
source_dir = data_dir + "lightmap"
if not os.path.exists(source_dir):
logging.error("The original lightmap dir seems to be missing: %s", source_dir)
sys.exit(1)
for level_two_dir in level_two_dirs:
logging.info("Copying lightmap stuff directory %s", level_two_dir)
content_list = os.listdir(source_dir)
for content in content_list:
shutil.copy(source_dir + os.sep + content, level_two_dir)
if parameters.FLAG_2017_2:
for level_two_dir in level_two_dirs:
if scenery_type == 'Roads':
_write_roads_eff(level_two_dir + os.sep)
elif scenery_type == 'Buildings':
_write_citylm_eff(level_two_dir + os.sep)
else:
# light-map effects
source_dir = data_dir + "lightmap"
if not os.path.exists(source_dir):
logging.error("The original lightmap dir seems to be missing: %s", source_dir)
sys.exit(1)
for level_two_dir in level_two_dirs:
logging.info("Copying lightmap stuff directory %s", level_two_dir)
content_list = os.listdir(source_dir)
for content in content_list:
shutil.copy(source_dir + os.sep + content, level_two_dir)
if copy_fg_data:
if parameters.TRAFFIC_SHADER_ENABLE and not parameters.FLAG_2017_2:
fg_root_dir = util.get_fg_root()
logging.info("Copying fgdata directory into $FG_ROOT (%s)", fg_root_dir)
source_dir = data_dir + "fgdata"
......@@ -76,10 +131,8 @@ if __name__ == "__main__":
parser.add_argument("-t", "--type", dest="scenery_type",
help="Mandatory: Scenery type - typically 'Buildings', 'Roads', 'Pylons'",
metavar="STRING", required=True)
parser.add_argument("-a", action="store_true",
help="also copy effects etc. in fgdata to $FG_ROOT", required=False)
args = parser.parse_args()
parameters.read_from_file(args.filename)
process(args.a, args.scenery_type)
process(args.scenery_type)
......@@ -32,7 +32,6 @@ If you are using ``buildings.py`` to generate buildings or ``roads.py`` to gener
/usr/bin/python3 /home/pingu/development/osm2city/copy_data_stuff.py -f LSZS/params.ini -t Buildings
If ``copy_data_stuff.py`` is called with the optional ``-a`` argument, then also the effects and shaders in directory ``fgdata`` in ``osm2city-data`` are copied to ``$FG_ROOT``. This is necessary if you set parameter ``TRAFFIC_SHADER_ENABLE`` to ``True`` (see chapter :ref:`Light Effects <chapter-parameters-light>`).
The mandatory ``-t`` argument is used to write the data to a specific Terrasync folder.
......
......@@ -82,6 +82,8 @@ USE_EXTERNAL_MODELS = False
WRITE_CLUSTER_STATS = False
FLAG_2017_2 = False # Feature flag for 2017.2 version of FG
# =============================================================================
# PARAMETERS RELATED TO BUILDINGS IN osm2city
# =============================================================================
......
......@@ -1119,21 +1119,15 @@ def _process_clusters(clusters, replacement_prefix, fg_elev: utilities.FGElev, s
def _write_xml(path_to_stg, file_name, object_name):
xml = open(path_to_stg + file_name + '.xml', "w")
if parameters.TRAFFIC_SHADER_ENABLE:
shader_str = "<inherits-from>Effects/road-high</inherits-from>"
if parameters.TRAFFIC_SHADER_ENABLE and not parameters.FLAG_2017_2:
shader_str = "Effects/road-high"
else:
shader_str = "<inherits-from>roads</inherits-from>"
shader_str = "roads"
xml.write(textwrap.dedent(""" <?xml version="1.0"?>
<PropertyList>
<path>%s.ac</path>
<effect>
<!--
EITHER enable the traffic shader
<inherits-from>Effects/road-high</inherits-from>
OR the lightmap shader
<inherits-from>roads</inherits-from>
-->
%s
<inherits-from>%s</inherits-from>
<object-name>%s</object-name>
</effect>
</PropertyList>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment