Advertisement
logancberrypie

eLF botched code

Mar 28th, 2020
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.86 KB | None | 0 0
  1. import math
  2.  
  3. class HObject:
  4.  
  5. def __init__(self, objectID, posX, posY , posZ, rotX , rotY, rotZ):
  6. self.objectID = objectID
  7. self.posX = float(posX)
  8. self.posY = float(posY)
  9. self.posZ = float(posZ)
  10. self.rotX = float(rotX)
  11. self.rotY = float(rotY)
  12. self.rotZ = float(rotZ)
  13.  
  14. def __str__(self):
  15. string = "objects_override " + str(self.objectID) + " " + str(self.posX) + " " + str(self.posY) + " " + str(self.posZ) +" " + str(self.rotX) + " " + str(self.rotY) + " " + str(self.rotZ)
  16. return string
  17.  
  18.  
  19.  
  20.  
  21.  
  22. blueprintString = """
  23. objects_override AlaskaCedar_Desktop_Young3 147.45 8.99 372.66 0.00 24.67 0.00
  24. objects_override AlaskaCedar_Desktop_Young 157.88 9.47 374.66 0.00 75.17 0.00
  25. objects_override AlaskaCedar_Desktop_Young3 157.64 9.04 365.17 0.00 178.68 0.00
  26. objects_override Blue_Spruce_Desktop 151.94 7.54 359.29 0.00 222.49 0.00
  27. """
  28.  
  29. newPoint = "object_overide base 204.28 7.04 274.37 0.00 202.67 0.00"
  30.  
  31.  
  32.  
  33. def generateBluePrint(bluePrint):
  34. Array = []
  35. for line in bluePrint.strip("\n").split("\n"):
  36. lineArray = line.split(" ")
  37. objectID = lineArray[1]
  38. posX = lineArray[2]
  39. posY = lineArray[3]
  40. posZ = lineArray[4]
  41. rotX = lineArray[5]
  42. rotY = lineArray[6]
  43. rotZ = lineArray[7]
  44. point = HObject(objectID , posX , posY,posZ,rotX,rotY,rotZ)
  45. Array.append(point)
  46. return Array
  47.  
  48. Structure = []
  49. Structure = generateBluePrint(blueprintString)
  50. newBase = generateBluePrint(newPoint)
  51. def translateBluePrint(bluePrint, newBaseA):
  52.  
  53. finalArray = []
  54.  
  55. newBase = newBaseA[0]
  56. firstPoint = bluePrint[0]
  57. translateX = newBase.posX - firstPoint.posX
  58. translateY = newBase.posY - firstPoint.posY
  59. translateZ = newBase.posZ - firstPoint.posZ
  60. rotationAngle = newBase.rotY - firstPoint.rotY
  61.  
  62. newFirstPoint= HObject(firstPoint.objectID, newBase.posX,newBase.posY,newBase.posZ,newBase.rotX,round((newBase.rotY+firstPoint.rotY) % 360,2),newBase.rotZ)
  63. finalArray.append(newFirstPoint)
  64.  
  65.  
  66. for point in bluePrint[1:]:
  67. relX = point.posX - firstPoint.posX
  68. relY = point.posY - firstPoint.posY
  69. relZ = point.posZ - firstPoint.posZ
  70. relAngle = firstPoint.rotY - point.rotY
  71.  
  72. cos = math.cos(math.radians(relAngle))
  73. sin = math.sin(math.radians(relAngle))
  74. rotatedX = relX * cos - relZ * sin
  75. rotatedZ = relX * sin + relZ * cos
  76.  
  77. finalX = round(rotatedX + newBase.posX,2)
  78. finalY = round(relY + newBase.posY,2)
  79. finalZ = round(rotatedZ + newBase.posZ,2)
  80. rotation = round((point.posY + rotationAngle) % 360,2)
  81. newPoint = HObject(point.objectID, finalX,finalY,finalZ,point.rotX,rotation,point.rotZ)
  82. finalArray.append(newPoint)
  83. for p in finalArray:
  84. print(p)
  85.  
  86. def duplicateInDirection(initialPoint,direction,objectSize,totalDistance):
  87. newPoints = []
  88.  
  89. amountToSpawn = math.ceil(totalDistance / objectSize)
  90. print(amountToSpawn)
  91. x = initialPoint.posX
  92. Z = initialPoint.posZ
  93.  
  94. cos = math.cos(math.radians(direction))
  95. sin = math.sin(math.radians(direction))
  96. directionZ = objectSize * cos
  97. directionX = objectSize * sin
  98.  
  99. for i in range(0,amountToSpawn):
  100. newX = round(x + i * directionX,2)
  101. newZ = round(Z + i * directionZ,2)
  102. newY = round(initialPoint.posY + i * 0.15,2)
  103.  
  104. temp = HObject(initialPoint.objectID,newX,newY,newZ,initialPoint.rotX,direction,initialPoint.rotZ)
  105. newPoints.append(temp)
  106. print(temp)
  107. print("Finished")
  108.  
  109. def duplicateInDirectionKeepDir(initialPoint,direction,objectSize,totalDistance):
  110.  
  111. yVariant = 0 #should make a parameter but cba
  112. newPoints = []
  113.  
  114. amountToSpawn = math.ceil(totalDistance / objectSize)
  115. print(amountToSpawn)
  116. x = initialPoint.posX
  117. Z = initialPoint.posZ
  118.  
  119. cos = math.cos(math.radians(direction))
  120. sin = math.sin(math.radians(direction))
  121. directionZ = objectSize * cos
  122. directionX = objectSize * sin
  123.  
  124. for i in range(0,amountToSpawn):
  125. newX = round(x + i * directionX,2)
  126. newZ = round(Z + i * directionZ,2)
  127. newY = round(initialPoint.posY + i * (yVariant),2)#calculates y variation per instance
  128.  
  129. temp = HObject(initialPoint.objectID,newX,newY,newZ,initialPoint.rotX,initialPoint.rotY,initialPoint.rotZ)
  130. newPoints.append(temp)
  131. print(temp)
  132. print("Finished")
  133.  
  134.  
  135. map_road = """
  136. objects_override FencingWallVines3 306.44 10.31 366.83 0.00 270 0.00
  137. """
  138. print("new")
  139. initialMap = generateBluePrint(map_road)
  140. print(initialMap[0])
  141. #duplicateInDirection(initialMap[0],90,3.5,40)
  142. duplicateInDirectionKeepDir(initialMap[0],180,3.5,40)
  143. print("new done")
  144.  
  145. #translateBluePrint(Structure,newBase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement