Commit 4d36e3b2 authored by Thomas Albrecht's avatar Thomas Albrecht

add date suffix to texture atlas file name if parameters.ATLAS_SUFFIX_DATE = True

parent 4eccd3fd
......@@ -15,7 +15,7 @@ import math
import string
from vec2d import vec2d
from textures.manager import find_matching_texture
import textures.manager as tm
import os
import re
import ac3d_fast
......@@ -716,9 +716,9 @@ def write(ac_file_name, buildings, elev, tile_elev, transform, offset):
ac = ac3d.File(stats=tools.stats)
LOD_objects = []
LOD_objects.append(ac.new_object('LOD_bare', 'tex/atlas_facades.png'))
LOD_objects.append(ac.new_object('LOD_rough', 'tex/atlas_facades.png'))
LOD_objects.append(ac.new_object('LOD_detail', 'tex/atlas_facades.png'))
LOD_objects.append(ac.new_object('LOD_bare', tm.atlas_file_name + '.png'))
LOD_objects.append(ac.new_object('LOD_rough', tm.atlas_file_name + '.png'))
LOD_objects.append(ac.new_object('LOD_detail', tm.atlas_file_name + '.png'))
global nb # FIXME: still need this?
......
......@@ -84,6 +84,7 @@ from numpy.core.numeric import True_
from shapely.geometry.multipoint import MultiPoint
from shapely.geos import TopologicalError, PredicateError
from tools import transform
import random
buildings = [] # -- master list, holds all buildings
......@@ -477,15 +478,6 @@ def write_xml(path, fname, buildings):
<effect>
<inherits-from>cityLM</inherits-from>
"""))
# <parameters>
# <lightmap-enabled type="int">1</lightmap-enabled>
# <texture n="3">
# <image>%s_LM.png</image>
# <wrap-s>repeat</wrap-s>
# <wrap-t>repeat</wrap-t>
# </texture>
# </parameters>
# """ % 'tex/atlas_facades
xml.write(" <object-name>LOD_detail</object-name>\n")
xml.write(" <object-name>LOD_rough</object-name>\n")
xml.write("</effect>\n")
......@@ -562,7 +554,7 @@ def write_xml(path, fname, buildings):
# -----------------------------------------------------------------------------
if __name__ == "__main__":
random.seed(42)
# -- Parse arguments. Command line overrides config file.
parser = argparse.ArgumentParser(description="osm2city reads OSM data and creates buildings for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
......
......@@ -75,6 +75,7 @@ ELEV_RASTER_Y = 10
#=============================================================================
CREATE_ATLAS = True # -- create texture atlas on osm2city startup
ATLAS_SUFFIX_DATE = False # -- add timestamp to file name
# -- check for overlap with static models. The scenery folder must contain an "Objects" folder
OVERLAP_CHECK = True
......
......@@ -102,6 +102,7 @@ import re
import random
import graph
import troubleshoot
import argparse
# debug stuff
import test
......@@ -1026,7 +1027,7 @@ def debug_create_eps(roads, clusters, elev, plot_cluster_borders=0):
def main():
import argparse
random.seed(42)
parser = argparse.ArgumentParser(description="bridge.py reads OSM data and creates bridge models for use with FlightGear")
parser.add_argument("-f", "--file", dest="filename",
help="read parameters from FILE (e.g. params.ini)", metavar="FILE")
......
......@@ -30,11 +30,12 @@ import atlas
from texture import Texture
import catalog
import tools
#import textures_src
import datetime
import img2np
import parameters
atlas_file_name = None
def next_pow2(value):
return 2**(int(math.log(value) / math.log(2)) + 1)
......@@ -321,14 +322,18 @@ def find_matching_texture(cls, textures):
# pitched roof: requires = facade:age:old
def init(tex_prefix='', create_atlas=False):
logging.debug("textures: init")
global facades
global roofs
global atlas_file_name
atlas_file_name = tex_prefix + 'tex/atlas_facades'
if parameters.ATLAS_SUFFIX_DATE:
now = datetime.datetime.now()
atlas_file_name += "_%04i%02i%02i" % (now.year, now.month, now.day)
filename = tex_prefix + 'tex/atlas_facades'
pkl_fname = filename + '.pkl'
pkl_fname = atlas_file_name + '.pkl'
if create_atlas:
facades = FacadeManager('facade')
......@@ -362,7 +367,7 @@ def init(tex_prefix='', create_atlas=False):
# -- make texture atlas
texture_list = facades.get_list() + roofs.get_list()
make_texture_atlas(texture_list, filename, '.png', lightmap=True, ambient_occlusion=parameters.BUILDING_FAKE_AMBIENT_OCCLUSION)
make_texture_atlas(texture_list, atlas_file_name, '.png', lightmap=True, ambient_occlusion=parameters.BUILDING_FAKE_AMBIENT_OCCLUSION)
logging.info("Saving %s", pkl_fname)
fpickle = open(pkl_fname, 'wb')
......
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