Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- class HObject:
- def __init__(self, objectID, posX, posY , posZ, rotX , rotY, rotZ):
- self.objectID = objectID
- self.posX = float(posX)
- self.posY = float(posY)
- self.posZ = float(posZ)
- self.rotX = float(rotX)
- self.rotY = float(rotY)
- self.rotZ = float(rotZ)
- def __str__(self):
- string = "objects_override " + str(self.objectID) + " " + str(self.posX) + " " + str(self.posY) + " " + str(self.posZ) +" " + str(self.rotX) + " " + str(self.rotY) + " " + str(self.rotZ)
- return string
- blueprintString = """
- objects_override AlaskaCedar_Desktop_Young3 147.45 8.99 372.66 0.00 24.67 0.00
- objects_override AlaskaCedar_Desktop_Young 157.88 9.47 374.66 0.00 75.17 0.00
- objects_override AlaskaCedar_Desktop_Young3 157.64 9.04 365.17 0.00 178.68 0.00
- objects_override Blue_Spruce_Desktop 151.94 7.54 359.29 0.00 222.49 0.00
- """
- newPoint = "object_overide base 204.28 7.04 274.37 0.00 202.67 0.00"
- def generateBluePrint(bluePrint):
- Array = []
- for line in bluePrint.strip("\n").split("\n"):
- lineArray = line.split(" ")
- objectID = lineArray[1]
- posX = lineArray[2]
- posY = lineArray[3]
- posZ = lineArray[4]
- rotX = lineArray[5]
- rotY = lineArray[6]
- rotZ = lineArray[7]
- point = HObject(objectID , posX , posY,posZ,rotX,rotY,rotZ)
- Array.append(point)
- return Array
- Structure = []
- Structure = generateBluePrint(blueprintString)
- newBase = generateBluePrint(newPoint)
- def translateBluePrint(bluePrint, newBaseA):
- finalArray = []
- newBase = newBaseA[0]
- firstPoint = bluePrint[0]
- translateX = newBase.posX - firstPoint.posX
- translateY = newBase.posY - firstPoint.posY
- translateZ = newBase.posZ - firstPoint.posZ
- rotationAngle = newBase.rotY - firstPoint.rotY
- newFirstPoint= HObject(firstPoint.objectID, newBase.posX,newBase.posY,newBase.posZ,newBase.rotX,round((newBase.rotY+firstPoint.rotY) % 360,2),newBase.rotZ)
- finalArray.append(newFirstPoint)
- for point in bluePrint[1:]:
- relX = point.posX - firstPoint.posX
- relY = point.posY - firstPoint.posY
- relZ = point.posZ - firstPoint.posZ
- relAngle = firstPoint.rotY - point.rotY
- cos = math.cos(math.radians(relAngle))
- sin = math.sin(math.radians(relAngle))
- rotatedX = relX * cos - relZ * sin
- rotatedZ = relX * sin + relZ * cos
- finalX = round(rotatedX + newBase.posX,2)
- finalY = round(relY + newBase.posY,2)
- finalZ = round(rotatedZ + newBase.posZ,2)
- rotation = round((point.posY + rotationAngle) % 360,2)
- newPoint = HObject(point.objectID, finalX,finalY,finalZ,point.rotX,rotation,point.rotZ)
- finalArray.append(newPoint)
- for p in finalArray:
- print(p)
- def duplicateInDirection(initialPoint,direction,objectSize,totalDistance):
- newPoints = []
- amountToSpawn = math.ceil(totalDistance / objectSize)
- print(amountToSpawn)
- x = initialPoint.posX
- Z = initialPoint.posZ
- cos = math.cos(math.radians(direction))
- sin = math.sin(math.radians(direction))
- directionZ = objectSize * cos
- directionX = objectSize * sin
- for i in range(0,amountToSpawn):
- newX = round(x + i * directionX,2)
- newZ = round(Z + i * directionZ,2)
- newY = round(initialPoint.posY + i * 0.15,2)
- temp = HObject(initialPoint.objectID,newX,newY,newZ,initialPoint.rotX,direction,initialPoint.rotZ)
- newPoints.append(temp)
- print(temp)
- print("Finished")
- def duplicateInDirectionKeepDir(initialPoint,direction,objectSize,totalDistance):
- yVariant = 0 #should make a parameter but cba
- newPoints = []
- amountToSpawn = math.ceil(totalDistance / objectSize)
- print(amountToSpawn)
- x = initialPoint.posX
- Z = initialPoint.posZ
- cos = math.cos(math.radians(direction))
- sin = math.sin(math.radians(direction))
- directionZ = objectSize * cos
- directionX = objectSize * sin
- for i in range(0,amountToSpawn):
- newX = round(x + i * directionX,2)
- newZ = round(Z + i * directionZ,2)
- newY = round(initialPoint.posY + i * (yVariant),2)#calculates y variation per instance
- temp = HObject(initialPoint.objectID,newX,newY,newZ,initialPoint.rotX,initialPoint.rotY,initialPoint.rotZ)
- newPoints.append(temp)
- print(temp)
- print("Finished")
- map_road = """
- objects_override FencingWallVines3 306.44 10.31 366.83 0.00 270 0.00
- """
- print("new")
- initialMap = generateBluePrint(map_road)
- print(initialMap[0])
- #duplicateInDirection(initialMap[0],90,3.5,40)
- duplicateInDirectionKeepDir(initialMap[0],180,3.5,40)
- print("new done")
- #translateBluePrint(Structure,newBase)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement