Forums

Full Version: surfaces.txt
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
can the person who created surfaces.txt (log0) also update the list.txt files with the appropriate values. i made the mistake of moving the surfaces.txt files to the top directory for each track and now most tracks don't work because of the missing parameters. sorry for the inconvenience and i hope we sort this out soon.

--alex--
The new surfaces won't work because the surface loader has to be updated. The current one only supports 6 unique surfaces. Will fix it asap.
thanks for the fix. i guess we need to come up with a way to get rid of the surface values from list.txt. any thoughts?

--alex--
can we have the scripts used for the conversion to surfaces.txt be made available. i have a lot of tracks i need to update now and i don't really feel like doing it by hand (and i guess writing my own scripts). thanks.

--alex--
The script looks for list.txt files in root, creates surfaces.txt and updates list.txt.

Code:
import os

def locate(pattern, root=os.getcwd()):
    for path, dirs, files in os.walk(root):
        for filename in [os.path.abspath(os.path.join(path, filename)) for filename in files if filename.endswith(pattern)]:
            yield filename

root = 'E:/vdrift/vdrift-data/tracks'
pattern = 'list.txt'

for filename in locate(pattern, root):
    print filename
    objects = []
    object = []
    file = open(filename)
    line = file.readline().rstrip()
    while line != '':
        if '.joe' in line:
            if len(object): objects.append(object)
            object = []
            object.append(line)
        elif len(object) > 0 and line != '\n' and line != '' and not line.startswith('#'):
            object.append(line)
        line = file.readline()
    objects.append(object)
    file.close()
    #print 'objects: ' + str(len(objects))
    surfaces = []
    for object in objects:
        surface = [object[6], object[7], object[10], object[11], object[12], object[13]]
        i = 0
        while i < len(surfaces):
            if surface == surfaces[i]: break
            i = i + 1
        if i == len(surfaces):
            surfaces.append(surface)
        if len(object) == 14:
            object.extend(['0\n', '0\n', str(i)+'\n'])
        elif len(object) == 16:
            object.append(str(i)+'\n')
        else:
            object[16] = str(i)+'\n'
    #print 'surfaces: ' + str(len(surfaces))
    dir = os.path.dirname(filename)
    sfile = open(dir + '/surfaces.txt', 'w')
    id = 0
    for surface in surfaces:
        #print surface
        sfile.write('[surface-'+ str(id).zfill(2) + ']\n')
        #sfile.write('ID = ' + str(id) + '\n')
        sfile.write('Type = asphalt\n')
        sfile.write('BumpWaveLength = ' + str(surface[0]))
        sfile.write('BumpAmplitude = ' + str(surface[1]))
        sfile.write('FrictionNonTread = ' + str(surface[2]))
        sfile.write('FrictionTread = ' + str(surface[3]))
        sfile.write('RollResistanceCoefficient = ' + str(surface[4]))
        sfile.write('RollingDrag = ' + str(surface[5]))
        sfile.write('\n')
        id = id + 1
    sfile.close()
    #print 'write objects'
    file = open(filename, 'w')
    file.write('17\n')
    i = 0
    for object in objects:
        file.write('\n#entry ' + str(i) + '\n')
        i = i + 1
        for entry in object:
            file.write(str(entry))
    file.close()

By the way, I am currently updating the import_jpk/export_jpk scripts to support object parameters.
[Image: Unbenannto5oj0.jpg]
thanks. it definitely makes converting a lot easier.
I've hit a serious issue not sure how to deal with. For some strange reason Blender limits the length of the texture/model name to 21 characters. This means some texture/joe names will be truncated/incorrect after export, sigh.

Any suggestions are welcomed.
NaN Wrote:By the way, I am currently updating the import_jpk/export_jpk scripts to support object parameters.

That would be really cool, have you gotten anywhere with this?
It is actually ready since July 25th. I just haven't uploaded it. I would like to rewrite the scene description format completely, evaluating the options at the moment.
NaN Wrote:It is actually ready since July 25th. I just haven't uploaded it. I would like to rewrite the scene description format completely, evaluating the options at the moment.
having just used the import script i have to say that i found it extremely useful. great job. let me make a suggestion, if i may (based on the experience with hungaroring06). joe file names look something like this: bridge_ad_lights_02.dof-00.joe, bridge_ad_lights_02.dof-01.joe. when importing, it will be nice to strip the .dof-??.joe part and combine them into a single blender object. then when i export them back i would get a single dof object bridge_ad_lights_02.dof so it would be easier to see what changed (and ultimately the names of the joe object files would stay the same). hopefully i was clear enough and that this is something simple enough to implement (this would also save 10 characters for the file names which considering the blender name length limitation will also help).

thanks for the great work.

--alex--
NaN Wrote:I've hit a serious issue not sure how to deal with. For some strange reason Blender limits the length of the texture/model name to 21 characters. This means some texture/joe names will be truncated/incorrect after export, sigh.

Any suggestions are welcomed.
i suggest mapping the names to something blender will accept (take the first 18 characters and add a three digit prefix, for example. this is what i think blender does). write the mapping to a file. have the export file read the mapping file and rename the object back to its original name when saving it. i'm using blender and the import/export scripts to fix the tracks and trying to figure out the mapping between the blender names and the original names is a real pain in the ass. i don't think it would be that hard to implement (maybe not elegant, but such is life). thanks.

--alex--
Haven't made much progress towards a new track description format, sigh.

I've uploaded the most recent vdrift.py. The script will apply materials named surface-xx with distinct colors to track objects depending on their surface. To change the surface select one of the available surface-xx materials or create a new one called surface-xx(xx number of the surface).

http://svn.vdrift.net/repos/vdrift-art/trunk/tools/
hmm, this broke the import scripts:

Code:
max: 0
Traceback (most recent call last):
  File "import-jpk.py", line 25, in load_jpk
    jpk = joe_pack().load(filename)
  File "./vdrift.py", line 352, in load
    self.load_list(filename)
  File "./vdrift.py", line 479, in load_list
    delta = scale / maxid
ZeroDivisionError: integer division or modulo by zero

as for the long names. apparently you can store the long names in IDProperties and then use that on export. trying to figure out how to actually do it.

--alex--
Which track is it? The error means that the only applied track surface is surface-00 (maxid = 0). Will add a check for this case.
I've updated vdrift.py to support single surface(surface-00) tracks.
Pages: 1 2 3