Forums

Full Version: Steering wheel
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've used a script to add steering wheels to all cars in trunk. Position was calculated relative to driver mesh position. The steering wheel mesh/texture are from LE.

It looks OK for most of the cars. Still some of them might need adjustments. Individual steering wheel meshes would be great too.

Script:
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 = 'D:/vdrift-data/cars'
pattern = '.car'
for filename in locate(pattern, root):
    lines = []
    file = open(filename, 'r')
    line = file.readline()
    driverconf = []
    position = []
    driver = 0
    while line != '':
        if line.startswith('[driver]'):
            driverconf.append(line)
            driver = 1
        elif driver:
            driverconf.append(line)
            if line.startswith('position'):
                line = line.split('#')[0]
                namevalue = line.split('=')
                position = [float(n) for n in namevalue[1].split(',')]
                position[0] = position[0] + 0.00
                position[1] = position[1] + 0.37
                position[2] = position[2] + 0.04
            elif line.startswith('['):
                driver = 0
                steeringconf = [ \
                    '[steering]\n', \
                    'texture = steering_wheel.png\n', \
                    'mesh = steering_wheel.joe\n', \
                    'position = %.2f, %.2f, %.2f\n' % (position[0], position[1], position[2]), \
                    'rotation = 87.5, 0.0, 0.0\n', \
                    'max-angle = 320\n\n']
                steeringconf.extend(driverconf)
                lines.extend(steeringconf)
        else:
            lines.append(line)
        line = file.readline()
    
    file.close()
    file = open(filename, 'w')
    for line in lines:
        file.write(line)
    file.close()