Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grades = #()
- --
- fn Get2PositionGrade posMin posMax =
- (
- local vertZMin = posMin.z
- local vertZMax = posMax.z
- local verticalDistance = vertZMax - vertZMin
- local vertXY1 = [posMin.x, posMin.y, 0]
- local vertXY2 = [posMax.x, posMax.y, 0]
- local horizontalDistance = distance vertXY1 vertXY2
- local grade = horizontalDistance / verticalDistance as float
- append grades grade
- )
- fn GradeFace theObj arr =
- (
- local numberOfPlayers = arr.count
- local round = 1
- for i = 1 to numberOfPlayers - 1 do
- (
- for n = (1+round) to numberOfPlayers do
- (
- if ((polyOp.getVert theObj arr[i]).z < (polyOp.getVert theObj arr[n]).z) then
- (
- Get2PositionGrade (polyOp.getVert theObj arr[i]) (polyOp.getVert theObj arr[n])
- ) else --the argument requires the min and max in that order, so we flip it here.
- (
- if (polyOp.getVert theObj arr[i]).z > (polyOp.getVert theObj arr[n]).z do
- (
- Get2PositionGrade (polyOp.getVert theObj arr[n]) (polyOp.getVert theObj arr[i])
- )
- )
- )
- round += 1
- )
- )
- fn CalcGrade theObj=
- --Send the vert numbers that make up each face to the GradeFace function.
- --That pairs up the vert positions and gets the grade using the Get2PositionGrade function.
- --An array of grades is populated, it is sorted and the lowest value (which is the steepest grade) is printed.
- (
- for i = 1 to polyOp.getNumFaces theObj do
- (
- local faceVerts = polyOp.getFaceVerts theObj i
- GradeFace theObj faceVerts
- )
- if grades.count == 0 then
- (
- "The object is flat"
- ) else
- (
- steepestGrade = (sort grades)[1]
- "The Maximum Grade is: 1:" + steepestGrade as string
- )
- )
- --
- if selection.count == 1 and (classof selection[1] == PolyMeshObject or classof selection[1] == Editable_Poly) then
- (
- CalcGrade selection[1]
- ) else
- (
- "\n****\nInvalid. There needs to be just 1 POLY object selected.\n****\n"
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement