Advertisement
logancberrypie

holdfast

Apr 18th, 2020
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 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 419.59 14.69 230.80 0.00 308.54 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.  
  52.  
  53. def translateBluePrint(bluePrint, newBaseA):
  54.  
  55. finalArray = []
  56.  
  57. newBase = newBaseA[0]
  58. firstPoint = bluePrint[0]
  59. translateX = newBase.posX - firstPoint.posX
  60. translateY = newBase.posY - firstPoint.posY
  61. translateZ = newBase.posZ - firstPoint.posZ
  62. rotationAngle = newBase.rotY - firstPoint.rotY
  63.  
  64. newFirstPoint= HObject(firstPoint.objectID, newBase.posX,newBase.posY,newBase.posZ,newBase.rotX,round((newBase.rotY+firstPoint.rotY) % 360,2),newBase.rotZ)
  65. finalArray.append(newFirstPoint)
  66.  
  67.  
  68. for point in bluePrint[1:]:
  69. relX = point.posX - firstPoint.posX
  70. relY = point.posY - firstPoint.posY
  71. relZ = point.posZ - firstPoint.posZ
  72. relAngle = firstPoint.rotY - point.rotY
  73.  
  74. cos = math.cos(math.radians(relAngle))
  75. sin = math.sin(math.radians(relAngle))
  76. rotatedX = relX * cos - relZ * sin
  77. rotatedZ = relX * sin + relZ * cos
  78.  
  79. finalX = round(rotatedX + newBase.posX,2)
  80. finalY = round(relY + newBase.posY,2)
  81. finalZ = round(rotatedZ + newBase.posZ,2)
  82. rotation = round((point.posY + rotationAngle) % 360,2)
  83. newPoint = HObject(point.objectID, finalX,finalY,finalZ,point.rotX,rotation,point.rotZ)
  84. finalArray.append(newPoint)
  85. for p in finalArray:
  86. print(p)
  87.  
  88. def duplicateInDirection(initialPoint,direction,objectSize,totalDistance):
  89. newPoints = []
  90.  
  91. amountToSpawn = math.ceil(totalDistance / objectSize)
  92. print(amountToSpawn)
  93. x = initialPoint.posX
  94. Z = initialPoint.posZ
  95.  
  96. cos = math.cos(math.radians(direction))
  97. sin = math.sin(math.radians(direction))
  98. directionZ = objectSize * cos
  99. directionX = objectSize * sin
  100.  
  101. for i in range(0,amountToSpawn):
  102. newX = round(x + i * directionX,2)
  103. newZ = round(Z + i * directionZ,2)
  104. newY = round(initialPoint.posY + i * 0.15,2)
  105.  
  106. temp = HObject(initialPoint.objectID,newX,newY,newZ,initialPoint.rotX,direction,initialPoint.rotZ)
  107. newPoints.append(temp)
  108. print(temp)
  109. print("Finished")
  110.  
  111. def duplicateInDirectionKeepDir(initialPoint,direction,objectSize,totalDistance):
  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 * (-0.3),2)
  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. def duplicateUpWards(initialPoint,upDistance,size):
  135. newPoints = []
  136. X = initialPoint.posX
  137. y = initialPoint.posY
  138. Z = initialPoint.posZ
  139. rotX = initialPoint.posX
  140. rotY = initialPoint.posY
  141. rotZ = initialPoint.posZ
  142. amountToSpawn = math.ceil(upDistance / size)
  143. for i in range(0,amountToSpawn):
  144. newY = round(y + i * size)
  145. new_RotY = ( 0 + 45 * i ) % 360
  146. temp = HObject(initialPoint.objectID,X,newY,Z,0,new_RotY,0)
  147.  
  148. newPoints.append(temp)
  149. print(temp)
  150.  
  151.  
  152. #initialMap = generateBluePrint(map_road)
  153. #duplicateUpWards(initialMap[0],1600,8)
  154. print("Done")
  155.  
  156.  
  157. translateBluePrint(Structure,newBase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement