Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- INITIAL_POINT = (1576.0, 44.3, 613.0)
- INITIAL_ROTATION = (0.0, 0.0, 0.0)
- OFFSET_Z = 40.0
- OFFSET_X = -40.0
- TEMPLATE = """
- rem *** housingblock_1_groundfloor_v2 ***
- Object.create housingblock_1_groundfloor_v2
- Object.absolutePosition 0.0/0.0/0.0
- Object.rotation 0.0/0.0/0.0
- Object.layer 1
- rem *** housingblock_1_midfloor_v1 ***
- Object.create housingblock_1_midfloor_v1
- Object.absolutePosition 0.0/3.5/0.0
- Object.rotation 0.0/0.0/0.0
- Object.layer 1
- rem *** housingblock_1_topfloor ***
- Object.create housingblock_1_topfloor
- Object.absolutePosition 0.0/7.0/0.0
- Object.rotation 0.0/0.0/0.0
- Object.layer 1
- """
- class BF2Object(object):
- def __init__(self, name, position=(0.0, 0.0, 0.0), rotation=(0.0, 0.0, 0.0)):
- self.name = name
- self.position = position
- self.rotation = rotation
- def generate_tshape(position, rotation, num_floors):
- HEIGHT_midfloor = 3.5
- objects = []
- # ground floor
- ground_floor = BF2Object('housingblock_1_groundfloor_v2', position, rotation)
- objects.append(ground_floor)
- #print('added %s at %s at floor %d' % (ground_floor.name, ground_floor.position, 0))
- # middle floors
- for floor_num in range(1, num_floors):
- positionY = position[1] + HEIGHT_midfloor * floor_num
- position_midfloor = (position[0], positionY, position[2])
- middle_floor = BF2Object('housingblock_1_midfloor_v1', position_midfloor, rotation)
- objects.append(middle_floor)
- #print('added %s at %s at floor %d' % (middle_floor.name, middle_floor.position, floor_num))
- # top floor
- # anchor of housingblock_1_topfloor is -10.5, so its on 3rd floor height
- positionY = position[1] + HEIGHT_midfloor * num_floors
- position_topfloor = (position[0], positionY, position[2])
- topfloor = BF2Object('housingblock_1_topfloor', position_topfloor, rotation)
- objects.append(topfloor)
- #print('added %s at %s at floor %d' % (topfloor.name, topfloor.position, num_floors))
- return objects
- def createScript(bf2object):
- createScriptString = ''
- createScriptString += 'rem *** {0.name} ***\n'.format(bf2object)
- createScriptString += 'Object.create {0.name}\n'.format(bf2object)
- createScriptString += 'Object.absolutePosition {0.position[0]}/{0.position[1]}/{0.position[2]}\n'.format(bf2object)
- createScriptString += 'Object.rotation {0.rotation[0]}/{0.rotation[1]}/{0.rotation[2]}\n'.format(bf2object)
- createScriptString += 'Object.layer 1\n\n'
- return createScriptString
- def main():
- path_testing = 'D:\\Games\\Project Reality\\mods\\pr_repo\\levels\\test_airfield\\staticobjects_testing.con'
- with open(path_testing, 'w') as staticobjects:
- CITY_X = 5
- CITY_Z = 10
- NUM_FLOORS = 10
- for i in range(0, CITY_X):
- for j in range(0, CITY_Z):
- positionX = INITIAL_POINT[0] + OFFSET_X * i
- positionZ = INITIAL_POINT[2] + OFFSET_Z * j
- position = (positionX, INITIAL_POINT[1], positionZ)
- print('generating T-shape[%d][%d] of %d floors at %s' % (i, j, NUM_FLOORS, position))
- tshape = generate_tshape(position, INITIAL_ROTATION, NUM_FLOORS)
- for bf2object in tshape:
- staticobjects.write(createScript(bf2object))
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement