Discordant

3dmodels

Mar 19th, 2015
224
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import mouse, Image, os, subprocess, math, imgpie, threading, time, win32gui, win32con
  2. import HLMVModel, Stitch, uploadFile, scriptconstants
  3. from SendKeys import SendKeys
  4. from screenshot import screenshot
  5. from threadpool import threadpool
  6. from win32api import GetKeyState
  7. try:
  8. import psyco
  9. psyco.full()
  10. except:
  11. pass
  12.  
  13. paintDict = scriptconstants.paintDict
  14. BLUPaintDict = scriptconstants.BLUPaintDict
  15. paintHexDict = scriptconstants.paintHexDict
  16.  
  17. degreesToRadiansFactor = math.pi / 180.0
  18. outputImagesDir = r'output' # The directory where the output images will be saved.
  19. SDKLauncherStartingPoint = (20, 20) # Rough x, y screen coordindates of SDK Launcher. This is near the top left of the screen by default.
  20. monitorResolution = [1366, 768] # The monitor resolution of the user in the form of a list; [pixel width, pixel height].
  21. imgCropBoundaries = (3, 43, 1363, 280) # The cropping boundaries, as a pixel distance from the top left corner, for the images as a tuple; (left boundary, top boundary, right boundary, bottom boundary).
  22. fileButtonCoordindates = (14, 32) # The coordinates for the File menu button in HLMV
  23. threadedBlending = True # Use threading for blending computations
  24. sleepFactor = 1.0 # Sleep time factor that affects how long the script waits for HLMV to load/models to load etc
  25.  
  26. def openHLMV(pathToHlmv):
  27. subprocess.Popen([pathToHlmv + os.sep + 'hlmv.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  28.  
  29. def closeHLMV():
  30. subprocess.Popen(['taskkill', '/f', '/t' ,'/im', 'hlmv.exe'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  31.  
  32. def prepareHLMV():
  33. window_list = []
  34. def enum_callback(hwnd, results):
  35. window_list.append((hwnd, win32gui.GetWindowText(hwnd)))
  36.  
  37. win32gui.EnumWindows(enum_callback, [])
  38.  
  39. handle_id = None
  40. for hwnd, title in window_list:
  41. if 'half-life model viewer' in title.lower():
  42. handle_id = hwnd
  43. break
  44. win32gui.SetForegroundWindow(handle_id)
  45. win32gui.ShowWindow(handle_id, win32con.SW_MAXIMIZE)
  46.  
  47. def sleep(sleeptime):
  48. time.sleep(sleeptime*sleepFactor)
  49.  
  50. def paintHat(colour, VMTFile):
  51. vmt = open(VMTFile, 'rb').read()
  52. pattern = '"\$color2"\s+"\{(.[^\}]+)\}"'
  53. regex = re.compile(pattern, re.IGNORECASE)
  54. if regex.search(vmt):
  55. if colour == 'Stock':
  56. pattern2 = '(\s*)"\$colortint_base"\s+"\{(.[^\}]+)\}"'
  57. regex = re.compile(pattern2, re.IGNORECASE)
  58. result = regex.search(vmt)
  59. vmt = re.sub(pattern, '"$color2" "{' + result.group(2) + '}"', vmt)
  60. else:
  61. vmt = re.sub(pattern, '"$color2" "{' + colour + '}"', vmt)
  62. else:
  63. pattern = '(\s*)"\$colortint_base"\s+"\{(.[^\}]+)\}"'
  64. regex = re.compile(pattern, re.IGNORECASE)
  65. result = regex.search(vmt)
  66. if colour == 'Stock':
  67. vmt = re.sub(pattern, result.group(1) + '"$colortint_base" "{' + result.group(2) + '}"\n' + result.group(1).replace('\r\n','') + '"$color2" "{' + result.group(2) + '}"', vmt)
  68. else:
  69. vmt = re.sub(pattern, result.group(1) + '"$colortint_base" "{' + result.group(2) + '}"\n' + result.group(1).replace('\r\n','') + '"$color2" "{' + colour + '}"', vmt)
  70. f = open(VMTFile, 'wb')
  71. f.write(vmt)
  72. f.close()
  73.  
  74. def getBrightness(p):
  75. return (299.0 * p[0] + 587.0 * p[1] + 114.0 * p[2]) / 1000.0
  76.  
  77. def toAlphaBlackWhite(blackImg, whiteImg):
  78. size = blackImg.size
  79. blackImg = blackImg.convert('RGBA')
  80. loadedBlack = blackImg.load()
  81. loadedWhite = whiteImg.load()
  82. for x in range(size[0]):
  83. for y in range(size[1]):
  84. blackPixel = loadedBlack[x, y]
  85. whitePixel = loadedWhite[x, y]
  86. loadedBlack[x, y] = (
  87. (blackPixel[0] + whitePixel[0]) / 2,
  88. (blackPixel[1] + whitePixel[1]) / 2,
  89. (blackPixel[2] + whitePixel[2]) / 2,
  90. int(255.0 - 255.0 * (getBrightness(whitePixel) - getBrightness(blackPixel)))
  91. )
  92. return blackImg
  93.  
  94. def rotateAboutNewCentre(currentXPosition, currentYPosition, currentZPosition, rotationOffset, yangle, xangle):
  95. """ Method to position a model in HLMV with a new center of rotation.
  96.  
  97. Parameters:
  98. currentXPosition -> The current x position of the model.
  99. currentYPosition -> The current y position of the model.
  100. currentZPosition -> The current z position of the model.
  101. rotationOffset -> The distance from the default centre of rotation to the new one (in HLMV units).
  102. yangle -> The angle the model has been rotated by around the y axis.
  103. xangle -> The angle the model has been rotated by around the x axis.
  104. """
  105. yangle = float(yangle)
  106. xangle = float(xangle)
  107. rotationOffset = float(rotationOffset)
  108. if yangle < 0.0:
  109. yangle = 360.0 - abs(yangle) # Funky HLMV coordinate system
  110. newX = (math.cos(yangle * degreesToRadiansFactor) * rotationOffset) + float(currentXPosition)
  111. newY = (math.sin(yangle * degreesToRadiansFactor) * rotationOffset) + float(currentYPosition)
  112. newZ = float(currentZPosition) - (math.sin(xangle * degreesToRadiansFactor) * rotationOffset)
  113. return [newX, newY, newZ]
  114.  
  115. def offsetVertically(currentXPosition, currentYPosition, currentZPosition, verticalOffset, yangle, xangle):
  116. yangle = float(yangle)
  117. verticalOffset = float(verticalOffset)
  118. if yangle < 0.0:
  119. yangle = 360.0 - abs(yangle) # Funky HLMV coordinate system
  120. newX = ((math.sin(xangle * degreesToRadiansFactor)) * (math.sin(yangle * degreesToRadiansFactor)) * verticalOffset) + float(currentXPosition)
  121. newY = ((math.sin(yangle * degreesToRadiansFactor)) * (math.sin(xangle * degreesToRadiansFactor)) * verticalOffset) + float(currentYPosition)
  122. newZ = currentZPosition
  123. return [newX, newY, newZ]
  124.  
  125. class BlendingThread(threading.Thread):
  126. def __init__(self, xrotation, n, blackImages, whiteImages, saveDir, painted, teamColours):
  127. self.xrotation = xrotation
  128. self.n = n
  129. self.blackImages = blackImages
  130. self.whiteImages = whiteImages
  131. self.saveDir = saveDir
  132. self.painted = painted
  133. self.teamColours = teamColours
  134. self.started = False
  135. def join(self):
  136. if self.started:
  137. threading.Thread.join(self)
  138. def go(self, threaded=True):
  139. if threaded:
  140. self.started = True
  141. self.start()
  142. else:
  143. self.run()
  144. def start(self):
  145. threading.Thread.__init__(self)
  146. threading.Thread.start(self)
  147. def run(self):
  148. if self.painted:
  149. for colour in self.whiteImages:
  150. print 'Processing ' + colour
  151. if self.xrotation == -15:
  152. imgname = str(self.n) + '_1_' + paintHexDict[colour] + '.png'
  153. elif self.xrotation == 15:
  154. imgname = str(self.n) + '_-1_' + paintHexDict[colour] + '.png'
  155. else:
  156. imgname = str(self.n) + '_0_' + paintHexDict[colour] + '.png'
  157. black = imgpie.wrap(self.blackImages[colour])
  158. white = imgpie.wrap(self.whiteImages[colour])
  159. blended = black.blackWhiteBlend(white)
  160. blended.save(self.saveDir + os.sep + imgname)
  161. else:
  162. if self.teamColours:
  163. img = toAlphaBlackWhite(self.blackImages['RED'], self.whiteImages['RED'])
  164. img2 = toAlphaBlackWhite(self.blackImages['BLU'], self.whiteImages['BLU'])
  165. if self.xrotation == -15:
  166. imgname = str(self.n) + '_1_RED.png'
  167. imgname2 = str(self.n) + '_1_BLU.png'
  168. elif self.xrotation == 15:
  169. imgname = str(self.n) + '_-1_RED.png'
  170. imgname2 = str(self.n) + '_-1_BLU.png'
  171. else:
  172. imgname = str(self.n) + '_0_RED.png'
  173. imgname2 = str(self.n) + '_0_BLU.png'
  174. img.save(self.saveDir + os.sep + imgname, "PNG")
  175. img2.save(self.saveDir + os.sep + imgname2, "PNG")
  176. else:
  177. img = toAlphaBlackWhite(self.blackImages, self.whiteImages)
  178. if self.xrotation == -15:
  179. imgname = str(self.n) + '_1.png'
  180. elif self.xrotation == 15:
  181. imgname = str(self.n) + '_-1.png'
  182. else:
  183. imgname = str(self.n) + '_0.png'
  184. img.save(self.saveDir + os.sep + imgname, "PNG")
  185.  
  186. blendThread = None
  187. def blendingMachine(*args, **kwargs):
  188. """
  189. Dis is blending masheen.
  190. Poot things it, they get passed to BlendingThread.
  191. Whether they actually run threaded or not is up to the "threadedBlending" variable up there.
  192. It handles the join'ing of old threads, if it runs threaded in the first place.
  193. Make sure to call blendingMachine() without arguments when the thing is done, to ensure that threads (if any) terminate.
  194. """
  195. global blendThread, threadedBlending
  196. if blendThread is not None:
  197. blendThread.join()
  198. if len(args) or len(kwargs):
  199. blendThread = BlendingThread(*args, **kwargs)
  200. blendThread.go(threaded=threadedBlending)
  201.  
  202. def automateDis(model,
  203. numberOfImages=24,
  204. n=0,
  205. rotationOffset=0,
  206. initialRotation=0,
  207. initialTranslation=(44.628479, 0.000000, 1.150419),
  208. verticalOffset=0,
  209. verticalRotations=1,
  210. screenshotPause=False,
  211. paint=False,
  212. teamColours=False,
  213. pathToHlmv='C://Program Files (x86)//Steam//SteamApps//common//Team Fortress 2//bin//',
  214. itemName='User DrOcsid MutatedMilk',
  215. REDVMTFiles=None,
  216. BLUVMTFiles=None,
  217. wikiUsername=None,
  218. wikiPassword=None):
  219. """ Method to automize process of taking images for 3D model views.
  220.  
  221. Parameters:
  222. model -> An instance of a HLMVModelRegistryKey object for the model. Required.
  223. numberOfImages -> Number of images to take for one full rotation. Optional, default is 24.
  224. n -> Which nth step of rotation to start at. Optional, default is 0.
  225. rotationOffset -> The distance from the default centre of rotation to the new one (in HLMV units). Optional, default is none.
  226. initialRotation -> The initial model rotation as a tuple. Optional, default is (0 0 0).
  227. initialTranslation -> The initial model translation as a tuple. Optional, default is (0 0 0).
  228. verticalOffset -> The vertical offset for models that are centered in both other planes but not vertically. Optional, default is none.
  229. verticalRotations -> Int number where 1 = up/down rotations and 0 = no vertical rotations. Default is 1.
  230. screenshotPause -> Pause on every screenshot to pose model. Press number lock key to move on once finished posing. Default is False.
  231. paint -> Boolean to indicate whether model is paintable. Optional, default is False.
  232. teamColours -> Boolean to indicate whether model is team coloured. Optional, default is False.
  233. pathToHlmv -> Path to hlmv.exe. Usually in common\Team Fortress 2\bin
  234. itemName -> The name of the item. Optional, default is blank.
  235. REDVMTFiles -> The RED vmt file locations. Optional, default is none.
  236. BLUVMTFiles -> The BLU vmt file locations. Optional, default is none.
  237. wikiUsername -> wiki.tf2.com username. Optional, default is none.
  238. wikiPassword -> wiki.tf2.com password. Optional, default is none.
  239. """
  240.  
  241. folder = raw_input('Folder name for created images: ')
  242. outputFolder = outputImagesDir + os.sep + folder
  243. try:
  244. os.makedirs(outputFolder)
  245. except:
  246. answer = raw_input('Folder already exists, overwrite files? y\\n? ')
  247. if answer.lower() in ['no', 'n']:
  248. sys.exit(1)
  249.  
  250. if initialTranslation is None:
  251. initialTranslation = [model.returnTranslation()['x'], model.returnTranslation()['y'], model.returnTranslation()['z']]
  252. if initialRotation is None:
  253. initialRotation = [model.returnRotation()['x'], model.returnRotation()['y'], model.returnRotation()['z']]
  254.  
  255. # Time for user to cancel script start
  256. time.sleep(3)
  257.  
  258. try:
  259. closeHLMV()
  260. sleep(2.0)
  261. except:
  262. pass
  263. print 'initialTranslation =', initialTranslation
  264. print 'initialRotation =', initialRotation
  265.  
  266. model.setTranslation(x = initialTranslation[0], y = initialTranslation[1], z = initialTranslation[2])
  267. model.setNormalMapping(True)
  268. model.setBGColour(255, 255, 255, 255)
  269. for yrotation in range((-180 + (360/numberOfImages * n)), 180, 360/numberOfImages):
  270. print 'n =', str(n)
  271. for xrotation in range(-15, 30, 15):
  272. if (verticalRotations == 0 and xrotation == 0) or verticalRotations == 1:
  273. # Set rotation
  274. sleep(0.5)
  275. model.setRotation(x = xrotation + float(initialRotation[0]), y = yrotation + float(initialRotation[1]), z = initialRotation[2])
  276. print 'xRot = {0}, yRot = {1}'.format(xrotation, yrotation)
  277. if rotationOffset is not None:
  278. # Set translation to account for off centre rotation
  279. result = rotateAboutNewCentre(initialTranslation[0], initialTranslation[1], initialTranslation[2], rotationOffset, yrotation, xrotation)
  280. print 'translation =', result
  281. model.setTranslation(x = result[0], y = result[1], z = result[2])
  282. # Set translation to account for off centre horizontal rotation
  283. elif verticalOffset is not None:
  284. result = offsetVertically(initialTranslation[0], initialTranslation[1], initialTranslation[2], verticalOffset, yrotation, xrotation)
  285. print 'translation =', result
  286. model.setTranslation(x = result[0], y = result[1], z = result[2])
  287. # Open HLMV
  288. openHLMV(pathToHlmv)
  289. sleep(2)
  290. # Focus and maximise HLMV
  291. prepareHLMV()
  292. # Open recent model
  293. mouse.click(x=fileButtonCoordindates[0],y=fileButtonCoordindates[1])
  294. SendKeys(r'{DOWN 10}{RIGHT}{ENTER}')
  295. sleep(1)
  296. # If user wants to pose model before taking screenshot, make script wait
  297. if screenshotPause:
  298. numKeyState = GetKeyState(win32con.VK_NUMLOCK)
  299. while GetKeyState(win32con.VK_NUMLOCK) == numKeyState:
  300. pass
  301. # Item painting method
  302. def paintcycle(dict, whiteBackgroundImages, blackBackgroundImages):
  303. # Take whiteBG screenshots and crop
  304. for colour in dict:
  305. paintHat(dict[colour], REDVMTFiles)
  306. SendKeys(r'{F5}')
  307. sleep(1.0)
  308. imgWhiteBG = screenshot()
  309. imgWhiteBG = imgWhiteBG.crop(imgCropBoundaries)
  310. whiteBackgroundImages[colour] = imgWhiteBG
  311. # Change BG colour to black
  312. SendKeys(r'^b')
  313. # Take blackBG screenshots and crop
  314. for colour in dict:
  315. paintHat(dict[colour], REDVMTFiles)
  316. SendKeys(r'{F5}')
  317. sleep(1.0)
  318. imgBlackBG = screenshot()
  319. imgBlackBG = imgBlackBG.crop(imgCropBoundaries)
  320. blackBackgroundImages[colour] = imgBlackBG
  321. SendKeys(r'^b')
  322. SendKeys(r'{F5}')
  323. return whiteBackgroundImages, blackBackgroundImages
  324. if paint:
  325. whiteBackgroundImages = {}
  326. blackBackgroundImages = {}
  327. whiteBackgroundImages, blackBackgroundImages = paintcycle(paintDict, whiteBackgroundImages, blackBackgroundImages)
  328. if teamColours:
  329. # Change RED hat to BLU
  330. redFiles = []
  331. bluFiles = []
  332. for fileName in REDVMTFiles:
  333. redFiles.append(open(fileName, 'rb').read())
  334. for fileName in BLUVMTFiles:
  335. bluFiles.append(open(fileName, 'rb').read())
  336. for file, fileName in zip(bluFiles, redFileNames):
  337. with open(fileName, 'wb') as f:
  338. f.write(file)
  339. whiteBackgroundImages, blackBackgroundImages = paintcycle(BLUPaintDict, whiteBackgroundImages, blackBackgroundImages)
  340. for file, fileName in zip(bluFiles, redFileNames):
  341. with open(fileName, 'wb') as f:
  342. f.write(file)
  343. else:
  344. whiteBackgroundImages, blackBackgroundImages = paintcycle(BLUPaintDict, whiteBackgroundImages, blackBackgroundImages)
  345. else:
  346. if teamColours:
  347. # Take whiteBG screenshot and crop
  348. imgWhiteBGRED = screenshot()
  349. imgWhiteBGRED = imgWhiteBGRED.crop(imgCropBoundaries)
  350. # Change BG colour to black
  351. SendKeys(r'^b')
  352. # Take blackBG screenshot and crop
  353. imgBlackBGRED = screenshot()
  354. imgBlackBGRED = imgBlackBGRED.crop(imgCropBoundaries)
  355. # Change BG colour to white
  356. SendKeys(r'^b')
  357. # Change weapon colour to BLU
  358. redFiles = []
  359. bluFiles = []
  360. for fileName in REDVMTFiles:
  361. redFiles.append(open(fileName, 'rb').read())
  362. for fileName in BLUVMTFiles:
  363. bluFiles.append(open(fileName, 'rb').read())
  364. for file, fileName in zip(bluFiles, redFileNames):
  365. with open(fileName, 'wb') as f:
  366. f.write(file)
  367. SendKeys(r'{F5}')
  368. sleep(1.0)
  369. # Take whiteBG screenshot and crop
  370. imgWhiteBGBLU = screenshot()
  371. imgWhiteBGBLU = imgWhiteBGBLU.crop(imgCropBoundaries)
  372. # Change BG colour to black
  373. SendKeys(r'^b')
  374. # Take blackBG screenshot and crop
  375. imgBlackBGBLU = screenshot()
  376. imgBlackBGBLU = imgBlackBGBLU.crop(imgCropBoundaries)
  377. # Return VMT back to RED
  378. for file, fileName in zip(bluFiles, redFileNames):
  379. with open(fileName, 'wb') as f:
  380. f.write(file)
  381. else:
  382. # Take whiteBG screenshot and crop
  383. imgWhiteBG = screenshot()
  384. imgWhiteBG = imgWhiteBG.crop(imgCropBoundaries)
  385. # Change BG colour to black
  386. SendKeys(r'^b')
  387. # Take blackBG screenshot and crop
  388. imgBlackBG = screenshot()
  389. imgBlackBG = imgBlackBG.crop(imgCropBoundaries)
  390. # Remove background from images
  391. if paint:
  392. blendingMachine(xrotation, n, blackBackgroundImages, whiteBackgroundImages, outputFolder, True, True)
  393. else:
  394. if teamColours:
  395. blendingMachine(xrotation, n, {'RED':imgBlackBGRED,'BLU':imgBlackBGBLU}, {'RED':imgWhiteBGRED,'BLU':imgWhiteBGBLU}, outputFolder, False, True)
  396. else:
  397. blendingMachine(xrotation, n, imgBlackBG, imgWhiteBG, outputFolder, False, False)
  398. # Close HLMV
  399. closeHLMV()
  400. # Check for kill switch
  401. killKeyState = GetKeyState(win32con.VK_CAPITAL)
  402. if killKeyState in [1, -127]:
  403. print 'Successfully terminated'
  404. sys.exit(0)
  405. n += 1
  406. blendingMachine() # Wait for threads to finish, if any
  407. # Stitch images together
  408. print 'Stitching images together...'
  409. stitchPool = threadpool(numThreads=2, defaultTarget=Stitch.stitch)
  410. if paint:
  411. for colour in paintHexDict:
  412. if colour == 'Stock':
  413. if teamColours:
  414. finalImageName = itemName + ' RED 3D.jpg'
  415. else:
  416. finalImageName = itemName + ' 3D.jpg'
  417. elif colour == 'Stock (BLU)':
  418. if teamColours:
  419. finalImageName = itemName + ' BLU 3D.jpg'
  420. else:
  421. finalImageName = '{0} {1} 3D.jpg'.format(itemName, paintHexDict[colour])
  422. ##### Need to thread this #####
  423. if colour != 'Stock (BLU)' or teamColours:
  424. stitchPool(outputFolder, paintHexDict[colour], finalImageName, numberOfImages, verticalRotations)
  425. else:
  426. if teamColours:
  427. finalREDImageName = itemName + ' RED 3D.jpg'
  428. finalBLUImageName = itemName + ' BLU 3D.jpg'
  429. stitchPool(outputFolder, 'RED', finalREDImageName, numberOfImages, verticalRotations)
  430. stitchPool(outputFolder, 'BLU', finalBLUImageName, numberOfImages, verticalRotations)
  431. else:
  432. finalImageName = itemName + ' 3D.jpg'
  433. stitchPool(outputFolder, None, finalImageName, numberOfImages, verticalRotations)
  434. stitchPool.shutdown()
  435. # Upload images to wiki
  436. if paint:
  437. for colour in paintHexDict:
  438. if colour == 'Stock':
  439. if teamColours:
  440. fileName = itemName + ' RED 3D.jpg'
  441. else:
  442. fileName = itemName + ' 3D.jpg'
  443. elif colour == 'Stock (BLU)':
  444. if teamColours:
  445. fileName = itemName + ' BLU 3D.jpg'
  446. else:
  447. fileName = '{0} {1} 3D.jpg'.format(itemName, paintHexDict[colour])
  448. url = uploadFile.fileURL(fileName)
  449. description = open(outputFolder + os.sep + fileName + ' offsetmap.txt', 'rb').read()
  450. description = description.replace('url = <nowiki></nowiki>', 'url = <nowiki>' + url + '</nowiki>')
  451. if colour != 'Stock (BLU)' or teamColours:
  452. uploadFile.uploadFile(outputFolder + os.sep + fileName, fileName, description, wikiUsername, wikiPassword, category='', overwrite=False)
  453. else:
  454. if teamColours:
  455. finalREDImageName = itemName + ' RED 3D.jpg'
  456. finalBLUImageName = itemName + ' BLU 3D.jpg'
  457. url = uploadFile.fileURL(finalREDImageName)
  458. url2 = uploadFile.fileURL(finalBLUImageName)
  459. description = open(outputFolder + os.sep + finalREDImageName + ' offsetmap.txt', 'rb').read()
  460. description = description.replace('url = <nowiki></nowiki>','url = <nowiki>' + url + '</nowiki>')
  461. description2 = open(outputFolder + os.sep + finalBLUImageName + ' offsetmap.txt', 'rb').read()
  462. description2 = description2.replace('url = <nowiki></nowiki>','url = <nowiki>' + url2 + '</nowiki>')
  463. uploadFile.uploadFile(outputFolder + os.sep + finalREDImageName, finalREDImageName, description, wikiUsername, wikiPassword, category='', overwrite=False)
  464. uploadFile.uploadFile(outputFolder + os.sep + finalBLUImageName, finalBLUImageName, description2, wikiUsername, wikiPassword, category='', overwrite=False)
  465. else:
  466. finalImageName = itemName + ' 3D.jpg'
  467. url = uploadFile.fileURL(finalImageName)
  468. description = open(outputFolder + os.sep + finalImageName + ' offsetmap.txt', 'rb').read()
  469. description = description.replace('url = <nowiki></nowiki>','url = <nowiki>' + url + '</nowiki>')
  470. uploadFile.uploadFile(outputFolder + os.sep + finalImageName, finalImageName, description, wikiUsername, wikiPassword, category='', overwrite=False)
  471. # All done yay
  472. print '\nAll done'
  473.  
  474. if __name__ == '__main__':
  475. # Poot values here
  476. starttime = int(round(time.time()))
  477.  
  478. # Example usage
  479. model = HLMVModel.HLMVModelRegistryKey('models.weapons.c_models.c_breadmonster.c_breadmonster_milk.mdl')
  480. automateDis(model = model,
  481. numberOfImages = 24,
  482. n = 0,
  483. rotationOffset = None,
  484. verticalOffset = None,
  485. verticalRotations = 1,
  486. screenshotPause = False,
  487. initialRotation = (0.000000, 0.000000, 0.000000),
  488. initialTranslation = (40.320000, 0.000000, 0.000000),
  489. paint = True,
  490. teamColours = True,
  491. pathToHlmv = 'C://Program Files (x86)//Steam//SteamApps//common//Team Fortress 2//bin//',
  492. itemName = 'User DrOcsid MutatedMilk',
  493. )
  494.  
  495. print 'completed in ' + str(int(round(time.time())) - starttime) + 'seconds'
RAW Paste Data